babylon.module.d.ts 5.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125
  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. get 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 get 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 set LogLevels(level: 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/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Instrumentation/timeToken" {
  586. import { Nullable } from "babylonjs/types";
  587. /**
  588. * @hidden
  589. **/
  590. export class _TimeToken {
  591. _startTimeQuery: Nullable<WebGLQuery>;
  592. _endTimeQuery: Nullable<WebGLQuery>;
  593. _timeElapsedQuery: Nullable<WebGLQuery>;
  594. _timeElapsedQueryEnded: boolean;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** 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 */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** 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 */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** 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 */
  693. static readonly GEQUAL: number;
  694. /** 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 */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** Bilinear is mag = linear and min = linear and mip = nearest */
  779. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** nearest is mag = nearest and min = nearest and mip = linear */
  783. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  784. /** Bilinear is mag = linear and min = linear and mip = nearest */
  785. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** mag = nearest and min = nearest and mip = none */
  797. static readonly TEXTURE_NEAREST_NEAREST: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** mag = linear and min = linear and mip = none */
  803. static readonly TEXTURE_LINEAR_LINEAR: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * 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.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * 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.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1065. * @param fallback defines the fallback internal texture if any
  1066. * @param isBase64 defines whether the texture is encoded as a base64
  1067. * @param isBuffer defines whether the texture data are stored as a buffer
  1068. * @returns true if the loader can load the specified file
  1069. */
  1070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1071. /**
  1072. * Transform the url before loading if required.
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the transformed texture
  1076. */
  1077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1078. /**
  1079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1080. * @param rootUrl the url of the texture
  1081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1082. * @returns the fallback texture
  1083. */
  1084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1085. /**
  1086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param createPolynomials will be true if polynomials have been requested
  1090. * @param onLoad defines the callback to trigger once the texture is ready
  1091. * @param onError defines the callback to trigger in case of error
  1092. */
  1093. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1094. /**
  1095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1096. * @param data contains the texture data
  1097. * @param texture defines the BabylonJS internal texture
  1098. * @param callback defines the method to call once ready to upload
  1099. */
  1100. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1101. }
  1102. }
  1103. declare module "babylonjs/Engines/IPipelineContext" {
  1104. /**
  1105. * Class used to store and describe the pipeline context associated with an effect
  1106. */
  1107. export interface IPipelineContext {
  1108. /**
  1109. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1110. */
  1111. isAsync: boolean;
  1112. /**
  1113. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1114. */
  1115. isReady: boolean;
  1116. /** @hidden */
  1117. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1118. }
  1119. }
  1120. declare module "babylonjs/Meshes/dataBuffer" {
  1121. /**
  1122. * Class used to store gfx data (like WebGLBuffer)
  1123. */
  1124. export class DataBuffer {
  1125. /**
  1126. * Gets or sets the number of objects referencing this buffer
  1127. */
  1128. references: number;
  1129. /** Gets or sets the size of the underlying buffer */
  1130. capacity: number;
  1131. /**
  1132. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1133. */
  1134. is32Bits: boolean;
  1135. /**
  1136. * Gets the underlying buffer
  1137. */
  1138. get underlyingResource(): any;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1142. /** @hidden */
  1143. export interface IShaderProcessor {
  1144. attributeProcessor?: (attribute: string) => string;
  1145. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1146. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1147. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1148. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1149. lineProcessor?: (line: string, isFragment: boolean) => string;
  1150. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1151. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1155. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1156. /** @hidden */
  1157. export interface ProcessingOptions {
  1158. defines: string[];
  1159. indexParameters: any;
  1160. isFragment: boolean;
  1161. shouldUseHighPrecisionShader: boolean;
  1162. supportsUniformBuffers: boolean;
  1163. shadersRepository: string;
  1164. includesShadersStore: {
  1165. [key: string]: string;
  1166. };
  1167. processor?: IShaderProcessor;
  1168. version: string;
  1169. platformName: string;
  1170. lookForClosingBracketForUniformBuffer?: boolean;
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1174. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1175. /** @hidden */
  1176. export class ShaderCodeNode {
  1177. line: string;
  1178. children: ShaderCodeNode[];
  1179. additionalDefineKey?: string;
  1180. additionalDefineValue?: string;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. process(preprocessors: {
  1185. [key: string]: string;
  1186. }, options: ProcessingOptions): string;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1190. /** @hidden */
  1191. export class ShaderCodeCursor {
  1192. private _lines;
  1193. lineIndex: number;
  1194. get currentLine(): string;
  1195. get canRead(): boolean;
  1196. set lines(value: string[]);
  1197. }
  1198. }
  1199. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1200. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1201. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1202. /** @hidden */
  1203. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1204. process(preprocessors: {
  1205. [key: string]: string;
  1206. }, options: ProcessingOptions): string;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1210. /** @hidden */
  1211. export class ShaderDefineExpression {
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1218. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderCodeTestNode extends ShaderCodeNode {
  1222. testExpression: ShaderDefineExpression;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1232. define: string;
  1233. not: boolean;
  1234. constructor(define: string, not?: boolean);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1241. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1242. /** @hidden */
  1243. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1244. leftOperand: ShaderDefineExpression;
  1245. rightOperand: ShaderDefineExpression;
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1252. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. operand: string;
  1268. testValue: string;
  1269. constructor(define: string, operand: string, testValue: string);
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Offline/IOfflineProvider" {
  1276. /**
  1277. * Class used to enable access to offline support
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. export interface IOfflineProvider {
  1281. /**
  1282. * Gets a boolean indicating if scene must be saved in the database
  1283. */
  1284. enableSceneOffline: boolean;
  1285. /**
  1286. * Gets a boolean indicating if textures must be saved in the database
  1287. */
  1288. enableTexturesOffline: boolean;
  1289. /**
  1290. * Open the offline support and make it available
  1291. * @param successCallback defines the callback to call on success
  1292. * @param errorCallback defines the callback to call on error
  1293. */
  1294. open(successCallback: () => void, errorCallback: () => void): void;
  1295. /**
  1296. * Loads an image from the offline support
  1297. * @param url defines the url to load from
  1298. * @param image defines the target DOM image
  1299. */
  1300. loadImage(url: string, image: HTMLImageElement): void;
  1301. /**
  1302. * Loads a file from offline support
  1303. * @param url defines the URL to load from
  1304. * @param sceneLoaded defines a callback to call on success
  1305. * @param progressCallBack defines a callback to call when progress changed
  1306. * @param errorCallback defines a callback to call on error
  1307. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1308. */
  1309. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1310. }
  1311. }
  1312. declare module "babylonjs/Misc/filesInputStore" {
  1313. /**
  1314. * Class used to help managing file picking and drag'n'drop
  1315. * File Storage
  1316. */
  1317. export class FilesInputStore {
  1318. /**
  1319. * List of files ready to be loaded
  1320. */
  1321. static FilesToLoad: {
  1322. [key: string]: File;
  1323. };
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/retryStrategy" {
  1327. import { WebRequest } from "babylonjs/Misc/webRequest";
  1328. /**
  1329. * Class used to define a retry strategy when error happens while loading assets
  1330. */
  1331. export class RetryStrategy {
  1332. /**
  1333. * Function used to defines an exponential back off strategy
  1334. * @param maxRetries defines the maximum number of retries (3 by default)
  1335. * @param baseInterval defines the interval between retries
  1336. * @returns the strategy function to use
  1337. */
  1338. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/baseError" {
  1342. /**
  1343. * @ignore
  1344. * Application error to support additional information when loading a file
  1345. */
  1346. export abstract class BaseError extends Error {
  1347. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/fileTools" {
  1351. import { WebRequest } from "babylonjs/Misc/webRequest";
  1352. import { Nullable } from "babylonjs/types";
  1353. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1354. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1355. import { BaseError } from "babylonjs/Misc/baseError";
  1356. /** @ignore */
  1357. export class LoadFileError extends BaseError {
  1358. request?: WebRequest;
  1359. file?: File;
  1360. /**
  1361. * Creates a new LoadFileError
  1362. * @param message defines the message of the error
  1363. * @param request defines the optional web request
  1364. * @param file defines the optional file
  1365. */
  1366. constructor(message: string, object?: WebRequest | File);
  1367. }
  1368. /** @ignore */
  1369. export class RequestFileError extends BaseError {
  1370. request: WebRequest;
  1371. /**
  1372. * Creates a new LoadFileError
  1373. * @param message defines the message of the error
  1374. * @param request defines the optional web request
  1375. */
  1376. constructor(message: string, request: WebRequest);
  1377. }
  1378. /** @ignore */
  1379. export class ReadFileError extends BaseError {
  1380. file: File;
  1381. /**
  1382. * Creates a new ReadFileError
  1383. * @param message defines the message of the error
  1384. * @param file defines the optional file
  1385. */
  1386. constructor(message: string, file: File);
  1387. }
  1388. /**
  1389. * @hidden
  1390. */
  1391. export class FileTools {
  1392. /**
  1393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1394. */
  1395. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1396. /**
  1397. * Gets or sets the base URL to use to load assets
  1398. */
  1399. static BaseUrl: string;
  1400. /**
  1401. * Default behaviour for cors in the application.
  1402. * It can be a string if the expected behavior is identical in the entire app.
  1403. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1404. */
  1405. static CorsBehavior: string | ((url: string | string[]) => string);
  1406. /**
  1407. * Gets or sets a function used to pre-process url before using them to load assets
  1408. */
  1409. static PreprocessUrl: (url: string) => string;
  1410. /**
  1411. * Removes unwanted characters from an url
  1412. * @param url defines the url to clean
  1413. * @returns the cleaned url
  1414. */
  1415. private static _CleanUrl;
  1416. /**
  1417. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1418. * @param url define the url we are trying
  1419. * @param element define the dom element where to configure the cors policy
  1420. */
  1421. static SetCorsBehavior(url: string | string[], element: {
  1422. crossOrigin: string | null;
  1423. }): void;
  1424. /**
  1425. * Loads an image as an HTMLImageElement.
  1426. * @param input url string, ArrayBuffer, or Blob to load
  1427. * @param onLoad callback called when the image successfully loads
  1428. * @param onError callback called when the image fails to load
  1429. * @param offlineProvider offline provider for caching
  1430. * @param mimeType optional mime type
  1431. * @returns the HTMLImageElement of the loaded image
  1432. */
  1433. 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>;
  1434. /**
  1435. * Reads a file from a File object
  1436. * @param file defines the file to load
  1437. * @param onSuccess defines the callback to call when data is loaded
  1438. * @param onProgress defines the callback to call during loading process
  1439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1440. * @param onError defines the callback to call when an error occurs
  1441. * @returns a file request object
  1442. */
  1443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1444. /**
  1445. * Loads a file from a url
  1446. * @param url url to load
  1447. * @param onSuccess callback called when the file successfully loads
  1448. * @param onProgress callback called while file is loading (if the server supports this mode)
  1449. * @param offlineProvider defines the offline provider for caching
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @returns a file request object
  1453. */
  1454. 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;
  1455. /**
  1456. * Loads a file
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1461. * @param onError callback called when the file fails to load
  1462. * @param onOpened callback called when the web request is opened
  1463. * @returns a file request object
  1464. */
  1465. 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;
  1466. /**
  1467. * Checks if the loaded document was accessed via `file:`-Protocol.
  1468. * @returns boolean
  1469. */
  1470. static IsFileURL(): boolean;
  1471. }
  1472. }
  1473. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1474. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1475. /** @hidden */
  1476. export class ShaderProcessor {
  1477. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1478. private static _ProcessPrecision;
  1479. private static _ExtractOperation;
  1480. private static _BuildSubExpression;
  1481. private static _BuildExpression;
  1482. private static _MoveCursorWithinIf;
  1483. private static _MoveCursor;
  1484. private static _EvaluatePreProcessors;
  1485. private static _PreparePreProcessors;
  1486. private static _ProcessShaderConversion;
  1487. private static _ProcessIncludes;
  1488. }
  1489. }
  1490. declare module "babylonjs/Maths/math.like" {
  1491. import { float, int, DeepImmutable } from "babylonjs/types";
  1492. /**
  1493. * @hidden
  1494. */
  1495. export interface IColor4Like {
  1496. r: float;
  1497. g: float;
  1498. b: float;
  1499. a: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IColor3Like {
  1505. r: float;
  1506. g: float;
  1507. b: float;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IVector4Like {
  1513. x: float;
  1514. y: float;
  1515. z: float;
  1516. w: float;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IVector3Like {
  1522. x: float;
  1523. y: float;
  1524. z: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IVector2Like {
  1530. x: float;
  1531. y: float;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IMatrixLike {
  1537. toArray(): DeepImmutable<Float32Array>;
  1538. updateFlag: int;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IViewportLike {
  1544. x: float;
  1545. y: float;
  1546. width: float;
  1547. height: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IPlaneLike {
  1553. normal: IVector3Like;
  1554. d: float;
  1555. normalize(): void;
  1556. }
  1557. }
  1558. declare module "babylonjs/Materials/iEffectFallbacks" {
  1559. import { Effect } from "babylonjs/Materials/effect";
  1560. /**
  1561. * Interface used to define common properties for effect fallbacks
  1562. */
  1563. export interface IEffectFallbacks {
  1564. /**
  1565. * Removes the defines that should be removed when falling back.
  1566. * @param currentDefines defines the current define statements for the shader.
  1567. * @param effect defines the current effect we try to compile
  1568. * @returns The resulting defines with defines of the current rank removed.
  1569. */
  1570. reduce(currentDefines: string, effect: Effect): string;
  1571. /**
  1572. * Removes the fallback from the bound mesh.
  1573. */
  1574. unBindMesh(): void;
  1575. /**
  1576. * Checks to see if more fallbacks are still availible.
  1577. */
  1578. hasMoreFallbacks: boolean;
  1579. }
  1580. }
  1581. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1582. /**
  1583. * Class used to evalaute queries containing `and` and `or` operators
  1584. */
  1585. export class AndOrNotEvaluator {
  1586. /**
  1587. * Evaluate a query
  1588. * @param query defines the query to evaluate
  1589. * @param evaluateCallback defines the callback used to filter result
  1590. * @returns true if the query matches
  1591. */
  1592. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1593. private static _HandleParenthesisContent;
  1594. private static _SimplifyNegation;
  1595. }
  1596. }
  1597. declare module "babylonjs/Misc/tags" {
  1598. /**
  1599. * Class used to store custom tags
  1600. */
  1601. export class Tags {
  1602. /**
  1603. * Adds support for tags on the given object
  1604. * @param obj defines the object to use
  1605. */
  1606. static EnableFor(obj: any): void;
  1607. /**
  1608. * Removes tags support
  1609. * @param obj defines the object to use
  1610. */
  1611. static DisableFor(obj: any): void;
  1612. /**
  1613. * Gets a boolean indicating if the given object has tags
  1614. * @param obj defines the object to use
  1615. * @returns a boolean
  1616. */
  1617. static HasTags(obj: any): boolean;
  1618. /**
  1619. * Gets the tags available on a given object
  1620. * @param obj defines the object to use
  1621. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1622. * @returns the tags
  1623. */
  1624. static GetTags(obj: any, asString?: boolean): any;
  1625. /**
  1626. * Adds tags to an object
  1627. * @param obj defines the object to use
  1628. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1629. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1630. */
  1631. static AddTagsTo(obj: any, tagsString: string): void;
  1632. /**
  1633. * @hidden
  1634. */
  1635. static _AddTagTo(obj: any, tag: string): void;
  1636. /**
  1637. * Removes specific tags from a specific object
  1638. * @param obj defines the object to use
  1639. * @param tagsString defines the tags to remove
  1640. */
  1641. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1642. /**
  1643. * @hidden
  1644. */
  1645. static _RemoveTagFrom(obj: any, tag: string): void;
  1646. /**
  1647. * Defines if tags hosted on an object match a given query
  1648. * @param obj defines the object to use
  1649. * @param tagsQuery defines the tag query
  1650. * @returns a boolean
  1651. */
  1652. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1653. }
  1654. }
  1655. declare module "babylonjs/Maths/math.scalar" {
  1656. /**
  1657. * Scalar computation library
  1658. */
  1659. export class Scalar {
  1660. /**
  1661. * Two pi constants convenient for computation.
  1662. */
  1663. static TwoPi: number;
  1664. /**
  1665. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1666. * @param a number
  1667. * @param b number
  1668. * @param epsilon (default = 1.401298E-45)
  1669. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1670. */
  1671. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1672. /**
  1673. * Returns a string : the upper case translation of the number i to hexadecimal.
  1674. * @param i number
  1675. * @returns the upper case translation of the number i to hexadecimal.
  1676. */
  1677. static ToHex(i: number): string;
  1678. /**
  1679. * Returns -1 if value is negative and +1 is value is positive.
  1680. * @param value the value
  1681. * @returns the value itself if it's equal to zero.
  1682. */
  1683. static Sign(value: number): number;
  1684. /**
  1685. * Returns the value itself if it's between min and max.
  1686. * Returns min if the value is lower than min.
  1687. * Returns max if the value is greater than max.
  1688. * @param value the value to clmap
  1689. * @param min the min value to clamp to (default: 0)
  1690. * @param max the max value to clamp to (default: 1)
  1691. * @returns the clamped value
  1692. */
  1693. static Clamp(value: number, min?: number, max?: number): number;
  1694. /**
  1695. * the log2 of value.
  1696. * @param value the value to compute log2 of
  1697. * @returns the log2 of value.
  1698. */
  1699. static Log2(value: number): number;
  1700. /**
  1701. * Loops the value, so that it is never larger than length and never smaller than 0.
  1702. *
  1703. * This is similar to the modulo operator but it works with floating point numbers.
  1704. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1705. * With t = 5 and length = 2.5, the result would be 0.0.
  1706. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1707. * @param value the value
  1708. * @param length the length
  1709. * @returns the looped value
  1710. */
  1711. static Repeat(value: number, length: number): number;
  1712. /**
  1713. * Normalize the value between 0.0 and 1.0 using min and max values
  1714. * @param value value to normalize
  1715. * @param min max to normalize between
  1716. * @param max min to normalize between
  1717. * @returns the normalized value
  1718. */
  1719. static Normalize(value: number, min: number, max: number): number;
  1720. /**
  1721. * Denormalize the value from 0.0 and 1.0 using min and max values
  1722. * @param normalized value to denormalize
  1723. * @param min max to denormalize between
  1724. * @param max min to denormalize between
  1725. * @returns the denormalized value
  1726. */
  1727. static Denormalize(normalized: number, min: number, max: number): number;
  1728. /**
  1729. * Calculates the shortest difference between two given angles given in degrees.
  1730. * @param current current angle in degrees
  1731. * @param target target angle in degrees
  1732. * @returns the delta
  1733. */
  1734. static DeltaAngle(current: number, target: number): number;
  1735. /**
  1736. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1737. * @param tx value
  1738. * @param length length
  1739. * @returns The returned value will move back and forth between 0 and length
  1740. */
  1741. static PingPong(tx: number, length: number): number;
  1742. /**
  1743. * Interpolates between min and max with smoothing at the limits.
  1744. *
  1745. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1746. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1747. * @param from from
  1748. * @param to to
  1749. * @param tx value
  1750. * @returns the smooth stepped value
  1751. */
  1752. static SmoothStep(from: number, to: number, tx: number): number;
  1753. /**
  1754. * Moves a value current towards target.
  1755. *
  1756. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1757. * Negative values of maxDelta pushes the value away from target.
  1758. * @param current current value
  1759. * @param target target value
  1760. * @param maxDelta max distance to move
  1761. * @returns resulting value
  1762. */
  1763. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1764. /**
  1765. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1766. *
  1767. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1768. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1769. * @param current current value
  1770. * @param target target value
  1771. * @param maxDelta max distance to move
  1772. * @returns resulting angle
  1773. */
  1774. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1775. /**
  1776. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1777. * @param start start value
  1778. * @param end target value
  1779. * @param amount amount to lerp between
  1780. * @returns the lerped value
  1781. */
  1782. static Lerp(start: number, end: number, amount: number): number;
  1783. /**
  1784. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1785. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1786. * @param start start value
  1787. * @param end target value
  1788. * @param amount amount to lerp between
  1789. * @returns the lerped value
  1790. */
  1791. static LerpAngle(start: number, end: number, amount: number): number;
  1792. /**
  1793. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1794. * @param a start value
  1795. * @param b target value
  1796. * @param value value between a and b
  1797. * @returns the inverseLerp value
  1798. */
  1799. static InverseLerp(a: number, b: number, value: number): number;
  1800. /**
  1801. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1802. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1803. * @param value1 spline value
  1804. * @param tangent1 spline value
  1805. * @param value2 spline value
  1806. * @param tangent2 spline value
  1807. * @param amount input value
  1808. * @returns hermite result
  1809. */
  1810. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1811. /**
  1812. * Returns a random float number between and min and max values
  1813. * @param min min value of random
  1814. * @param max max value of random
  1815. * @returns random value
  1816. */
  1817. static RandomRange(min: number, max: number): number;
  1818. /**
  1819. * This function returns percentage of a number in a given range.
  1820. *
  1821. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1822. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1823. * @param number to convert to percentage
  1824. * @param min min range
  1825. * @param max max range
  1826. * @returns the percentage
  1827. */
  1828. static RangeToPercent(number: number, min: number, max: number): number;
  1829. /**
  1830. * This function returns number that corresponds to the percentage in a given range.
  1831. *
  1832. * PercentToRange(0.34,0,100) will return 34.
  1833. * @param percent to convert to number
  1834. * @param min min range
  1835. * @param max max range
  1836. * @returns the number
  1837. */
  1838. static PercentToRange(percent: number, min: number, max: number): number;
  1839. /**
  1840. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1841. * @param angle The angle to normalize in radian.
  1842. * @return The converted angle.
  1843. */
  1844. static NormalizeRadians(angle: number): number;
  1845. }
  1846. }
  1847. declare module "babylonjs/Maths/math.constants" {
  1848. /**
  1849. * Constant used to convert a value to gamma space
  1850. * @ignorenaming
  1851. */
  1852. export const ToGammaSpace: number;
  1853. /**
  1854. * Constant used to convert a value to linear space
  1855. * @ignorenaming
  1856. */
  1857. export const ToLinearSpace = 2.2;
  1858. /**
  1859. * Constant used to define the minimal number value in Babylon.js
  1860. * @ignorenaming
  1861. */
  1862. let Epsilon: number;
  1863. export { Epsilon };
  1864. }
  1865. declare module "babylonjs/Maths/math.viewport" {
  1866. /**
  1867. * Class used to represent a viewport on screen
  1868. */
  1869. export class Viewport {
  1870. /** viewport left coordinate */
  1871. x: number;
  1872. /** viewport top coordinate */
  1873. y: number;
  1874. /**viewport width */
  1875. width: number;
  1876. /** viewport height */
  1877. height: number;
  1878. /**
  1879. * Creates a Viewport object located at (x, y) and sized (width, height)
  1880. * @param x defines viewport left coordinate
  1881. * @param y defines viewport top coordinate
  1882. * @param width defines the viewport width
  1883. * @param height defines the viewport height
  1884. */
  1885. constructor(
  1886. /** viewport left coordinate */
  1887. x: number,
  1888. /** viewport top coordinate */
  1889. y: number,
  1890. /**viewport width */
  1891. width: number,
  1892. /** viewport height */
  1893. height: number);
  1894. /**
  1895. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @returns a new Viewport
  1899. */
  1900. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1901. /**
  1902. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1903. * @param renderWidth defines the rendering width
  1904. * @param renderHeight defines the rendering height
  1905. * @param ref defines the target viewport
  1906. * @returns the current viewport
  1907. */
  1908. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1909. /**
  1910. * Returns a new Viewport copied from the current one
  1911. * @returns a new Viewport
  1912. */
  1913. clone(): Viewport;
  1914. }
  1915. }
  1916. declare module "babylonjs/Misc/arrayTools" {
  1917. /**
  1918. * Class containing a set of static utilities functions for arrays.
  1919. */
  1920. export class ArrayTools {
  1921. /**
  1922. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1923. * @param size the number of element to construct and put in the array
  1924. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1925. * @returns a new array filled with new objects
  1926. */
  1927. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1928. }
  1929. }
  1930. declare module "babylonjs/Maths/math.vector" {
  1931. import { Viewport } from "babylonjs/Maths/math.viewport";
  1932. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1933. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1934. /**
  1935. * Class representing a vector containing 2 coordinates
  1936. */
  1937. export class Vector2 {
  1938. /** defines the first coordinate */
  1939. x: number;
  1940. /** defines the second coordinate */
  1941. y: number;
  1942. /**
  1943. * Creates a new Vector2 from the given x and y coordinates
  1944. * @param x defines the first coordinate
  1945. * @param y defines the second coordinate
  1946. */
  1947. constructor(
  1948. /** defines the first coordinate */
  1949. x?: number,
  1950. /** defines the second coordinate */
  1951. y?: number);
  1952. /**
  1953. * Gets a string with the Vector2 coordinates
  1954. * @returns a string with the Vector2 coordinates
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Gets class name
  1959. * @returns the string "Vector2"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Gets current vector hash code
  1964. * @returns the Vector2 hash code as a number
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1969. * @param array defines the source array
  1970. * @param index defines the offset in source array
  1971. * @returns the current Vector2
  1972. */
  1973. toArray(array: FloatArray, index?: number): Vector2;
  1974. /**
  1975. * Copy the current vector to an array
  1976. * @returns a new array with 2 elements: the Vector2 coordinates.
  1977. */
  1978. asArray(): number[];
  1979. /**
  1980. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1981. * @param source defines the source Vector2
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. copyFromFloats(x: number, y: number): Vector2;
  1992. /**
  1993. * Sets the Vector2 coordinates with the given floats
  1994. * @param x defines the first coordinate
  1995. * @param y defines the second coordinate
  1996. * @returns the current updated Vector2
  1997. */
  1998. set(x: number, y: number): Vector2;
  1999. /**
  2000. * Add another vector with the current one
  2001. * @param otherVector defines the other vector
  2002. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2003. */
  2004. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2005. /**
  2006. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2007. * @param otherVector defines the other vector
  2008. * @param result defines the target vector
  2009. * @returns the unmodified current Vector2
  2010. */
  2011. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2012. /**
  2013. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2014. * @param otherVector defines the other vector
  2015. * @returns the current updated Vector2
  2016. */
  2017. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2018. /**
  2019. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2020. * @param otherVector defines the other vector
  2021. * @returns a new Vector2
  2022. */
  2023. addVector3(otherVector: Vector3): Vector2;
  2024. /**
  2025. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2026. * @param otherVector defines the other vector
  2027. * @returns a new Vector2
  2028. */
  2029. subtract(otherVector: Vector2): Vector2;
  2030. /**
  2031. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2032. * @param otherVector defines the other vector
  2033. * @param result defines the target vector
  2034. * @returns the unmodified current Vector2
  2035. */
  2036. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2037. /**
  2038. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @returns the current updated Vector2
  2041. */
  2042. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2043. /**
  2044. * Multiplies in place the current Vector2 coordinates by the given ones
  2045. * @param otherVector defines the other vector
  2046. * @returns the current updated Vector2
  2047. */
  2048. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2049. /**
  2050. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2051. * @param otherVector defines the other vector
  2052. * @returns a new Vector2
  2053. */
  2054. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2055. /**
  2056. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @param result defines the target vector
  2059. * @returns the unmodified current Vector2
  2060. */
  2061. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2062. /**
  2063. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2064. * @param x defines the first coordinate
  2065. * @param y defines the second coordinate
  2066. * @returns a new Vector2
  2067. */
  2068. multiplyByFloats(x: number, y: number): Vector2;
  2069. /**
  2070. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2071. * @param otherVector defines the other vector
  2072. * @returns a new Vector2
  2073. */
  2074. divide(otherVector: Vector2): Vector2;
  2075. /**
  2076. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2077. * @param otherVector defines the other vector
  2078. * @param result defines the target vector
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2082. /**
  2083. * Divides the current Vector2 coordinates by the given ones
  2084. * @param otherVector defines the other vector
  2085. * @returns the current updated Vector2
  2086. */
  2087. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2088. /**
  2089. * Gets a new Vector2 with current Vector2 negated coordinates
  2090. * @returns a new Vector2
  2091. */
  2092. negate(): Vector2;
  2093. /**
  2094. * Multiply the Vector2 coordinates by scale
  2095. * @param scale defines the scaling factor
  2096. * @returns the current updated Vector2
  2097. */
  2098. scaleInPlace(scale: number): Vector2;
  2099. /**
  2100. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2101. * @param scale defines the scaling factor
  2102. * @returns a new Vector2
  2103. */
  2104. scale(scale: number): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2114. * @param scale defines the scale factor
  2115. * @param result defines the Vector2 object where to store the result
  2116. * @returns the unmodified current Vector2
  2117. */
  2118. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2119. /**
  2120. * Gets a boolean if two vectors are equals
  2121. * @param otherVector defines the other vector
  2122. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2123. */
  2124. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2125. /**
  2126. * Gets a boolean if two vectors are equals (using an epsilon value)
  2127. * @param otherVector defines the other vector
  2128. * @param epsilon defines the minimal distance to consider equality
  2129. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2130. */
  2131. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2132. /**
  2133. * Gets a new Vector2 from current Vector2 floored values
  2134. * @returns a new Vector2
  2135. */
  2136. floor(): Vector2;
  2137. /**
  2138. * Gets a new Vector2 from current Vector2 floored values
  2139. * @returns a new Vector2
  2140. */
  2141. fract(): Vector2;
  2142. /**
  2143. * Gets the length of the vector
  2144. * @returns the vector length (float)
  2145. */
  2146. length(): number;
  2147. /**
  2148. * Gets the vector squared length
  2149. * @returns the vector squared length (float)
  2150. */
  2151. lengthSquared(): number;
  2152. /**
  2153. * Normalize the vector
  2154. * @returns the current updated Vector2
  2155. */
  2156. normalize(): Vector2;
  2157. /**
  2158. * Gets a new Vector2 copied from the Vector2
  2159. * @returns a new Vector2
  2160. */
  2161. clone(): Vector2;
  2162. /**
  2163. * Gets a new Vector2(0, 0)
  2164. * @returns a new Vector2
  2165. */
  2166. static Zero(): Vector2;
  2167. /**
  2168. * Gets a new Vector2(1, 1)
  2169. * @returns a new Vector2
  2170. */
  2171. static One(): Vector2;
  2172. /**
  2173. * Gets a new Vector2 set from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @returns a new Vector2
  2177. */
  2178. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2179. /**
  2180. * Sets "result" from the given index element of the given array
  2181. * @param array defines the data source
  2182. * @param offset defines the offset in the data source
  2183. * @param result defines the target vector
  2184. */
  2185. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2186. /**
  2187. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2188. * @param value1 defines 1st point of control
  2189. * @param value2 defines 2nd point of control
  2190. * @param value3 defines 3rd point of control
  2191. * @param value4 defines 4th point of control
  2192. * @param amount defines the interpolation factor
  2193. * @returns a new Vector2
  2194. */
  2195. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2196. /**
  2197. * 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".
  2198. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2199. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2200. * @param value defines the value to clamp
  2201. * @param min defines the lower limit
  2202. * @param max defines the upper limit
  2203. * @returns a new Vector2
  2204. */
  2205. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2208. * @param value1 defines the 1st control point
  2209. * @param tangent1 defines the outgoing tangent
  2210. * @param value2 defines the 2nd control point
  2211. * @param tangent2 defines the incoming tangent
  2212. * @param amount defines the interpolation factor
  2213. * @returns a new Vector2
  2214. */
  2215. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2216. /**
  2217. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2218. * @param start defines the start vector
  2219. * @param end defines the end vector
  2220. * @param amount defines the interpolation factor
  2221. * @returns a new Vector2
  2222. */
  2223. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2224. /**
  2225. * Gets the dot product of the vector "left" and the vector "right"
  2226. * @param left defines first vector
  2227. * @param right defines second vector
  2228. * @returns the dot product (float)
  2229. */
  2230. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2231. /**
  2232. * Returns a new Vector2 equal to the normalized given vector
  2233. * @param vector defines the vector to normalize
  2234. * @returns a new Vector2
  2235. */
  2236. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2246. * @param left defines 1st vector
  2247. * @param right defines 2nd vector
  2248. * @returns a new Vector2
  2249. */
  2250. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2251. /**
  2252. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @returns a new Vector2
  2256. */
  2257. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2258. /**
  2259. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2260. * @param vector defines the vector to transform
  2261. * @param transformation defines the matrix to apply
  2262. * @param result defines the target vector
  2263. */
  2264. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2265. /**
  2266. * Determines if a given vector is included in a triangle
  2267. * @param p defines the vector to test
  2268. * @param p0 defines 1st triangle point
  2269. * @param p1 defines 2nd triangle point
  2270. * @param p2 defines 3rd triangle point
  2271. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2272. */
  2273. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2274. /**
  2275. * Gets the distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the distance between vectors
  2279. */
  2280. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Returns the squared distance between the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns the squared distance between vectors
  2286. */
  2287. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2288. /**
  2289. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2290. * @param value1 defines first vector
  2291. * @param value2 defines second vector
  2292. * @returns a new Vector2
  2293. */
  2294. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2295. /**
  2296. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2297. * @param p defines the middle point
  2298. * @param segA defines one point of the segment
  2299. * @param segB defines the other point of the segment
  2300. * @returns the shortest distance
  2301. */
  2302. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2303. }
  2304. /**
  2305. * Class used to store (x,y,z) vector representation
  2306. * A Vector3 is the main object used in 3D geometry
  2307. * It can represent etiher the coordinates of a point the space, either a direction
  2308. * Reminder: js uses a left handed forward facing system
  2309. */
  2310. export class Vector3 {
  2311. /**
  2312. * Defines the first coordinates (on X axis)
  2313. */
  2314. x: number;
  2315. /**
  2316. * Defines the second coordinates (on Y axis)
  2317. */
  2318. y: number;
  2319. /**
  2320. * Defines the third coordinates (on Z axis)
  2321. */
  2322. z: number;
  2323. private static _UpReadOnly;
  2324. private static _ZeroReadOnly;
  2325. /**
  2326. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2327. * @param x defines the first coordinates (on X axis)
  2328. * @param y defines the second coordinates (on Y axis)
  2329. * @param z defines the third coordinates (on Z axis)
  2330. */
  2331. constructor(
  2332. /**
  2333. * Defines the first coordinates (on X axis)
  2334. */
  2335. x?: number,
  2336. /**
  2337. * Defines the second coordinates (on Y axis)
  2338. */
  2339. y?: number,
  2340. /**
  2341. * Defines the third coordinates (on Z axis)
  2342. */
  2343. z?: number);
  2344. /**
  2345. * Creates a string representation of the Vector3
  2346. * @returns a string with the Vector3 coordinates.
  2347. */
  2348. toString(): string;
  2349. /**
  2350. * Gets the class name
  2351. * @returns the string "Vector3"
  2352. */
  2353. getClassName(): string;
  2354. /**
  2355. * Creates the Vector3 hash code
  2356. * @returns a number which tends to be unique between Vector3 instances
  2357. */
  2358. getHashCode(): number;
  2359. /**
  2360. * Creates an array containing three elements : the coordinates of the Vector3
  2361. * @returns a new array of numbers
  2362. */
  2363. asArray(): number[];
  2364. /**
  2365. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2366. * @param array defines the destination array
  2367. * @param index defines the offset in the destination array
  2368. * @returns the current Vector3
  2369. */
  2370. toArray(array: FloatArray, index?: number): Vector3;
  2371. /**
  2372. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2373. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2374. */
  2375. toQuaternion(): Quaternion;
  2376. /**
  2377. * Adds the given vector to the current Vector3
  2378. * @param otherVector defines the second operand
  2379. * @returns the current updated Vector3
  2380. */
  2381. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2382. /**
  2383. * Adds the given coordinates to the current Vector3
  2384. * @param x defines the x coordinate of the operand
  2385. * @param y defines the y coordinate of the operand
  2386. * @param z defines the z coordinate of the operand
  2387. * @returns the current updated Vector3
  2388. */
  2389. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2390. /**
  2391. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2392. * @param otherVector defines the second operand
  2393. * @returns the resulting Vector3
  2394. */
  2395. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2396. /**
  2397. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2398. * @param otherVector defines the second operand
  2399. * @param result defines the Vector3 object where to store the result
  2400. * @returns the current Vector3
  2401. */
  2402. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2403. /**
  2404. * Subtract the given vector from the current Vector3
  2405. * @param otherVector defines the second operand
  2406. * @returns the current updated Vector3
  2407. */
  2408. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2409. /**
  2410. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2411. * @param otherVector defines the second operand
  2412. * @returns the resulting Vector3
  2413. */
  2414. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2415. /**
  2416. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2417. * @param otherVector defines the second operand
  2418. * @param result defines the Vector3 object where to store the result
  2419. * @returns the current Vector3
  2420. */
  2421. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2422. /**
  2423. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2424. * @param x defines the x coordinate of the operand
  2425. * @param y defines the y coordinate of the operand
  2426. * @param z defines the z coordinate of the operand
  2427. * @returns the resulting Vector3
  2428. */
  2429. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2430. /**
  2431. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2432. * @param x defines the x coordinate of the operand
  2433. * @param y defines the y coordinate of the operand
  2434. * @param z defines the z coordinate of the operand
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2439. /**
  2440. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2441. * @returns a new Vector3
  2442. */
  2443. negate(): Vector3;
  2444. /**
  2445. * Multiplies the Vector3 coordinates by the float "scale"
  2446. * @param scale defines the multiplier factor
  2447. * @returns the current updated Vector3
  2448. */
  2449. scaleInPlace(scale: number): Vector3;
  2450. /**
  2451. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2452. * @param scale defines the multiplier factor
  2453. * @returns a new Vector3
  2454. */
  2455. scale(scale: number): Vector3;
  2456. /**
  2457. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2458. * @param scale defines the multiplier factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the current Vector3
  2461. */
  2462. scaleToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2465. * @param scale defines the scale factor
  2466. * @param result defines the Vector3 object where to store the result
  2467. * @returns the unmodified current Vector3
  2468. */
  2469. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2470. /**
  2471. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2472. * @param otherVector defines the second operand
  2473. * @returns true if both vectors are equals
  2474. */
  2475. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2478. * @param otherVector defines the second operand
  2479. * @param epsilon defines the minimal distance to define values as equals
  2480. * @returns true if both vectors are distant less than epsilon
  2481. */
  2482. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2483. /**
  2484. * Returns true if the current Vector3 coordinates equals the given floats
  2485. * @param x defines the x coordinate of the operand
  2486. * @param y defines the y coordinate of the operand
  2487. * @param z defines the z coordinate of the operand
  2488. * @returns true if both vectors are equals
  2489. */
  2490. equalsToFloats(x: number, y: number, z: number): boolean;
  2491. /**
  2492. * Multiplies the current Vector3 coordinates by the given ones
  2493. * @param otherVector defines the second operand
  2494. * @returns the current updated Vector3
  2495. */
  2496. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2497. /**
  2498. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2499. * @param otherVector defines the second operand
  2500. * @returns the new Vector3
  2501. */
  2502. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2503. /**
  2504. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2505. * @param otherVector defines the second operand
  2506. * @param result defines the Vector3 object where to store the result
  2507. * @returns the current Vector3
  2508. */
  2509. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2510. /**
  2511. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2512. * @param x defines the x coordinate of the operand
  2513. * @param y defines the y coordinate of the operand
  2514. * @param z defines the z coordinate of the operand
  2515. * @returns the new Vector3
  2516. */
  2517. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2518. /**
  2519. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2520. * @param otherVector defines the second operand
  2521. * @returns the new Vector3
  2522. */
  2523. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2526. * @param otherVector defines the second operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Divides the current Vector3 coordinates by the given ones.
  2533. * @param otherVector defines the second operand
  2534. * @returns the current updated Vector3
  2535. */
  2536. divideInPlace(otherVector: Vector3): Vector3;
  2537. /**
  2538. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2539. * @param other defines the second operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2545. * @param other defines the second operand
  2546. * @returns the current updated Vector3
  2547. */
  2548. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2549. /**
  2550. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2551. * @param x defines the x coordinate of the operand
  2552. * @param y defines the y coordinate of the operand
  2553. * @param z defines the z coordinate of the operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2557. /**
  2558. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2567. * Check if is non uniform within a certain amount of decimal places to account for this
  2568. * @param epsilon the amount the values can differ
  2569. * @returns if the the vector is non uniform to a certain number of decimal places
  2570. */
  2571. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2572. /**
  2573. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2574. */
  2575. get isNonUniform(): boolean;
  2576. /**
  2577. * Gets a new Vector3 from current Vector3 floored values
  2578. * @returns a new Vector3
  2579. */
  2580. floor(): Vector3;
  2581. /**
  2582. * Gets a new Vector3 from current Vector3 floored values
  2583. * @returns a new Vector3
  2584. */
  2585. fract(): Vector3;
  2586. /**
  2587. * Gets the length of the Vector3
  2588. * @returns the length of the Vector3
  2589. */
  2590. length(): number;
  2591. /**
  2592. * Gets the squared length of the Vector3
  2593. * @returns squared length of the Vector3
  2594. */
  2595. lengthSquared(): number;
  2596. /**
  2597. * Normalize the current Vector3.
  2598. * Please note that this is an in place operation.
  2599. * @returns the current updated Vector3
  2600. */
  2601. normalize(): Vector3;
  2602. /**
  2603. * Reorders the x y z properties of the vector in place
  2604. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2605. * @returns the current updated vector
  2606. */
  2607. reorderInPlace(order: string): this;
  2608. /**
  2609. * Rotates the vector around 0,0,0 by a quaternion
  2610. * @param quaternion the rotation quaternion
  2611. * @param result vector to store the result
  2612. * @returns the resulting vector
  2613. */
  2614. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2615. /**
  2616. * Rotates a vector around a given point
  2617. * @param quaternion the rotation quaternion
  2618. * @param point the point to rotate around
  2619. * @param result vector to store the result
  2620. * @returns the resulting vector
  2621. */
  2622. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2623. /**
  2624. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2625. * The cross product is then orthogonal to both current and "other"
  2626. * @param other defines the right operand
  2627. * @returns the cross product
  2628. */
  2629. cross(other: Vector3): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 with the given input length.
  2632. * Please note that this is an in place operation.
  2633. * @param len the length of the vector
  2634. * @returns the current updated Vector3
  2635. */
  2636. normalizeFromLength(len: number): Vector3;
  2637. /**
  2638. * Normalize the current Vector3 to a new vector
  2639. * @returns the new Vector3
  2640. */
  2641. normalizeToNew(): Vector3;
  2642. /**
  2643. * Normalize the current Vector3 to the reference
  2644. * @param reference define the Vector3 to update
  2645. * @returns the updated Vector3
  2646. */
  2647. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2648. /**
  2649. * Creates a new Vector3 copied from the current Vector3
  2650. * @returns the new Vector3
  2651. */
  2652. clone(): Vector3;
  2653. /**
  2654. * Copies the given vector coordinates to the current Vector3 ones
  2655. * @param source defines the source Vector3
  2656. * @returns the current updated Vector3
  2657. */
  2658. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2659. /**
  2660. * Copies the given floats to the current Vector3 coordinates
  2661. * @param x defines the x coordinate of the operand
  2662. * @param y defines the y coordinate of the operand
  2663. * @param z defines the z coordinate of the operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. copyFromFloats(x: number, y: number, z: number): Vector3;
  2667. /**
  2668. * Copies the given floats to the current Vector3 coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. set(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Copies the given float to the current Vector3 coordinates
  2677. * @param v defines the x, y and z coordinates of the operand
  2678. * @returns the current updated Vector3
  2679. */
  2680. setAll(v: number): Vector3;
  2681. /**
  2682. * Get the clip factor between two vectors
  2683. * @param vector0 defines the first operand
  2684. * @param vector1 defines the second operand
  2685. * @param axis defines the axis to use
  2686. * @param size defines the size along the axis
  2687. * @returns the clip factor
  2688. */
  2689. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2690. /**
  2691. * Get angle between two vectors
  2692. * @param vector0 angle between vector0 and vector1
  2693. * @param vector1 angle between vector0 and vector1
  2694. * @param normal direction of the normal
  2695. * @return the angle between vector0 and vector1
  2696. */
  2697. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given array
  2700. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. */
  2704. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2707. * @param array defines the source array
  2708. * @param offset defines the offset in the source array
  2709. * @returns the new Vector3
  2710. * @deprecated Please use FromArray instead.
  2711. */
  2712. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. */
  2719. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2720. /**
  2721. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2722. * @param array defines the source array
  2723. * @param offset defines the offset in the source array
  2724. * @param result defines the Vector3 where to store the result
  2725. * @deprecated Please use FromArrayToRef instead.
  2726. */
  2727. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2728. /**
  2729. * Sets the given vector "result" with the given floats.
  2730. * @param x defines the x coordinate of the source
  2731. * @param y defines the y coordinate of the source
  2732. * @param z defines the z coordinate of the source
  2733. * @param result defines the Vector3 where to store the result
  2734. */
  2735. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2736. /**
  2737. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2738. * @returns a new empty Vector3
  2739. */
  2740. static Zero(): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2743. * @returns a new unit Vector3
  2744. */
  2745. static One(): Vector3;
  2746. /**
  2747. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2748. * @returns a new up Vector3
  2749. */
  2750. static Up(): Vector3;
  2751. /**
  2752. * Gets a up Vector3 that must not be updated
  2753. */
  2754. static get UpReadOnly(): DeepImmutable<Vector3>;
  2755. /**
  2756. * Gets a zero Vector3 that must not be updated
  2757. */
  2758. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2761. * @returns a new down Vector3
  2762. */
  2763. static Down(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2766. * @returns a new forward Vector3
  2767. */
  2768. static Forward(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2771. * @returns a new forward Vector3
  2772. */
  2773. static Backward(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2776. * @returns a new right Vector3
  2777. */
  2778. static Right(): Vector3;
  2779. /**
  2780. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2781. * @returns a new left Vector3
  2782. */
  2783. static Left(): Vector3;
  2784. /**
  2785. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2786. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2787. * @param vector defines the Vector3 to transform
  2788. * @param transformation defines the transformation matrix
  2789. * @returns the transformed Vector3
  2790. */
  2791. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2792. /**
  2793. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2794. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2795. * @param vector defines the Vector3 to transform
  2796. * @param transformation defines the transformation matrix
  2797. * @param result defines the Vector3 where to store the result
  2798. */
  2799. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2800. /**
  2801. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2802. * This method computes tranformed coordinates only, not transformed direction vectors
  2803. * @param x define the x coordinate of the source vector
  2804. * @param y define the y coordinate of the source vector
  2805. * @param z define the z coordinate of the source vector
  2806. * @param transformation defines the transformation matrix
  2807. * @param result defines the Vector3 where to store the result
  2808. */
  2809. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2810. /**
  2811. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2812. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2813. * @param vector defines the Vector3 to transform
  2814. * @param transformation defines the transformation matrix
  2815. * @returns the new Vector3
  2816. */
  2817. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2818. /**
  2819. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2820. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @param result defines the Vector3 where to store the result
  2824. */
  2825. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2826. /**
  2827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2829. * @param x define the x coordinate of the source vector
  2830. * @param y define the y coordinate of the source vector
  2831. * @param z define the z coordinate of the source vector
  2832. * @param transformation defines the transformation matrix
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2838. * @param value1 defines the first control point
  2839. * @param value2 defines the second control point
  2840. * @param value3 defines the third control point
  2841. * @param value4 defines the fourth control point
  2842. * @param amount defines the amount on the spline to use
  2843. * @returns the new Vector3
  2844. */
  2845. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * 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"
  2848. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2849. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2850. * @param value defines the current value
  2851. * @param min defines the lower range value
  2852. * @param max defines the upper range value
  2853. * @returns the new Vector3
  2854. */
  2855. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2856. /**
  2857. * 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"
  2858. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2859. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2860. * @param value defines the current value
  2861. * @param min defines the lower range value
  2862. * @param max defines the upper range value
  2863. * @param result defines the Vector3 where to store the result
  2864. */
  2865. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2866. /**
  2867. * Checks if a given vector is inside a specific range
  2868. * @param v defines the vector to test
  2869. * @param min defines the minimum range
  2870. * @param max defines the maximum range
  2871. */
  2872. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2873. /**
  2874. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2875. * @param value1 defines the first control point
  2876. * @param tangent1 defines the first tangent vector
  2877. * @param value2 defines the second control point
  2878. * @param tangent2 defines the second tangent vector
  2879. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2880. * @returns the new Vector3
  2881. */
  2882. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2883. /**
  2884. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2885. * @param start defines the start value
  2886. * @param end defines the end value
  2887. * @param amount max defines amount between both (between 0 and 1)
  2888. * @returns the new Vector3
  2889. */
  2890. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2891. /**
  2892. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2893. * @param start defines the start value
  2894. * @param end defines the end value
  2895. * @param amount max defines amount between both (between 0 and 1)
  2896. * @param result defines the Vector3 where to store the result
  2897. */
  2898. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2899. /**
  2900. * Returns the dot product (float) between the vectors "left" and "right"
  2901. * @param left defines the left operand
  2902. * @param right defines the right operand
  2903. * @returns the dot product
  2904. */
  2905. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2906. /**
  2907. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2908. * The cross product is then orthogonal to both "left" and "right"
  2909. * @param left defines the left operand
  2910. * @param right defines the right operand
  2911. * @returns the cross product
  2912. */
  2913. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the cross product of "left" and "right"
  2916. * The cross product is then orthogonal to both "left" and "right"
  2917. * @param left defines the left operand
  2918. * @param right defines the right operand
  2919. * @param result defines the Vector3 where to store the result
  2920. */
  2921. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2922. /**
  2923. * Returns a new Vector3 as the normalization of the given vector
  2924. * @param vector defines the Vector3 to normalize
  2925. * @returns the new Vector3
  2926. */
  2927. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2928. /**
  2929. * Sets the given vector "result" with the normalization of the given first vector
  2930. * @param vector defines the Vector3 to normalize
  2931. * @param result defines the Vector3 where to store the result
  2932. */
  2933. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2934. /**
  2935. * Project a Vector3 onto screen space
  2936. * @param vector defines the Vector3 to project
  2937. * @param world defines the world matrix to use
  2938. * @param transform defines the transform (view x projection) matrix to use
  2939. * @param viewport defines the screen viewport to use
  2940. * @returns the new Vector3
  2941. */
  2942. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2943. /** @hidden */
  2944. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2945. /**
  2946. * Unproject from screen space to object space
  2947. * @param source defines the screen space Vector3 to use
  2948. * @param viewportWidth defines the current width of the viewport
  2949. * @param viewportHeight defines the current height of the viewport
  2950. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2951. * @param transform defines the transform (view x projection) matrix to use
  2952. * @returns the new Vector3
  2953. */
  2954. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2955. /**
  2956. * Unproject from screen space to object space
  2957. * @param source defines the screen space Vector3 to use
  2958. * @param viewportWidth defines the current width of the viewport
  2959. * @param viewportHeight defines the current height of the viewport
  2960. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2961. * @param view defines the view matrix to use
  2962. * @param projection defines the projection matrix to use
  2963. * @returns the new Vector3
  2964. */
  2965. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2966. /**
  2967. * Unproject from screen space to object space
  2968. * @param source defines the screen space Vector3 to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param view defines the view matrix to use
  2973. * @param projection defines the projection matrix to use
  2974. * @param result defines the Vector3 where to store the result
  2975. */
  2976. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2977. /**
  2978. * Unproject from screen space to object space
  2979. * @param sourceX defines the screen space x coordinate to use
  2980. * @param sourceY defines the screen space y coordinate to use
  2981. * @param sourceZ defines the screen space z coordinate to use
  2982. * @param viewportWidth defines the current width of the viewport
  2983. * @param viewportHeight defines the current height of the viewport
  2984. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2985. * @param view defines the view matrix to use
  2986. * @param projection defines the projection matrix to use
  2987. * @param result defines the Vector3 where to store the result
  2988. */
  2989. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2990. /**
  2991. * Gets the minimal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Gets the maximal coordinate values between two Vector3
  2999. * @param left defines the first operand
  3000. * @param right defines the second operand
  3001. * @returns the new Vector3
  3002. */
  3003. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3004. /**
  3005. * Returns the distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the distance
  3009. */
  3010. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns the squared distance between the vectors "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the squared distance
  3016. */
  3017. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3018. /**
  3019. * Returns a new Vector3 located at the center between "value1" and "value2"
  3020. * @param value1 defines the first operand
  3021. * @param value2 defines the second operand
  3022. * @returns the new Vector3
  3023. */
  3024. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3025. /**
  3026. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3027. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3028. * to something in order to rotate it from its local system to the given target system
  3029. * Note: axis1, axis2 and axis3 are normalized during this operation
  3030. * @param axis1 defines the first axis
  3031. * @param axis2 defines the second axis
  3032. * @param axis3 defines the third axis
  3033. * @returns a new Vector3
  3034. */
  3035. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3036. /**
  3037. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3038. * @param axis1 defines the first axis
  3039. * @param axis2 defines the second axis
  3040. * @param axis3 defines the third axis
  3041. * @param ref defines the Vector3 where to store the result
  3042. */
  3043. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3044. }
  3045. /**
  3046. * Vector4 class created for EulerAngle class conversion to Quaternion
  3047. */
  3048. export class Vector4 {
  3049. /** x value of the vector */
  3050. x: number;
  3051. /** y value of the vector */
  3052. y: number;
  3053. /** z value of the vector */
  3054. z: number;
  3055. /** w value of the vector */
  3056. w: number;
  3057. /**
  3058. * Creates a Vector4 object from the given floats.
  3059. * @param x x value of the vector
  3060. * @param y y value of the vector
  3061. * @param z z value of the vector
  3062. * @param w w value of the vector
  3063. */
  3064. constructor(
  3065. /** x value of the vector */
  3066. x: number,
  3067. /** y value of the vector */
  3068. y: number,
  3069. /** z value of the vector */
  3070. z: number,
  3071. /** w value of the vector */
  3072. w: number);
  3073. /**
  3074. * Returns the string with the Vector4 coordinates.
  3075. * @returns a string containing all the vector values
  3076. */
  3077. toString(): string;
  3078. /**
  3079. * Returns the string "Vector4".
  3080. * @returns "Vector4"
  3081. */
  3082. getClassName(): string;
  3083. /**
  3084. * Returns the Vector4 hash code.
  3085. * @returns a unique hash code
  3086. */
  3087. getHashCode(): number;
  3088. /**
  3089. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3090. * @returns the resulting array
  3091. */
  3092. asArray(): number[];
  3093. /**
  3094. * Populates the given array from the given index with the Vector4 coordinates.
  3095. * @param array array to populate
  3096. * @param index index of the array to start at (default: 0)
  3097. * @returns the Vector4.
  3098. */
  3099. toArray(array: FloatArray, index?: number): Vector4;
  3100. /**
  3101. * Adds the given vector to the current Vector4.
  3102. * @param otherVector the vector to add
  3103. * @returns the updated Vector4.
  3104. */
  3105. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3106. /**
  3107. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3108. * @param otherVector the vector to add
  3109. * @returns the resulting vector
  3110. */
  3111. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3112. /**
  3113. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3114. * @param otherVector the vector to add
  3115. * @param result the vector to store the result
  3116. * @returns the current Vector4.
  3117. */
  3118. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3119. /**
  3120. * Subtract in place the given vector from the current Vector4.
  3121. * @param otherVector the vector to subtract
  3122. * @returns the updated Vector4.
  3123. */
  3124. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3125. /**
  3126. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3127. * @param otherVector the vector to add
  3128. * @returns the new vector with the result
  3129. */
  3130. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3131. /**
  3132. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3133. * @param otherVector the vector to subtract
  3134. * @param result the vector to store the result
  3135. * @returns the current Vector4.
  3136. */
  3137. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3138. /**
  3139. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3140. */
  3141. /**
  3142. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3143. * @param x value to subtract
  3144. * @param y value to subtract
  3145. * @param z value to subtract
  3146. * @param w value to subtract
  3147. * @returns new vector containing the result
  3148. */
  3149. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3150. /**
  3151. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3152. * @param x value to subtract
  3153. * @param y value to subtract
  3154. * @param z value to subtract
  3155. * @param w value to subtract
  3156. * @param result the vector to store the result in
  3157. * @returns the current Vector4.
  3158. */
  3159. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3160. /**
  3161. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3162. * @returns a new vector with the negated values
  3163. */
  3164. negate(): Vector4;
  3165. /**
  3166. * Multiplies the current Vector4 coordinates by scale (float).
  3167. * @param scale the number to scale with
  3168. * @returns the updated Vector4.
  3169. */
  3170. scaleInPlace(scale: number): Vector4;
  3171. /**
  3172. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3173. * @param scale the number to scale with
  3174. * @returns a new vector with the result
  3175. */
  3176. scale(scale: number): Vector4;
  3177. /**
  3178. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3179. * @param scale the number to scale with
  3180. * @param result a vector to store the result in
  3181. * @returns the current Vector4.
  3182. */
  3183. scaleToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3186. * @param scale defines the scale factor
  3187. * @param result defines the Vector4 object where to store the result
  3188. * @returns the unmodified current Vector4
  3189. */
  3190. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3191. /**
  3192. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3193. * @param otherVector the vector to compare against
  3194. * @returns true if they are equal
  3195. */
  3196. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3197. /**
  3198. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3199. * @param otherVector vector to compare against
  3200. * @param epsilon (Default: very small number)
  3201. * @returns true if they are equal
  3202. */
  3203. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3204. /**
  3205. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3206. * @param x x value to compare against
  3207. * @param y y value to compare against
  3208. * @param z z value to compare against
  3209. * @param w w value to compare against
  3210. * @returns true if equal
  3211. */
  3212. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3213. /**
  3214. * Multiplies in place the current Vector4 by the given one.
  3215. * @param otherVector vector to multiple with
  3216. * @returns the updated Vector4.
  3217. */
  3218. multiplyInPlace(otherVector: Vector4): Vector4;
  3219. /**
  3220. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3221. * @param otherVector vector to multiple with
  3222. * @returns resulting new vector
  3223. */
  3224. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3225. /**
  3226. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3227. * @param otherVector vector to multiple with
  3228. * @param result vector to store the result
  3229. * @returns the current Vector4.
  3230. */
  3231. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3232. /**
  3233. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3234. * @param x x value multiply with
  3235. * @param y y value multiply with
  3236. * @param z z value multiply with
  3237. * @param w w value multiply with
  3238. * @returns resulting new vector
  3239. */
  3240. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3241. /**
  3242. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3243. * @param otherVector vector to devide with
  3244. * @returns resulting new vector
  3245. */
  3246. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3247. /**
  3248. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3249. * @param otherVector vector to devide with
  3250. * @param result vector to store the result
  3251. * @returns the current Vector4.
  3252. */
  3253. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3254. /**
  3255. * Divides the current Vector3 coordinates by the given ones.
  3256. * @param otherVector vector to devide with
  3257. * @returns the updated Vector3.
  3258. */
  3259. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3260. /**
  3261. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3262. * @param other defines the second operand
  3263. * @returns the current updated Vector4
  3264. */
  3265. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3268. * @param other defines the second operand
  3269. * @returns the current updated Vector4
  3270. */
  3271. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3272. /**
  3273. * Gets a new Vector4 from current Vector4 floored values
  3274. * @returns a new Vector4
  3275. */
  3276. floor(): Vector4;
  3277. /**
  3278. * Gets a new Vector4 from current Vector3 floored values
  3279. * @returns a new Vector4
  3280. */
  3281. fract(): Vector4;
  3282. /**
  3283. * Returns the Vector4 length (float).
  3284. * @returns the length
  3285. */
  3286. length(): number;
  3287. /**
  3288. * Returns the Vector4 squared length (float).
  3289. * @returns the length squared
  3290. */
  3291. lengthSquared(): number;
  3292. /**
  3293. * Normalizes in place the Vector4.
  3294. * @returns the updated Vector4.
  3295. */
  3296. normalize(): Vector4;
  3297. /**
  3298. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3299. * @returns this converted to a new vector3
  3300. */
  3301. toVector3(): Vector3;
  3302. /**
  3303. * Returns a new Vector4 copied from the current one.
  3304. * @returns the new cloned vector
  3305. */
  3306. clone(): Vector4;
  3307. /**
  3308. * Updates the current Vector4 with the given one coordinates.
  3309. * @param source the source vector to copy from
  3310. * @returns the updated Vector4.
  3311. */
  3312. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3313. /**
  3314. * Updates the current Vector4 coordinates with the given floats.
  3315. * @param x float to copy from
  3316. * @param y float to copy from
  3317. * @param z float to copy from
  3318. * @param w float to copy from
  3319. * @returns the updated Vector4.
  3320. */
  3321. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3322. /**
  3323. * Updates the current Vector4 coordinates with the given floats.
  3324. * @param x float to set from
  3325. * @param y float to set from
  3326. * @param z float to set from
  3327. * @param w float to set from
  3328. * @returns the updated Vector4.
  3329. */
  3330. set(x: number, y: number, z: number, w: number): Vector4;
  3331. /**
  3332. * Copies the given float to the current Vector3 coordinates
  3333. * @param v defines the x, y, z and w coordinates of the operand
  3334. * @returns the current updated Vector3
  3335. */
  3336. setAll(v: number): Vector4;
  3337. /**
  3338. * Returns a new Vector4 set from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @returns the new vector
  3342. */
  3343. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" from the starting index of the given Float32Array.
  3353. * @param array the array to pull values from
  3354. * @param offset the offset into the array to start at
  3355. * @param result the vector to store the result in
  3356. */
  3357. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3358. /**
  3359. * Updates the given vector "result" coordinates from the given floats.
  3360. * @param x float to set from
  3361. * @param y float to set from
  3362. * @param z float to set from
  3363. * @param w float to set from
  3364. * @param result the vector to the floats in
  3365. */
  3366. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3367. /**
  3368. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3369. * @returns the new vector
  3370. */
  3371. static Zero(): Vector4;
  3372. /**
  3373. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3374. * @returns the new vector
  3375. */
  3376. static One(): Vector4;
  3377. /**
  3378. * Returns a new normalized Vector4 from the given one.
  3379. * @param vector the vector to normalize
  3380. * @returns the vector
  3381. */
  3382. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3383. /**
  3384. * Updates the given vector "result" from the normalization of the given one.
  3385. * @param vector the vector to normalize
  3386. * @param result the vector to store the result in
  3387. */
  3388. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3389. /**
  3390. * Returns a vector with the minimum values from the left and right vectors
  3391. * @param left left vector to minimize
  3392. * @param right right vector to minimize
  3393. * @returns a new vector with the minimum of the left and right vector values
  3394. */
  3395. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns a vector with the maximum values from the left and right vectors
  3398. * @param left left vector to maximize
  3399. * @param right right vector to maximize
  3400. * @returns a new vector with the maximum of the left and right vector values
  3401. */
  3402. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3403. /**
  3404. * Returns the distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors
  3408. */
  3409. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the distance between
  3413. * @param value2 value to calulate the distance between
  3414. * @return the distance between the two vectors squared
  3415. */
  3416. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3417. /**
  3418. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3419. * @param value1 value to calulate the center between
  3420. * @param value2 value to calulate the center between
  3421. * @return the center between the two vectors
  3422. */
  3423. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3424. /**
  3425. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3426. * This methods computes transformed normalized direction vectors only.
  3427. * @param vector the vector to transform
  3428. * @param transformation the transformation matrix to apply
  3429. * @returns the new vector
  3430. */
  3431. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3432. /**
  3433. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3434. * This methods computes transformed normalized direction vectors only.
  3435. * @param vector the vector to transform
  3436. * @param transformation the transformation matrix to apply
  3437. * @param result the vector to store the result in
  3438. */
  3439. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3440. /**
  3441. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3442. * This methods computes transformed normalized direction vectors only.
  3443. * @param x value to transform
  3444. * @param y value to transform
  3445. * @param z value to transform
  3446. * @param w value to transform
  3447. * @param transformation the transformation matrix to apply
  3448. * @param result the vector to store the results in
  3449. */
  3450. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3451. /**
  3452. * Creates a new Vector4 from a Vector3
  3453. * @param source defines the source data
  3454. * @param w defines the 4th component (default is 0)
  3455. * @returns a new Vector4
  3456. */
  3457. static FromVector3(source: Vector3, w?: number): Vector4;
  3458. }
  3459. /**
  3460. * Class used to store quaternion data
  3461. * @see https://en.wikipedia.org/wiki/Quaternion
  3462. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3463. */
  3464. export class Quaternion {
  3465. /** defines the first component (0 by default) */
  3466. x: number;
  3467. /** defines the second component (0 by default) */
  3468. y: number;
  3469. /** defines the third component (0 by default) */
  3470. z: number;
  3471. /** defines the fourth component (1.0 by default) */
  3472. w: number;
  3473. /**
  3474. * Creates a new Quaternion from the given floats
  3475. * @param x defines the first component (0 by default)
  3476. * @param y defines the second component (0 by default)
  3477. * @param z defines the third component (0 by default)
  3478. * @param w defines the fourth component (1.0 by default)
  3479. */
  3480. constructor(
  3481. /** defines the first component (0 by default) */
  3482. x?: number,
  3483. /** defines the second component (0 by default) */
  3484. y?: number,
  3485. /** defines the third component (0 by default) */
  3486. z?: number,
  3487. /** defines the fourth component (1.0 by default) */
  3488. w?: number);
  3489. /**
  3490. * Gets a string representation for the current quaternion
  3491. * @returns a string with the Quaternion coordinates
  3492. */
  3493. toString(): string;
  3494. /**
  3495. * Gets the class name of the quaternion
  3496. * @returns the string "Quaternion"
  3497. */
  3498. getClassName(): string;
  3499. /**
  3500. * Gets a hash code for this quaternion
  3501. * @returns the quaternion hash code
  3502. */
  3503. getHashCode(): number;
  3504. /**
  3505. * Copy the quaternion to an array
  3506. * @returns a new array populated with 4 elements from the quaternion coordinates
  3507. */
  3508. asArray(): number[];
  3509. /**
  3510. * Check if two quaternions are equals
  3511. * @param otherQuaternion defines the second operand
  3512. * @return true if the current quaternion and the given one coordinates are strictly equals
  3513. */
  3514. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3515. /**
  3516. * Clone the current quaternion
  3517. * @returns a new quaternion copied from the current one
  3518. */
  3519. clone(): Quaternion;
  3520. /**
  3521. * Copy a quaternion to the current one
  3522. * @param other defines the other quaternion
  3523. * @returns the updated current quaternion
  3524. */
  3525. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3526. /**
  3527. * Updates the current quaternion with the given float coordinates
  3528. * @param x defines the x coordinate
  3529. * @param y defines the y coordinate
  3530. * @param z defines the z coordinate
  3531. * @param w defines the w coordinate
  3532. * @returns the updated current quaternion
  3533. */
  3534. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3535. /**
  3536. * Updates the current quaternion from the given float coordinates
  3537. * @param x defines the x coordinate
  3538. * @param y defines the y coordinate
  3539. * @param z defines the z coordinate
  3540. * @param w defines the w coordinate
  3541. * @returns the updated current quaternion
  3542. */
  3543. set(x: number, y: number, z: number, w: number): Quaternion;
  3544. /**
  3545. * Adds two quaternions
  3546. * @param other defines the second operand
  3547. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3548. */
  3549. add(other: DeepImmutable<Quaternion>): Quaternion;
  3550. /**
  3551. * Add a quaternion to the current one
  3552. * @param other defines the quaternion to add
  3553. * @returns the current quaternion
  3554. */
  3555. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3556. /**
  3557. * Subtract two quaternions
  3558. * @param other defines the second operand
  3559. * @returns a new quaternion as the subtraction result of the given one from the current one
  3560. */
  3561. subtract(other: Quaternion): Quaternion;
  3562. /**
  3563. * Multiplies the current quaternion by a scale factor
  3564. * @param value defines the scale factor
  3565. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3566. */
  3567. scale(value: number): Quaternion;
  3568. /**
  3569. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3570. * @param scale defines the scale factor
  3571. * @param result defines the Quaternion object where to store the result
  3572. * @returns the unmodified current quaternion
  3573. */
  3574. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3575. /**
  3576. * Multiplies in place the current quaternion by a scale factor
  3577. * @param value defines the scale factor
  3578. * @returns the current modified quaternion
  3579. */
  3580. scaleInPlace(value: number): Quaternion;
  3581. /**
  3582. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3583. * @param scale defines the scale factor
  3584. * @param result defines the Quaternion object where to store the result
  3585. * @returns the unmodified current quaternion
  3586. */
  3587. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies two quaternions
  3590. * @param q1 defines the second operand
  3591. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3592. */
  3593. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3594. /**
  3595. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @param result defines the target quaternion
  3598. * @returns the current quaternion
  3599. */
  3600. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3601. /**
  3602. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3603. * @param q1 defines the second operand
  3604. * @returns the currentupdated quaternion
  3605. */
  3606. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3607. /**
  3608. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3609. * @param ref defines the target quaternion
  3610. * @returns the current quaternion
  3611. */
  3612. conjugateToRef(ref: Quaternion): Quaternion;
  3613. /**
  3614. * Conjugates in place (1-q) the current quaternion
  3615. * @returns the current updated quaternion
  3616. */
  3617. conjugateInPlace(): Quaternion;
  3618. /**
  3619. * Conjugates in place (1-q) the current quaternion
  3620. * @returns a new quaternion
  3621. */
  3622. conjugate(): Quaternion;
  3623. /**
  3624. * Gets length of current quaternion
  3625. * @returns the quaternion length (float)
  3626. */
  3627. length(): number;
  3628. /**
  3629. * Normalize in place the current quaternion
  3630. * @returns the current updated quaternion
  3631. */
  3632. normalize(): Quaternion;
  3633. /**
  3634. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns a new Vector3 containing the Euler angles
  3637. */
  3638. toEulerAngles(order?: string): Vector3;
  3639. /**
  3640. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3641. * @param result defines the vector which will be filled with the Euler angles
  3642. * @param order is a reserved parameter and is ignore for now
  3643. * @returns the current unchanged quaternion
  3644. */
  3645. toEulerAnglesToRef(result: Vector3): Quaternion;
  3646. /**
  3647. * Updates the given rotation matrix with the current quaternion values
  3648. * @param result defines the target matrix
  3649. * @returns the current unchanged quaternion
  3650. */
  3651. toRotationMatrix(result: Matrix): Quaternion;
  3652. /**
  3653. * Updates the current quaternion from the given rotation matrix values
  3654. * @param matrix defines the source matrix
  3655. * @returns the current updated quaternion
  3656. */
  3657. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3658. /**
  3659. * Creates a new quaternion from a rotation matrix
  3660. * @param matrix defines the source matrix
  3661. * @returns a new quaternion created from the given rotation matrix values
  3662. */
  3663. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3664. /**
  3665. * Updates the given quaternion with the given rotation matrix values
  3666. * @param matrix defines the source matrix
  3667. * @param result defines the target quaternion
  3668. */
  3669. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3670. /**
  3671. * Returns the dot product (float) between the quaternions "left" and "right"
  3672. * @param left defines the left operand
  3673. * @param right defines the right operand
  3674. * @returns the dot product
  3675. */
  3676. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3677. /**
  3678. * Checks if the two quaternions are close to each other
  3679. * @param quat0 defines the first quaternion to check
  3680. * @param quat1 defines the second quaternion to check
  3681. * @returns true if the two quaternions are close to each other
  3682. */
  3683. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3684. /**
  3685. * Creates an empty quaternion
  3686. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3687. */
  3688. static Zero(): Quaternion;
  3689. /**
  3690. * Inverse a given quaternion
  3691. * @param q defines the source quaternion
  3692. * @returns a new quaternion as the inverted current quaternion
  3693. */
  3694. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3695. /**
  3696. * Inverse a given quaternion
  3697. * @param q defines the source quaternion
  3698. * @param result the quaternion the result will be stored in
  3699. * @returns the result quaternion
  3700. */
  3701. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3702. /**
  3703. * Creates an identity quaternion
  3704. * @returns the identity quaternion
  3705. */
  3706. static Identity(): Quaternion;
  3707. /**
  3708. * Gets a boolean indicating if the given quaternion is identity
  3709. * @param quaternion defines the quaternion to check
  3710. * @returns true if the quaternion is identity
  3711. */
  3712. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3713. /**
  3714. * Creates a quaternion from a rotation around an axis
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3718. */
  3719. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3720. /**
  3721. * Creates a rotation around an axis and stores it into the given quaternion
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle to use
  3724. * @param result defines the target quaternion
  3725. * @returns the target quaternion
  3726. */
  3727. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from data stored into an array
  3730. * @param array defines the data source
  3731. * @param offset defines the offset in the source array where the data starts
  3732. * @returns a new quaternion
  3733. */
  3734. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3735. /**
  3736. * Create a quaternion from Euler rotation angles
  3737. * @param x Pitch
  3738. * @param y Yaw
  3739. * @param z Roll
  3740. * @returns the new Quaternion
  3741. */
  3742. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3743. /**
  3744. * Updates a quaternion from Euler rotation angles
  3745. * @param x Pitch
  3746. * @param y Yaw
  3747. * @param z Roll
  3748. * @param result the quaternion to store the result
  3749. * @returns the updated quaternion
  3750. */
  3751. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3752. /**
  3753. * Create a quaternion from Euler rotation vector
  3754. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3755. * @returns the new Quaternion
  3756. */
  3757. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3758. /**
  3759. * Updates a quaternion from Euler rotation vector
  3760. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3761. * @param result the quaternion to store the result
  3762. * @returns the updated quaternion
  3763. */
  3764. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3765. /**
  3766. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3767. * @param yaw defines the rotation around Y axis
  3768. * @param pitch defines the rotation around X axis
  3769. * @param roll defines the rotation around Z axis
  3770. * @returns the new quaternion
  3771. */
  3772. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3773. /**
  3774. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3775. * @param yaw defines the rotation around Y axis
  3776. * @param pitch defines the rotation around X axis
  3777. * @param roll defines the rotation around Z axis
  3778. * @param result defines the target quaternion
  3779. */
  3780. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3781. /**
  3782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3783. * @param alpha defines the rotation around first axis
  3784. * @param beta defines the rotation around second axis
  3785. * @param gamma defines the rotation around third axis
  3786. * @returns the new quaternion
  3787. */
  3788. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3789. /**
  3790. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3791. * @param alpha defines the rotation around first axis
  3792. * @param beta defines the rotation around second axis
  3793. * @param gamma defines the rotation around third axis
  3794. * @param result defines the target quaternion
  3795. */
  3796. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3797. /**
  3798. * 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)
  3799. * @param axis1 defines the first axis
  3800. * @param axis2 defines the second axis
  3801. * @param axis3 defines the third axis
  3802. * @returns the new quaternion
  3803. */
  3804. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3805. /**
  3806. * 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
  3807. * @param axis1 defines the first axis
  3808. * @param axis2 defines the second axis
  3809. * @param axis3 defines the third axis
  3810. * @param ref defines the target quaternion
  3811. */
  3812. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3813. /**
  3814. * Interpolates between two quaternions
  3815. * @param left defines first quaternion
  3816. * @param right defines second quaternion
  3817. * @param amount defines the gradient to use
  3818. * @returns the new interpolated quaternion
  3819. */
  3820. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3821. /**
  3822. * Interpolates between two quaternions and stores it into a target quaternion
  3823. * @param left defines first quaternion
  3824. * @param right defines second quaternion
  3825. * @param amount defines the gradient to use
  3826. * @param result defines the target quaternion
  3827. */
  3828. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3829. /**
  3830. * Interpolate between two quaternions using Hermite interpolation
  3831. * @param value1 defines first quaternion
  3832. * @param tangent1 defines the incoming tangent
  3833. * @param value2 defines second quaternion
  3834. * @param tangent2 defines the outgoing tangent
  3835. * @param amount defines the target quaternion
  3836. * @returns the new interpolated quaternion
  3837. */
  3838. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3839. }
  3840. /**
  3841. * Class used to store matrix data (4x4)
  3842. */
  3843. export class Matrix {
  3844. private static _updateFlagSeed;
  3845. private static _identityReadOnly;
  3846. private _isIdentity;
  3847. private _isIdentityDirty;
  3848. private _isIdentity3x2;
  3849. private _isIdentity3x2Dirty;
  3850. /**
  3851. * Gets the update flag of the matrix which is an unique number for the matrix.
  3852. * It will be incremented every time the matrix data change.
  3853. * You can use it to speed the comparison between two versions of the same matrix.
  3854. */
  3855. updateFlag: number;
  3856. private readonly _m;
  3857. /**
  3858. * Gets the internal data of the matrix
  3859. */
  3860. get m(): DeepImmutable<Float32Array>;
  3861. /** @hidden */
  3862. _markAsUpdated(): void;
  3863. /** @hidden */
  3864. private _updateIdentityStatus;
  3865. /**
  3866. * Creates an empty matrix (filled with zeros)
  3867. */
  3868. constructor();
  3869. /**
  3870. * Check if the current matrix is identity
  3871. * @returns true is the matrix is the identity matrix
  3872. */
  3873. isIdentity(): boolean;
  3874. /**
  3875. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3876. * @returns true is the matrix is the identity matrix
  3877. */
  3878. isIdentityAs3x2(): boolean;
  3879. /**
  3880. * Gets the determinant of the matrix
  3881. * @returns the matrix determinant
  3882. */
  3883. determinant(): number;
  3884. /**
  3885. * Returns the matrix as a Float32Array
  3886. * @returns the matrix underlying array
  3887. */
  3888. toArray(): DeepImmutable<Float32Array>;
  3889. /**
  3890. * Returns the matrix as a Float32Array
  3891. * @returns the matrix underlying array.
  3892. */
  3893. asArray(): DeepImmutable<Float32Array>;
  3894. /**
  3895. * Inverts the current matrix in place
  3896. * @returns the current inverted matrix
  3897. */
  3898. invert(): Matrix;
  3899. /**
  3900. * Sets all the matrix elements to zero
  3901. * @returns the current matrix
  3902. */
  3903. reset(): Matrix;
  3904. /**
  3905. * Adds the current matrix with a second one
  3906. * @param other defines the matrix to add
  3907. * @returns a new matrix as the addition of the current matrix and the given one
  3908. */
  3909. add(other: DeepImmutable<Matrix>): Matrix;
  3910. /**
  3911. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3912. * @param other defines the matrix to add
  3913. * @param result defines the target matrix
  3914. * @returns the current matrix
  3915. */
  3916. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3917. /**
  3918. * Adds in place the given matrix to the current matrix
  3919. * @param other defines the second operand
  3920. * @returns the current updated matrix
  3921. */
  3922. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3923. /**
  3924. * Sets the given matrix to the current inverted Matrix
  3925. * @param other defines the target matrix
  3926. * @returns the unmodified current matrix
  3927. */
  3928. invertToRef(other: Matrix): Matrix;
  3929. /**
  3930. * add a value at the specified position in the current Matrix
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. addAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * mutiply the specified position in the current Matrix by a value
  3938. * @param index the index of the value within the matrix. between 0 and 15.
  3939. * @param value the value to be added
  3940. * @returns the current updated matrix
  3941. */
  3942. multiplyAtIndex(index: number, value: number): Matrix;
  3943. /**
  3944. * Inserts the translation vector (using 3 floats) in the current matrix
  3945. * @param x defines the 1st component of the translation
  3946. * @param y defines the 2nd component of the translation
  3947. * @param z defines the 3rd component of the translation
  3948. * @returns the current updated matrix
  3949. */
  3950. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3951. /**
  3952. * Adds the translation vector (using 3 floats) in the current matrix
  3953. * @param x defines the 1st component of the translation
  3954. * @param y defines the 2nd component of the translation
  3955. * @param z defines the 3rd component of the translation
  3956. * @returns the current updated matrix
  3957. */
  3958. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3959. /**
  3960. * Inserts the translation vector in the current matrix
  3961. * @param vector3 defines the translation to insert
  3962. * @returns the current updated matrix
  3963. */
  3964. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3965. /**
  3966. * Gets the translation value of the current matrix
  3967. * @returns a new Vector3 as the extracted translation from the matrix
  3968. */
  3969. getTranslation(): Vector3;
  3970. /**
  3971. * Fill a Vector3 with the extracted translation from the matrix
  3972. * @param result defines the Vector3 where to store the translation
  3973. * @returns the current matrix
  3974. */
  3975. getTranslationToRef(result: Vector3): Matrix;
  3976. /**
  3977. * Remove rotation and scaling part from the matrix
  3978. * @returns the updated matrix
  3979. */
  3980. removeRotationAndScaling(): Matrix;
  3981. /**
  3982. * Multiply two matrices
  3983. * @param other defines the second operand
  3984. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3985. */
  3986. multiply(other: DeepImmutable<Matrix>): Matrix;
  3987. /**
  3988. * Copy the current matrix from the given one
  3989. * @param other defines the source matrix
  3990. * @returns the current updated matrix
  3991. */
  3992. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3993. /**
  3994. * Populates the given array from the starting index with the current matrix values
  3995. * @param array defines the target array
  3996. * @param offset defines the offset in the target array where to start storing values
  3997. * @returns the current matrix
  3998. */
  3999. copyToArray(array: Float32Array, offset?: number): Matrix;
  4000. /**
  4001. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the matrix where to store the multiplication
  4004. * @returns the current matrix
  4005. */
  4006. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4007. /**
  4008. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4009. * @param other defines the second operand
  4010. * @param result defines the array where to store the multiplication
  4011. * @param offset defines the offset in the target array where to start storing values
  4012. * @returns the current matrix
  4013. */
  4014. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4015. /**
  4016. * Check equality between this matrix and a second one
  4017. * @param value defines the second matrix to compare
  4018. * @returns true is the current matrix and the given one values are strictly equal
  4019. */
  4020. equals(value: DeepImmutable<Matrix>): boolean;
  4021. /**
  4022. * Clone the current matrix
  4023. * @returns a new matrix from the current matrix
  4024. */
  4025. clone(): Matrix;
  4026. /**
  4027. * Returns the name of the current matrix class
  4028. * @returns the string "Matrix"
  4029. */
  4030. getClassName(): string;
  4031. /**
  4032. * Gets the hash code of the current matrix
  4033. * @returns the hash code
  4034. */
  4035. getHashCode(): number;
  4036. /**
  4037. * Decomposes the current Matrix into a translation, rotation and scaling components
  4038. * @param scale defines the scale vector3 given as a reference to update
  4039. * @param rotation defines the rotation quaternion given as a reference to update
  4040. * @param translation defines the translation vector3 given as a reference to update
  4041. * @returns true if operation was successful
  4042. */
  4043. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4044. /**
  4045. * Gets specific row of the matrix
  4046. * @param index defines the number of the row to get
  4047. * @returns the index-th row of the current matrix as a new Vector4
  4048. */
  4049. getRow(index: number): Nullable<Vector4>;
  4050. /**
  4051. * Sets the index-th row of the current matrix to the vector4 values
  4052. * @param index defines the number of the row to set
  4053. * @param row defines the target vector4
  4054. * @returns the updated current matrix
  4055. */
  4056. setRow(index: number, row: Vector4): Matrix;
  4057. /**
  4058. * Compute the transpose of the matrix
  4059. * @returns the new transposed matrix
  4060. */
  4061. transpose(): Matrix;
  4062. /**
  4063. * Compute the transpose of the matrix and store it in a given matrix
  4064. * @param result defines the target matrix
  4065. * @returns the current matrix
  4066. */
  4067. transposeToRef(result: Matrix): Matrix;
  4068. /**
  4069. * Sets the index-th row of the current matrix with the given 4 x float values
  4070. * @param index defines the row index
  4071. * @param x defines the x component to set
  4072. * @param y defines the y component to set
  4073. * @param z defines the z component to set
  4074. * @param w defines the w component to set
  4075. * @returns the updated current matrix
  4076. */
  4077. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4078. /**
  4079. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4080. * @param scale defines the scale factor
  4081. * @returns a new matrix
  4082. */
  4083. scale(scale: number): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor to a given result matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Scale the current matrix values by a factor and add the result to a given matrix
  4093. * @param scale defines the scale factor
  4094. * @param result defines the Matrix to store the result
  4095. * @returns the current matrix
  4096. */
  4097. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4098. /**
  4099. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4100. * @param ref matrix to store the result
  4101. */
  4102. toNormalMatrix(ref: Matrix): void;
  4103. /**
  4104. * Gets only rotation part of the current matrix
  4105. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4106. */
  4107. getRotationMatrix(): Matrix;
  4108. /**
  4109. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4110. * @param result defines the target matrix to store data to
  4111. * @returns the current matrix
  4112. */
  4113. getRotationMatrixToRef(result: Matrix): Matrix;
  4114. /**
  4115. * Toggles model matrix from being right handed to left handed in place and vice versa
  4116. */
  4117. toggleModelMatrixHandInPlace(): void;
  4118. /**
  4119. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4120. */
  4121. toggleProjectionMatrixHandInPlace(): void;
  4122. /**
  4123. * Creates a matrix from an array
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @returns a new Matrix set from the starting index of the given array
  4127. */
  4128. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4129. /**
  4130. * Copy the content of an array into a given matrix
  4131. * @param array defines the source array
  4132. * @param offset defines an offset in the source array
  4133. * @param result defines the target matrix
  4134. */
  4135. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4136. /**
  4137. * Stores an array into a matrix after having multiplied each component by a given factor
  4138. * @param array defines the source array
  4139. * @param offset defines the offset in the source array
  4140. * @param scale defines the scaling factor
  4141. * @param result defines the target matrix
  4142. */
  4143. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4144. /**
  4145. * Gets an identity matrix that must not be updated
  4146. */
  4147. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4148. /**
  4149. * Stores a list of values (16) inside a given matrix
  4150. * @param initialM11 defines 1st value of 1st row
  4151. * @param initialM12 defines 2nd value of 1st row
  4152. * @param initialM13 defines 3rd value of 1st row
  4153. * @param initialM14 defines 4th value of 1st row
  4154. * @param initialM21 defines 1st value of 2nd row
  4155. * @param initialM22 defines 2nd value of 2nd row
  4156. * @param initialM23 defines 3rd value of 2nd row
  4157. * @param initialM24 defines 4th value of 2nd row
  4158. * @param initialM31 defines 1st value of 3rd row
  4159. * @param initialM32 defines 2nd value of 3rd row
  4160. * @param initialM33 defines 3rd value of 3rd row
  4161. * @param initialM34 defines 4th value of 3rd row
  4162. * @param initialM41 defines 1st value of 4th row
  4163. * @param initialM42 defines 2nd value of 4th row
  4164. * @param initialM43 defines 3rd value of 4th row
  4165. * @param initialM44 defines 4th value of 4th row
  4166. * @param result defines the target matrix
  4167. */
  4168. 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;
  4169. /**
  4170. * Creates new matrix from a list of values (16)
  4171. * @param initialM11 defines 1st value of 1st row
  4172. * @param initialM12 defines 2nd value of 1st row
  4173. * @param initialM13 defines 3rd value of 1st row
  4174. * @param initialM14 defines 4th value of 1st row
  4175. * @param initialM21 defines 1st value of 2nd row
  4176. * @param initialM22 defines 2nd value of 2nd row
  4177. * @param initialM23 defines 3rd value of 2nd row
  4178. * @param initialM24 defines 4th value of 2nd row
  4179. * @param initialM31 defines 1st value of 3rd row
  4180. * @param initialM32 defines 2nd value of 3rd row
  4181. * @param initialM33 defines 3rd value of 3rd row
  4182. * @param initialM34 defines 4th value of 3rd row
  4183. * @param initialM41 defines 1st value of 4th row
  4184. * @param initialM42 defines 2nd value of 4th row
  4185. * @param initialM43 defines 3rd value of 4th row
  4186. * @param initialM44 defines 4th value of 4th row
  4187. * @returns the new matrix
  4188. */
  4189. 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;
  4190. /**
  4191. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4192. * @param scale defines the scale vector3
  4193. * @param rotation defines the rotation quaternion
  4194. * @param translation defines the translation vector3
  4195. * @returns a new matrix
  4196. */
  4197. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4198. /**
  4199. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4200. * @param scale defines the scale vector3
  4201. * @param rotation defines the rotation quaternion
  4202. * @param translation defines the translation vector3
  4203. * @param result defines the target matrix
  4204. */
  4205. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4206. /**
  4207. * Creates a new identity matrix
  4208. * @returns a new identity matrix
  4209. */
  4210. static Identity(): Matrix;
  4211. /**
  4212. * Creates a new identity matrix and stores the result in a given matrix
  4213. * @param result defines the target matrix
  4214. */
  4215. static IdentityToRef(result: Matrix): void;
  4216. /**
  4217. * Creates a new zero matrix
  4218. * @returns a new zero matrix
  4219. */
  4220. static Zero(): Matrix;
  4221. /**
  4222. * Creates a new rotation matrix for "angle" radians around the X axis
  4223. * @param angle defines the angle (in radians) to use
  4224. * @return the new matrix
  4225. */
  4226. static RotationX(angle: number): Matrix;
  4227. /**
  4228. * Creates a new matrix as the invert of a given matrix
  4229. * @param source defines the source matrix
  4230. * @returns the new matrix
  4231. */
  4232. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the X 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 RotationXToRef(angle: number, result: Matrix): void;
  4239. /**
  4240. * Creates a new rotation matrix for "angle" radians around the Y axis
  4241. * @param angle defines the angle (in radians) to use
  4242. * @return the new matrix
  4243. */
  4244. static RotationY(angle: number): Matrix;
  4245. /**
  4246. * Creates a new rotation matrix for "angle" radians around the Y 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 RotationYToRef(angle: number, result: Matrix): void;
  4251. /**
  4252. * Creates a new rotation matrix for "angle" radians around the Z axis
  4253. * @param angle defines the angle (in radians) to use
  4254. * @return the new matrix
  4255. */
  4256. static RotationZ(angle: number): Matrix;
  4257. /**
  4258. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4259. * @param angle defines the angle (in radians) to use
  4260. * @param result defines the target matrix
  4261. */
  4262. static RotationZToRef(angle: number, result: Matrix): void;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @return the new matrix
  4268. */
  4269. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4270. /**
  4271. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4272. * @param axis defines the axis to use
  4273. * @param angle defines the angle (in radians) to use
  4274. * @param result defines the target matrix
  4275. */
  4276. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4277. /**
  4278. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4279. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4280. * @param from defines the vector to align
  4281. * @param to defines the vector to align to
  4282. * @param result defines the target matrix
  4283. */
  4284. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4285. /**
  4286. * Creates a rotation matrix
  4287. * @param yaw defines the yaw angle in radians (Y axis)
  4288. * @param pitch defines the pitch angle in radians (X axis)
  4289. * @param roll defines the roll angle in radians (X axis)
  4290. * @returns the new rotation matrix
  4291. */
  4292. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4293. /**
  4294. * Creates a rotation matrix and stores it in a given matrix
  4295. * @param yaw defines the yaw angle in radians (Y axis)
  4296. * @param pitch defines the pitch angle in radians (X axis)
  4297. * @param roll defines the roll angle in radians (X axis)
  4298. * @param result defines the target matrix
  4299. */
  4300. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4301. /**
  4302. * Creates a scaling matrix
  4303. * @param x defines the scale factor on X axis
  4304. * @param y defines the scale factor on Y axis
  4305. * @param z defines the scale factor on Z axis
  4306. * @returns the new matrix
  4307. */
  4308. static Scaling(x: number, y: number, z: number): Matrix;
  4309. /**
  4310. * Creates a scaling matrix and stores it in a given matrix
  4311. * @param x defines the scale factor on X axis
  4312. * @param y defines the scale factor on Y axis
  4313. * @param z defines the scale factor on Z axis
  4314. * @param result defines the target matrix
  4315. */
  4316. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4317. /**
  4318. * Creates a translation matrix
  4319. * @param x defines the translation on X axis
  4320. * @param y defines the translation on Y axis
  4321. * @param z defines the translationon Z axis
  4322. * @returns the new matrix
  4323. */
  4324. static Translation(x: number, y: number, z: number): Matrix;
  4325. /**
  4326. * Creates a translation matrix and stores it in a given matrix
  4327. * @param x defines the translation on X axis
  4328. * @param y defines the translation on Y axis
  4329. * @param z defines the translationon Z axis
  4330. * @param result defines the target matrix
  4331. */
  4332. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4333. /**
  4334. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4335. * @param startValue defines the start value
  4336. * @param endValue defines the end value
  4337. * @param gradient defines the gradient factor
  4338. * @returns the new matrix
  4339. */
  4340. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4341. /**
  4342. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4343. * @param startValue defines the start value
  4344. * @param endValue defines the end value
  4345. * @param gradient defines the gradient factor
  4346. * @param result defines the Matrix object where to store data
  4347. */
  4348. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4349. /**
  4350. * Builds a new matrix whose values are computed by:
  4351. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4352. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4353. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4354. * @param startValue defines the first matrix
  4355. * @param endValue defines the second matrix
  4356. * @param gradient defines the gradient between the two matrices
  4357. * @returns the new matrix
  4358. */
  4359. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4360. /**
  4361. * Update a matrix to values which are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @param result defines the target matrix
  4369. */
  4370. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4371. /**
  4372. * 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"
  4373. * This function works in left handed mode
  4374. * @param eye defines the final position of the entity
  4375. * @param target defines where the entity should look at
  4376. * @param up defines the up vector for the entity
  4377. * @returns the new matrix
  4378. */
  4379. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4380. /**
  4381. * 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".
  4382. * This function works in left handed mode
  4383. * @param eye defines the final position of the entity
  4384. * @param target defines where the entity should look at
  4385. * @param up defines the up vector for the entity
  4386. * @param result defines the target matrix
  4387. */
  4388. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4389. /**
  4390. * 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"
  4391. * This function works in right handed mode
  4392. * @param eye defines the final position of the entity
  4393. * @param target defines where the entity should look at
  4394. * @param up defines the up vector for the entity
  4395. * @returns the new matrix
  4396. */
  4397. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4398. /**
  4399. * 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".
  4400. * This function works in right handed mode
  4401. * @param eye defines the final position of the entity
  4402. * @param target defines where the entity should look at
  4403. * @param up defines the up vector for the entity
  4404. * @param result defines the target matrix
  4405. */
  4406. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4407. /**
  4408. * Create a left-handed orthographic projection matrix
  4409. * @param width defines the viewport width
  4410. * @param height defines the viewport height
  4411. * @param znear defines the near clip plane
  4412. * @param zfar defines the far clip plane
  4413. * @returns a new matrix as a left-handed orthographic projection matrix
  4414. */
  4415. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4416. /**
  4417. * Store a left-handed orthographic projection to a given matrix
  4418. * @param width defines the viewport width
  4419. * @param height defines the viewport height
  4420. * @param znear defines the near clip plane
  4421. * @param zfar defines the far clip plane
  4422. * @param result defines the target matrix
  4423. */
  4424. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4425. /**
  4426. * Create a left-handed orthographic projection matrix
  4427. * @param left defines the viewport left coordinate
  4428. * @param right defines the viewport right coordinate
  4429. * @param bottom defines the viewport bottom coordinate
  4430. * @param top defines the viewport top coordinate
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @returns a new matrix as a left-handed orthographic projection matrix
  4434. */
  4435. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4436. /**
  4437. * Stores a left-handed orthographic projection into a given matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @param result defines the target matrix
  4445. */
  4446. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4447. /**
  4448. * Creates a right-handed orthographic projection matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @returns a new matrix as a right-handed orthographic projection matrix
  4456. */
  4457. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4458. /**
  4459. * Stores a right-handed orthographic projection into a given matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Creates a left-handed perspective projection matrix
  4471. * @param width defines the viewport width
  4472. * @param height defines the viewport height
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @returns a new matrix as a left-handed perspective projection matrix
  4476. */
  4477. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4478. /**
  4479. * Creates a left-handed perspective projection matrix
  4480. * @param fov defines the horizontal field of view
  4481. * @param aspect defines the aspect ratio
  4482. * @param znear defines the near clip plane
  4483. * @param zfar defines the far clip plane
  4484. * @returns a new matrix as a left-handed perspective projection matrix
  4485. */
  4486. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4487. /**
  4488. * Stores a left-handed perspective projection into a given matrix
  4489. * @param fov defines the horizontal field of view
  4490. * @param aspect defines the aspect ratio
  4491. * @param znear defines the near clip plane
  4492. * @param zfar defines the far clip plane
  4493. * @param result defines the target matrix
  4494. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4495. */
  4496. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4497. /**
  4498. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4499. * @param fov defines the horizontal field of view
  4500. * @param aspect defines the aspect ratio
  4501. * @param znear defines the near clip plane
  4502. * @param zfar not used as infinity is used as far clip
  4503. * @param result defines the target matrix
  4504. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4505. */
  4506. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4507. /**
  4508. * Creates a right-handed perspective projection matrix
  4509. * @param fov defines the horizontal field of view
  4510. * @param aspect defines the aspect ratio
  4511. * @param znear defines the near clip plane
  4512. * @param zfar defines the far clip plane
  4513. * @returns a new matrix as a right-handed perspective projection matrix
  4514. */
  4515. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4516. /**
  4517. * Stores a right-handed perspective projection into a given matrix
  4518. * @param fov defines the horizontal field of view
  4519. * @param aspect defines the aspect ratio
  4520. * @param znear defines the near clip plane
  4521. * @param zfar defines the far clip plane
  4522. * @param result defines the target matrix
  4523. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4524. */
  4525. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4526. /**
  4527. * Stores a right-handed perspective projection into a given matrix
  4528. * @param fov defines the horizontal field of view
  4529. * @param aspect defines the aspect ratio
  4530. * @param znear defines the near clip plane
  4531. * @param zfar not used as infinity is used as far clip
  4532. * @param result defines the target matrix
  4533. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4534. */
  4535. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4536. /**
  4537. * Stores a perspective projection for WebVR info a given matrix
  4538. * @param fov defines the field of view
  4539. * @param znear defines the near clip plane
  4540. * @param zfar defines the far clip plane
  4541. * @param result defines the target matrix
  4542. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4543. */
  4544. static PerspectiveFovWebVRToRef(fov: {
  4545. upDegrees: number;
  4546. downDegrees: number;
  4547. leftDegrees: number;
  4548. rightDegrees: number;
  4549. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4550. /**
  4551. * Computes a complete transformation matrix
  4552. * @param viewport defines the viewport to use
  4553. * @param world defines the world matrix
  4554. * @param view defines the view matrix
  4555. * @param projection defines the projection matrix
  4556. * @param zmin defines the near clip plane
  4557. * @param zmax defines the far clip plane
  4558. * @returns the transformation matrix
  4559. */
  4560. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4561. /**
  4562. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4563. * @param matrix defines the matrix to use
  4564. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4565. */
  4566. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4567. /**
  4568. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4569. * @param matrix defines the matrix to use
  4570. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4571. */
  4572. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4573. /**
  4574. * Compute the transpose of a given matrix
  4575. * @param matrix defines the matrix to transpose
  4576. * @returns the new matrix
  4577. */
  4578. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4579. /**
  4580. * Compute the transpose of a matrix and store it in a target matrix
  4581. * @param matrix defines the matrix to transpose
  4582. * @param result defines the target matrix
  4583. */
  4584. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4585. /**
  4586. * Computes a reflection matrix from a plane
  4587. * @param plane defines the reflection plane
  4588. * @returns a new matrix
  4589. */
  4590. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4591. /**
  4592. * Computes a reflection matrix from a plane
  4593. * @param plane defines the reflection plane
  4594. * @param result defines the target matrix
  4595. */
  4596. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4597. /**
  4598. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4599. * @param xaxis defines the value of the 1st axis
  4600. * @param yaxis defines the value of the 2nd axis
  4601. * @param zaxis defines the value of the 3rd axis
  4602. * @param result defines the target matrix
  4603. */
  4604. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4605. /**
  4606. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4607. * @param quat defines the quaternion to use
  4608. * @param result defines the target matrix
  4609. */
  4610. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4611. }
  4612. /**
  4613. * @hidden
  4614. */
  4615. export class TmpVectors {
  4616. static Vector2: Vector2[];
  4617. static Vector3: Vector3[];
  4618. static Vector4: Vector4[];
  4619. static Quaternion: Quaternion[];
  4620. static Matrix: Matrix[];
  4621. }
  4622. }
  4623. declare module "babylonjs/Maths/math.path" {
  4624. import { DeepImmutable, Nullable } from "babylonjs/types";
  4625. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4626. /**
  4627. * Defines potential orientation for back face culling
  4628. */
  4629. export enum Orientation {
  4630. /**
  4631. * Clockwise
  4632. */
  4633. CW = 0,
  4634. /** Counter clockwise */
  4635. CCW = 1
  4636. }
  4637. /** Class used to represent a Bezier curve */
  4638. export class BezierCurve {
  4639. /**
  4640. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4641. * @param t defines the time
  4642. * @param x1 defines the left coordinate on X axis
  4643. * @param y1 defines the left coordinate on Y axis
  4644. * @param x2 defines the right coordinate on X axis
  4645. * @param y2 defines the right coordinate on Y axis
  4646. * @returns the interpolated value
  4647. */
  4648. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4649. }
  4650. /**
  4651. * Defines angle representation
  4652. */
  4653. export class Angle {
  4654. private _radians;
  4655. /**
  4656. * Creates an Angle object of "radians" radians (float).
  4657. * @param radians the angle in radians
  4658. */
  4659. constructor(radians: number);
  4660. /**
  4661. * Get value in degrees
  4662. * @returns the Angle value in degrees (float)
  4663. */
  4664. degrees(): number;
  4665. /**
  4666. * Get value in radians
  4667. * @returns the Angle value in radians (float)
  4668. */
  4669. radians(): number;
  4670. /**
  4671. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4672. * @param a defines first vector
  4673. * @param b defines second vector
  4674. * @returns a new Angle
  4675. */
  4676. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4677. /**
  4678. * Gets a new Angle object from the given float in radians
  4679. * @param radians defines the angle value in radians
  4680. * @returns a new Angle
  4681. */
  4682. static FromRadians(radians: number): Angle;
  4683. /**
  4684. * Gets a new Angle object from the given float in degrees
  4685. * @param degrees defines the angle value in degrees
  4686. * @returns a new Angle
  4687. */
  4688. static FromDegrees(degrees: number): Angle;
  4689. }
  4690. /**
  4691. * This represents an arc in a 2d space.
  4692. */
  4693. export class Arc2 {
  4694. /** Defines the start point of the arc */
  4695. startPoint: Vector2;
  4696. /** Defines the mid point of the arc */
  4697. midPoint: Vector2;
  4698. /** Defines the end point of the arc */
  4699. endPoint: Vector2;
  4700. /**
  4701. * Defines the center point of the arc.
  4702. */
  4703. centerPoint: Vector2;
  4704. /**
  4705. * Defines the radius of the arc.
  4706. */
  4707. radius: number;
  4708. /**
  4709. * Defines the angle of the arc (from mid point to end point).
  4710. */
  4711. angle: Angle;
  4712. /**
  4713. * Defines the start angle of the arc (from start point to middle point).
  4714. */
  4715. startAngle: Angle;
  4716. /**
  4717. * Defines the orientation of the arc (clock wise/counter clock wise).
  4718. */
  4719. orientation: Orientation;
  4720. /**
  4721. * Creates an Arc object from the three given points : start, middle and end.
  4722. * @param startPoint Defines the start point of the arc
  4723. * @param midPoint Defines the midlle point of the arc
  4724. * @param endPoint Defines the end point of the arc
  4725. */
  4726. constructor(
  4727. /** Defines the start point of the arc */
  4728. startPoint: Vector2,
  4729. /** Defines the mid point of the arc */
  4730. midPoint: Vector2,
  4731. /** Defines the end point of the arc */
  4732. endPoint: Vector2);
  4733. }
  4734. /**
  4735. * Represents a 2D path made up of multiple 2D points
  4736. */
  4737. export class Path2 {
  4738. private _points;
  4739. private _length;
  4740. /**
  4741. * If the path start and end point are the same
  4742. */
  4743. closed: boolean;
  4744. /**
  4745. * Creates a Path2 object from the starting 2D coordinates x and y.
  4746. * @param x the starting points x value
  4747. * @param y the starting points y value
  4748. */
  4749. constructor(x: number, y: number);
  4750. /**
  4751. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4752. * @param x the added points x value
  4753. * @param y the added points y value
  4754. * @returns the updated Path2.
  4755. */
  4756. addLineTo(x: number, y: number): Path2;
  4757. /**
  4758. * 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.
  4759. * @param midX middle point x value
  4760. * @param midY middle point y value
  4761. * @param endX end point x value
  4762. * @param endY end point y value
  4763. * @param numberOfSegments (default: 36)
  4764. * @returns the updated Path2.
  4765. */
  4766. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4767. /**
  4768. * Closes the Path2.
  4769. * @returns the Path2.
  4770. */
  4771. close(): Path2;
  4772. /**
  4773. * Gets the sum of the distance between each sequential point in the path
  4774. * @returns the Path2 total length (float).
  4775. */
  4776. length(): number;
  4777. /**
  4778. * Gets the points which construct the path
  4779. * @returns the Path2 internal array of points.
  4780. */
  4781. getPoints(): Vector2[];
  4782. /**
  4783. * Retreives the point at the distance aways from the starting point
  4784. * @param normalizedLengthPosition the length along the path to retreive the point from
  4785. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4786. */
  4787. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4788. /**
  4789. * Creates a new path starting from an x and y position
  4790. * @param x starting x value
  4791. * @param y starting y value
  4792. * @returns a new Path2 starting at the coordinates (x, y).
  4793. */
  4794. static StartingAt(x: number, y: number): Path2;
  4795. }
  4796. /**
  4797. * Represents a 3D path made up of multiple 3D points
  4798. */
  4799. export class Path3D {
  4800. /**
  4801. * an array of Vector3, the curve axis of the Path3D
  4802. */
  4803. path: Vector3[];
  4804. private _curve;
  4805. private _distances;
  4806. private _tangents;
  4807. private _normals;
  4808. private _binormals;
  4809. private _raw;
  4810. private _alignTangentsWithPath;
  4811. private readonly _pointAtData;
  4812. /**
  4813. * new Path3D(path, normal, raw)
  4814. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4815. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4816. * @param path an array of Vector3, the curve axis of the Path3D
  4817. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4818. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4819. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4820. */
  4821. constructor(
  4822. /**
  4823. * an array of Vector3, the curve axis of the Path3D
  4824. */
  4825. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4826. /**
  4827. * Returns the Path3D array of successive Vector3 designing its curve.
  4828. * @returns the Path3D array of successive Vector3 designing its curve.
  4829. */
  4830. getCurve(): Vector3[];
  4831. /**
  4832. * Returns the Path3D array of successive Vector3 designing its curve.
  4833. * @returns the Path3D array of successive Vector3 designing its curve.
  4834. */
  4835. getPoints(): Vector3[];
  4836. /**
  4837. * @returns the computed length (float) of the path.
  4838. */
  4839. length(): number;
  4840. /**
  4841. * Returns an array populated with tangent vectors on each Path3D curve point.
  4842. * @returns an array populated with tangent vectors on each Path3D curve point.
  4843. */
  4844. getTangents(): Vector3[];
  4845. /**
  4846. * Returns an array populated with normal vectors on each Path3D curve point.
  4847. * @returns an array populated with normal vectors on each Path3D curve point.
  4848. */
  4849. getNormals(): Vector3[];
  4850. /**
  4851. * Returns an array populated with binormal vectors on each Path3D curve point.
  4852. * @returns an array populated with binormal vectors on each Path3D curve point.
  4853. */
  4854. getBinormals(): Vector3[];
  4855. /**
  4856. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4857. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4858. */
  4859. getDistances(): number[];
  4860. /**
  4861. * Returns an interpolated point along this path
  4862. * @param position the position of the point along this path, from 0.0 to 1.0
  4863. * @returns a new Vector3 as the point
  4864. */
  4865. getPointAt(position: number): Vector3;
  4866. /**
  4867. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4868. * @param position the position of the point along this path, from 0.0 to 1.0
  4869. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4870. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4871. */
  4872. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4873. /**
  4874. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4877. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4878. */
  4879. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4880. /**
  4881. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4884. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4885. */
  4886. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4887. /**
  4888. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4889. * @param position the position of the point along this path, from 0.0 to 1.0
  4890. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4891. */
  4892. getDistanceAt(position: number): number;
  4893. /**
  4894. * Returns the array index of the previous point of an interpolated point along this path
  4895. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4896. * @returns the array index
  4897. */
  4898. getPreviousPointIndexAt(position: number): number;
  4899. /**
  4900. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4901. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4902. * @returns the sub position
  4903. */
  4904. getSubPositionAt(position: number): number;
  4905. /**
  4906. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4907. * @param target the vector of which to get the closest position to
  4908. * @returns the position of the closest virtual point on this path to the target vector
  4909. */
  4910. getClosestPositionTo(target: Vector3): number;
  4911. /**
  4912. * Returns a sub path (slice) of this path
  4913. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4914. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4915. * @returns a sub path (slice) of this path
  4916. */
  4917. slice(start?: number, end?: number): Path3D;
  4918. /**
  4919. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4920. * @param path path which all values are copied into the curves points
  4921. * @param firstNormal which should be projected onto the curve
  4922. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4923. * @returns the same object updated.
  4924. */
  4925. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4926. private _compute;
  4927. private _getFirstNonNullVector;
  4928. private _getLastNonNullVector;
  4929. private _normalVector;
  4930. /**
  4931. * Updates the point at data for an interpolated point along this curve
  4932. * @param position the position of the point along this curve, from 0.0 to 1.0
  4933. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4934. * @returns the (updated) point at data
  4935. */
  4936. private _updatePointAtData;
  4937. /**
  4938. * Updates the point at data from the specified parameters
  4939. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4940. * @param point the interpolated point
  4941. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4942. */
  4943. private _setPointAtData;
  4944. /**
  4945. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4946. */
  4947. private _updateInterpolationMatrix;
  4948. }
  4949. /**
  4950. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4951. * A Curve3 is designed from a series of successive Vector3.
  4952. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4953. */
  4954. export class Curve3 {
  4955. private _points;
  4956. private _length;
  4957. /**
  4958. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4959. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4960. * @param v1 (Vector3) the control point
  4961. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4962. * @param nbPoints (integer) the wanted number of points in the curve
  4963. * @returns the created Curve3
  4964. */
  4965. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4966. /**
  4967. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4969. * @param v1 (Vector3) the first control point
  4970. * @param v2 (Vector3) the second control point
  4971. * @param v3 (Vector3) the end point of the Cubic Bezier
  4972. * @param nbPoints (integer) the wanted number of points in the curve
  4973. * @returns the created Curve3
  4974. */
  4975. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4976. /**
  4977. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4978. * @param p1 (Vector3) the origin point of the Hermite Spline
  4979. * @param t1 (Vector3) the tangent vector at the origin point
  4980. * @param p2 (Vector3) the end point of the Hermite Spline
  4981. * @param t2 (Vector3) the tangent vector at the end point
  4982. * @param nbPoints (integer) the wanted number of points in the curve
  4983. * @returns the created Curve3
  4984. */
  4985. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4986. /**
  4987. * Returns a Curve3 object along a CatmullRom Spline curve :
  4988. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4989. * @param nbPoints (integer) the wanted number of points between each curve control points
  4990. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4994. /**
  4995. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4996. * A Curve3 is designed from a series of successive Vector3.
  4997. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4998. * @param points points which make up the curve
  4999. */
  5000. constructor(points: Vector3[]);
  5001. /**
  5002. * @returns the Curve3 stored array of successive Vector3
  5003. */
  5004. getPoints(): Vector3[];
  5005. /**
  5006. * @returns the computed length (float) of the curve.
  5007. */
  5008. length(): number;
  5009. /**
  5010. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5011. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5012. * curveA and curveB keep unchanged.
  5013. * @param curve the curve to continue from this curve
  5014. * @returns the newly constructed curve
  5015. */
  5016. continue(curve: DeepImmutable<Curve3>): Curve3;
  5017. private _computeLength;
  5018. }
  5019. }
  5020. declare module "babylonjs/Animations/easing" {
  5021. /**
  5022. * This represents the main contract an easing function should follow.
  5023. * Easing functions are used throughout the animation system.
  5024. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5025. */
  5026. export interface IEasingFunction {
  5027. /**
  5028. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5029. * of the easing function.
  5030. * The link below provides some of the most common examples of easing functions.
  5031. * @see https://easings.net/
  5032. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5033. * @returns the corresponding value on the curve defined by the easing function
  5034. */
  5035. ease(gradient: number): number;
  5036. }
  5037. /**
  5038. * Base class used for every default easing function.
  5039. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5040. */
  5041. export class EasingFunction implements IEasingFunction {
  5042. /**
  5043. * Interpolation follows the mathematical formula associated with the easing function.
  5044. */
  5045. static readonly EASINGMODE_EASEIN: number;
  5046. /**
  5047. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5048. */
  5049. static readonly EASINGMODE_EASEOUT: number;
  5050. /**
  5051. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5052. */
  5053. static readonly EASINGMODE_EASEINOUT: number;
  5054. private _easingMode;
  5055. /**
  5056. * Sets the easing mode of the current function.
  5057. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5058. */
  5059. setEasingMode(easingMode: number): void;
  5060. /**
  5061. * Gets the current easing mode.
  5062. * @returns the easing mode
  5063. */
  5064. getEasingMode(): number;
  5065. /**
  5066. * @hidden
  5067. */
  5068. easeInCore(gradient: number): number;
  5069. /**
  5070. * Given an input gradient between 0 and 1, this returns the corresponding value
  5071. * of the easing function.
  5072. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5073. * @returns the corresponding value on the curve defined by the easing function
  5074. */
  5075. ease(gradient: number): number;
  5076. }
  5077. /**
  5078. * Easing function with a circle shape (see link below).
  5079. * @see https://easings.net/#easeInCirc
  5080. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5081. */
  5082. export class CircleEase extends EasingFunction implements IEasingFunction {
  5083. /** @hidden */
  5084. easeInCore(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a ease back shape (see link below).
  5088. * @see https://easings.net/#easeInBack
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class BackEase extends EasingFunction implements IEasingFunction {
  5092. /** Defines the amplitude of the function */
  5093. amplitude: number;
  5094. /**
  5095. * Instantiates a back ease easing
  5096. * @see https://easings.net/#easeInBack
  5097. * @param amplitude Defines the amplitude of the function
  5098. */
  5099. constructor(
  5100. /** Defines the amplitude of the function */
  5101. amplitude?: number);
  5102. /** @hidden */
  5103. easeInCore(gradient: number): number;
  5104. }
  5105. /**
  5106. * Easing function with a bouncing shape (see link below).
  5107. * @see https://easings.net/#easeInBounce
  5108. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5109. */
  5110. export class BounceEase extends EasingFunction implements IEasingFunction {
  5111. /** Defines the number of bounces */
  5112. bounces: number;
  5113. /** Defines the amplitude of the bounce */
  5114. bounciness: number;
  5115. /**
  5116. * Instantiates a bounce easing
  5117. * @see https://easings.net/#easeInBounce
  5118. * @param bounces Defines the number of bounces
  5119. * @param bounciness Defines the amplitude of the bounce
  5120. */
  5121. constructor(
  5122. /** Defines the number of bounces */
  5123. bounces?: number,
  5124. /** Defines the amplitude of the bounce */
  5125. bounciness?: number);
  5126. /** @hidden */
  5127. easeInCore(gradient: number): number;
  5128. }
  5129. /**
  5130. * Easing function with a power of 3 shape (see link below).
  5131. * @see https://easings.net/#easeInCubic
  5132. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5133. */
  5134. export class CubicEase extends EasingFunction implements IEasingFunction {
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with an elastic shape (see link below).
  5140. * @see https://easings.net/#easeInElastic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5144. /** Defines the number of oscillations*/
  5145. oscillations: number;
  5146. /** Defines the amplitude of the oscillations*/
  5147. springiness: number;
  5148. /**
  5149. * Instantiates an elastic easing function
  5150. * @see https://easings.net/#easeInElastic
  5151. * @param oscillations Defines the number of oscillations
  5152. * @param springiness Defines the amplitude of the oscillations
  5153. */
  5154. constructor(
  5155. /** Defines the number of oscillations*/
  5156. oscillations?: number,
  5157. /** Defines the amplitude of the oscillations*/
  5158. springiness?: number);
  5159. /** @hidden */
  5160. easeInCore(gradient: number): number;
  5161. }
  5162. /**
  5163. * Easing function with an exponential shape (see link below).
  5164. * @see https://easings.net/#easeInExpo
  5165. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5166. */
  5167. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5168. /** Defines the exponent of the function */
  5169. exponent: number;
  5170. /**
  5171. * Instantiates an exponential easing function
  5172. * @see https://easings.net/#easeInExpo
  5173. * @param exponent Defines the exponent of the function
  5174. */
  5175. constructor(
  5176. /** Defines the exponent of the function */
  5177. exponent?: number);
  5178. /** @hidden */
  5179. easeInCore(gradient: number): number;
  5180. }
  5181. /**
  5182. * Easing function with a power shape (see link below).
  5183. * @see https://easings.net/#easeInQuad
  5184. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5185. */
  5186. export class PowerEase extends EasingFunction implements IEasingFunction {
  5187. /** Defines the power of the function */
  5188. power: number;
  5189. /**
  5190. * Instantiates an power base easing function
  5191. * @see https://easings.net/#easeInQuad
  5192. * @param power Defines the power of the function
  5193. */
  5194. constructor(
  5195. /** Defines the power of the function */
  5196. power?: number);
  5197. /** @hidden */
  5198. easeInCore(gradient: number): number;
  5199. }
  5200. /**
  5201. * Easing function with a power of 2 shape (see link below).
  5202. * @see https://easings.net/#easeInQuad
  5203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5204. */
  5205. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 4 shape (see link below).
  5211. * @see https://easings.net/#easeInQuart
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 5 shape (see link below).
  5220. * @see https://easings.net/#easeInQuint
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a sin shape (see link below).
  5229. * @see https://easings.net/#easeInSine
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class SineEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a bezier shape (see link below).
  5238. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the x component of the start tangent in the bezier curve */
  5243. x1: number;
  5244. /** Defines the y component of the start tangent in the bezier curve */
  5245. y1: number;
  5246. /** Defines the x component of the end tangent in the bezier curve */
  5247. x2: number;
  5248. /** Defines the y component of the end tangent in the bezier curve */
  5249. y2: number;
  5250. /**
  5251. * Instantiates a bezier function
  5252. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5253. * @param x1 Defines the x component of the start tangent in the bezier curve
  5254. * @param y1 Defines the y component of the start tangent in the bezier curve
  5255. * @param x2 Defines the x component of the end tangent in the bezier curve
  5256. * @param y2 Defines the y component of the end tangent in the bezier curve
  5257. */
  5258. constructor(
  5259. /** Defines the x component of the start tangent in the bezier curve */
  5260. x1?: number,
  5261. /** Defines the y component of the start tangent in the bezier curve */
  5262. y1?: number,
  5263. /** Defines the x component of the end tangent in the bezier curve */
  5264. x2?: number,
  5265. /** Defines the y component of the end tangent in the bezier curve */
  5266. y2?: number);
  5267. /** @hidden */
  5268. easeInCore(gradient: number): number;
  5269. }
  5270. }
  5271. declare module "babylonjs/Maths/math.color" {
  5272. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5273. /**
  5274. * Class used to hold a RBG color
  5275. */
  5276. export class Color3 {
  5277. /**
  5278. * Defines the red component (between 0 and 1, default is 0)
  5279. */
  5280. r: number;
  5281. /**
  5282. * Defines the green component (between 0 and 1, default is 0)
  5283. */
  5284. g: number;
  5285. /**
  5286. * Defines the blue component (between 0 and 1, default is 0)
  5287. */
  5288. b: number;
  5289. /**
  5290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5291. * @param r defines the red component (between 0 and 1, default is 0)
  5292. * @param g defines the green component (between 0 and 1, default is 0)
  5293. * @param b defines the blue component (between 0 and 1, default is 0)
  5294. */
  5295. constructor(
  5296. /**
  5297. * Defines the red component (between 0 and 1, default is 0)
  5298. */
  5299. r?: number,
  5300. /**
  5301. * Defines the green component (between 0 and 1, default is 0)
  5302. */
  5303. g?: number,
  5304. /**
  5305. * Defines the blue component (between 0 and 1, default is 0)
  5306. */
  5307. b?: number);
  5308. /**
  5309. * Creates a string with the Color3 current values
  5310. * @returns the string representation of the Color3 object
  5311. */
  5312. toString(): string;
  5313. /**
  5314. * Returns the string "Color3"
  5315. * @returns "Color3"
  5316. */
  5317. getClassName(): string;
  5318. /**
  5319. * Compute the Color3 hash code
  5320. * @returns an unique number that can be used to hash Color3 objects
  5321. */
  5322. getHashCode(): number;
  5323. /**
  5324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5325. * @param array defines the array where to store the r,g,b components
  5326. * @param index defines an optional index in the target array to define where to start storing values
  5327. * @returns the current Color3 object
  5328. */
  5329. toArray(array: FloatArray, index?: number): Color3;
  5330. /**
  5331. * Returns a new Color4 object from the current Color3 and the given alpha
  5332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5333. * @returns a new Color4 object
  5334. */
  5335. toColor4(alpha?: number): Color4;
  5336. /**
  5337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5338. * @returns the new array
  5339. */
  5340. asArray(): number[];
  5341. /**
  5342. * Returns the luminance value
  5343. * @returns a float value
  5344. */
  5345. toLuminance(): number;
  5346. /**
  5347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5348. * @param otherColor defines the second operand
  5349. * @returns the new Color3 object
  5350. */
  5351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5352. /**
  5353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5354. * @param otherColor defines the second operand
  5355. * @param result defines the Color3 object where to store the result
  5356. * @returns the current Color3
  5357. */
  5358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5359. /**
  5360. * Determines equality between Color3 objects
  5361. * @param otherColor defines the second operand
  5362. * @returns true if the rgb values are equal to the given ones
  5363. */
  5364. equals(otherColor: DeepImmutable<Color3>): boolean;
  5365. /**
  5366. * Determines equality between the current Color3 object and a set of r,b,g values
  5367. * @param r defines the red component to check
  5368. * @param g defines the green component to check
  5369. * @param b defines the blue component to check
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equalsFloats(r: number, g: number, b: number): boolean;
  5373. /**
  5374. * Multiplies in place each rgb value by scale
  5375. * @param scale defines the scaling factor
  5376. * @returns the updated Color3
  5377. */
  5378. scale(scale: number): Color3;
  5379. /**
  5380. * Multiplies the rgb values by scale and stores the result into "result"
  5381. * @param scale defines the scaling factor
  5382. * @param result defines the Color3 object where to store the result
  5383. * @returns the unmodified current Color3
  5384. */
  5385. scaleToRef(scale: number, result: Color3): Color3;
  5386. /**
  5387. * Scale the current Color3 values by a factor and add the result to a given Color3
  5388. * @param scale defines the scale factor
  5389. * @param result defines color to store the result into
  5390. * @returns the unmodified current Color3
  5391. */
  5392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5393. /**
  5394. * Clamps the rgb values by the min and max values and stores the result into "result"
  5395. * @param min defines minimum clamping value (default is 0)
  5396. * @param max defines maximum clamping value (default is 1)
  5397. * @param result defines color to store the result into
  5398. * @returns the original Color3
  5399. */
  5400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5401. /**
  5402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5403. * @param otherColor defines the second operand
  5404. * @returns the new Color3
  5405. */
  5406. add(otherColor: DeepImmutable<Color3>): Color3;
  5407. /**
  5408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5409. * @param otherColor defines the second operand
  5410. * @param result defines Color3 object to store the result into
  5411. * @returns the unmodified current Color3
  5412. */
  5413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5414. /**
  5415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5416. * @param otherColor defines the second operand
  5417. * @returns the new Color3
  5418. */
  5419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5420. /**
  5421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5422. * @param otherColor defines the second operand
  5423. * @param result defines Color3 object to store the result into
  5424. * @returns the unmodified current Color3
  5425. */
  5426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5427. /**
  5428. * Copy the current object
  5429. * @returns a new Color3 copied the current one
  5430. */
  5431. clone(): Color3;
  5432. /**
  5433. * Copies the rgb values from the source in the current Color3
  5434. * @param source defines the source Color3 object
  5435. * @returns the updated Color3 object
  5436. */
  5437. copyFrom(source: DeepImmutable<Color3>): Color3;
  5438. /**
  5439. * Updates the Color3 rgb values from the given floats
  5440. * @param r defines the red component to read from
  5441. * @param g defines the green component to read from
  5442. * @param b defines the blue component to read from
  5443. * @returns the current Color3 object
  5444. */
  5445. copyFromFloats(r: number, g: number, b: number): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. set(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Compute the Color3 hexadecimal code as a string
  5456. * @returns a string containing the hexadecimal representation of the Color3 object
  5457. */
  5458. toHexString(): string;
  5459. /**
  5460. * Computes a new Color3 converted from the current one to linear space
  5461. * @returns a new Color3 object
  5462. */
  5463. toLinearSpace(): Color3;
  5464. /**
  5465. * Converts current color in rgb space to HSV values
  5466. * @returns a new color3 representing the HSV values
  5467. */
  5468. toHSV(): Color3;
  5469. /**
  5470. * Converts current color in rgb space to HSV values
  5471. * @param result defines the Color3 where to store the HSV values
  5472. */
  5473. toHSVToRef(result: Color3): void;
  5474. /**
  5475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5476. * @param convertedColor defines the Color3 object where to store the linear space version
  5477. * @returns the unmodified Color3
  5478. */
  5479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5480. /**
  5481. * Computes a new Color3 converted from the current one to gamma space
  5482. * @returns a new Color3 object
  5483. */
  5484. toGammaSpace(): Color3;
  5485. /**
  5486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5487. * @param convertedColor defines the Color3 object where to store the gamma space version
  5488. * @returns the unmodified Color3
  5489. */
  5490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5491. private static _BlackReadOnly;
  5492. /**
  5493. * Convert Hue, saturation and value to a Color3 (RGB)
  5494. * @param hue defines the hue
  5495. * @param saturation defines the saturation
  5496. * @param value defines the value
  5497. * @param result defines the Color3 where to store the RGB values
  5498. */
  5499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5500. /**
  5501. * Creates a new Color3 from the string containing valid hexadecimal values
  5502. * @param hex defines a string containing valid hexadecimal values
  5503. * @returns a new Color3 object
  5504. */
  5505. static FromHexString(hex: string): Color3;
  5506. /**
  5507. * Creates a new Color3 from the starting index of the given array
  5508. * @param array defines the source array
  5509. * @param offset defines an offset in the source array
  5510. * @returns a new Color3 object
  5511. */
  5512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5513. /**
  5514. * Creates a new Color3 from integer values (< 256)
  5515. * @param r defines the red component to read from (value between 0 and 255)
  5516. * @param g defines the green component to read from (value between 0 and 255)
  5517. * @param b defines the blue component to read from (value between 0 and 255)
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromInts(r: number, g: number, b: number): Color3;
  5521. /**
  5522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5523. * @param start defines the start Color3 value
  5524. * @param end defines the end Color3 value
  5525. * @param amount defines the gradient value between start and end
  5526. * @returns a new Color3 object
  5527. */
  5528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param left defines the start value
  5532. * @param right defines the end value
  5533. * @param amount defines the gradient factor
  5534. * @param result defines the Color3 object where to store the result
  5535. */
  5536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5537. /**
  5538. * Returns a Color3 value containing a red color
  5539. * @returns a new Color3 object
  5540. */
  5541. static Red(): Color3;
  5542. /**
  5543. * Returns a Color3 value containing a green color
  5544. * @returns a new Color3 object
  5545. */
  5546. static Green(): Color3;
  5547. /**
  5548. * Returns a Color3 value containing a blue color
  5549. * @returns a new Color3 object
  5550. */
  5551. static Blue(): Color3;
  5552. /**
  5553. * Returns a Color3 value containing a black color
  5554. * @returns a new Color3 object
  5555. */
  5556. static Black(): Color3;
  5557. /**
  5558. * Gets a Color3 value containing a black color that must not be updated
  5559. */
  5560. static get BlackReadOnly(): DeepImmutable<Color3>;
  5561. /**
  5562. * Returns a Color3 value containing a white color
  5563. * @returns a new Color3 object
  5564. */
  5565. static White(): Color3;
  5566. /**
  5567. * Returns a Color3 value containing a purple color
  5568. * @returns a new Color3 object
  5569. */
  5570. static Purple(): Color3;
  5571. /**
  5572. * Returns a Color3 value containing a magenta color
  5573. * @returns a new Color3 object
  5574. */
  5575. static Magenta(): Color3;
  5576. /**
  5577. * Returns a Color3 value containing a yellow color
  5578. * @returns a new Color3 object
  5579. */
  5580. static Yellow(): Color3;
  5581. /**
  5582. * Returns a Color3 value containing a gray color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Gray(): Color3;
  5586. /**
  5587. * Returns a Color3 value containing a teal color
  5588. * @returns a new Color3 object
  5589. */
  5590. static Teal(): Color3;
  5591. /**
  5592. * Returns a Color3 value containing a random color
  5593. * @returns a new Color3 object
  5594. */
  5595. static Random(): Color3;
  5596. }
  5597. /**
  5598. * Class used to hold a RBGA color
  5599. */
  5600. export class Color4 {
  5601. /**
  5602. * Defines the red component (between 0 and 1, default is 0)
  5603. */
  5604. r: number;
  5605. /**
  5606. * Defines the green component (between 0 and 1, default is 0)
  5607. */
  5608. g: number;
  5609. /**
  5610. * Defines the blue component (between 0 and 1, default is 0)
  5611. */
  5612. b: number;
  5613. /**
  5614. * Defines the alpha component (between 0 and 1, default is 1)
  5615. */
  5616. a: number;
  5617. /**
  5618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5619. * @param r defines the red component (between 0 and 1, default is 0)
  5620. * @param g defines the green component (between 0 and 1, default is 0)
  5621. * @param b defines the blue component (between 0 and 1, default is 0)
  5622. * @param a defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. constructor(
  5625. /**
  5626. * Defines the red component (between 0 and 1, default is 0)
  5627. */
  5628. r?: number,
  5629. /**
  5630. * Defines the green component (between 0 and 1, default is 0)
  5631. */
  5632. g?: number,
  5633. /**
  5634. * Defines the blue component (between 0 and 1, default is 0)
  5635. */
  5636. b?: number,
  5637. /**
  5638. * Defines the alpha component (between 0 and 1, default is 1)
  5639. */
  5640. a?: number);
  5641. /**
  5642. * Adds in place the given Color4 values to the current Color4 object
  5643. * @param right defines the second operand
  5644. * @returns the current updated Color4 object
  5645. */
  5646. addInPlace(right: DeepImmutable<Color4>): Color4;
  5647. /**
  5648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5649. * @returns the new array
  5650. */
  5651. asArray(): number[];
  5652. /**
  5653. * Stores from the starting index in the given array the Color4 successive values
  5654. * @param array defines the array where to store the r,g,b components
  5655. * @param index defines an optional index in the target array to define where to start storing values
  5656. * @returns the current Color4 object
  5657. */
  5658. toArray(array: number[], index?: number): Color4;
  5659. /**
  5660. * Determines equality between Color4 objects
  5661. * @param otherColor defines the second operand
  5662. * @returns true if the rgba values are equal to the given ones
  5663. */
  5664. equals(otherColor: DeepImmutable<Color4>): boolean;
  5665. /**
  5666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5667. * @param right defines the second operand
  5668. * @returns a new Color4 object
  5669. */
  5670. add(right: DeepImmutable<Color4>): Color4;
  5671. /**
  5672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5673. * @param right defines the second operand
  5674. * @returns a new Color4 object
  5675. */
  5676. subtract(right: DeepImmutable<Color4>): Color4;
  5677. /**
  5678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5679. * @param right defines the second operand
  5680. * @param result defines the Color4 object where to store the result
  5681. * @returns the current Color4 object
  5682. */
  5683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5684. /**
  5685. * Creates a new Color4 with the current Color4 values multiplied by scale
  5686. * @param scale defines the scaling factor to apply
  5687. * @returns a new Color4 object
  5688. */
  5689. scale(scale: number): Color4;
  5690. /**
  5691. * Multiplies the current Color4 values by scale and stores the result in "result"
  5692. * @param scale defines the scaling factor to apply
  5693. * @param result defines the Color4 object where to store the result
  5694. * @returns the current unmodified Color4
  5695. */
  5696. scaleToRef(scale: number, result: Color4): Color4;
  5697. /**
  5698. * Scale the current Color4 values by a factor and add the result to a given Color4
  5699. * @param scale defines the scale factor
  5700. * @param result defines the Color4 object where to store the result
  5701. * @returns the unmodified current Color4
  5702. */
  5703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5704. /**
  5705. * Clamps the rgb values by the min and max values and stores the result into "result"
  5706. * @param min defines minimum clamping value (default is 0)
  5707. * @param max defines maximum clamping value (default is 1)
  5708. * @param result defines color to store the result into.
  5709. * @returns the cuurent Color4
  5710. */
  5711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5712. /**
  5713. * Multipy an Color4 value by another and return a new Color4 object
  5714. * @param color defines the Color4 value to multiply by
  5715. * @returns a new Color4 object
  5716. */
  5717. multiply(color: Color4): Color4;
  5718. /**
  5719. * Multipy a Color4 value by another and push the result in a reference value
  5720. * @param color defines the Color4 value to multiply by
  5721. * @param result defines the Color4 to fill the result in
  5722. * @returns the result Color4
  5723. */
  5724. multiplyToRef(color: Color4, result: Color4): Color4;
  5725. /**
  5726. * Creates a string with the Color4 current values
  5727. * @returns the string representation of the Color4 object
  5728. */
  5729. toString(): string;
  5730. /**
  5731. * Returns the string "Color4"
  5732. * @returns "Color4"
  5733. */
  5734. getClassName(): string;
  5735. /**
  5736. * Compute the Color4 hash code
  5737. * @returns an unique number that can be used to hash Color4 objects
  5738. */
  5739. getHashCode(): number;
  5740. /**
  5741. * Creates a new Color4 copied from the current one
  5742. * @returns a new Color4 object
  5743. */
  5744. clone(): Color4;
  5745. /**
  5746. * Copies the given Color4 values into the current one
  5747. * @param source defines the source Color4 object
  5748. * @returns the current updated Color4 object
  5749. */
  5750. copyFrom(source: Color4): Color4;
  5751. /**
  5752. * Copies the given float values into the current one
  5753. * @param r defines the red component to read from
  5754. * @param g defines the green component to read from
  5755. * @param b defines the blue component to read from
  5756. * @param a defines the alpha component to read from
  5757. * @returns the current updated Color4 object
  5758. */
  5759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5760. /**
  5761. * Copies the given float values into the current one
  5762. * @param r defines the red component to read from
  5763. * @param g defines the green component to read from
  5764. * @param b defines the blue component to read from
  5765. * @param a defines the alpha component to read from
  5766. * @returns the current updated Color4 object
  5767. */
  5768. set(r: number, g: number, b: number, a: number): Color4;
  5769. /**
  5770. * Compute the Color4 hexadecimal code as a string
  5771. * @returns a string containing the hexadecimal representation of the Color4 object
  5772. */
  5773. toHexString(): string;
  5774. /**
  5775. * Computes a new Color4 converted from the current one to linear space
  5776. * @returns a new Color4 object
  5777. */
  5778. toLinearSpace(): Color4;
  5779. /**
  5780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5781. * @param convertedColor defines the Color4 object where to store the linear space version
  5782. * @returns the unmodified Color4
  5783. */
  5784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5785. /**
  5786. * Computes a new Color4 converted from the current one to gamma space
  5787. * @returns a new Color4 object
  5788. */
  5789. toGammaSpace(): Color4;
  5790. /**
  5791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5792. * @param convertedColor defines the Color4 object where to store the gamma space version
  5793. * @returns the unmodified Color4
  5794. */
  5795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5796. /**
  5797. * Creates a new Color4 from the string containing valid hexadecimal values
  5798. * @param hex defines a string containing valid hexadecimal values
  5799. * @returns a new Color4 object
  5800. */
  5801. static FromHexString(hex: string): Color4;
  5802. /**
  5803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5804. * @param left defines the start value
  5805. * @param right defines the end value
  5806. * @param amount defines the gradient factor
  5807. * @returns a new Color4 object
  5808. */
  5809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5810. /**
  5811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @param result defines the Color4 object where to store data
  5816. */
  5817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5818. /**
  5819. * Creates a new Color4 from a Color3 and an alpha value
  5820. * @param color3 defines the source Color3 to read from
  5821. * @param alpha defines the alpha component (1.0 by default)
  5822. * @returns a new Color4 object
  5823. */
  5824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5825. /**
  5826. * Creates a new Color4 from the starting index element of the given array
  5827. * @param array defines the source array to read from
  5828. * @param offset defines the offset in the source array
  5829. * @returns a new Color4 object
  5830. */
  5831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5832. /**
  5833. * Creates a new Color3 from integer values (< 256)
  5834. * @param r defines the red component to read from (value between 0 and 255)
  5835. * @param g defines the green component to read from (value between 0 and 255)
  5836. * @param b defines the blue component to read from (value between 0 and 255)
  5837. * @param a defines the alpha component to read from (value between 0 and 255)
  5838. * @returns a new Color3 object
  5839. */
  5840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5841. /**
  5842. * Check the content of a given array and convert it to an array containing RGBA data
  5843. * If the original array was already containing count * 4 values then it is returned directly
  5844. * @param colors defines the array to check
  5845. * @param count defines the number of RGBA data to expect
  5846. * @returns an array containing count * 4 values (RGBA)
  5847. */
  5848. static CheckColors4(colors: number[], count: number): number[];
  5849. }
  5850. /**
  5851. * @hidden
  5852. */
  5853. export class TmpColors {
  5854. static Color3: Color3[];
  5855. static Color4: Color4[];
  5856. }
  5857. }
  5858. declare module "babylonjs/Animations/animationKey" {
  5859. /**
  5860. * Defines an interface which represents an animation key frame
  5861. */
  5862. export interface IAnimationKey {
  5863. /**
  5864. * Frame of the key frame
  5865. */
  5866. frame: number;
  5867. /**
  5868. * Value at the specifies key frame
  5869. */
  5870. value: any;
  5871. /**
  5872. * The input tangent for the cubic hermite spline
  5873. */
  5874. inTangent?: any;
  5875. /**
  5876. * The output tangent for the cubic hermite spline
  5877. */
  5878. outTangent?: any;
  5879. /**
  5880. * The animation interpolation type
  5881. */
  5882. interpolation?: AnimationKeyInterpolation;
  5883. }
  5884. /**
  5885. * Enum for the animation key frame interpolation type
  5886. */
  5887. export enum AnimationKeyInterpolation {
  5888. /**
  5889. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5890. */
  5891. STEP = 1
  5892. }
  5893. }
  5894. declare module "babylonjs/Animations/animationRange" {
  5895. /**
  5896. * Represents the range of an animation
  5897. */
  5898. export class AnimationRange {
  5899. /**The name of the animation range**/
  5900. name: string;
  5901. /**The starting frame of the animation */
  5902. from: number;
  5903. /**The ending frame of the animation*/
  5904. to: number;
  5905. /**
  5906. * Initializes the range of an animation
  5907. * @param name The name of the animation range
  5908. * @param from The starting frame of the animation
  5909. * @param to The ending frame of the animation
  5910. */
  5911. constructor(
  5912. /**The name of the animation range**/
  5913. name: string,
  5914. /**The starting frame of the animation */
  5915. from: number,
  5916. /**The ending frame of the animation*/
  5917. to: number);
  5918. /**
  5919. * Makes a copy of the animation range
  5920. * @returns A copy of the animation range
  5921. */
  5922. clone(): AnimationRange;
  5923. }
  5924. }
  5925. declare module "babylonjs/Animations/animationEvent" {
  5926. /**
  5927. * Composed of a frame, and an action function
  5928. */
  5929. export class AnimationEvent {
  5930. /** The frame for which the event is triggered **/
  5931. frame: number;
  5932. /** The event to perform when triggered **/
  5933. action: (currentFrame: number) => void;
  5934. /** Specifies if the event should be triggered only once**/
  5935. onlyOnce?: boolean | undefined;
  5936. /**
  5937. * Specifies if the animation event is done
  5938. */
  5939. isDone: boolean;
  5940. /**
  5941. * Initializes the animation event
  5942. * @param frame The frame for which the event is triggered
  5943. * @param action The event to perform when triggered
  5944. * @param onlyOnce Specifies if the event should be triggered only once
  5945. */
  5946. constructor(
  5947. /** The frame for which the event is triggered **/
  5948. frame: number,
  5949. /** The event to perform when triggered **/
  5950. action: (currentFrame: number) => void,
  5951. /** Specifies if the event should be triggered only once**/
  5952. onlyOnce?: boolean | undefined);
  5953. /** @hidden */
  5954. _clone(): AnimationEvent;
  5955. }
  5956. }
  5957. declare module "babylonjs/Behaviors/behavior" {
  5958. import { Nullable } from "babylonjs/types";
  5959. /**
  5960. * Interface used to define a behavior
  5961. */
  5962. export interface Behavior<T> {
  5963. /** gets or sets behavior's name */
  5964. name: string;
  5965. /**
  5966. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5967. */
  5968. init(): void;
  5969. /**
  5970. * Called when the behavior is attached to a target
  5971. * @param target defines the target where the behavior is attached to
  5972. */
  5973. attach(target: T): void;
  5974. /**
  5975. * Called when the behavior is detached from its target
  5976. */
  5977. detach(): void;
  5978. }
  5979. /**
  5980. * Interface implemented by classes supporting behaviors
  5981. */
  5982. export interface IBehaviorAware<T> {
  5983. /**
  5984. * Attach a behavior
  5985. * @param behavior defines the behavior to attach
  5986. * @returns the current host
  5987. */
  5988. addBehavior(behavior: Behavior<T>): T;
  5989. /**
  5990. * Remove a behavior from the current object
  5991. * @param behavior defines the behavior to detach
  5992. * @returns the current host
  5993. */
  5994. removeBehavior(behavior: Behavior<T>): T;
  5995. /**
  5996. * Gets a behavior using its name to search
  5997. * @param name defines the name to search
  5998. * @returns the behavior or null if not found
  5999. */
  6000. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6001. }
  6002. }
  6003. declare module "babylonjs/Misc/smartArray" {
  6004. /**
  6005. * Defines an array and its length.
  6006. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6007. */
  6008. export interface ISmartArrayLike<T> {
  6009. /**
  6010. * The data of the array.
  6011. */
  6012. data: Array<T>;
  6013. /**
  6014. * The active length of the array.
  6015. */
  6016. length: number;
  6017. }
  6018. /**
  6019. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6020. */
  6021. export class SmartArray<T> implements ISmartArrayLike<T> {
  6022. /**
  6023. * The full set of data from the array.
  6024. */
  6025. data: Array<T>;
  6026. /**
  6027. * The active length of the array.
  6028. */
  6029. length: number;
  6030. protected _id: number;
  6031. /**
  6032. * Instantiates a Smart Array.
  6033. * @param capacity defines the default capacity of the array.
  6034. */
  6035. constructor(capacity: number);
  6036. /**
  6037. * Pushes a value at the end of the active data.
  6038. * @param value defines the object to push in the array.
  6039. */
  6040. push(value: T): void;
  6041. /**
  6042. * Iterates over the active data and apply the lambda to them.
  6043. * @param func defines the action to apply on each value.
  6044. */
  6045. forEach(func: (content: T) => void): void;
  6046. /**
  6047. * Sorts the full sets of data.
  6048. * @param compareFn defines the comparison function to apply.
  6049. */
  6050. sort(compareFn: (a: T, b: T) => number): void;
  6051. /**
  6052. * Resets the active data to an empty array.
  6053. */
  6054. reset(): void;
  6055. /**
  6056. * Releases all the data from the array as well as the array.
  6057. */
  6058. dispose(): void;
  6059. /**
  6060. * Concats the active data with a given array.
  6061. * @param array defines the data to concatenate with.
  6062. */
  6063. concat(array: any): void;
  6064. /**
  6065. * Returns the position of a value in the active data.
  6066. * @param value defines the value to find the index for
  6067. * @returns the index if found in the active data otherwise -1
  6068. */
  6069. indexOf(value: T): number;
  6070. /**
  6071. * Returns whether an element is part of the active data.
  6072. * @param value defines the value to look for
  6073. * @returns true if found in the active data otherwise false
  6074. */
  6075. contains(value: T): boolean;
  6076. private static _GlobalId;
  6077. }
  6078. /**
  6079. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6080. * The data in this array can only be present once
  6081. */
  6082. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6083. private _duplicateId;
  6084. /**
  6085. * Pushes a value at the end of the active data.
  6086. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6087. * @param value defines the object to push in the array.
  6088. */
  6089. push(value: T): void;
  6090. /**
  6091. * Pushes a value at the end of the active data.
  6092. * If the data is already present, it won t be added again
  6093. * @param value defines the object to push in the array.
  6094. * @returns true if added false if it was already present
  6095. */
  6096. pushNoDuplicate(value: T): boolean;
  6097. /**
  6098. * Resets the active data to an empty array.
  6099. */
  6100. reset(): void;
  6101. /**
  6102. * Concats the active data with a given array.
  6103. * This ensures no dupplicate will be present in the result.
  6104. * @param array defines the data to concatenate with.
  6105. */
  6106. concatWithNoDuplicate(array: any): void;
  6107. }
  6108. }
  6109. declare module "babylonjs/Cameras/cameraInputsManager" {
  6110. import { Nullable } from "babylonjs/types";
  6111. import { Camera } from "babylonjs/Cameras/camera";
  6112. /**
  6113. * @ignore
  6114. * This is a list of all the different input types that are available in the application.
  6115. * Fo instance: ArcRotateCameraGamepadInput...
  6116. */
  6117. export var CameraInputTypes: {};
  6118. /**
  6119. * This is the contract to implement in order to create a new input class.
  6120. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6121. */
  6122. export interface ICameraInput<TCamera extends Camera> {
  6123. /**
  6124. * Defines the camera the input is attached to.
  6125. */
  6126. camera: Nullable<TCamera>;
  6127. /**
  6128. * Gets the class name of the current intput.
  6129. * @returns the class name
  6130. */
  6131. getClassName(): string;
  6132. /**
  6133. * Get the friendly name associated with the input class.
  6134. * @returns the input friendly name
  6135. */
  6136. getSimpleName(): string;
  6137. /**
  6138. * Attach the input controls to a specific dom element to get the input from.
  6139. * @param element Defines the element the controls should be listened from
  6140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6141. */
  6142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6143. /**
  6144. * Detach the current controls from the specified dom element.
  6145. * @param element Defines the element to stop listening the inputs from
  6146. */
  6147. detachControl(element: Nullable<HTMLElement>): void;
  6148. /**
  6149. * Update the current camera state depending on the inputs that have been used this frame.
  6150. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6151. */
  6152. checkInputs?: () => void;
  6153. }
  6154. /**
  6155. * Represents a map of input types to input instance or input index to input instance.
  6156. */
  6157. export interface CameraInputsMap<TCamera extends Camera> {
  6158. /**
  6159. * Accessor to the input by input type.
  6160. */
  6161. [name: string]: ICameraInput<TCamera>;
  6162. /**
  6163. * Accessor to the input by input index.
  6164. */
  6165. [idx: number]: ICameraInput<TCamera>;
  6166. }
  6167. /**
  6168. * This represents the input manager used within a camera.
  6169. * It helps dealing with all the different kind of input attached to a camera.
  6170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6171. */
  6172. export class CameraInputsManager<TCamera extends Camera> {
  6173. /**
  6174. * Defines the list of inputs attahed to the camera.
  6175. */
  6176. attached: CameraInputsMap<TCamera>;
  6177. /**
  6178. * Defines the dom element the camera is collecting inputs from.
  6179. * This is null if the controls have not been attached.
  6180. */
  6181. attachedElement: Nullable<HTMLElement>;
  6182. /**
  6183. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6184. */
  6185. noPreventDefault: boolean;
  6186. /**
  6187. * Defined the camera the input manager belongs to.
  6188. */
  6189. camera: TCamera;
  6190. /**
  6191. * Update the current camera state depending on the inputs that have been used this frame.
  6192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6193. */
  6194. checkInputs: () => void;
  6195. /**
  6196. * Instantiate a new Camera Input Manager.
  6197. * @param camera Defines the camera the input manager blongs to
  6198. */
  6199. constructor(camera: TCamera);
  6200. /**
  6201. * Add an input method to a camera
  6202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6203. * @param input camera input method
  6204. */
  6205. add(input: ICameraInput<TCamera>): void;
  6206. /**
  6207. * Remove a specific input method from a camera
  6208. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6209. * @param inputToRemove camera input method
  6210. */
  6211. remove(inputToRemove: ICameraInput<TCamera>): void;
  6212. /**
  6213. * Remove a specific input type from a camera
  6214. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6215. * @param inputType the type of the input to remove
  6216. */
  6217. removeByType(inputType: string): void;
  6218. private _addCheckInputs;
  6219. /**
  6220. * Attach the input controls to the currently attached dom element to listen the events from.
  6221. * @param input Defines the input to attach
  6222. */
  6223. attachInput(input: ICameraInput<TCamera>): void;
  6224. /**
  6225. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6226. * @param element Defines the dom element to collect the events from
  6227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6228. */
  6229. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6230. /**
  6231. * Detach the current manager inputs controls from a specific dom element.
  6232. * @param element Defines the dom element to collect the events from
  6233. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6234. */
  6235. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6236. /**
  6237. * Rebuild the dynamic inputCheck function from the current list of
  6238. * defined inputs in the manager.
  6239. */
  6240. rebuildInputCheck(): void;
  6241. /**
  6242. * Remove all attached input methods from a camera
  6243. */
  6244. clear(): void;
  6245. /**
  6246. * Serialize the current input manager attached to a camera.
  6247. * This ensures than once parsed,
  6248. * the input associated to the camera will be identical to the current ones
  6249. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6250. */
  6251. serialize(serializedCamera: any): void;
  6252. /**
  6253. * Parses an input manager serialized JSON to restore the previous list of inputs
  6254. * and states associated to a camera.
  6255. * @param parsedCamera Defines the JSON to parse
  6256. */
  6257. parse(parsedCamera: any): void;
  6258. }
  6259. }
  6260. declare module "babylonjs/Meshes/buffer" {
  6261. import { Nullable, DataArray } from "babylonjs/types";
  6262. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6263. /**
  6264. * Class used to store data that will be store in GPU memory
  6265. */
  6266. export class Buffer {
  6267. private _engine;
  6268. private _buffer;
  6269. /** @hidden */
  6270. _data: Nullable<DataArray>;
  6271. private _updatable;
  6272. private _instanced;
  6273. private _divisor;
  6274. /**
  6275. * Gets the byte stride.
  6276. */
  6277. readonly byteStride: number;
  6278. /**
  6279. * Constructor
  6280. * @param engine the engine
  6281. * @param data the data to use for this buffer
  6282. * @param updatable whether the data is updatable
  6283. * @param stride the stride (optional)
  6284. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6285. * @param instanced whether the buffer is instanced (optional)
  6286. * @param useBytes set to true if the stride in in bytes (optional)
  6287. * @param divisor sets an optional divisor for instances (1 by default)
  6288. */
  6289. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6290. /**
  6291. * Create a new VertexBuffer based on the current buffer
  6292. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6293. * @param offset defines offset in the buffer (0 by default)
  6294. * @param size defines the size in floats of attributes (position is 3 for instance)
  6295. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6296. * @param instanced defines if the vertex buffer contains indexed data
  6297. * @param useBytes defines if the offset and stride are in bytes *
  6298. * @param divisor sets an optional divisor for instances (1 by default)
  6299. * @returns the new vertex buffer
  6300. */
  6301. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6302. /**
  6303. * Gets a boolean indicating if the Buffer is updatable?
  6304. * @returns true if the buffer is updatable
  6305. */
  6306. isUpdatable(): boolean;
  6307. /**
  6308. * Gets current buffer's data
  6309. * @returns a DataArray or null
  6310. */
  6311. getData(): Nullable<DataArray>;
  6312. /**
  6313. * Gets underlying native buffer
  6314. * @returns underlying native buffer
  6315. */
  6316. getBuffer(): Nullable<DataBuffer>;
  6317. /**
  6318. * Gets the stride in float32 units (i.e. byte stride / 4).
  6319. * May not be an integer if the byte stride is not divisible by 4.
  6320. * @returns the stride in float32 units
  6321. * @deprecated Please use byteStride instead.
  6322. */
  6323. getStrideSize(): number;
  6324. /**
  6325. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6326. * @param data defines the data to store
  6327. */
  6328. create(data?: Nullable<DataArray>): void;
  6329. /** @hidden */
  6330. _rebuild(): void;
  6331. /**
  6332. * Update current buffer data
  6333. * @param data defines the data to store
  6334. */
  6335. update(data: DataArray): void;
  6336. /**
  6337. * Updates the data directly.
  6338. * @param data the new data
  6339. * @param offset the new offset
  6340. * @param vertexCount the vertex count (optional)
  6341. * @param useBytes set to true if the offset is in bytes
  6342. */
  6343. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6344. /**
  6345. * Release all resources
  6346. */
  6347. dispose(): void;
  6348. }
  6349. /**
  6350. * Specialized buffer used to store vertex data
  6351. */
  6352. export class VertexBuffer {
  6353. /** @hidden */
  6354. _buffer: Buffer;
  6355. private _kind;
  6356. private _size;
  6357. private _ownsBuffer;
  6358. private _instanced;
  6359. private _instanceDivisor;
  6360. /**
  6361. * The byte type.
  6362. */
  6363. static readonly BYTE: number;
  6364. /**
  6365. * The unsigned byte type.
  6366. */
  6367. static readonly UNSIGNED_BYTE: number;
  6368. /**
  6369. * The short type.
  6370. */
  6371. static readonly SHORT: number;
  6372. /**
  6373. * The unsigned short type.
  6374. */
  6375. static readonly UNSIGNED_SHORT: number;
  6376. /**
  6377. * The integer type.
  6378. */
  6379. static readonly INT: number;
  6380. /**
  6381. * The unsigned integer type.
  6382. */
  6383. static readonly UNSIGNED_INT: number;
  6384. /**
  6385. * The float type.
  6386. */
  6387. static readonly FLOAT: number;
  6388. /**
  6389. * Gets or sets the instance divisor when in instanced mode
  6390. */
  6391. get instanceDivisor(): number;
  6392. set instanceDivisor(value: number);
  6393. /**
  6394. * Gets the byte stride.
  6395. */
  6396. readonly byteStride: number;
  6397. /**
  6398. * Gets the byte offset.
  6399. */
  6400. readonly byteOffset: number;
  6401. /**
  6402. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6403. */
  6404. readonly normalized: boolean;
  6405. /**
  6406. * Gets the data type of each component in the array.
  6407. */
  6408. readonly type: number;
  6409. /**
  6410. * Constructor
  6411. * @param engine the engine
  6412. * @param data the data to use for this vertex buffer
  6413. * @param kind the vertex buffer kind
  6414. * @param updatable whether the data is updatable
  6415. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6416. * @param stride the stride (optional)
  6417. * @param instanced whether the buffer is instanced (optional)
  6418. * @param offset the offset of the data (optional)
  6419. * @param size the number of components (optional)
  6420. * @param type the type of the component (optional)
  6421. * @param normalized whether the data contains normalized data (optional)
  6422. * @param useBytes set to true if stride and offset are in bytes (optional)
  6423. * @param divisor defines the instance divisor to use (1 by default)
  6424. */
  6425. 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);
  6426. /** @hidden */
  6427. _rebuild(): void;
  6428. /**
  6429. * Returns the kind of the VertexBuffer (string)
  6430. * @returns a string
  6431. */
  6432. getKind(): string;
  6433. /**
  6434. * Gets a boolean indicating if the VertexBuffer is updatable?
  6435. * @returns true if the buffer is updatable
  6436. */
  6437. isUpdatable(): boolean;
  6438. /**
  6439. * Gets current buffer's data
  6440. * @returns a DataArray or null
  6441. */
  6442. getData(): Nullable<DataArray>;
  6443. /**
  6444. * Gets underlying native buffer
  6445. * @returns underlying native buffer
  6446. */
  6447. getBuffer(): Nullable<DataBuffer>;
  6448. /**
  6449. * Gets the stride in float32 units (i.e. byte stride / 4).
  6450. * May not be an integer if the byte stride is not divisible by 4.
  6451. * @returns the stride in float32 units
  6452. * @deprecated Please use byteStride instead.
  6453. */
  6454. getStrideSize(): number;
  6455. /**
  6456. * Returns the offset as a multiple of the type byte length.
  6457. * @returns the offset in bytes
  6458. * @deprecated Please use byteOffset instead.
  6459. */
  6460. getOffset(): number;
  6461. /**
  6462. * Returns the number of components per vertex attribute (integer)
  6463. * @returns the size in float
  6464. */
  6465. getSize(): number;
  6466. /**
  6467. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6468. * @returns true if this buffer is instanced
  6469. */
  6470. getIsInstanced(): boolean;
  6471. /**
  6472. * Returns the instancing divisor, zero for non-instanced (integer).
  6473. * @returns a number
  6474. */
  6475. getInstanceDivisor(): number;
  6476. /**
  6477. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6478. * @param data defines the data to store
  6479. */
  6480. create(data?: DataArray): void;
  6481. /**
  6482. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6483. * This function will create a new buffer if the current one is not updatable
  6484. * @param data defines the data to store
  6485. */
  6486. update(data: DataArray): void;
  6487. /**
  6488. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6489. * Returns the directly updated WebGLBuffer.
  6490. * @param data the new data
  6491. * @param offset the new offset
  6492. * @param useBytes set to true if the offset is in bytes
  6493. */
  6494. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6495. /**
  6496. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6497. */
  6498. dispose(): void;
  6499. /**
  6500. * Enumerates each value of this vertex buffer as numbers.
  6501. * @param count the number of values to enumerate
  6502. * @param callback the callback function called for each value
  6503. */
  6504. forEach(count: number, callback: (value: number, index: number) => void): void;
  6505. /**
  6506. * Positions
  6507. */
  6508. static readonly PositionKind: string;
  6509. /**
  6510. * Normals
  6511. */
  6512. static readonly NormalKind: string;
  6513. /**
  6514. * Tangents
  6515. */
  6516. static readonly TangentKind: string;
  6517. /**
  6518. * Texture coordinates
  6519. */
  6520. static readonly UVKind: string;
  6521. /**
  6522. * Texture coordinates 2
  6523. */
  6524. static readonly UV2Kind: string;
  6525. /**
  6526. * Texture coordinates 3
  6527. */
  6528. static readonly UV3Kind: string;
  6529. /**
  6530. * Texture coordinates 4
  6531. */
  6532. static readonly UV4Kind: string;
  6533. /**
  6534. * Texture coordinates 5
  6535. */
  6536. static readonly UV5Kind: string;
  6537. /**
  6538. * Texture coordinates 6
  6539. */
  6540. static readonly UV6Kind: string;
  6541. /**
  6542. * Colors
  6543. */
  6544. static readonly ColorKind: string;
  6545. /**
  6546. * Matrix indices (for bones)
  6547. */
  6548. static readonly MatricesIndicesKind: string;
  6549. /**
  6550. * Matrix weights (for bones)
  6551. */
  6552. static readonly MatricesWeightsKind: string;
  6553. /**
  6554. * Additional matrix indices (for bones)
  6555. */
  6556. static readonly MatricesIndicesExtraKind: string;
  6557. /**
  6558. * Additional matrix weights (for bones)
  6559. */
  6560. static readonly MatricesWeightsExtraKind: string;
  6561. /**
  6562. * Deduces the stride given a kind.
  6563. * @param kind The kind string to deduce
  6564. * @returns The deduced stride
  6565. */
  6566. static DeduceStride(kind: string): number;
  6567. /**
  6568. * Gets the byte length of the given type.
  6569. * @param type the type
  6570. * @returns the number of bytes
  6571. */
  6572. static GetTypeByteLength(type: number): number;
  6573. /**
  6574. * Enumerates each value of the given parameters as numbers.
  6575. * @param data the data to enumerate
  6576. * @param byteOffset the byte offset of the data
  6577. * @param byteStride the byte stride of the data
  6578. * @param componentCount the number of components per element
  6579. * @param componentType the type of the component
  6580. * @param count the number of values to enumerate
  6581. * @param normalized whether the data is normalized
  6582. * @param callback the callback function called for each value
  6583. */
  6584. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6585. private static _GetFloatValue;
  6586. }
  6587. }
  6588. declare module "babylonjs/Collisions/intersectionInfo" {
  6589. import { Nullable } from "babylonjs/types";
  6590. /**
  6591. * @hidden
  6592. */
  6593. export class IntersectionInfo {
  6594. bu: Nullable<number>;
  6595. bv: Nullable<number>;
  6596. distance: number;
  6597. faceId: number;
  6598. subMeshId: number;
  6599. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6600. }
  6601. }
  6602. declare module "babylonjs/Maths/math.plane" {
  6603. import { DeepImmutable } from "babylonjs/types";
  6604. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module "babylonjs/Culling/boundingSphere" {
  6713. import { DeepImmutable } from "babylonjs/types";
  6714. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6715. import { Plane } from "babylonjs/Maths/math.plane";
  6716. /**
  6717. * Class used to store bounding sphere information
  6718. */
  6719. export class BoundingSphere {
  6720. /**
  6721. * Gets the center of the bounding sphere in local space
  6722. */
  6723. readonly center: Vector3;
  6724. /**
  6725. * Radius of the bounding sphere in local space
  6726. */
  6727. radius: number;
  6728. /**
  6729. * Gets the center of the bounding sphere in world space
  6730. */
  6731. readonly centerWorld: Vector3;
  6732. /**
  6733. * Radius of the bounding sphere in world space
  6734. */
  6735. radiusWorld: number;
  6736. /**
  6737. * Gets the minimum vector in local space
  6738. */
  6739. readonly minimum: Vector3;
  6740. /**
  6741. * Gets the maximum vector in local space
  6742. */
  6743. readonly maximum: Vector3;
  6744. private _worldMatrix;
  6745. private static readonly TmpVector3;
  6746. /**
  6747. * Creates a new bounding sphere
  6748. * @param min defines the minimum vector (in local space)
  6749. * @param max defines the maximum vector (in local space)
  6750. * @param worldMatrix defines the new world matrix
  6751. */
  6752. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6753. /**
  6754. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6755. * @param min defines the new minimum vector (in local space)
  6756. * @param max defines the new maximum vector (in local space)
  6757. * @param worldMatrix defines the new world matrix
  6758. */
  6759. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6760. /**
  6761. * Scale the current bounding sphere by applying a scale factor
  6762. * @param factor defines the scale factor to apply
  6763. * @returns the current bounding box
  6764. */
  6765. scale(factor: number): BoundingSphere;
  6766. /**
  6767. * Gets the world matrix of the bounding box
  6768. * @returns a matrix
  6769. */
  6770. getWorldMatrix(): DeepImmutable<Matrix>;
  6771. /** @hidden */
  6772. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6773. /**
  6774. * Tests if the bounding sphere is intersecting the frustum planes
  6775. * @param frustumPlanes defines the frustum planes to test
  6776. * @returns true if there is an intersection
  6777. */
  6778. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6779. /**
  6780. * Tests if the bounding sphere center is in between the frustum planes.
  6781. * Used for optimistic fast inclusion.
  6782. * @param frustumPlanes defines the frustum planes to test
  6783. * @returns true if the sphere center is in between the frustum planes
  6784. */
  6785. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6786. /**
  6787. * Tests if a point is inside the bounding sphere
  6788. * @param point defines the point to test
  6789. * @returns true if the point is inside the bounding sphere
  6790. */
  6791. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6792. /**
  6793. * Checks if two sphere intersct
  6794. * @param sphere0 sphere 0
  6795. * @param sphere1 sphere 1
  6796. * @returns true if the speres intersect
  6797. */
  6798. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6799. }
  6800. }
  6801. declare module "babylonjs/Culling/boundingBox" {
  6802. import { DeepImmutable } from "babylonjs/types";
  6803. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6804. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6805. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6806. import { Plane } from "babylonjs/Maths/math.plane";
  6807. /**
  6808. * Class used to store bounding box information
  6809. */
  6810. export class BoundingBox implements ICullable {
  6811. /**
  6812. * Gets the 8 vectors representing the bounding box in local space
  6813. */
  6814. readonly vectors: Vector3[];
  6815. /**
  6816. * Gets the center of the bounding box in local space
  6817. */
  6818. readonly center: Vector3;
  6819. /**
  6820. * Gets the center of the bounding box in world space
  6821. */
  6822. readonly centerWorld: Vector3;
  6823. /**
  6824. * Gets the extend size in local space
  6825. */
  6826. readonly extendSize: Vector3;
  6827. /**
  6828. * Gets the extend size in world space
  6829. */
  6830. readonly extendSizeWorld: Vector3;
  6831. /**
  6832. * Gets the OBB (object bounding box) directions
  6833. */
  6834. readonly directions: Vector3[];
  6835. /**
  6836. * Gets the 8 vectors representing the bounding box in world space
  6837. */
  6838. readonly vectorsWorld: Vector3[];
  6839. /**
  6840. * Gets the minimum vector in world space
  6841. */
  6842. readonly minimumWorld: Vector3;
  6843. /**
  6844. * Gets the maximum vector in world space
  6845. */
  6846. readonly maximumWorld: Vector3;
  6847. /**
  6848. * Gets the minimum vector in local space
  6849. */
  6850. readonly minimum: Vector3;
  6851. /**
  6852. * Gets the maximum vector in local space
  6853. */
  6854. readonly maximum: Vector3;
  6855. private _worldMatrix;
  6856. private static readonly TmpVector3;
  6857. /**
  6858. * @hidden
  6859. */
  6860. _tag: number;
  6861. /**
  6862. * Creates a new bounding box
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding box by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingBox;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(world: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding box is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding box is entirely inside the frustum planes
  6896. * @param frustumPlanes defines the frustum planes to test
  6897. * @returns true if there is an inclusion
  6898. */
  6899. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6900. /**
  6901. * Tests if a point is inside the bounding box
  6902. * @param point defines the point to test
  6903. * @returns true if the point is inside the bounding box
  6904. */
  6905. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6906. /**
  6907. * Tests if the bounding box intersects with a bounding sphere
  6908. * @param sphere defines the sphere to test
  6909. * @returns true if there is an intersection
  6910. */
  6911. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6912. /**
  6913. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6914. * @param min defines the min vector to use
  6915. * @param max defines the max vector to use
  6916. * @returns true if there is an intersection
  6917. */
  6918. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6919. /**
  6920. * Tests if two bounding boxes are intersections
  6921. * @param box0 defines the first box to test
  6922. * @param box1 defines the second box to test
  6923. * @returns true if there is an intersection
  6924. */
  6925. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6926. /**
  6927. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6928. * @param minPoint defines the minimum vector of the bounding box
  6929. * @param maxPoint defines the maximum vector of the bounding box
  6930. * @param sphereCenter defines the sphere center
  6931. * @param sphereRadius defines the sphere radius
  6932. * @returns true if there is an intersection
  6933. */
  6934. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6935. /**
  6936. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6937. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @return true if there is an inclusion
  6940. */
  6941. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6944. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @return true if there is an intersection
  6947. */
  6948. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. }
  6950. }
  6951. declare module "babylonjs/Collisions/collider" {
  6952. import { Nullable, IndicesArray } from "babylonjs/types";
  6953. import { Vector3 } from "babylonjs/Maths/math.vector";
  6954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6955. import { Plane } from "babylonjs/Maths/math.plane";
  6956. /** @hidden */
  6957. export class Collider {
  6958. /** Define if a collision was found */
  6959. collisionFound: boolean;
  6960. /**
  6961. * Define last intersection point in local space
  6962. */
  6963. intersectionPoint: Vector3;
  6964. /**
  6965. * Define last collided mesh
  6966. */
  6967. collidedMesh: Nullable<AbstractMesh>;
  6968. private _collisionPoint;
  6969. private _planeIntersectionPoint;
  6970. private _tempVector;
  6971. private _tempVector2;
  6972. private _tempVector3;
  6973. private _tempVector4;
  6974. private _edge;
  6975. private _baseToVertex;
  6976. private _destinationPoint;
  6977. private _slidePlaneNormal;
  6978. private _displacementVector;
  6979. /** @hidden */
  6980. _radius: Vector3;
  6981. /** @hidden */
  6982. _retry: number;
  6983. private _velocity;
  6984. private _basePoint;
  6985. private _epsilon;
  6986. /** @hidden */
  6987. _velocityWorldLength: number;
  6988. /** @hidden */
  6989. _basePointWorld: Vector3;
  6990. private _velocityWorld;
  6991. private _normalizedVelocity;
  6992. /** @hidden */
  6993. _initialVelocity: Vector3;
  6994. /** @hidden */
  6995. _initialPosition: Vector3;
  6996. private _nearestDistance;
  6997. private _collisionMask;
  6998. get collisionMask(): number;
  6999. set collisionMask(mask: number);
  7000. /**
  7001. * Gets the plane normal used to compute the sliding response (in local space)
  7002. */
  7003. get slidePlaneNormal(): Vector3;
  7004. /** @hidden */
  7005. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7006. /** @hidden */
  7007. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7008. /** @hidden */
  7009. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7010. /** @hidden */
  7011. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7014. /** @hidden */
  7015. _getResponse(pos: Vector3, vel: Vector3): void;
  7016. }
  7017. }
  7018. declare module "babylonjs/Culling/boundingInfo" {
  7019. import { DeepImmutable } from "babylonjs/types";
  7020. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7021. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7022. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7023. import { Plane } from "babylonjs/Maths/math.plane";
  7024. import { Collider } from "babylonjs/Collisions/collider";
  7025. /**
  7026. * Interface for cullable objects
  7027. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7028. */
  7029. export interface ICullable {
  7030. /**
  7031. * Checks if the object or part of the object is in the frustum
  7032. * @param frustumPlanes Camera near/planes
  7033. * @returns true if the object is in frustum otherwise false
  7034. */
  7035. isInFrustum(frustumPlanes: Plane[]): boolean;
  7036. /**
  7037. * Checks if a cullable object (mesh...) is in the camera frustum
  7038. * Unlike isInFrustum this cheks the full bounding box
  7039. * @param frustumPlanes Camera near/planes
  7040. * @returns true if the object is in frustum otherwise false
  7041. */
  7042. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7043. }
  7044. /**
  7045. * Info for a bounding data of a mesh
  7046. */
  7047. export class BoundingInfo implements ICullable {
  7048. /**
  7049. * Bounding box for the mesh
  7050. */
  7051. readonly boundingBox: BoundingBox;
  7052. /**
  7053. * Bounding sphere for the mesh
  7054. */
  7055. readonly boundingSphere: BoundingSphere;
  7056. private _isLocked;
  7057. private static readonly TmpVector3;
  7058. /**
  7059. * Constructs bounding info
  7060. * @param minimum min vector of the bounding box/sphere
  7061. * @param maximum max vector of the bounding box/sphere
  7062. * @param worldMatrix defines the new world matrix
  7063. */
  7064. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7065. /**
  7066. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7067. * @param min defines the new minimum vector (in local space)
  7068. * @param max defines the new maximum vector (in local space)
  7069. * @param worldMatrix defines the new world matrix
  7070. */
  7071. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * min vector of the bounding box/sphere
  7074. */
  7075. get minimum(): Vector3;
  7076. /**
  7077. * max vector of the bounding box/sphere
  7078. */
  7079. get maximum(): Vector3;
  7080. /**
  7081. * If the info is locked and won't be updated to avoid perf overhead
  7082. */
  7083. get isLocked(): boolean;
  7084. set isLocked(value: boolean);
  7085. /**
  7086. * Updates the bounding sphere and box
  7087. * @param world world matrix to be used to update
  7088. */
  7089. update(world: DeepImmutable<Matrix>): void;
  7090. /**
  7091. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7092. * @param center New center of the bounding info
  7093. * @param extend New extend of the bounding info
  7094. * @returns the current bounding info
  7095. */
  7096. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7097. /**
  7098. * Scale the current bounding info by applying a scale factor
  7099. * @param factor defines the scale factor to apply
  7100. * @returns the current bounding info
  7101. */
  7102. scale(factor: number): BoundingInfo;
  7103. /**
  7104. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7105. * @param frustumPlanes defines the frustum to test
  7106. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7107. * @returns true if the bounding info is in the frustum planes
  7108. */
  7109. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7110. /**
  7111. * Gets the world distance between the min and max points of the bounding box
  7112. */
  7113. get diagonalLength(): number;
  7114. /**
  7115. * Checks if a cullable object (mesh...) is in the camera frustum
  7116. * Unlike isInFrustum this cheks the full bounding box
  7117. * @param frustumPlanes Camera near/planes
  7118. * @returns true if the object is in frustum otherwise false
  7119. */
  7120. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. /** @hidden */
  7122. _checkCollision(collider: Collider): boolean;
  7123. /**
  7124. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7125. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7126. * @param point the point to check intersection with
  7127. * @returns if the point intersects
  7128. */
  7129. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7130. /**
  7131. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7132. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7133. * @param boundingInfo the bounding info to check intersection with
  7134. * @param precise if the intersection should be done using OBB
  7135. * @returns if the bounding info intersects
  7136. */
  7137. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7138. }
  7139. }
  7140. declare module "babylonjs/Maths/math.functions" {
  7141. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7142. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7143. /**
  7144. * Extracts minimum and maximum values from a list of indexed positions
  7145. * @param positions defines the positions to use
  7146. * @param indices defines the indices to the positions
  7147. * @param indexStart defines the start index
  7148. * @param indexCount defines the end index
  7149. * @param bias defines bias value to add to the result
  7150. * @return minimum and maximum values
  7151. */
  7152. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7153. minimum: Vector3;
  7154. maximum: Vector3;
  7155. };
  7156. /**
  7157. * Extracts minimum and maximum values from a list of positions
  7158. * @param positions defines the positions to use
  7159. * @param start defines the start index in the positions array
  7160. * @param count defines the number of positions to handle
  7161. * @param bias defines bias value to add to the result
  7162. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7163. * @return minimum and maximum values
  7164. */
  7165. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7166. minimum: Vector3;
  7167. maximum: Vector3;
  7168. };
  7169. }
  7170. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7171. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7172. /** @hidden */
  7173. export class WebGLDataBuffer extends DataBuffer {
  7174. private _buffer;
  7175. constructor(resource: WebGLBuffer);
  7176. get underlyingResource(): any;
  7177. }
  7178. }
  7179. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7180. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7181. import { Nullable } from "babylonjs/types";
  7182. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7183. /** @hidden */
  7184. export class WebGLPipelineContext implements IPipelineContext {
  7185. engine: ThinEngine;
  7186. program: Nullable<WebGLProgram>;
  7187. context?: WebGLRenderingContext;
  7188. vertexShader?: WebGLShader;
  7189. fragmentShader?: WebGLShader;
  7190. isParallelCompiled: boolean;
  7191. onCompiled?: () => void;
  7192. transformFeedback?: WebGLTransformFeedback | null;
  7193. vertexCompilationError: Nullable<string>;
  7194. fragmentCompilationError: Nullable<string>;
  7195. programLinkError: Nullable<string>;
  7196. programValidationError: Nullable<string>;
  7197. get isAsync(): boolean;
  7198. get isReady(): boolean;
  7199. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7200. }
  7201. }
  7202. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7203. import { FloatArray, Nullable } from "babylonjs/types";
  7204. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7205. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7206. module "babylonjs/Engines/thinEngine" {
  7207. interface ThinEngine {
  7208. /**
  7209. * Create an uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param elements defines the content of the uniform buffer
  7212. * @returns the webGL uniform buffer
  7213. */
  7214. createUniformBuffer(elements: FloatArray): DataBuffer;
  7215. /**
  7216. * Create a dynamic uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Update an existing uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param uniformBuffer defines the target uniform buffer
  7226. * @param elements defines the content to update
  7227. * @param offset defines the offset in the uniform buffer where update should start
  7228. * @param count defines the size of the data to update
  7229. */
  7230. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7231. /**
  7232. * Bind an uniform buffer to the current webGL context
  7233. * @param buffer defines the buffer to bind
  7234. */
  7235. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7236. /**
  7237. * Bind a buffer to the current webGL context at a given location
  7238. * @param buffer defines the buffer to bind
  7239. * @param location defines the index where to bind the buffer
  7240. */
  7241. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7242. /**
  7243. * Bind a specific block at a given index in a specific shader program
  7244. * @param pipelineContext defines the pipeline context to use
  7245. * @param blockName defines the block name
  7246. * @param index defines the index where to bind the block
  7247. */
  7248. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7249. }
  7250. }
  7251. }
  7252. declare module "babylonjs/Materials/uniformBuffer" {
  7253. import { Nullable, FloatArray } from "babylonjs/types";
  7254. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7255. import { Engine } from "babylonjs/Engines/engine";
  7256. import { Effect } from "babylonjs/Materials/effect";
  7257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7258. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7259. import { Color3 } from "babylonjs/Maths/math.color";
  7260. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7261. /**
  7262. * Uniform buffer objects.
  7263. *
  7264. * Handles blocks of uniform on the GPU.
  7265. *
  7266. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7267. *
  7268. * For more information, please refer to :
  7269. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7270. */
  7271. export class UniformBuffer {
  7272. private _engine;
  7273. private _buffer;
  7274. private _data;
  7275. private _bufferData;
  7276. private _dynamic?;
  7277. private _uniformLocations;
  7278. private _uniformSizes;
  7279. private _uniformLocationPointer;
  7280. private _needSync;
  7281. private _noUBO;
  7282. private _currentEffect;
  7283. /** @hidden */
  7284. _alreadyBound: boolean;
  7285. private static _MAX_UNIFORM_SIZE;
  7286. private static _tempBuffer;
  7287. /**
  7288. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7289. * This is dynamic to allow compat with webgl 1 and 2.
  7290. * You will need to pass the name of the uniform as well as the value.
  7291. */
  7292. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7293. /**
  7294. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7295. * This is dynamic to allow compat with webgl 1 and 2.
  7296. * You will need to pass the name of the uniform as well as the value.
  7297. */
  7298. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7299. /**
  7300. * Lambda to Update a single float in a uniform buffer.
  7301. * This is dynamic to allow compat with webgl 1 and 2.
  7302. * You will need to pass the name of the uniform as well as the value.
  7303. */
  7304. updateFloat: (name: string, x: number) => void;
  7305. /**
  7306. * Lambda to Update a vec2 of float in a uniform buffer.
  7307. * This is dynamic to allow compat with webgl 1 and 2.
  7308. * You will need to pass the name of the uniform as well as the value.
  7309. */
  7310. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7311. /**
  7312. * Lambda to Update a vec3 of float in a uniform buffer.
  7313. * This is dynamic to allow compat with webgl 1 and 2.
  7314. * You will need to pass the name of the uniform as well as the value.
  7315. */
  7316. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7317. /**
  7318. * Lambda to Update a vec4 of float in a uniform buffer.
  7319. * This is dynamic to allow compat with webgl 1 and 2.
  7320. * You will need to pass the name of the uniform as well as the value.
  7321. */
  7322. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7323. /**
  7324. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7325. * This is dynamic to allow compat with webgl 1 and 2.
  7326. * You will need to pass the name of the uniform as well as the value.
  7327. */
  7328. updateMatrix: (name: string, mat: Matrix) => void;
  7329. /**
  7330. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7331. * This is dynamic to allow compat with webgl 1 and 2.
  7332. * You will need to pass the name of the uniform as well as the value.
  7333. */
  7334. updateVector3: (name: string, vector: Vector3) => void;
  7335. /**
  7336. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7337. * This is dynamic to allow compat with webgl 1 and 2.
  7338. * You will need to pass the name of the uniform as well as the value.
  7339. */
  7340. updateVector4: (name: string, vector: Vector4) => void;
  7341. /**
  7342. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7343. * This is dynamic to allow compat with webgl 1 and 2.
  7344. * You will need to pass the name of the uniform as well as the value.
  7345. */
  7346. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7347. /**
  7348. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7349. * This is dynamic to allow compat with webgl 1 and 2.
  7350. * You will need to pass the name of the uniform as well as the value.
  7351. */
  7352. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7353. /**
  7354. * Instantiates a new Uniform buffer objects.
  7355. *
  7356. * Handles blocks of uniform on the GPU.
  7357. *
  7358. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7359. *
  7360. * For more information, please refer to :
  7361. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7362. * @param engine Define the engine the buffer is associated with
  7363. * @param data Define the data contained in the buffer
  7364. * @param dynamic Define if the buffer is updatable
  7365. */
  7366. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7367. /**
  7368. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7369. * or just falling back on setUniformXXX calls.
  7370. */
  7371. get useUbo(): boolean;
  7372. /**
  7373. * Indicates if the WebGL underlying uniform buffer is in sync
  7374. * with the javascript cache data.
  7375. */
  7376. get isSync(): boolean;
  7377. /**
  7378. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7379. * Also, a dynamic UniformBuffer will disable cache verification and always
  7380. * update the underlying WebGL uniform buffer to the GPU.
  7381. * @returns if Dynamic, otherwise false
  7382. */
  7383. isDynamic(): boolean;
  7384. /**
  7385. * The data cache on JS side.
  7386. * @returns the underlying data as a float array
  7387. */
  7388. getData(): Float32Array;
  7389. /**
  7390. * The underlying WebGL Uniform buffer.
  7391. * @returns the webgl buffer
  7392. */
  7393. getBuffer(): Nullable<DataBuffer>;
  7394. /**
  7395. * std140 layout specifies how to align data within an UBO structure.
  7396. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7397. * for specs.
  7398. */
  7399. private _fillAlignment;
  7400. /**
  7401. * Adds an uniform in the buffer.
  7402. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7403. * for the layout to be correct !
  7404. * @param name Name of the uniform, as used in the uniform block in the shader.
  7405. * @param size Data size, or data directly.
  7406. */
  7407. addUniform(name: string, size: number | number[]): void;
  7408. /**
  7409. * Adds a Matrix 4x4 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param mat A 4x4 matrix.
  7412. */
  7413. addMatrix(name: string, mat: Matrix): void;
  7414. /**
  7415. * Adds a vec2 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. * @param x Define the x component value of the vec2
  7418. * @param y Define the y component value of the vec2
  7419. */
  7420. addFloat2(name: string, x: number, y: number): void;
  7421. /**
  7422. * Adds a vec3 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param x Define the x component value of the vec3
  7425. * @param y Define the y component value of the vec3
  7426. * @param z Define the z component value of the vec3
  7427. */
  7428. addFloat3(name: string, x: number, y: number, z: number): void;
  7429. /**
  7430. * Adds a vec3 to the uniform buffer.
  7431. * @param name Name of the uniform, as used in the uniform block in the shader.
  7432. * @param color Define the vec3 from a Color
  7433. */
  7434. addColor3(name: string, color: Color3): void;
  7435. /**
  7436. * Adds a vec4 to the uniform buffer.
  7437. * @param name Name of the uniform, as used in the uniform block in the shader.
  7438. * @param color Define the rgb components from a Color
  7439. * @param alpha Define the a component of the vec4
  7440. */
  7441. addColor4(name: string, color: Color3, alpha: number): void;
  7442. /**
  7443. * Adds a vec3 to the uniform buffer.
  7444. * @param name Name of the uniform, as used in the uniform block in the shader.
  7445. * @param vector Define the vec3 components from a Vector
  7446. */
  7447. addVector3(name: string, vector: Vector3): void;
  7448. /**
  7449. * Adds a Matrix 3x3 to the uniform buffer.
  7450. * @param name Name of the uniform, as used in the uniform block in the shader.
  7451. */
  7452. addMatrix3x3(name: string): void;
  7453. /**
  7454. * Adds a Matrix 2x2 to the uniform buffer.
  7455. * @param name Name of the uniform, as used in the uniform block in the shader.
  7456. */
  7457. addMatrix2x2(name: string): void;
  7458. /**
  7459. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7460. */
  7461. create(): void;
  7462. /** @hidden */
  7463. _rebuild(): void;
  7464. /**
  7465. * Updates the WebGL Uniform Buffer on the GPU.
  7466. * If the `dynamic` flag is set to true, no cache comparison is done.
  7467. * Otherwise, the buffer will be updated only if the cache differs.
  7468. */
  7469. update(): void;
  7470. /**
  7471. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7472. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7473. * @param data Define the flattened data
  7474. * @param size Define the size of the data.
  7475. */
  7476. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7477. private _valueCache;
  7478. private _cacheMatrix;
  7479. private _updateMatrix3x3ForUniform;
  7480. private _updateMatrix3x3ForEffect;
  7481. private _updateMatrix2x2ForEffect;
  7482. private _updateMatrix2x2ForUniform;
  7483. private _updateFloatForEffect;
  7484. private _updateFloatForUniform;
  7485. private _updateFloat2ForEffect;
  7486. private _updateFloat2ForUniform;
  7487. private _updateFloat3ForEffect;
  7488. private _updateFloat3ForUniform;
  7489. private _updateFloat4ForEffect;
  7490. private _updateFloat4ForUniform;
  7491. private _updateMatrixForEffect;
  7492. private _updateMatrixForUniform;
  7493. private _updateVector3ForEffect;
  7494. private _updateVector3ForUniform;
  7495. private _updateVector4ForEffect;
  7496. private _updateVector4ForUniform;
  7497. private _updateColor3ForEffect;
  7498. private _updateColor3ForUniform;
  7499. private _updateColor4ForEffect;
  7500. private _updateColor4ForUniform;
  7501. /**
  7502. * Sets a sampler uniform on the effect.
  7503. * @param name Define the name of the sampler.
  7504. * @param texture Define the texture to set in the sampler
  7505. */
  7506. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7507. /**
  7508. * Directly updates the value of the uniform in the cache AND on the GPU.
  7509. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7510. * @param data Define the flattened data
  7511. */
  7512. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7513. /**
  7514. * Binds this uniform buffer to an effect.
  7515. * @param effect Define the effect to bind the buffer to
  7516. * @param name Name of the uniform block in the shader.
  7517. */
  7518. bindToEffect(effect: Effect, name: string): void;
  7519. /**
  7520. * Disposes the uniform buffer.
  7521. */
  7522. dispose(): void;
  7523. }
  7524. }
  7525. declare module "babylonjs/Misc/iInspectable" {
  7526. /**
  7527. * Enum that determines the text-wrapping mode to use.
  7528. */
  7529. export enum InspectableType {
  7530. /**
  7531. * Checkbox for booleans
  7532. */
  7533. Checkbox = 0,
  7534. /**
  7535. * Sliders for numbers
  7536. */
  7537. Slider = 1,
  7538. /**
  7539. * Vector3
  7540. */
  7541. Vector3 = 2,
  7542. /**
  7543. * Quaternions
  7544. */
  7545. Quaternion = 3,
  7546. /**
  7547. * Color3
  7548. */
  7549. Color3 = 4,
  7550. /**
  7551. * String
  7552. */
  7553. String = 5
  7554. }
  7555. /**
  7556. * Interface used to define custom inspectable properties.
  7557. * This interface is used by the inspector to display custom property grids
  7558. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7559. */
  7560. export interface IInspectable {
  7561. /**
  7562. * Gets the label to display
  7563. */
  7564. label: string;
  7565. /**
  7566. * Gets the name of the property to edit
  7567. */
  7568. propertyName: string;
  7569. /**
  7570. * Gets the type of the editor to use
  7571. */
  7572. type: InspectableType;
  7573. /**
  7574. * Gets the minimum value of the property when using in "slider" mode
  7575. */
  7576. min?: number;
  7577. /**
  7578. * Gets the maximum value of the property when using in "slider" mode
  7579. */
  7580. max?: number;
  7581. /**
  7582. * Gets the setp to use when using in "slider" mode
  7583. */
  7584. step?: number;
  7585. }
  7586. }
  7587. declare module "babylonjs/Misc/timingTools" {
  7588. /**
  7589. * Class used to provide helper for timing
  7590. */
  7591. export class TimingTools {
  7592. /**
  7593. * Polyfill for setImmediate
  7594. * @param action defines the action to execute after the current execution block
  7595. */
  7596. static SetImmediate(action: () => void): void;
  7597. }
  7598. }
  7599. declare module "babylonjs/Misc/instantiationTools" {
  7600. /**
  7601. * Class used to enable instatition of objects by class name
  7602. */
  7603. export class InstantiationTools {
  7604. /**
  7605. * Use this object to register external classes like custom textures or material
  7606. * to allow the laoders to instantiate them
  7607. */
  7608. static RegisteredExternalClasses: {
  7609. [key: string]: Object;
  7610. };
  7611. /**
  7612. * Tries to instantiate a new object from a given class name
  7613. * @param className defines the class name to instantiate
  7614. * @returns the new object or null if the system was not able to do the instantiation
  7615. */
  7616. static Instantiate(className: string): any;
  7617. }
  7618. }
  7619. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7620. /**
  7621. * Define options used to create a depth texture
  7622. */
  7623. export class DepthTextureCreationOptions {
  7624. /** Specifies whether or not a stencil should be allocated in the texture */
  7625. generateStencil?: boolean;
  7626. /** Specifies whether or not bilinear filtering is enable on the texture */
  7627. bilinearFiltering?: boolean;
  7628. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7629. comparisonFunction?: number;
  7630. /** Specifies if the created texture is a cube texture */
  7631. isCube?: boolean;
  7632. }
  7633. }
  7634. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7635. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7636. import { Nullable } from "babylonjs/types";
  7637. import { Scene } from "babylonjs/scene";
  7638. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7639. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7640. module "babylonjs/Engines/thinEngine" {
  7641. interface ThinEngine {
  7642. /**
  7643. * Creates a depth stencil cube texture.
  7644. * This is only available in WebGL 2.
  7645. * @param size The size of face edge in the cube texture.
  7646. * @param options The options defining the cube texture.
  7647. * @returns The cube texture
  7648. */
  7649. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7650. /**
  7651. * Creates a cube texture
  7652. * @param rootUrl defines the url where the files to load is located
  7653. * @param scene defines the current scene
  7654. * @param files defines the list of files to load (1 per face)
  7655. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7656. * @param onLoad defines an optional callback raised when the texture is loaded
  7657. * @param onError defines an optional callback raised if there is an issue to load the texture
  7658. * @param format defines the format of the data
  7659. * @param forcedExtension defines the extension to use to pick the right loader
  7660. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7661. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7662. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7663. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7664. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7665. * @returns the cube texture as an InternalTexture
  7666. */
  7667. 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;
  7668. /**
  7669. * Creates a cube texture
  7670. * @param rootUrl defines the url where the files to load is located
  7671. * @param scene defines the current scene
  7672. * @param files defines the list of files to load (1 per face)
  7673. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7674. * @param onLoad defines an optional callback raised when the texture is loaded
  7675. * @param onError defines an optional callback raised if there is an issue to load the texture
  7676. * @param format defines the format of the data
  7677. * @param forcedExtension defines the extension to use to pick the right loader
  7678. * @returns the cube texture as an InternalTexture
  7679. */
  7680. 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;
  7681. /**
  7682. * Creates a cube texture
  7683. * @param rootUrl defines the url where the files to load is located
  7684. * @param scene defines the current scene
  7685. * @param files defines the list of files to load (1 per face)
  7686. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7687. * @param onLoad defines an optional callback raised when the texture is loaded
  7688. * @param onError defines an optional callback raised if there is an issue to load the texture
  7689. * @param format defines the format of the data
  7690. * @param forcedExtension defines the extension to use to pick the right loader
  7691. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7692. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7693. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7694. * @returns the cube texture as an InternalTexture
  7695. */
  7696. 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;
  7697. /** @hidden */
  7698. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7699. /** @hidden */
  7700. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7701. /** @hidden */
  7702. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7703. /** @hidden */
  7704. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7705. /**
  7706. * @hidden
  7707. */
  7708. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7709. }
  7710. }
  7711. }
  7712. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7713. import { Nullable } from "babylonjs/types";
  7714. import { Scene } from "babylonjs/scene";
  7715. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7716. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7717. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7718. /**
  7719. * Class for creating a cube texture
  7720. */
  7721. export class CubeTexture extends BaseTexture {
  7722. private _delayedOnLoad;
  7723. /**
  7724. * The url of the texture
  7725. */
  7726. url: string;
  7727. /**
  7728. * Gets or sets the center of the bounding box associated with the cube texture.
  7729. * It must define where the camera used to render the texture was set
  7730. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7731. */
  7732. boundingBoxPosition: Vector3;
  7733. private _boundingBoxSize;
  7734. /**
  7735. * Gets or sets the size of the bounding box associated with the cube texture
  7736. * When defined, the cubemap will switch to local mode
  7737. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7738. * @example https://www.babylonjs-playground.com/#RNASML
  7739. */
  7740. set boundingBoxSize(value: Vector3);
  7741. /**
  7742. * Returns the bounding box size
  7743. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7744. */
  7745. get boundingBoxSize(): Vector3;
  7746. protected _rotationY: number;
  7747. /**
  7748. * Sets texture matrix rotation angle around Y axis in radians.
  7749. */
  7750. set rotationY(value: number);
  7751. /**
  7752. * Gets texture matrix rotation angle around Y axis radians.
  7753. */
  7754. get rotationY(): number;
  7755. /**
  7756. * Are mip maps generated for this texture or not.
  7757. */
  7758. get noMipmap(): boolean;
  7759. private _noMipmap;
  7760. private _files;
  7761. protected _forcedExtension: Nullable<string>;
  7762. private _extensions;
  7763. private _textureMatrix;
  7764. private _format;
  7765. private _createPolynomials;
  7766. /** @hidden */
  7767. _prefiltered: boolean;
  7768. /**
  7769. * Creates a cube texture from an array of image urls
  7770. * @param files defines an array of image urls
  7771. * @param scene defines the hosting scene
  7772. * @param noMipmap specifies if mip maps are not used
  7773. * @returns a cube texture
  7774. */
  7775. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7776. /**
  7777. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7778. * @param url defines the url of the prefiltered texture
  7779. * @param scene defines the scene the texture is attached to
  7780. * @param forcedExtension defines the extension of the file if different from the url
  7781. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7782. * @return the prefiltered texture
  7783. */
  7784. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7785. /**
  7786. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7787. * as prefiltered data.
  7788. * @param rootUrl defines the url of the texture or the root name of the six images
  7789. * @param scene defines the scene the texture is attached to
  7790. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7791. * @param noMipmap defines if mipmaps should be created or not
  7792. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7793. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7794. * @param onError defines a callback triggered in case of error during load
  7795. * @param format defines the internal format to use for the texture once loaded
  7796. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7797. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7798. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7799. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7800. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7801. * @return the cube texture
  7802. */
  7803. 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);
  7804. /**
  7805. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7806. */
  7807. get isPrefiltered(): boolean;
  7808. /**
  7809. * Get the current class name of the texture useful for serialization or dynamic coding.
  7810. * @returns "CubeTexture"
  7811. */
  7812. getClassName(): string;
  7813. /**
  7814. * Update the url (and optional buffer) of this texture if url was null during construction.
  7815. * @param url the url of the texture
  7816. * @param forcedExtension defines the extension to use
  7817. * @param onLoad callback called when the texture is loaded (defaults to null)
  7818. */
  7819. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7820. /**
  7821. * Delays loading of the cube texture
  7822. * @param forcedExtension defines the extension to use
  7823. */
  7824. delayLoad(forcedExtension?: string): void;
  7825. /**
  7826. * Returns the reflection texture matrix
  7827. * @returns the reflection texture matrix
  7828. */
  7829. getReflectionTextureMatrix(): Matrix;
  7830. /**
  7831. * Sets the reflection texture matrix
  7832. * @param value Reflection texture matrix
  7833. */
  7834. setReflectionTextureMatrix(value: Matrix): void;
  7835. /**
  7836. * Parses text to create a cube texture
  7837. * @param parsedTexture define the serialized text to read from
  7838. * @param scene defines the hosting scene
  7839. * @param rootUrl defines the root url of the cube texture
  7840. * @returns a cube texture
  7841. */
  7842. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7843. /**
  7844. * Makes a clone, or deep copy, of the cube texture
  7845. * @returns a new cube texture
  7846. */
  7847. clone(): CubeTexture;
  7848. }
  7849. }
  7850. declare module "babylonjs/Materials/materialDefines" {
  7851. /**
  7852. * Manages the defines for the Material
  7853. */
  7854. export class MaterialDefines {
  7855. /** @hidden */
  7856. protected _keys: string[];
  7857. private _isDirty;
  7858. /** @hidden */
  7859. _renderId: number;
  7860. /** @hidden */
  7861. _areLightsDirty: boolean;
  7862. /** @hidden */
  7863. _areLightsDisposed: boolean;
  7864. /** @hidden */
  7865. _areAttributesDirty: boolean;
  7866. /** @hidden */
  7867. _areTexturesDirty: boolean;
  7868. /** @hidden */
  7869. _areFresnelDirty: boolean;
  7870. /** @hidden */
  7871. _areMiscDirty: boolean;
  7872. /** @hidden */
  7873. _areImageProcessingDirty: boolean;
  7874. /** @hidden */
  7875. _normals: boolean;
  7876. /** @hidden */
  7877. _uvs: boolean;
  7878. /** @hidden */
  7879. _needNormals: boolean;
  7880. /** @hidden */
  7881. _needUVs: boolean;
  7882. [id: string]: any;
  7883. /**
  7884. * Specifies if the material needs to be re-calculated
  7885. */
  7886. get isDirty(): boolean;
  7887. /**
  7888. * Marks the material to indicate that it has been re-calculated
  7889. */
  7890. markAsProcessed(): void;
  7891. /**
  7892. * Marks the material to indicate that it needs to be re-calculated
  7893. */
  7894. markAsUnprocessed(): void;
  7895. /**
  7896. * Marks the material to indicate all of its defines need to be re-calculated
  7897. */
  7898. markAllAsDirty(): void;
  7899. /**
  7900. * Marks the material to indicate that image processing needs to be re-calculated
  7901. */
  7902. markAsImageProcessingDirty(): void;
  7903. /**
  7904. * Marks the material to indicate the lights need to be re-calculated
  7905. * @param disposed Defines whether the light is dirty due to dispose or not
  7906. */
  7907. markAsLightDirty(disposed?: boolean): void;
  7908. /**
  7909. * Marks the attribute state as changed
  7910. */
  7911. markAsAttributesDirty(): void;
  7912. /**
  7913. * Marks the texture state as changed
  7914. */
  7915. markAsTexturesDirty(): void;
  7916. /**
  7917. * Marks the fresnel state as changed
  7918. */
  7919. markAsFresnelDirty(): void;
  7920. /**
  7921. * Marks the misc state as changed
  7922. */
  7923. markAsMiscDirty(): void;
  7924. /**
  7925. * Rebuilds the material defines
  7926. */
  7927. rebuild(): void;
  7928. /**
  7929. * Specifies if two material defines are equal
  7930. * @param other - A material define instance to compare to
  7931. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7932. */
  7933. isEqual(other: MaterialDefines): boolean;
  7934. /**
  7935. * Clones this instance's defines to another instance
  7936. * @param other - material defines to clone values to
  7937. */
  7938. cloneTo(other: MaterialDefines): void;
  7939. /**
  7940. * Resets the material define values
  7941. */
  7942. reset(): void;
  7943. /**
  7944. * Converts the material define values to a string
  7945. * @returns - String of material define information
  7946. */
  7947. toString(): string;
  7948. }
  7949. }
  7950. declare module "babylonjs/Materials/colorCurves" {
  7951. import { Effect } from "babylonjs/Materials/effect";
  7952. /**
  7953. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7954. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7955. * 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;
  7956. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7957. */
  7958. export class ColorCurves {
  7959. private _dirty;
  7960. private _tempColor;
  7961. private _globalCurve;
  7962. private _highlightsCurve;
  7963. private _midtonesCurve;
  7964. private _shadowsCurve;
  7965. private _positiveCurve;
  7966. private _negativeCurve;
  7967. private _globalHue;
  7968. private _globalDensity;
  7969. private _globalSaturation;
  7970. private _globalExposure;
  7971. /**
  7972. * Gets the global Hue value.
  7973. * 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).
  7974. */
  7975. get globalHue(): number;
  7976. /**
  7977. * Sets the global Hue value.
  7978. * 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).
  7979. */
  7980. set globalHue(value: number);
  7981. /**
  7982. * Gets the global Density value.
  7983. * 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.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. get globalDensity(): number;
  7987. /**
  7988. * Sets the global Density value.
  7989. * 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.
  7990. * Values less than zero provide a filter of opposite hue.
  7991. */
  7992. set globalDensity(value: number);
  7993. /**
  7994. * Gets the global Saturation value.
  7995. * 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.
  7996. */
  7997. get globalSaturation(): number;
  7998. /**
  7999. * Sets the global Saturation value.
  8000. * 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.
  8001. */
  8002. set globalSaturation(value: number);
  8003. /**
  8004. * Gets the global Exposure value.
  8005. * 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.
  8006. */
  8007. get globalExposure(): number;
  8008. /**
  8009. * Sets the global Exposure value.
  8010. * 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.
  8011. */
  8012. set globalExposure(value: number);
  8013. private _highlightsHue;
  8014. private _highlightsDensity;
  8015. private _highlightsSaturation;
  8016. private _highlightsExposure;
  8017. /**
  8018. * Gets the highlights Hue value.
  8019. * 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).
  8020. */
  8021. get highlightsHue(): number;
  8022. /**
  8023. * Sets the highlights Hue value.
  8024. * 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).
  8025. */
  8026. set highlightsHue(value: number);
  8027. /**
  8028. * Gets the highlights Density value.
  8029. * 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.
  8030. * Values less than zero provide a filter of opposite hue.
  8031. */
  8032. get highlightsDensity(): number;
  8033. /**
  8034. * Sets the highlights Density value.
  8035. * 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.
  8036. * Values less than zero provide a filter of opposite hue.
  8037. */
  8038. set highlightsDensity(value: number);
  8039. /**
  8040. * Gets the highlights Saturation value.
  8041. * 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.
  8042. */
  8043. get highlightsSaturation(): number;
  8044. /**
  8045. * Sets the highlights Saturation value.
  8046. * 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.
  8047. */
  8048. set highlightsSaturation(value: number);
  8049. /**
  8050. * Gets the highlights Exposure value.
  8051. * 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.
  8052. */
  8053. get highlightsExposure(): number;
  8054. /**
  8055. * Sets the highlights Exposure value.
  8056. * 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.
  8057. */
  8058. set highlightsExposure(value: number);
  8059. private _midtonesHue;
  8060. private _midtonesDensity;
  8061. private _midtonesSaturation;
  8062. private _midtonesExposure;
  8063. /**
  8064. * Gets the midtones Hue value.
  8065. * 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).
  8066. */
  8067. get midtonesHue(): number;
  8068. /**
  8069. * Sets the midtones Hue value.
  8070. * 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).
  8071. */
  8072. set midtonesHue(value: number);
  8073. /**
  8074. * Gets the midtones Density value.
  8075. * 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.
  8076. * Values less than zero provide a filter of opposite hue.
  8077. */
  8078. get midtonesDensity(): number;
  8079. /**
  8080. * Sets the midtones Density value.
  8081. * 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.
  8082. * Values less than zero provide a filter of opposite hue.
  8083. */
  8084. set midtonesDensity(value: number);
  8085. /**
  8086. * Gets the midtones Saturation value.
  8087. * 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.
  8088. */
  8089. get midtonesSaturation(): number;
  8090. /**
  8091. * Sets the midtones Saturation value.
  8092. * 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.
  8093. */
  8094. set midtonesSaturation(value: number);
  8095. /**
  8096. * Gets the midtones Exposure value.
  8097. * 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.
  8098. */
  8099. get midtonesExposure(): number;
  8100. /**
  8101. * Sets the midtones Exposure value.
  8102. * 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.
  8103. */
  8104. set midtonesExposure(value: number);
  8105. private _shadowsHue;
  8106. private _shadowsDensity;
  8107. private _shadowsSaturation;
  8108. private _shadowsExposure;
  8109. /**
  8110. * Gets the shadows Hue value.
  8111. * 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).
  8112. */
  8113. get shadowsHue(): number;
  8114. /**
  8115. * Sets the shadows Hue value.
  8116. * 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).
  8117. */
  8118. set shadowsHue(value: number);
  8119. /**
  8120. * Gets the shadows Density value.
  8121. * 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.
  8122. * Values less than zero provide a filter of opposite hue.
  8123. */
  8124. get shadowsDensity(): number;
  8125. /**
  8126. * Sets the shadows Density value.
  8127. * 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.
  8128. * Values less than zero provide a filter of opposite hue.
  8129. */
  8130. set shadowsDensity(value: number);
  8131. /**
  8132. * Gets the shadows Saturation value.
  8133. * 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.
  8134. */
  8135. get shadowsSaturation(): number;
  8136. /**
  8137. * Sets the shadows Saturation value.
  8138. * 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.
  8139. */
  8140. set shadowsSaturation(value: number);
  8141. /**
  8142. * Gets the shadows Exposure value.
  8143. * 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.
  8144. */
  8145. get shadowsExposure(): number;
  8146. /**
  8147. * Sets the shadows Exposure value.
  8148. * 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.
  8149. */
  8150. set shadowsExposure(value: number);
  8151. /**
  8152. * Returns the class name
  8153. * @returns The class name
  8154. */
  8155. getClassName(): string;
  8156. /**
  8157. * Binds the color curves to the shader.
  8158. * @param colorCurves The color curve to bind
  8159. * @param effect The effect to bind to
  8160. * @param positiveUniform The positive uniform shader parameter
  8161. * @param neutralUniform The neutral uniform shader parameter
  8162. * @param negativeUniform The negative uniform shader parameter
  8163. */
  8164. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8165. /**
  8166. * Prepare the list of uniforms associated with the ColorCurves effects.
  8167. * @param uniformsList The list of uniforms used in the effect
  8168. */
  8169. static PrepareUniforms(uniformsList: string[]): void;
  8170. /**
  8171. * Returns color grading data based on a hue, density, saturation and exposure value.
  8172. * @param filterHue The hue of the color filter.
  8173. * @param filterDensity The density of the color filter.
  8174. * @param saturation The saturation.
  8175. * @param exposure The exposure.
  8176. * @param result The result data container.
  8177. */
  8178. private getColorGradingDataToRef;
  8179. /**
  8180. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8181. * @param value The input slider value in range [-100,100].
  8182. * @returns Adjusted value.
  8183. */
  8184. private static applyColorGradingSliderNonlinear;
  8185. /**
  8186. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8187. * @param hue The hue (H) input.
  8188. * @param saturation The saturation (S) input.
  8189. * @param brightness The brightness (B) input.
  8190. * @result An RGBA color represented as Vector4.
  8191. */
  8192. private static fromHSBToRef;
  8193. /**
  8194. * Returns a value clamped between min and max
  8195. * @param value The value to clamp
  8196. * @param min The minimum of value
  8197. * @param max The maximum of value
  8198. * @returns The clamped value.
  8199. */
  8200. private static clamp;
  8201. /**
  8202. * Clones the current color curve instance.
  8203. * @return The cloned curves
  8204. */
  8205. clone(): ColorCurves;
  8206. /**
  8207. * Serializes the current color curve instance to a json representation.
  8208. * @return a JSON representation
  8209. */
  8210. serialize(): any;
  8211. /**
  8212. * Parses the color curve from a json representation.
  8213. * @param source the JSON source to parse
  8214. * @return The parsed curves
  8215. */
  8216. static Parse(source: any): ColorCurves;
  8217. }
  8218. }
  8219. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8220. import { Observable } from "babylonjs/Misc/observable";
  8221. import { Nullable } from "babylonjs/types";
  8222. import { Color4 } from "babylonjs/Maths/math.color";
  8223. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8224. import { Effect } from "babylonjs/Materials/effect";
  8225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8226. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8227. /**
  8228. * Interface to follow in your material defines to integrate easily the
  8229. * Image proccessing functions.
  8230. * @hidden
  8231. */
  8232. export interface IImageProcessingConfigurationDefines {
  8233. IMAGEPROCESSING: boolean;
  8234. VIGNETTE: boolean;
  8235. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8236. VIGNETTEBLENDMODEOPAQUE: boolean;
  8237. TONEMAPPING: boolean;
  8238. TONEMAPPING_ACES: boolean;
  8239. CONTRAST: boolean;
  8240. EXPOSURE: boolean;
  8241. COLORCURVES: boolean;
  8242. COLORGRADING: boolean;
  8243. COLORGRADING3D: boolean;
  8244. SAMPLER3DGREENDEPTH: boolean;
  8245. SAMPLER3DBGRMAP: boolean;
  8246. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8247. }
  8248. /**
  8249. * @hidden
  8250. */
  8251. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8252. IMAGEPROCESSING: boolean;
  8253. VIGNETTE: boolean;
  8254. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8255. VIGNETTEBLENDMODEOPAQUE: boolean;
  8256. TONEMAPPING: boolean;
  8257. TONEMAPPING_ACES: boolean;
  8258. CONTRAST: boolean;
  8259. COLORCURVES: boolean;
  8260. COLORGRADING: boolean;
  8261. COLORGRADING3D: boolean;
  8262. SAMPLER3DGREENDEPTH: boolean;
  8263. SAMPLER3DBGRMAP: boolean;
  8264. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8265. EXPOSURE: boolean;
  8266. constructor();
  8267. }
  8268. /**
  8269. * This groups together the common properties used for image processing either in direct forward pass
  8270. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8271. * or not.
  8272. */
  8273. export class ImageProcessingConfiguration {
  8274. /**
  8275. * Default tone mapping applied in BabylonJS.
  8276. */
  8277. static readonly TONEMAPPING_STANDARD: number;
  8278. /**
  8279. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8280. * to other engines rendering to increase portability.
  8281. */
  8282. static readonly TONEMAPPING_ACES: number;
  8283. /**
  8284. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8285. */
  8286. colorCurves: Nullable<ColorCurves>;
  8287. private _colorCurvesEnabled;
  8288. /**
  8289. * Gets wether the color curves effect is enabled.
  8290. */
  8291. get colorCurvesEnabled(): boolean;
  8292. /**
  8293. * Sets wether the color curves effect is enabled.
  8294. */
  8295. set colorCurvesEnabled(value: boolean);
  8296. private _colorGradingTexture;
  8297. /**
  8298. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8299. */
  8300. get colorGradingTexture(): Nullable<BaseTexture>;
  8301. /**
  8302. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8303. */
  8304. set colorGradingTexture(value: Nullable<BaseTexture>);
  8305. private _colorGradingEnabled;
  8306. /**
  8307. * Gets wether the color grading effect is enabled.
  8308. */
  8309. get colorGradingEnabled(): boolean;
  8310. /**
  8311. * Sets wether the color grading effect is enabled.
  8312. */
  8313. set colorGradingEnabled(value: boolean);
  8314. private _colorGradingWithGreenDepth;
  8315. /**
  8316. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8317. */
  8318. get colorGradingWithGreenDepth(): boolean;
  8319. /**
  8320. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8321. */
  8322. set colorGradingWithGreenDepth(value: boolean);
  8323. private _colorGradingBGR;
  8324. /**
  8325. * Gets wether the color grading texture contains BGR values.
  8326. */
  8327. get colorGradingBGR(): boolean;
  8328. /**
  8329. * Sets wether the color grading texture contains BGR values.
  8330. */
  8331. set colorGradingBGR(value: boolean);
  8332. /** @hidden */
  8333. _exposure: number;
  8334. /**
  8335. * Gets the Exposure used in the effect.
  8336. */
  8337. get exposure(): number;
  8338. /**
  8339. * Sets the Exposure used in the effect.
  8340. */
  8341. set exposure(value: number);
  8342. private _toneMappingEnabled;
  8343. /**
  8344. * Gets wether the tone mapping effect is enabled.
  8345. */
  8346. get toneMappingEnabled(): boolean;
  8347. /**
  8348. * Sets wether the tone mapping effect is enabled.
  8349. */
  8350. set toneMappingEnabled(value: boolean);
  8351. private _toneMappingType;
  8352. /**
  8353. * Gets the type of tone mapping effect.
  8354. */
  8355. get toneMappingType(): number;
  8356. /**
  8357. * Sets the type of tone mapping effect used in BabylonJS.
  8358. */
  8359. set toneMappingType(value: number);
  8360. protected _contrast: number;
  8361. /**
  8362. * Gets the contrast used in the effect.
  8363. */
  8364. get contrast(): number;
  8365. /**
  8366. * Sets the contrast used in the effect.
  8367. */
  8368. set contrast(value: number);
  8369. /**
  8370. * Vignette stretch size.
  8371. */
  8372. vignetteStretch: number;
  8373. /**
  8374. * Vignette centre X Offset.
  8375. */
  8376. vignetteCentreX: number;
  8377. /**
  8378. * Vignette centre Y Offset.
  8379. */
  8380. vignetteCentreY: number;
  8381. /**
  8382. * Vignette weight or intensity of the vignette effect.
  8383. */
  8384. vignetteWeight: number;
  8385. /**
  8386. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8387. * if vignetteEnabled is set to true.
  8388. */
  8389. vignetteColor: Color4;
  8390. /**
  8391. * Camera field of view used by the Vignette effect.
  8392. */
  8393. vignetteCameraFov: number;
  8394. private _vignetteBlendMode;
  8395. /**
  8396. * Gets the vignette blend mode allowing different kind of effect.
  8397. */
  8398. get vignetteBlendMode(): number;
  8399. /**
  8400. * Sets the vignette blend mode allowing different kind of effect.
  8401. */
  8402. set vignetteBlendMode(value: number);
  8403. private _vignetteEnabled;
  8404. /**
  8405. * Gets wether the vignette effect is enabled.
  8406. */
  8407. get vignetteEnabled(): boolean;
  8408. /**
  8409. * Sets wether the vignette effect is enabled.
  8410. */
  8411. set vignetteEnabled(value: boolean);
  8412. private _applyByPostProcess;
  8413. /**
  8414. * Gets wether the image processing is applied through a post process or not.
  8415. */
  8416. get applyByPostProcess(): boolean;
  8417. /**
  8418. * Sets wether the image processing is applied through a post process or not.
  8419. */
  8420. set applyByPostProcess(value: boolean);
  8421. private _isEnabled;
  8422. /**
  8423. * Gets wether the image processing is enabled or not.
  8424. */
  8425. get isEnabled(): boolean;
  8426. /**
  8427. * Sets wether the image processing is enabled or not.
  8428. */
  8429. set isEnabled(value: boolean);
  8430. /**
  8431. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8432. */
  8433. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8434. /**
  8435. * Method called each time the image processing information changes requires to recompile the effect.
  8436. */
  8437. protected _updateParameters(): void;
  8438. /**
  8439. * Gets the current class name.
  8440. * @return "ImageProcessingConfiguration"
  8441. */
  8442. getClassName(): string;
  8443. /**
  8444. * Prepare the list of uniforms associated with the Image Processing effects.
  8445. * @param uniforms The list of uniforms used in the effect
  8446. * @param defines the list of defines currently in use
  8447. */
  8448. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8449. /**
  8450. * Prepare the list of samplers associated with the Image Processing effects.
  8451. * @param samplersList The list of uniforms used in the effect
  8452. * @param defines the list of defines currently in use
  8453. */
  8454. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8455. /**
  8456. * Prepare the list of defines associated to the shader.
  8457. * @param defines the list of defines to complete
  8458. * @param forPostProcess Define if we are currently in post process mode or not
  8459. */
  8460. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8461. /**
  8462. * Returns true if all the image processing information are ready.
  8463. * @returns True if ready, otherwise, false
  8464. */
  8465. isReady(): boolean;
  8466. /**
  8467. * Binds the image processing to the shader.
  8468. * @param effect The effect to bind to
  8469. * @param overrideAspectRatio Override the aspect ratio of the effect
  8470. */
  8471. bind(effect: Effect, overrideAspectRatio?: number): void;
  8472. /**
  8473. * Clones the current image processing instance.
  8474. * @return The cloned image processing
  8475. */
  8476. clone(): ImageProcessingConfiguration;
  8477. /**
  8478. * Serializes the current image processing instance to a json representation.
  8479. * @return a JSON representation
  8480. */
  8481. serialize(): any;
  8482. /**
  8483. * Parses the image processing from a json representation.
  8484. * @param source the JSON source to parse
  8485. * @return The parsed image processing
  8486. */
  8487. static Parse(source: any): ImageProcessingConfiguration;
  8488. private static _VIGNETTEMODE_MULTIPLY;
  8489. private static _VIGNETTEMODE_OPAQUE;
  8490. /**
  8491. * Used to apply the vignette as a mix with the pixel color.
  8492. */
  8493. static get VIGNETTEMODE_MULTIPLY(): number;
  8494. /**
  8495. * Used to apply the vignette as a replacement of the pixel color.
  8496. */
  8497. static get VIGNETTEMODE_OPAQUE(): number;
  8498. }
  8499. }
  8500. declare module "babylonjs/Shaders/postprocess.vertex" {
  8501. /** @hidden */
  8502. export var postprocessVertexShader: {
  8503. name: string;
  8504. shader: string;
  8505. };
  8506. }
  8507. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8508. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8509. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8510. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8511. module "babylonjs/Engines/thinEngine" {
  8512. interface ThinEngine {
  8513. /**
  8514. * Creates a new render target texture
  8515. * @param size defines the size of the texture
  8516. * @param options defines the options used to create the texture
  8517. * @returns a new render target texture stored in an InternalTexture
  8518. */
  8519. createRenderTargetTexture(size: number | {
  8520. width: number;
  8521. height: number;
  8522. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8523. /**
  8524. * Creates a depth stencil texture.
  8525. * This is only available in WebGL 2 or with the depth texture extension available.
  8526. * @param size The size of face edge in the texture.
  8527. * @param options The options defining the texture.
  8528. * @returns The texture
  8529. */
  8530. createDepthStencilTexture(size: number | {
  8531. width: number;
  8532. height: number;
  8533. }, options: DepthTextureCreationOptions): InternalTexture;
  8534. /** @hidden */
  8535. _createDepthStencilTexture(size: number | {
  8536. width: number;
  8537. height: number;
  8538. }, options: DepthTextureCreationOptions): InternalTexture;
  8539. }
  8540. }
  8541. }
  8542. declare module "babylonjs/Maths/math.axis" {
  8543. import { Vector3 } from "babylonjs/Maths/math.vector";
  8544. /** Defines supported spaces */
  8545. export enum Space {
  8546. /** Local (object) space */
  8547. LOCAL = 0,
  8548. /** World space */
  8549. WORLD = 1,
  8550. /** Bone space */
  8551. BONE = 2
  8552. }
  8553. /** Defines the 3 main axes */
  8554. export class Axis {
  8555. /** X axis */
  8556. static X: Vector3;
  8557. /** Y axis */
  8558. static Y: Vector3;
  8559. /** Z axis */
  8560. static Z: Vector3;
  8561. }
  8562. }
  8563. declare module "babylonjs/Cameras/targetCamera" {
  8564. import { Nullable } from "babylonjs/types";
  8565. import { Camera } from "babylonjs/Cameras/camera";
  8566. import { Scene } from "babylonjs/scene";
  8567. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8568. /**
  8569. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8570. * This is the base of the follow, arc rotate cameras and Free camera
  8571. * @see http://doc.babylonjs.com/features/cameras
  8572. */
  8573. export class TargetCamera extends Camera {
  8574. private static _RigCamTransformMatrix;
  8575. private static _TargetTransformMatrix;
  8576. private static _TargetFocalPoint;
  8577. /**
  8578. * Define the current direction the camera is moving to
  8579. */
  8580. cameraDirection: Vector3;
  8581. /**
  8582. * Define the current rotation the camera is rotating to
  8583. */
  8584. cameraRotation: Vector2;
  8585. /**
  8586. * When set, the up vector of the camera will be updated by the rotation of the camera
  8587. */
  8588. updateUpVectorFromRotation: boolean;
  8589. private _tmpQuaternion;
  8590. /**
  8591. * Define the current rotation of the camera
  8592. */
  8593. rotation: Vector3;
  8594. /**
  8595. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8596. */
  8597. rotationQuaternion: Quaternion;
  8598. /**
  8599. * Define the current speed of the camera
  8600. */
  8601. speed: number;
  8602. /**
  8603. * Add constraint to the camera to prevent it to move freely in all directions and
  8604. * around all axis.
  8605. */
  8606. noRotationConstraint: boolean;
  8607. /**
  8608. * Define the current target of the camera as an object or a position.
  8609. */
  8610. lockedTarget: any;
  8611. /** @hidden */
  8612. _currentTarget: Vector3;
  8613. /** @hidden */
  8614. _initialFocalDistance: number;
  8615. /** @hidden */
  8616. _viewMatrix: Matrix;
  8617. /** @hidden */
  8618. _camMatrix: Matrix;
  8619. /** @hidden */
  8620. _cameraTransformMatrix: Matrix;
  8621. /** @hidden */
  8622. _cameraRotationMatrix: Matrix;
  8623. /** @hidden */
  8624. _referencePoint: Vector3;
  8625. /** @hidden */
  8626. _transformedReferencePoint: Vector3;
  8627. protected _globalCurrentTarget: Vector3;
  8628. protected _globalCurrentUpVector: Vector3;
  8629. /** @hidden */
  8630. _reset: () => void;
  8631. private _defaultUp;
  8632. /**
  8633. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8634. * This is the base of the follow, arc rotate cameras and Free camera
  8635. * @see http://doc.babylonjs.com/features/cameras
  8636. * @param name Defines the name of the camera in the scene
  8637. * @param position Defines the start position of the camera in the scene
  8638. * @param scene Defines the scene the camera belongs to
  8639. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8640. */
  8641. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8642. /**
  8643. * Gets the position in front of the camera at a given distance.
  8644. * @param distance The distance from the camera we want the position to be
  8645. * @returns the position
  8646. */
  8647. getFrontPosition(distance: number): Vector3;
  8648. /** @hidden */
  8649. _getLockedTargetPosition(): Nullable<Vector3>;
  8650. private _storedPosition;
  8651. private _storedRotation;
  8652. private _storedRotationQuaternion;
  8653. /**
  8654. * Store current camera state of the camera (fov, position, rotation, etc..)
  8655. * @returns the camera
  8656. */
  8657. storeState(): Camera;
  8658. /**
  8659. * Restored camera state. You must call storeState() first
  8660. * @returns whether it was successful or not
  8661. * @hidden
  8662. */
  8663. _restoreStateValues(): boolean;
  8664. /** @hidden */
  8665. _initCache(): void;
  8666. /** @hidden */
  8667. _updateCache(ignoreParentClass?: boolean): void;
  8668. /** @hidden */
  8669. _isSynchronizedViewMatrix(): boolean;
  8670. /** @hidden */
  8671. _computeLocalCameraSpeed(): number;
  8672. /**
  8673. * Defines the target the camera should look at.
  8674. * @param target Defines the new target as a Vector or a mesh
  8675. */
  8676. setTarget(target: Vector3): void;
  8677. /**
  8678. * Return the current target position of the camera. This value is expressed in local space.
  8679. * @returns the target position
  8680. */
  8681. getTarget(): Vector3;
  8682. /** @hidden */
  8683. _decideIfNeedsToMove(): boolean;
  8684. /** @hidden */
  8685. _updatePosition(): void;
  8686. /** @hidden */
  8687. _checkInputs(): void;
  8688. protected _updateCameraRotationMatrix(): void;
  8689. /**
  8690. * 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)
  8691. * @returns the current camera
  8692. */
  8693. private _rotateUpVectorWithCameraRotationMatrix;
  8694. private _cachedRotationZ;
  8695. private _cachedQuaternionRotationZ;
  8696. /** @hidden */
  8697. _getViewMatrix(): Matrix;
  8698. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8699. /**
  8700. * @hidden
  8701. */
  8702. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8703. /**
  8704. * @hidden
  8705. */
  8706. _updateRigCameras(): void;
  8707. private _getRigCamPositionAndTarget;
  8708. /**
  8709. * Gets the current object class name.
  8710. * @return the class name
  8711. */
  8712. getClassName(): string;
  8713. }
  8714. }
  8715. declare module "babylonjs/Events/keyboardEvents" {
  8716. /**
  8717. * Gather the list of keyboard event types as constants.
  8718. */
  8719. export class KeyboardEventTypes {
  8720. /**
  8721. * The keydown event is fired when a key becomes active (pressed).
  8722. */
  8723. static readonly KEYDOWN: number;
  8724. /**
  8725. * The keyup event is fired when a key has been released.
  8726. */
  8727. static readonly KEYUP: number;
  8728. }
  8729. /**
  8730. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8731. */
  8732. export class KeyboardInfo {
  8733. /**
  8734. * Defines the type of event (KeyboardEventTypes)
  8735. */
  8736. type: number;
  8737. /**
  8738. * Defines the related dom event
  8739. */
  8740. event: KeyboardEvent;
  8741. /**
  8742. * Instantiates a new keyboard info.
  8743. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8744. * @param type Defines the type of event (KeyboardEventTypes)
  8745. * @param event Defines the related dom event
  8746. */
  8747. constructor(
  8748. /**
  8749. * Defines the type of event (KeyboardEventTypes)
  8750. */
  8751. type: number,
  8752. /**
  8753. * Defines the related dom event
  8754. */
  8755. event: KeyboardEvent);
  8756. }
  8757. /**
  8758. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8759. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8760. */
  8761. export class KeyboardInfoPre extends KeyboardInfo {
  8762. /**
  8763. * Defines the type of event (KeyboardEventTypes)
  8764. */
  8765. type: number;
  8766. /**
  8767. * Defines the related dom event
  8768. */
  8769. event: KeyboardEvent;
  8770. /**
  8771. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8772. */
  8773. skipOnPointerObservable: boolean;
  8774. /**
  8775. * Instantiates a new keyboard pre info.
  8776. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8777. * @param type Defines the type of event (KeyboardEventTypes)
  8778. * @param event Defines the related dom event
  8779. */
  8780. constructor(
  8781. /**
  8782. * Defines the type of event (KeyboardEventTypes)
  8783. */
  8784. type: number,
  8785. /**
  8786. * Defines the related dom event
  8787. */
  8788. event: KeyboardEvent);
  8789. }
  8790. }
  8791. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8792. import { Nullable } from "babylonjs/types";
  8793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8794. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8795. /**
  8796. * Manage the keyboard inputs to control the movement of a free camera.
  8797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8798. */
  8799. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8800. /**
  8801. * Defines the camera the input is attached to.
  8802. */
  8803. camera: FreeCamera;
  8804. /**
  8805. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8806. */
  8807. keysUp: number[];
  8808. /**
  8809. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8810. */
  8811. keysDown: number[];
  8812. /**
  8813. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8814. */
  8815. keysLeft: number[];
  8816. /**
  8817. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8818. */
  8819. keysRight: number[];
  8820. private _keys;
  8821. private _onCanvasBlurObserver;
  8822. private _onKeyboardObserver;
  8823. private _engine;
  8824. private _scene;
  8825. /**
  8826. * Attach the input controls to a specific dom element to get the input from.
  8827. * @param element Defines the element the controls should be listened from
  8828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8829. */
  8830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8831. /**
  8832. * Detach the current controls from the specified dom element.
  8833. * @param element Defines the element to stop listening the inputs from
  8834. */
  8835. detachControl(element: Nullable<HTMLElement>): void;
  8836. /**
  8837. * Update the current camera state depending on the inputs that have been used this frame.
  8838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8839. */
  8840. checkInputs(): void;
  8841. /**
  8842. * Gets the class name of the current intput.
  8843. * @returns the class name
  8844. */
  8845. getClassName(): string;
  8846. /** @hidden */
  8847. _onLostFocus(): void;
  8848. /**
  8849. * Get the friendly name associated with the input class.
  8850. * @returns the input friendly name
  8851. */
  8852. getSimpleName(): string;
  8853. }
  8854. }
  8855. declare module "babylonjs/Lights/shadowLight" {
  8856. import { Camera } from "babylonjs/Cameras/camera";
  8857. import { Scene } from "babylonjs/scene";
  8858. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8860. import { Light } from "babylonjs/Lights/light";
  8861. /**
  8862. * Interface describing all the common properties and methods a shadow light needs to implement.
  8863. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8864. * as well as binding the different shadow properties to the effects.
  8865. */
  8866. export interface IShadowLight extends Light {
  8867. /**
  8868. * The light id in the scene (used in scene.findLighById for instance)
  8869. */
  8870. id: string;
  8871. /**
  8872. * The position the shdow will be casted from.
  8873. */
  8874. position: Vector3;
  8875. /**
  8876. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8877. */
  8878. direction: Vector3;
  8879. /**
  8880. * The transformed position. Position of the light in world space taking parenting in account.
  8881. */
  8882. transformedPosition: Vector3;
  8883. /**
  8884. * The transformed direction. Direction of the light in world space taking parenting in account.
  8885. */
  8886. transformedDirection: Vector3;
  8887. /**
  8888. * The friendly name of the light in the scene.
  8889. */
  8890. name: string;
  8891. /**
  8892. * Defines the shadow projection clipping minimum z value.
  8893. */
  8894. shadowMinZ: number;
  8895. /**
  8896. * Defines the shadow projection clipping maximum z value.
  8897. */
  8898. shadowMaxZ: number;
  8899. /**
  8900. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8901. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8902. */
  8903. computeTransformedInformation(): boolean;
  8904. /**
  8905. * Gets the scene the light belongs to.
  8906. * @returns The scene
  8907. */
  8908. getScene(): Scene;
  8909. /**
  8910. * Callback defining a custom Projection Matrix Builder.
  8911. * This can be used to override the default projection matrix computation.
  8912. */
  8913. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8914. /**
  8915. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8916. * @param matrix The materix to updated with the projection information
  8917. * @param viewMatrix The transform matrix of the light
  8918. * @param renderList The list of mesh to render in the map
  8919. * @returns The current light
  8920. */
  8921. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8922. /**
  8923. * Gets the current depth scale used in ESM.
  8924. * @returns The scale
  8925. */
  8926. getDepthScale(): number;
  8927. /**
  8928. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8929. * @returns true if a cube texture needs to be use
  8930. */
  8931. needCube(): boolean;
  8932. /**
  8933. * Detects if the projection matrix requires to be recomputed this frame.
  8934. * @returns true if it requires to be recomputed otherwise, false.
  8935. */
  8936. needProjectionMatrixCompute(): boolean;
  8937. /**
  8938. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8939. */
  8940. forceProjectionMatrixCompute(): void;
  8941. /**
  8942. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8943. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8944. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8945. */
  8946. getShadowDirection(faceIndex?: number): Vector3;
  8947. /**
  8948. * Gets the minZ used for shadow according to both the scene and the light.
  8949. * @param activeCamera The camera we are returning the min for
  8950. * @returns the depth min z
  8951. */
  8952. getDepthMinZ(activeCamera: Camera): number;
  8953. /**
  8954. * Gets the maxZ used for shadow according to both the scene and the light.
  8955. * @param activeCamera The camera we are returning the max for
  8956. * @returns the depth max z
  8957. */
  8958. getDepthMaxZ(activeCamera: Camera): number;
  8959. }
  8960. /**
  8961. * Base implementation IShadowLight
  8962. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8963. */
  8964. export abstract class ShadowLight extends Light implements IShadowLight {
  8965. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8966. protected _position: Vector3;
  8967. protected _setPosition(value: Vector3): void;
  8968. /**
  8969. * Sets the position the shadow will be casted from. Also use as the light position for both
  8970. * point and spot lights.
  8971. */
  8972. get position(): Vector3;
  8973. /**
  8974. * Sets the position the shadow will be casted from. Also use as the light position for both
  8975. * point and spot lights.
  8976. */
  8977. set position(value: Vector3);
  8978. protected _direction: Vector3;
  8979. protected _setDirection(value: Vector3): void;
  8980. /**
  8981. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8982. * Also use as the light direction on spot and directional lights.
  8983. */
  8984. get direction(): Vector3;
  8985. /**
  8986. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8987. * Also use as the light direction on spot and directional lights.
  8988. */
  8989. set direction(value: Vector3);
  8990. private _shadowMinZ;
  8991. /**
  8992. * Gets the shadow projection clipping minimum z value.
  8993. */
  8994. get shadowMinZ(): number;
  8995. /**
  8996. * Sets the shadow projection clipping minimum z value.
  8997. */
  8998. set shadowMinZ(value: number);
  8999. private _shadowMaxZ;
  9000. /**
  9001. * Sets the shadow projection clipping maximum z value.
  9002. */
  9003. get shadowMaxZ(): number;
  9004. /**
  9005. * Gets the shadow projection clipping maximum z value.
  9006. */
  9007. set shadowMaxZ(value: number);
  9008. /**
  9009. * Callback defining a custom Projection Matrix Builder.
  9010. * This can be used to override the default projection matrix computation.
  9011. */
  9012. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9013. /**
  9014. * The transformed position. Position of the light in world space taking parenting in account.
  9015. */
  9016. transformedPosition: Vector3;
  9017. /**
  9018. * The transformed direction. Direction of the light in world space taking parenting in account.
  9019. */
  9020. transformedDirection: Vector3;
  9021. private _needProjectionMatrixCompute;
  9022. /**
  9023. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9024. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9025. */
  9026. computeTransformedInformation(): boolean;
  9027. /**
  9028. * Return the depth scale used for the shadow map.
  9029. * @returns the depth scale.
  9030. */
  9031. getDepthScale(): number;
  9032. /**
  9033. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9034. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9035. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9036. */
  9037. getShadowDirection(faceIndex?: number): Vector3;
  9038. /**
  9039. * Returns the ShadowLight absolute position in the World.
  9040. * @returns the position vector in world space
  9041. */
  9042. getAbsolutePosition(): Vector3;
  9043. /**
  9044. * Sets the ShadowLight direction toward the passed target.
  9045. * @param target The point to target in local space
  9046. * @returns the updated ShadowLight direction
  9047. */
  9048. setDirectionToTarget(target: Vector3): Vector3;
  9049. /**
  9050. * Returns the light rotation in euler definition.
  9051. * @returns the x y z rotation in local space.
  9052. */
  9053. getRotation(): Vector3;
  9054. /**
  9055. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9056. * @returns true if a cube texture needs to be use
  9057. */
  9058. needCube(): boolean;
  9059. /**
  9060. * Detects if the projection matrix requires to be recomputed this frame.
  9061. * @returns true if it requires to be recomputed otherwise, false.
  9062. */
  9063. needProjectionMatrixCompute(): boolean;
  9064. /**
  9065. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9066. */
  9067. forceProjectionMatrixCompute(): void;
  9068. /** @hidden */
  9069. _initCache(): void;
  9070. /** @hidden */
  9071. _isSynchronized(): boolean;
  9072. /**
  9073. * Computes the world matrix of the node
  9074. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9075. * @returns the world matrix
  9076. */
  9077. computeWorldMatrix(force?: boolean): Matrix;
  9078. /**
  9079. * Gets the minZ used for shadow according to both the scene and the light.
  9080. * @param activeCamera The camera we are returning the min for
  9081. * @returns the depth min z
  9082. */
  9083. getDepthMinZ(activeCamera: Camera): number;
  9084. /**
  9085. * Gets the maxZ used for shadow according to both the scene and the light.
  9086. * @param activeCamera The camera we are returning the max for
  9087. * @returns the depth max z
  9088. */
  9089. getDepthMaxZ(activeCamera: Camera): number;
  9090. /**
  9091. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9092. * @param matrix The materix to updated with the projection information
  9093. * @param viewMatrix The transform matrix of the light
  9094. * @param renderList The list of mesh to render in the map
  9095. * @returns The current light
  9096. */
  9097. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9098. }
  9099. }
  9100. declare module "babylonjs/Materials/effectFallbacks" {
  9101. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9102. import { Effect } from "babylonjs/Materials/effect";
  9103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9104. /**
  9105. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9106. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9107. */
  9108. export class EffectFallbacks implements IEffectFallbacks {
  9109. private _defines;
  9110. private _currentRank;
  9111. private _maxRank;
  9112. private _mesh;
  9113. /**
  9114. * Removes the fallback from the bound mesh.
  9115. */
  9116. unBindMesh(): void;
  9117. /**
  9118. * Adds a fallback on the specified property.
  9119. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9120. * @param define The name of the define in the shader
  9121. */
  9122. addFallback(rank: number, define: string): void;
  9123. /**
  9124. * Sets the mesh to use CPU skinning when needing to fallback.
  9125. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9126. * @param mesh The mesh to use the fallbacks.
  9127. */
  9128. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9129. /**
  9130. * Checks to see if more fallbacks are still availible.
  9131. */
  9132. get hasMoreFallbacks(): boolean;
  9133. /**
  9134. * Removes the defines that should be removed when falling back.
  9135. * @param currentDefines defines the current define statements for the shader.
  9136. * @param effect defines the current effect we try to compile
  9137. * @returns The resulting defines with defines of the current rank removed.
  9138. */
  9139. reduce(currentDefines: string, effect: Effect): string;
  9140. }
  9141. }
  9142. declare module "babylonjs/Materials/materialHelper" {
  9143. import { Nullable } from "babylonjs/types";
  9144. import { Scene } from "babylonjs/scene";
  9145. import { Engine } from "babylonjs/Engines/engine";
  9146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9147. import { Light } from "babylonjs/Lights/light";
  9148. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9149. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9150. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9151. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9152. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9153. /**
  9154. * "Static Class" containing the most commonly used helper while dealing with material for
  9155. * rendering purpose.
  9156. *
  9157. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9158. *
  9159. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9160. */
  9161. export class MaterialHelper {
  9162. /**
  9163. * Bind the current view position to an effect.
  9164. * @param effect The effect to be bound
  9165. * @param scene The scene the eyes position is used from
  9166. */
  9167. static BindEyePosition(effect: Effect, scene: Scene): void;
  9168. /**
  9169. * Helps preparing the defines values about the UVs in used in the effect.
  9170. * UVs are shared as much as we can accross channels in the shaders.
  9171. * @param texture The texture we are preparing the UVs for
  9172. * @param defines The defines to update
  9173. * @param key The channel key "diffuse", "specular"... used in the shader
  9174. */
  9175. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9176. /**
  9177. * Binds a texture matrix value to its corrsponding uniform
  9178. * @param texture The texture to bind the matrix for
  9179. * @param uniformBuffer The uniform buffer receivin the data
  9180. * @param key The channel key "diffuse", "specular"... used in the shader
  9181. */
  9182. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9183. /**
  9184. * Gets the current status of the fog (should it be enabled?)
  9185. * @param mesh defines the mesh to evaluate for fog support
  9186. * @param scene defines the hosting scene
  9187. * @returns true if fog must be enabled
  9188. */
  9189. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9190. /**
  9191. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9192. * @param mesh defines the current mesh
  9193. * @param scene defines the current scene
  9194. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9195. * @param pointsCloud defines if point cloud rendering has to be turned on
  9196. * @param fogEnabled defines if fog has to be turned on
  9197. * @param alphaTest defines if alpha testing has to be turned on
  9198. * @param defines defines the current list of defines
  9199. */
  9200. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9201. /**
  9202. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9203. * @param scene defines the current scene
  9204. * @param engine defines the current engine
  9205. * @param defines specifies the list of active defines
  9206. * @param useInstances defines if instances have to be turned on
  9207. * @param useClipPlane defines if clip plane have to be turned on
  9208. */
  9209. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9210. /**
  9211. * Prepares the defines for bones
  9212. * @param mesh The mesh containing the geometry data we will draw
  9213. * @param defines The defines to update
  9214. */
  9215. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9216. /**
  9217. * Prepares the defines for morph targets
  9218. * @param mesh The mesh containing the geometry data we will draw
  9219. * @param defines The defines to update
  9220. */
  9221. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9222. /**
  9223. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9224. * @param mesh The mesh containing the geometry data we will draw
  9225. * @param defines The defines to update
  9226. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9227. * @param useBones Precise whether bones should be used or not (override mesh info)
  9228. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9229. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9230. * @returns false if defines are considered not dirty and have not been checked
  9231. */
  9232. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9233. /**
  9234. * Prepares the defines related to multiview
  9235. * @param scene The scene we are intending to draw
  9236. * @param defines The defines to update
  9237. */
  9238. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9239. /**
  9240. * Prepares the defines related to the light information passed in parameter
  9241. * @param scene The scene we are intending to draw
  9242. * @param mesh The mesh the effect is compiling for
  9243. * @param light The light the effect is compiling for
  9244. * @param lightIndex The index of the light
  9245. * @param defines The defines to update
  9246. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9247. * @param state Defines the current state regarding what is needed (normals, etc...)
  9248. */
  9249. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9250. needNormals: boolean;
  9251. needRebuild: boolean;
  9252. shadowEnabled: boolean;
  9253. specularEnabled: boolean;
  9254. lightmapMode: boolean;
  9255. }): void;
  9256. /**
  9257. * Prepares the defines related to the light information passed in parameter
  9258. * @param scene The scene we are intending to draw
  9259. * @param mesh The mesh the effect is compiling for
  9260. * @param defines The defines to update
  9261. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9262. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9263. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9264. * @returns true if normals will be required for the rest of the effect
  9265. */
  9266. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9267. /**
  9268. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9269. * @param lightIndex defines the light index
  9270. * @param uniformsList The uniform list
  9271. * @param samplersList The sampler list
  9272. * @param projectedLightTexture defines if projected texture must be used
  9273. * @param uniformBuffersList defines an optional list of uniform buffers
  9274. */
  9275. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9276. /**
  9277. * Prepares the uniforms and samplers list to be used in the effect
  9278. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9279. * @param samplersList The sampler list
  9280. * @param defines The defines helping in the list generation
  9281. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9282. */
  9283. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9284. /**
  9285. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9286. * @param defines The defines to update while falling back
  9287. * @param fallbacks The authorized effect fallbacks
  9288. * @param maxSimultaneousLights The maximum number of lights allowed
  9289. * @param rank the current rank of the Effect
  9290. * @returns The newly affected rank
  9291. */
  9292. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9293. private static _TmpMorphInfluencers;
  9294. /**
  9295. * Prepares the list of attributes required for morph targets according to the effect defines.
  9296. * @param attribs The current list of supported attribs
  9297. * @param mesh The mesh to prepare the morph targets attributes for
  9298. * @param influencers The number of influencers
  9299. */
  9300. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9301. /**
  9302. * Prepares the list of attributes required for morph targets according to the effect defines.
  9303. * @param attribs The current list of supported attribs
  9304. * @param mesh The mesh to prepare the morph targets attributes for
  9305. * @param defines The current Defines of the effect
  9306. */
  9307. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9308. /**
  9309. * Prepares the list of attributes required for bones according to the effect defines.
  9310. * @param attribs The current list of supported attribs
  9311. * @param mesh The mesh to prepare the bones attributes for
  9312. * @param defines The current Defines of the effect
  9313. * @param fallbacks The current efffect fallback strategy
  9314. */
  9315. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9316. /**
  9317. * Check and prepare the list of attributes required for instances according to the effect defines.
  9318. * @param attribs The current list of supported attribs
  9319. * @param defines The current MaterialDefines of the effect
  9320. */
  9321. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9322. /**
  9323. * Add the list of attributes required for instances to the attribs array.
  9324. * @param attribs The current list of supported attribs
  9325. */
  9326. static PushAttributesForInstances(attribs: string[]): void;
  9327. /**
  9328. * Binds the light information to the effect.
  9329. * @param light The light containing the generator
  9330. * @param effect The effect we are binding the data to
  9331. * @param lightIndex The light index in the effect used to render
  9332. */
  9333. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9334. /**
  9335. * Binds the lights information from the scene to the effect for the given mesh.
  9336. * @param light Light to bind
  9337. * @param lightIndex Light index
  9338. * @param scene The scene where the light belongs to
  9339. * @param effect The effect we are binding the data to
  9340. * @param useSpecular Defines if specular is supported
  9341. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9342. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9343. */
  9344. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9345. /**
  9346. * Binds the lights information from the scene to the effect for the given mesh.
  9347. * @param scene The scene the lights belongs to
  9348. * @param mesh The mesh we are binding the information to render
  9349. * @param effect The effect we are binding the data to
  9350. * @param defines The generated defines for the effect
  9351. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9352. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9353. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9354. */
  9355. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9356. private static _tempFogColor;
  9357. /**
  9358. * Binds the fog information from the scene to the effect for the given mesh.
  9359. * @param scene The scene the lights belongs to
  9360. * @param mesh The mesh we are binding the information to render
  9361. * @param effect The effect we are binding the data to
  9362. * @param linearSpace Defines if the fog effect is applied in linear space
  9363. */
  9364. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9365. /**
  9366. * Binds the bones information from the mesh to the effect.
  9367. * @param mesh The mesh we are binding the information to render
  9368. * @param effect The effect we are binding the data to
  9369. */
  9370. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9371. /**
  9372. * Binds the morph targets information from the mesh to the effect.
  9373. * @param abstractMesh The mesh we are binding the information to render
  9374. * @param effect The effect we are binding the data to
  9375. */
  9376. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9377. /**
  9378. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9379. * @param defines The generated defines used in the effect
  9380. * @param effect The effect we are binding the data to
  9381. * @param scene The scene we are willing to render with logarithmic scale for
  9382. */
  9383. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9384. /**
  9385. * Binds the clip plane information from the scene to the effect.
  9386. * @param scene The scene the clip plane information are extracted from
  9387. * @param effect The effect we are binding the data to
  9388. */
  9389. static BindClipPlane(effect: Effect, scene: Scene): void;
  9390. }
  9391. }
  9392. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9393. /** @hidden */
  9394. export var packingFunctions: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9400. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9401. /** @hidden */
  9402. export var shadowMapPixelShader: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9408. /** @hidden */
  9409. export var bonesDeclaration: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9415. /** @hidden */
  9416. export var morphTargetsVertexGlobalDeclaration: {
  9417. name: string;
  9418. shader: string;
  9419. };
  9420. }
  9421. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9422. /** @hidden */
  9423. export var morphTargetsVertexDeclaration: {
  9424. name: string;
  9425. shader: string;
  9426. };
  9427. }
  9428. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9429. /** @hidden */
  9430. export var instancesDeclaration: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9436. /** @hidden */
  9437. export var helperFunctions: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9443. /** @hidden */
  9444. export var morphTargetsVertex: {
  9445. name: string;
  9446. shader: string;
  9447. };
  9448. }
  9449. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9450. /** @hidden */
  9451. export var instancesVertex: {
  9452. name: string;
  9453. shader: string;
  9454. };
  9455. }
  9456. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9457. /** @hidden */
  9458. export var bonesVertex: {
  9459. name: string;
  9460. shader: string;
  9461. };
  9462. }
  9463. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9464. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9467. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9468. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9469. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9470. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9471. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9472. /** @hidden */
  9473. export var shadowMapVertexShader: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9479. /** @hidden */
  9480. export var depthBoxBlurPixelShader: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9486. import { Nullable } from "babylonjs/types";
  9487. import { Scene } from "babylonjs/scene";
  9488. import { Matrix } from "babylonjs/Maths/math.vector";
  9489. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9491. import { Mesh } from "babylonjs/Meshes/mesh";
  9492. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9493. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9494. import { Effect } from "babylonjs/Materials/effect";
  9495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9496. import "babylonjs/Shaders/shadowMap.fragment";
  9497. import "babylonjs/Shaders/shadowMap.vertex";
  9498. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9499. import { Observable } from "babylonjs/Misc/observable";
  9500. /**
  9501. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9502. */
  9503. export interface ICustomShaderOptions {
  9504. /**
  9505. * Gets or sets the custom shader name to use
  9506. */
  9507. shaderName: string;
  9508. /**
  9509. * The list of attribute names used in the shader
  9510. */
  9511. attributes?: string[];
  9512. /**
  9513. * The list of unifrom names used in the shader
  9514. */
  9515. uniforms?: string[];
  9516. /**
  9517. * The list of sampler names used in the shader
  9518. */
  9519. samplers?: string[];
  9520. /**
  9521. * The list of defines used in the shader
  9522. */
  9523. defines?: string[];
  9524. }
  9525. /**
  9526. * Interface to implement to create a shadow generator compatible with BJS.
  9527. */
  9528. export interface IShadowGenerator {
  9529. /**
  9530. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9531. * @returns The render target texture if present otherwise, null
  9532. */
  9533. getShadowMap(): Nullable<RenderTargetTexture>;
  9534. /**
  9535. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9536. * @returns The render target texture if the shadow map is present otherwise, null
  9537. */
  9538. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9539. /**
  9540. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9541. * @param subMesh The submesh we want to render in the shadow map
  9542. * @param useInstances Defines wether will draw in the map using instances
  9543. * @returns true if ready otherwise, false
  9544. */
  9545. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9546. /**
  9547. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9548. * @param defines Defines of the material we want to update
  9549. * @param lightIndex Index of the light in the enabled light list of the material
  9550. */
  9551. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9552. /**
  9553. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9554. * defined in the generator but impacting the effect).
  9555. * It implies the unifroms available on the materials are the standard BJS ones.
  9556. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9557. * @param effect The effect we are binfing the information for
  9558. */
  9559. bindShadowLight(lightIndex: string, effect: Effect): void;
  9560. /**
  9561. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9562. * (eq to shadow prjection matrix * light transform matrix)
  9563. * @returns The transform matrix used to create the shadow map
  9564. */
  9565. getTransformMatrix(): Matrix;
  9566. /**
  9567. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9568. * Cube and 2D textures for instance.
  9569. */
  9570. recreateShadowMap(): void;
  9571. /**
  9572. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9573. * @param onCompiled Callback triggered at the and of the effects compilation
  9574. * @param options Sets of optional options forcing the compilation with different modes
  9575. */
  9576. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9577. useInstances: boolean;
  9578. }>): void;
  9579. /**
  9580. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9581. * @param options Sets of optional options forcing the compilation with different modes
  9582. * @returns A promise that resolves when the compilation completes
  9583. */
  9584. forceCompilationAsync(options?: Partial<{
  9585. useInstances: boolean;
  9586. }>): Promise<void>;
  9587. /**
  9588. * Serializes the shadow generator setup to a json object.
  9589. * @returns The serialized JSON object
  9590. */
  9591. serialize(): any;
  9592. /**
  9593. * Disposes the Shadow map and related Textures and effects.
  9594. */
  9595. dispose(): void;
  9596. }
  9597. /**
  9598. * Default implementation IShadowGenerator.
  9599. * This is the main object responsible of generating shadows in the framework.
  9600. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9601. */
  9602. export class ShadowGenerator implements IShadowGenerator {
  9603. /**
  9604. * Shadow generator mode None: no filtering applied.
  9605. */
  9606. static readonly FILTER_NONE: number;
  9607. /**
  9608. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9609. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9610. */
  9611. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9612. /**
  9613. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9614. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9615. */
  9616. static readonly FILTER_POISSONSAMPLING: number;
  9617. /**
  9618. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9619. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9620. */
  9621. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9622. /**
  9623. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9624. * edge artifacts on steep falloff.
  9625. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9626. */
  9627. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9628. /**
  9629. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9630. * edge artifacts on steep falloff.
  9631. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9632. */
  9633. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9634. /**
  9635. * Shadow generator mode PCF: Percentage Closer Filtering
  9636. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9637. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9638. */
  9639. static readonly FILTER_PCF: number;
  9640. /**
  9641. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9642. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9643. * Contact Hardening
  9644. */
  9645. static readonly FILTER_PCSS: number;
  9646. /**
  9647. * Reserved for PCF and PCSS
  9648. * Highest Quality.
  9649. *
  9650. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9651. *
  9652. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9653. */
  9654. static readonly QUALITY_HIGH: number;
  9655. /**
  9656. * Reserved for PCF and PCSS
  9657. * Good tradeoff for quality/perf cross devices
  9658. *
  9659. * Execute PCF on a 3*3 kernel.
  9660. *
  9661. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9662. */
  9663. static readonly QUALITY_MEDIUM: number;
  9664. /**
  9665. * Reserved for PCF and PCSS
  9666. * The lowest quality but the fastest.
  9667. *
  9668. * Execute PCF on a 1*1 kernel.
  9669. *
  9670. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9671. */
  9672. static readonly QUALITY_LOW: number;
  9673. /** Gets or sets the custom shader name to use */
  9674. customShaderOptions: ICustomShaderOptions;
  9675. /**
  9676. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9677. */
  9678. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9679. /**
  9680. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9681. */
  9682. onAfterShadowMapRenderObservable: Observable<Effect>;
  9683. /**
  9684. * Observable triggered before a mesh is rendered in the shadow map.
  9685. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9686. */
  9687. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9688. /**
  9689. * Observable triggered after a mesh is rendered in the shadow map.
  9690. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9691. */
  9692. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9693. private _bias;
  9694. /**
  9695. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9696. */
  9697. get bias(): number;
  9698. /**
  9699. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9700. */
  9701. set bias(bias: number);
  9702. private _normalBias;
  9703. /**
  9704. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9705. */
  9706. get normalBias(): number;
  9707. /**
  9708. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9709. */
  9710. set normalBias(normalBias: number);
  9711. private _blurBoxOffset;
  9712. /**
  9713. * Gets the blur box offset: offset applied during the blur pass.
  9714. * Only useful if useKernelBlur = false
  9715. */
  9716. get blurBoxOffset(): number;
  9717. /**
  9718. * Sets the blur box offset: offset applied during the blur pass.
  9719. * Only useful if useKernelBlur = false
  9720. */
  9721. set blurBoxOffset(value: number);
  9722. private _blurScale;
  9723. /**
  9724. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9725. * 2 means half of the size.
  9726. */
  9727. get blurScale(): number;
  9728. /**
  9729. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9730. * 2 means half of the size.
  9731. */
  9732. set blurScale(value: number);
  9733. private _blurKernel;
  9734. /**
  9735. * Gets the blur kernel: kernel size of the blur pass.
  9736. * Only useful if useKernelBlur = true
  9737. */
  9738. get blurKernel(): number;
  9739. /**
  9740. * Sets the blur kernel: kernel size of the blur pass.
  9741. * Only useful if useKernelBlur = true
  9742. */
  9743. set blurKernel(value: number);
  9744. private _useKernelBlur;
  9745. /**
  9746. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9747. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9748. */
  9749. get useKernelBlur(): boolean;
  9750. /**
  9751. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9752. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9753. */
  9754. set useKernelBlur(value: boolean);
  9755. private _depthScale;
  9756. /**
  9757. * Gets the depth scale used in ESM mode.
  9758. */
  9759. get depthScale(): number;
  9760. /**
  9761. * Sets the depth scale used in ESM mode.
  9762. * This can override the scale stored on the light.
  9763. */
  9764. set depthScale(value: number);
  9765. private _filter;
  9766. /**
  9767. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9768. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9769. */
  9770. get filter(): number;
  9771. /**
  9772. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9773. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9774. */
  9775. set filter(value: number);
  9776. /**
  9777. * Gets if the current filter is set to Poisson Sampling.
  9778. */
  9779. get usePoissonSampling(): boolean;
  9780. /**
  9781. * Sets the current filter to Poisson Sampling.
  9782. */
  9783. set usePoissonSampling(value: boolean);
  9784. /**
  9785. * Gets if the current filter is set to ESM.
  9786. */
  9787. get useExponentialShadowMap(): boolean;
  9788. /**
  9789. * Sets the current filter is to ESM.
  9790. */
  9791. set useExponentialShadowMap(value: boolean);
  9792. /**
  9793. * Gets if the current filter is set to filtered ESM.
  9794. */
  9795. get useBlurExponentialShadowMap(): boolean;
  9796. /**
  9797. * Gets if the current filter is set to filtered ESM.
  9798. */
  9799. set useBlurExponentialShadowMap(value: boolean);
  9800. /**
  9801. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9802. * exponential to prevent steep falloff artifacts).
  9803. */
  9804. get useCloseExponentialShadowMap(): boolean;
  9805. /**
  9806. * Sets the current filter to "close ESM" (using the inverse of the
  9807. * exponential to prevent steep falloff artifacts).
  9808. */
  9809. set useCloseExponentialShadowMap(value: boolean);
  9810. /**
  9811. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9812. * exponential to prevent steep falloff artifacts).
  9813. */
  9814. get useBlurCloseExponentialShadowMap(): boolean;
  9815. /**
  9816. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9817. * exponential to prevent steep falloff artifacts).
  9818. */
  9819. set useBlurCloseExponentialShadowMap(value: boolean);
  9820. /**
  9821. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9822. */
  9823. get usePercentageCloserFiltering(): boolean;
  9824. /**
  9825. * Sets the current filter to "PCF" (percentage closer filtering).
  9826. */
  9827. set usePercentageCloserFiltering(value: boolean);
  9828. private _filteringQuality;
  9829. /**
  9830. * Gets the PCF or PCSS Quality.
  9831. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9832. */
  9833. get filteringQuality(): number;
  9834. /**
  9835. * Sets the PCF or PCSS Quality.
  9836. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9837. */
  9838. set filteringQuality(filteringQuality: number);
  9839. /**
  9840. * Gets if the current filter is set to "PCSS" (contact hardening).
  9841. */
  9842. get useContactHardeningShadow(): boolean;
  9843. /**
  9844. * Sets the current filter to "PCSS" (contact hardening).
  9845. */
  9846. set useContactHardeningShadow(value: boolean);
  9847. private _contactHardeningLightSizeUVRatio;
  9848. /**
  9849. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9850. * Using a ratio helps keeping shape stability independently of the map size.
  9851. *
  9852. * It does not account for the light projection as it was having too much
  9853. * instability during the light setup or during light position changes.
  9854. *
  9855. * Only valid if useContactHardeningShadow is true.
  9856. */
  9857. get contactHardeningLightSizeUVRatio(): number;
  9858. /**
  9859. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9860. * Using a ratio helps keeping shape stability independently of the map size.
  9861. *
  9862. * It does not account for the light projection as it was having too much
  9863. * instability during the light setup or during light position changes.
  9864. *
  9865. * Only valid if useContactHardeningShadow is true.
  9866. */
  9867. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9868. private _darkness;
  9869. /** Gets or sets the actual darkness of a shadow */
  9870. get darkness(): number;
  9871. set darkness(value: number);
  9872. /**
  9873. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9874. * 0 means strongest and 1 would means no shadow.
  9875. * @returns the darkness.
  9876. */
  9877. getDarkness(): number;
  9878. /**
  9879. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9880. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9881. * @returns the shadow generator allowing fluent coding.
  9882. */
  9883. setDarkness(darkness: number): ShadowGenerator;
  9884. private _transparencyShadow;
  9885. /** Gets or sets the ability to have transparent shadow */
  9886. get transparencyShadow(): boolean;
  9887. set transparencyShadow(value: boolean);
  9888. /**
  9889. * Sets the ability to have transparent shadow (boolean).
  9890. * @param transparent True if transparent else False
  9891. * @returns the shadow generator allowing fluent coding
  9892. */
  9893. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9894. private _shadowMap;
  9895. private _shadowMap2;
  9896. /**
  9897. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9898. * @returns The render target texture if present otherwise, null
  9899. */
  9900. getShadowMap(): Nullable<RenderTargetTexture>;
  9901. /**
  9902. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9903. * @returns The render target texture if the shadow map is present otherwise, null
  9904. */
  9905. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9906. /**
  9907. * Gets the class name of that object
  9908. * @returns "ShadowGenerator"
  9909. */
  9910. getClassName(): string;
  9911. /**
  9912. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9913. * @param mesh Mesh to add
  9914. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9915. * @returns the Shadow Generator itself
  9916. */
  9917. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9918. /**
  9919. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9920. * @param mesh Mesh to remove
  9921. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9922. * @returns the Shadow Generator itself
  9923. */
  9924. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9925. /**
  9926. * Controls the extent to which the shadows fade out at the edge of the frustum
  9927. * Used only by directionals and spots
  9928. */
  9929. frustumEdgeFalloff: number;
  9930. private _light;
  9931. /**
  9932. * Returns the associated light object.
  9933. * @returns the light generating the shadow
  9934. */
  9935. getLight(): IShadowLight;
  9936. /**
  9937. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9938. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9939. * It might on the other hand introduce peter panning.
  9940. */
  9941. forceBackFacesOnly: boolean;
  9942. private _scene;
  9943. private _lightDirection;
  9944. private _effect;
  9945. private _viewMatrix;
  9946. private _projectionMatrix;
  9947. private _transformMatrix;
  9948. private _cachedPosition;
  9949. private _cachedDirection;
  9950. private _cachedDefines;
  9951. private _currentRenderID;
  9952. private _boxBlurPostprocess;
  9953. private _kernelBlurXPostprocess;
  9954. private _kernelBlurYPostprocess;
  9955. private _blurPostProcesses;
  9956. private _mapSize;
  9957. private _currentFaceIndex;
  9958. private _currentFaceIndexCache;
  9959. private _textureType;
  9960. private _defaultTextureMatrix;
  9961. private _storedUniqueId;
  9962. /** @hidden */
  9963. static _SceneComponentInitialization: (scene: Scene) => void;
  9964. /**
  9965. * Creates a ShadowGenerator object.
  9966. * A ShadowGenerator is the required tool to use the shadows.
  9967. * Each light casting shadows needs to use its own ShadowGenerator.
  9968. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9969. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9970. * @param light The light object generating the shadows.
  9971. * @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.
  9972. */
  9973. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9974. private _initializeGenerator;
  9975. private _initializeShadowMap;
  9976. private _initializeBlurRTTAndPostProcesses;
  9977. private _renderForShadowMap;
  9978. private _renderSubMeshForShadowMap;
  9979. private _applyFilterValues;
  9980. /**
  9981. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9982. * @param onCompiled Callback triggered at the and of the effects compilation
  9983. * @param options Sets of optional options forcing the compilation with different modes
  9984. */
  9985. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9986. useInstances: boolean;
  9987. }>): void;
  9988. /**
  9989. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9990. * @param options Sets of optional options forcing the compilation with different modes
  9991. * @returns A promise that resolves when the compilation completes
  9992. */
  9993. forceCompilationAsync(options?: Partial<{
  9994. useInstances: boolean;
  9995. }>): Promise<void>;
  9996. /**
  9997. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9998. * @param subMesh The submesh we want to render in the shadow map
  9999. * @param useInstances Defines wether will draw in the map using instances
  10000. * @returns true if ready otherwise, false
  10001. */
  10002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10003. /**
  10004. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10005. * @param defines Defines of the material we want to update
  10006. * @param lightIndex Index of the light in the enabled light list of the material
  10007. */
  10008. prepareDefines(defines: any, lightIndex: number): void;
  10009. /**
  10010. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10011. * defined in the generator but impacting the effect).
  10012. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10013. * @param effect The effect we are binfing the information for
  10014. */
  10015. bindShadowLight(lightIndex: string, effect: Effect): void;
  10016. /**
  10017. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10018. * (eq to shadow prjection matrix * light transform matrix)
  10019. * @returns The transform matrix used to create the shadow map
  10020. */
  10021. getTransformMatrix(): Matrix;
  10022. /**
  10023. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10024. * Cube and 2D textures for instance.
  10025. */
  10026. recreateShadowMap(): void;
  10027. private _disposeBlurPostProcesses;
  10028. private _disposeRTTandPostProcesses;
  10029. /**
  10030. * Disposes the ShadowGenerator.
  10031. * Returns nothing.
  10032. */
  10033. dispose(): void;
  10034. /**
  10035. * Serializes the shadow generator setup to a json object.
  10036. * @returns The serialized JSON object
  10037. */
  10038. serialize(): any;
  10039. /**
  10040. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10041. * @param parsedShadowGenerator The JSON object to parse
  10042. * @param scene The scene to create the shadow map for
  10043. * @returns The parsed shadow generator
  10044. */
  10045. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10046. }
  10047. }
  10048. declare module "babylonjs/Lights/light" {
  10049. import { Nullable } from "babylonjs/types";
  10050. import { Scene } from "babylonjs/scene";
  10051. import { Vector3 } from "babylonjs/Maths/math.vector";
  10052. import { Color3 } from "babylonjs/Maths/math.color";
  10053. import { Node } from "babylonjs/node";
  10054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10055. import { Effect } from "babylonjs/Materials/effect";
  10056. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10057. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10058. /**
  10059. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10060. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10061. * 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.
  10062. */
  10063. export abstract class Light extends Node {
  10064. /**
  10065. * Falloff Default: light is falling off following the material specification:
  10066. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10067. */
  10068. static readonly FALLOFF_DEFAULT: number;
  10069. /**
  10070. * Falloff Physical: light is falling off following the inverse squared distance law.
  10071. */
  10072. static readonly FALLOFF_PHYSICAL: number;
  10073. /**
  10074. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10075. * to enhance interoperability with other engines.
  10076. */
  10077. static readonly FALLOFF_GLTF: number;
  10078. /**
  10079. * Falloff Standard: light is falling off like in the standard material
  10080. * to enhance interoperability with other materials.
  10081. */
  10082. static readonly FALLOFF_STANDARD: number;
  10083. /**
  10084. * If every light affecting the material is in this lightmapMode,
  10085. * material.lightmapTexture adds or multiplies
  10086. * (depends on material.useLightmapAsShadowmap)
  10087. * after every other light calculations.
  10088. */
  10089. static readonly LIGHTMAP_DEFAULT: number;
  10090. /**
  10091. * material.lightmapTexture as only diffuse lighting from this light
  10092. * adds only specular lighting from this light
  10093. * adds dynamic shadows
  10094. */
  10095. static readonly LIGHTMAP_SPECULAR: number;
  10096. /**
  10097. * material.lightmapTexture as only lighting
  10098. * no light calculation from this light
  10099. * only adds dynamic shadows from this light
  10100. */
  10101. static readonly LIGHTMAP_SHADOWSONLY: number;
  10102. /**
  10103. * Each light type uses the default quantity according to its type:
  10104. * point/spot lights use luminous intensity
  10105. * directional lights use illuminance
  10106. */
  10107. static readonly INTENSITYMODE_AUTOMATIC: number;
  10108. /**
  10109. * lumen (lm)
  10110. */
  10111. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10112. /**
  10113. * candela (lm/sr)
  10114. */
  10115. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10116. /**
  10117. * lux (lm/m^2)
  10118. */
  10119. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10120. /**
  10121. * nit (cd/m^2)
  10122. */
  10123. static readonly INTENSITYMODE_LUMINANCE: number;
  10124. /**
  10125. * Light type const id of the point light.
  10126. */
  10127. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10128. /**
  10129. * Light type const id of the directional light.
  10130. */
  10131. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10132. /**
  10133. * Light type const id of the spot light.
  10134. */
  10135. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10136. /**
  10137. * Light type const id of the hemispheric light.
  10138. */
  10139. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10140. /**
  10141. * Diffuse gives the basic color to an object.
  10142. */
  10143. diffuse: Color3;
  10144. /**
  10145. * Specular produces a highlight color on an object.
  10146. * Note: This is note affecting PBR materials.
  10147. */
  10148. specular: Color3;
  10149. /**
  10150. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10151. * falling off base on range or angle.
  10152. * This can be set to any values in Light.FALLOFF_x.
  10153. *
  10154. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10155. * other types of materials.
  10156. */
  10157. falloffType: number;
  10158. /**
  10159. * Strength of the light.
  10160. * Note: By default it is define in the framework own unit.
  10161. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10162. */
  10163. intensity: number;
  10164. private _range;
  10165. protected _inverseSquaredRange: number;
  10166. /**
  10167. * Defines how far from the source the light is impacting in scene units.
  10168. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10169. */
  10170. get range(): number;
  10171. /**
  10172. * Defines how far from the source the light is impacting in scene units.
  10173. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10174. */
  10175. set range(value: number);
  10176. /**
  10177. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10178. * of light.
  10179. */
  10180. private _photometricScale;
  10181. private _intensityMode;
  10182. /**
  10183. * Gets the photometric scale used to interpret the intensity.
  10184. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10185. */
  10186. get intensityMode(): number;
  10187. /**
  10188. * Sets the photometric scale used to interpret the intensity.
  10189. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10190. */
  10191. set intensityMode(value: number);
  10192. private _radius;
  10193. /**
  10194. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10195. */
  10196. get radius(): number;
  10197. /**
  10198. * sets the light radius used by PBR Materials to simulate soft area lights.
  10199. */
  10200. set radius(value: number);
  10201. private _renderPriority;
  10202. /**
  10203. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10204. * exceeding the number allowed of the materials.
  10205. */
  10206. renderPriority: number;
  10207. private _shadowEnabled;
  10208. /**
  10209. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10210. * the current shadow generator.
  10211. */
  10212. get shadowEnabled(): boolean;
  10213. /**
  10214. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10215. * the current shadow generator.
  10216. */
  10217. set shadowEnabled(value: boolean);
  10218. private _includedOnlyMeshes;
  10219. /**
  10220. * Gets the only meshes impacted by this light.
  10221. */
  10222. get includedOnlyMeshes(): AbstractMesh[];
  10223. /**
  10224. * Sets the only meshes impacted by this light.
  10225. */
  10226. set includedOnlyMeshes(value: AbstractMesh[]);
  10227. private _excludedMeshes;
  10228. /**
  10229. * Gets the meshes not impacted by this light.
  10230. */
  10231. get excludedMeshes(): AbstractMesh[];
  10232. /**
  10233. * Sets the meshes not impacted by this light.
  10234. */
  10235. set excludedMeshes(value: AbstractMesh[]);
  10236. private _excludeWithLayerMask;
  10237. /**
  10238. * Gets the layer id use to find what meshes are not impacted by the light.
  10239. * Inactive if 0
  10240. */
  10241. get excludeWithLayerMask(): number;
  10242. /**
  10243. * Sets the layer id use to find what meshes are not impacted by the light.
  10244. * Inactive if 0
  10245. */
  10246. set excludeWithLayerMask(value: number);
  10247. private _includeOnlyWithLayerMask;
  10248. /**
  10249. * Gets the layer id use to find what meshes are impacted by the light.
  10250. * Inactive if 0
  10251. */
  10252. get includeOnlyWithLayerMask(): number;
  10253. /**
  10254. * Sets the layer id use to find what meshes are impacted by the light.
  10255. * Inactive if 0
  10256. */
  10257. set includeOnlyWithLayerMask(value: number);
  10258. private _lightmapMode;
  10259. /**
  10260. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10261. */
  10262. get lightmapMode(): number;
  10263. /**
  10264. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10265. */
  10266. set lightmapMode(value: number);
  10267. /**
  10268. * Shadow generator associted to the light.
  10269. * @hidden Internal use only.
  10270. */
  10271. _shadowGenerator: Nullable<IShadowGenerator>;
  10272. /**
  10273. * @hidden Internal use only.
  10274. */
  10275. _excludedMeshesIds: string[];
  10276. /**
  10277. * @hidden Internal use only.
  10278. */
  10279. _includedOnlyMeshesIds: string[];
  10280. /**
  10281. * The current light unifom buffer.
  10282. * @hidden Internal use only.
  10283. */
  10284. _uniformBuffer: UniformBuffer;
  10285. /** @hidden */
  10286. _renderId: number;
  10287. /**
  10288. * Creates a Light object in the scene.
  10289. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10290. * @param name The firendly name of the light
  10291. * @param scene The scene the light belongs too
  10292. */
  10293. constructor(name: string, scene: Scene);
  10294. protected abstract _buildUniformLayout(): void;
  10295. /**
  10296. * Sets the passed Effect "effect" with the Light information.
  10297. * @param effect The effect to update
  10298. * @param lightIndex The index of the light in the effect to update
  10299. * @returns The light
  10300. */
  10301. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10302. /**
  10303. * Sets the passed Effect "effect" with the Light textures.
  10304. * @param effect The effect to update
  10305. * @param lightIndex The index of the light in the effect to update
  10306. * @returns The light
  10307. */
  10308. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10309. /**
  10310. * Binds the lights information from the scene to the effect for the given mesh.
  10311. * @param lightIndex Light index
  10312. * @param scene The scene where the light belongs to
  10313. * @param effect The effect we are binding the data to
  10314. * @param useSpecular Defines if specular is supported
  10315. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10316. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10317. */
  10318. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10319. /**
  10320. * Sets the passed Effect "effect" with the Light information.
  10321. * @param effect The effect to update
  10322. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10323. * @returns The light
  10324. */
  10325. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10326. /**
  10327. * Returns the string "Light".
  10328. * @returns the class name
  10329. */
  10330. getClassName(): string;
  10331. /** @hidden */
  10332. readonly _isLight: boolean;
  10333. /**
  10334. * Converts the light information to a readable string for debug purpose.
  10335. * @param fullDetails Supports for multiple levels of logging within scene loading
  10336. * @returns the human readable light info
  10337. */
  10338. toString(fullDetails?: boolean): string;
  10339. /** @hidden */
  10340. protected _syncParentEnabledState(): void;
  10341. /**
  10342. * Set the enabled state of this node.
  10343. * @param value - the new enabled state
  10344. */
  10345. setEnabled(value: boolean): void;
  10346. /**
  10347. * Returns the Light associated shadow generator if any.
  10348. * @return the associated shadow generator.
  10349. */
  10350. getShadowGenerator(): Nullable<IShadowGenerator>;
  10351. /**
  10352. * Returns a Vector3, the absolute light position in the World.
  10353. * @returns the world space position of the light
  10354. */
  10355. getAbsolutePosition(): Vector3;
  10356. /**
  10357. * Specifies if the light will affect the passed mesh.
  10358. * @param mesh The mesh to test against the light
  10359. * @return true the mesh is affected otherwise, false.
  10360. */
  10361. canAffectMesh(mesh: AbstractMesh): boolean;
  10362. /**
  10363. * Sort function to order lights for rendering.
  10364. * @param a First Light object to compare to second.
  10365. * @param b Second Light object to compare first.
  10366. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10367. */
  10368. static CompareLightsPriority(a: Light, b: Light): number;
  10369. /**
  10370. * Releases resources associated with this node.
  10371. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10372. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10373. */
  10374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10375. /**
  10376. * Returns the light type ID (integer).
  10377. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10378. */
  10379. getTypeID(): number;
  10380. /**
  10381. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10382. * @returns the scaled intensity in intensity mode unit
  10383. */
  10384. getScaledIntensity(): number;
  10385. /**
  10386. * Returns a new Light object, named "name", from the current one.
  10387. * @param name The name of the cloned light
  10388. * @returns the new created light
  10389. */
  10390. clone(name: string): Nullable<Light>;
  10391. /**
  10392. * Serializes the current light into a Serialization object.
  10393. * @returns the serialized object.
  10394. */
  10395. serialize(): any;
  10396. /**
  10397. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10398. * This new light is named "name" and added to the passed scene.
  10399. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10400. * @param name The friendly name of the light
  10401. * @param scene The scene the new light will belong to
  10402. * @returns the constructor function
  10403. */
  10404. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10405. /**
  10406. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10407. * @param parsedLight The JSON representation of the light
  10408. * @param scene The scene to create the parsed light in
  10409. * @returns the created light after parsing
  10410. */
  10411. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10412. private _hookArrayForExcluded;
  10413. private _hookArrayForIncludedOnly;
  10414. private _resyncMeshes;
  10415. /**
  10416. * Forces the meshes to update their light related information in their rendering used effects
  10417. * @hidden Internal Use Only
  10418. */
  10419. _markMeshesAsLightDirty(): void;
  10420. /**
  10421. * Recomputes the cached photometric scale if needed.
  10422. */
  10423. private _computePhotometricScale;
  10424. /**
  10425. * Returns the Photometric Scale according to the light type and intensity mode.
  10426. */
  10427. private _getPhotometricScale;
  10428. /**
  10429. * Reorder the light in the scene according to their defined priority.
  10430. * @hidden Internal Use Only
  10431. */
  10432. _reorderLightsInScene(): void;
  10433. /**
  10434. * Prepares the list of defines specific to the light type.
  10435. * @param defines the list of defines
  10436. * @param lightIndex defines the index of the light for the effect
  10437. */
  10438. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10439. }
  10440. }
  10441. declare module "babylonjs/Actions/action" {
  10442. import { Observable } from "babylonjs/Misc/observable";
  10443. import { Condition } from "babylonjs/Actions/condition";
  10444. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10445. import { ActionManager } from "babylonjs/Actions/actionManager";
  10446. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10447. /**
  10448. * Interface used to define Action
  10449. */
  10450. export interface IAction {
  10451. /**
  10452. * Trigger for the action
  10453. */
  10454. trigger: number;
  10455. /** Options of the trigger */
  10456. triggerOptions: any;
  10457. /**
  10458. * Gets the trigger parameters
  10459. * @returns the trigger parameters
  10460. */
  10461. getTriggerParameter(): any;
  10462. /**
  10463. * Internal only - executes current action event
  10464. * @hidden
  10465. */
  10466. _executeCurrent(evt?: ActionEvent): void;
  10467. /**
  10468. * Serialize placeholder for child classes
  10469. * @param parent of child
  10470. * @returns the serialized object
  10471. */
  10472. serialize(parent: any): any;
  10473. /**
  10474. * Internal only
  10475. * @hidden
  10476. */
  10477. _prepare(): void;
  10478. /**
  10479. * Internal only - manager for action
  10480. * @hidden
  10481. */
  10482. _actionManager: AbstractActionManager;
  10483. /**
  10484. * Adds action to chain of actions, may be a DoNothingAction
  10485. * @param action defines the next action to execute
  10486. * @returns The action passed in
  10487. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10488. */
  10489. then(action: IAction): IAction;
  10490. }
  10491. /**
  10492. * The action to be carried out following a trigger
  10493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10494. */
  10495. export class Action implements IAction {
  10496. /** the trigger, with or without parameters, for the action */
  10497. triggerOptions: any;
  10498. /**
  10499. * Trigger for the action
  10500. */
  10501. trigger: number;
  10502. /**
  10503. * Internal only - manager for action
  10504. * @hidden
  10505. */
  10506. _actionManager: ActionManager;
  10507. private _nextActiveAction;
  10508. private _child;
  10509. private _condition?;
  10510. private _triggerParameter;
  10511. /**
  10512. * An event triggered prior to action being executed.
  10513. */
  10514. onBeforeExecuteObservable: Observable<Action>;
  10515. /**
  10516. * Creates a new Action
  10517. * @param triggerOptions the trigger, with or without parameters, for the action
  10518. * @param condition an optional determinant of action
  10519. */
  10520. constructor(
  10521. /** the trigger, with or without parameters, for the action */
  10522. triggerOptions: any, condition?: Condition);
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. _prepare(): void;
  10528. /**
  10529. * Gets the trigger parameters
  10530. * @returns the trigger parameters
  10531. */
  10532. getTriggerParameter(): any;
  10533. /**
  10534. * Internal only - executes current action event
  10535. * @hidden
  10536. */
  10537. _executeCurrent(evt?: ActionEvent): void;
  10538. /**
  10539. * Execute placeholder for child classes
  10540. * @param evt optional action event
  10541. */
  10542. execute(evt?: ActionEvent): void;
  10543. /**
  10544. * Skips to next active action
  10545. */
  10546. skipToNextActiveAction(): void;
  10547. /**
  10548. * Adds action to chain of actions, may be a DoNothingAction
  10549. * @param action defines the next action to execute
  10550. * @returns The action passed in
  10551. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10552. */
  10553. then(action: Action): Action;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. _getProperty(propertyPath: string): string;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. _getEffectiveTarget(target: any, propertyPath: string): any;
  10564. /**
  10565. * Serialize placeholder for child classes
  10566. * @param parent of child
  10567. * @returns the serialized object
  10568. */
  10569. serialize(parent: any): any;
  10570. /**
  10571. * Internal only called by serialize
  10572. * @hidden
  10573. */
  10574. protected _serialize(serializedAction: any, parent?: any): any;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. static _SerializeValueAsString: (value: any) => string;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10585. name: string;
  10586. targetType: string;
  10587. value: string;
  10588. };
  10589. }
  10590. }
  10591. declare module "babylonjs/Actions/condition" {
  10592. import { ActionManager } from "babylonjs/Actions/actionManager";
  10593. /**
  10594. * A Condition applied to an Action
  10595. */
  10596. export class Condition {
  10597. /**
  10598. * Internal only - manager for action
  10599. * @hidden
  10600. */
  10601. _actionManager: ActionManager;
  10602. /**
  10603. * Internal only
  10604. * @hidden
  10605. */
  10606. _evaluationId: number;
  10607. /**
  10608. * Internal only
  10609. * @hidden
  10610. */
  10611. _currentResult: boolean;
  10612. /**
  10613. * Creates a new Condition
  10614. * @param actionManager the manager of the action the condition is applied to
  10615. */
  10616. constructor(actionManager: ActionManager);
  10617. /**
  10618. * Check if the current condition is valid
  10619. * @returns a boolean
  10620. */
  10621. isValid(): boolean;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. _getProperty(propertyPath: string): string;
  10627. /**
  10628. * Internal only
  10629. * @hidden
  10630. */
  10631. _getEffectiveTarget(target: any, propertyPath: string): any;
  10632. /**
  10633. * Serialize placeholder for child classes
  10634. * @returns the serialized object
  10635. */
  10636. serialize(): any;
  10637. /**
  10638. * Internal only
  10639. * @hidden
  10640. */
  10641. protected _serialize(serializedCondition: any): any;
  10642. }
  10643. /**
  10644. * Defines specific conditional operators as extensions of Condition
  10645. */
  10646. export class ValueCondition extends Condition {
  10647. /** path to specify the property of the target the conditional operator uses */
  10648. propertyPath: string;
  10649. /** the value compared by the conditional operator against the current value of the property */
  10650. value: any;
  10651. /** the conditional operator, default ValueCondition.IsEqual */
  10652. operator: number;
  10653. /**
  10654. * Internal only
  10655. * @hidden
  10656. */
  10657. private static _IsEqual;
  10658. /**
  10659. * Internal only
  10660. * @hidden
  10661. */
  10662. private static _IsDifferent;
  10663. /**
  10664. * Internal only
  10665. * @hidden
  10666. */
  10667. private static _IsGreater;
  10668. /**
  10669. * Internal only
  10670. * @hidden
  10671. */
  10672. private static _IsLesser;
  10673. /**
  10674. * returns the number for IsEqual
  10675. */
  10676. static get IsEqual(): number;
  10677. /**
  10678. * Returns the number for IsDifferent
  10679. */
  10680. static get IsDifferent(): number;
  10681. /**
  10682. * Returns the number for IsGreater
  10683. */
  10684. static get IsGreater(): number;
  10685. /**
  10686. * Returns the number for IsLesser
  10687. */
  10688. static get IsLesser(): number;
  10689. /**
  10690. * Internal only The action manager for the condition
  10691. * @hidden
  10692. */
  10693. _actionManager: ActionManager;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. private _target;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. private _effectiveTarget;
  10704. /**
  10705. * Internal only
  10706. * @hidden
  10707. */
  10708. private _property;
  10709. /**
  10710. * Creates a new ValueCondition
  10711. * @param actionManager manager for the action the condition applies to
  10712. * @param target for the action
  10713. * @param propertyPath path to specify the property of the target the conditional operator uses
  10714. * @param value the value compared by the conditional operator against the current value of the property
  10715. * @param operator the conditional operator, default ValueCondition.IsEqual
  10716. */
  10717. constructor(actionManager: ActionManager, target: any,
  10718. /** path to specify the property of the target the conditional operator uses */
  10719. propertyPath: string,
  10720. /** the value compared by the conditional operator against the current value of the property */
  10721. value: any,
  10722. /** the conditional operator, default ValueCondition.IsEqual */
  10723. operator?: number);
  10724. /**
  10725. * Compares the given value with the property value for the specified conditional operator
  10726. * @returns the result of the comparison
  10727. */
  10728. isValid(): boolean;
  10729. /**
  10730. * Serialize the ValueCondition into a JSON compatible object
  10731. * @returns serialization object
  10732. */
  10733. serialize(): any;
  10734. /**
  10735. * Gets the name of the conditional operator for the ValueCondition
  10736. * @param operator the conditional operator
  10737. * @returns the name
  10738. */
  10739. static GetOperatorName(operator: number): string;
  10740. }
  10741. /**
  10742. * Defines a predicate condition as an extension of Condition
  10743. */
  10744. export class PredicateCondition extends Condition {
  10745. /** defines the predicate function used to validate the condition */
  10746. predicate: () => boolean;
  10747. /**
  10748. * Internal only - manager for action
  10749. * @hidden
  10750. */
  10751. _actionManager: ActionManager;
  10752. /**
  10753. * Creates a new PredicateCondition
  10754. * @param actionManager manager for the action the condition applies to
  10755. * @param predicate defines the predicate function used to validate the condition
  10756. */
  10757. constructor(actionManager: ActionManager,
  10758. /** defines the predicate function used to validate the condition */
  10759. predicate: () => boolean);
  10760. /**
  10761. * @returns the validity of the predicate condition
  10762. */
  10763. isValid(): boolean;
  10764. }
  10765. /**
  10766. * Defines a state condition as an extension of Condition
  10767. */
  10768. export class StateCondition extends Condition {
  10769. /** Value to compare with target state */
  10770. value: string;
  10771. /**
  10772. * Internal only - manager for action
  10773. * @hidden
  10774. */
  10775. _actionManager: ActionManager;
  10776. /**
  10777. * Internal only
  10778. * @hidden
  10779. */
  10780. private _target;
  10781. /**
  10782. * Creates a new StateCondition
  10783. * @param actionManager manager for the action the condition applies to
  10784. * @param target of the condition
  10785. * @param value to compare with target state
  10786. */
  10787. constructor(actionManager: ActionManager, target: any,
  10788. /** Value to compare with target state */
  10789. value: string);
  10790. /**
  10791. * Gets a boolean indicating if the current condition is met
  10792. * @returns the validity of the state
  10793. */
  10794. isValid(): boolean;
  10795. /**
  10796. * Serialize the StateCondition into a JSON compatible object
  10797. * @returns serialization object
  10798. */
  10799. serialize(): any;
  10800. }
  10801. }
  10802. declare module "babylonjs/Actions/directActions" {
  10803. import { Action } from "babylonjs/Actions/action";
  10804. import { Condition } from "babylonjs/Actions/condition";
  10805. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10806. /**
  10807. * This defines an action responsible to toggle a boolean once triggered.
  10808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10809. */
  10810. export class SwitchBooleanAction extends Action {
  10811. /**
  10812. * The path to the boolean property in the target object
  10813. */
  10814. propertyPath: string;
  10815. private _target;
  10816. private _effectiveTarget;
  10817. private _property;
  10818. /**
  10819. * Instantiate the action
  10820. * @param triggerOptions defines the trigger options
  10821. * @param target defines the object containing the boolean
  10822. * @param propertyPath defines the path to the boolean property in the target object
  10823. * @param condition defines the trigger related conditions
  10824. */
  10825. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10826. /** @hidden */
  10827. _prepare(): void;
  10828. /**
  10829. * Execute the action toggle the boolean value.
  10830. */
  10831. execute(): void;
  10832. /**
  10833. * Serializes the actions and its related information.
  10834. * @param parent defines the object to serialize in
  10835. * @returns the serialized object
  10836. */
  10837. serialize(parent: any): any;
  10838. }
  10839. /**
  10840. * This defines an action responsible to set a the state field of the target
  10841. * to a desired value once triggered.
  10842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10843. */
  10844. export class SetStateAction extends Action {
  10845. /**
  10846. * The value to store in the state field.
  10847. */
  10848. value: string;
  10849. private _target;
  10850. /**
  10851. * Instantiate the action
  10852. * @param triggerOptions defines the trigger options
  10853. * @param target defines the object containing the state property
  10854. * @param value defines the value to store in the state field
  10855. * @param condition defines the trigger related conditions
  10856. */
  10857. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10858. /**
  10859. * Execute the action and store the value on the target state property.
  10860. */
  10861. execute(): void;
  10862. /**
  10863. * Serializes the actions and its related information.
  10864. * @param parent defines the object to serialize in
  10865. * @returns the serialized object
  10866. */
  10867. serialize(parent: any): any;
  10868. }
  10869. /**
  10870. * This defines an action responsible to set a property of the target
  10871. * to a desired value once triggered.
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10873. */
  10874. export class SetValueAction extends Action {
  10875. /**
  10876. * The path of the property to set in the target.
  10877. */
  10878. propertyPath: string;
  10879. /**
  10880. * The value to set in the property
  10881. */
  10882. value: any;
  10883. private _target;
  10884. private _effectiveTarget;
  10885. private _property;
  10886. /**
  10887. * Instantiate the action
  10888. * @param triggerOptions defines the trigger options
  10889. * @param target defines the object containing the property
  10890. * @param propertyPath defines the path of the property to set in the target
  10891. * @param value defines the value to set in the property
  10892. * @param condition defines the trigger related conditions
  10893. */
  10894. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10895. /** @hidden */
  10896. _prepare(): void;
  10897. /**
  10898. * Execute the action and set the targetted property to the desired value.
  10899. */
  10900. execute(): void;
  10901. /**
  10902. * Serializes the actions and its related information.
  10903. * @param parent defines the object to serialize in
  10904. * @returns the serialized object
  10905. */
  10906. serialize(parent: any): any;
  10907. }
  10908. /**
  10909. * This defines an action responsible to increment the target value
  10910. * to a desired value once triggered.
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10912. */
  10913. export class IncrementValueAction extends Action {
  10914. /**
  10915. * The path of the property to increment in the target.
  10916. */
  10917. propertyPath: string;
  10918. /**
  10919. * The value we should increment the property by.
  10920. */
  10921. value: any;
  10922. private _target;
  10923. private _effectiveTarget;
  10924. private _property;
  10925. /**
  10926. * Instantiate the action
  10927. * @param triggerOptions defines the trigger options
  10928. * @param target defines the object containing the property
  10929. * @param propertyPath defines the path of the property to increment in the target
  10930. * @param value defines the value value we should increment the property by
  10931. * @param condition defines the trigger related conditions
  10932. */
  10933. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10934. /** @hidden */
  10935. _prepare(): void;
  10936. /**
  10937. * Execute the action and increment the target of the value amount.
  10938. */
  10939. execute(): void;
  10940. /**
  10941. * Serializes the actions and its related information.
  10942. * @param parent defines the object to serialize in
  10943. * @returns the serialized object
  10944. */
  10945. serialize(parent: any): any;
  10946. }
  10947. /**
  10948. * This defines an action responsible to start an animation once triggered.
  10949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10950. */
  10951. export class PlayAnimationAction extends Action {
  10952. /**
  10953. * Where the animation should start (animation frame)
  10954. */
  10955. from: number;
  10956. /**
  10957. * Where the animation should stop (animation frame)
  10958. */
  10959. to: number;
  10960. /**
  10961. * Define if the animation should loop or stop after the first play.
  10962. */
  10963. loop?: boolean;
  10964. private _target;
  10965. /**
  10966. * Instantiate the action
  10967. * @param triggerOptions defines the trigger options
  10968. * @param target defines the target animation or animation name
  10969. * @param from defines from where the animation should start (animation frame)
  10970. * @param end defines where the animation should stop (animation frame)
  10971. * @param loop defines if the animation should loop or stop after the first play
  10972. * @param condition defines the trigger related conditions
  10973. */
  10974. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10975. /** @hidden */
  10976. _prepare(): void;
  10977. /**
  10978. * Execute the action and play the animation.
  10979. */
  10980. execute(): void;
  10981. /**
  10982. * Serializes the actions and its related information.
  10983. * @param parent defines the object to serialize in
  10984. * @returns the serialized object
  10985. */
  10986. serialize(parent: any): any;
  10987. }
  10988. /**
  10989. * This defines an action responsible to stop an animation once triggered.
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10991. */
  10992. export class StopAnimationAction extends Action {
  10993. private _target;
  10994. /**
  10995. * Instantiate the action
  10996. * @param triggerOptions defines the trigger options
  10997. * @param target defines the target animation or animation name
  10998. * @param condition defines the trigger related conditions
  10999. */
  11000. constructor(triggerOptions: any, target: any, condition?: Condition);
  11001. /** @hidden */
  11002. _prepare(): void;
  11003. /**
  11004. * Execute the action and stop the animation.
  11005. */
  11006. execute(): void;
  11007. /**
  11008. * Serializes the actions and its related information.
  11009. * @param parent defines the object to serialize in
  11010. * @returns the serialized object
  11011. */
  11012. serialize(parent: any): any;
  11013. }
  11014. /**
  11015. * This defines an action responsible that does nothing once triggered.
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11017. */
  11018. export class DoNothingAction extends Action {
  11019. /**
  11020. * Instantiate the action
  11021. * @param triggerOptions defines the trigger options
  11022. * @param condition defines the trigger related conditions
  11023. */
  11024. constructor(triggerOptions?: any, condition?: Condition);
  11025. /**
  11026. * Execute the action and do nothing.
  11027. */
  11028. execute(): void;
  11029. /**
  11030. * Serializes the actions and its related information.
  11031. * @param parent defines the object to serialize in
  11032. * @returns the serialized object
  11033. */
  11034. serialize(parent: any): any;
  11035. }
  11036. /**
  11037. * This defines an action responsible to trigger several actions once triggered.
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11039. */
  11040. export class CombineAction extends Action {
  11041. /**
  11042. * The list of aggregated animations to run.
  11043. */
  11044. children: Action[];
  11045. /**
  11046. * Instantiate the action
  11047. * @param triggerOptions defines the trigger options
  11048. * @param children defines the list of aggregated animations to run
  11049. * @param condition defines the trigger related conditions
  11050. */
  11051. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11052. /** @hidden */
  11053. _prepare(): void;
  11054. /**
  11055. * Execute the action and executes all the aggregated actions.
  11056. */
  11057. execute(evt: ActionEvent): void;
  11058. /**
  11059. * Serializes the actions and its related information.
  11060. * @param parent defines the object to serialize in
  11061. * @returns the serialized object
  11062. */
  11063. serialize(parent: any): any;
  11064. }
  11065. /**
  11066. * This defines an action responsible to run code (external event) once triggered.
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11068. */
  11069. export class ExecuteCodeAction extends Action {
  11070. /**
  11071. * The callback function to run.
  11072. */
  11073. func: (evt: ActionEvent) => void;
  11074. /**
  11075. * Instantiate the action
  11076. * @param triggerOptions defines the trigger options
  11077. * @param func defines the callback function to run
  11078. * @param condition defines the trigger related conditions
  11079. */
  11080. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11081. /**
  11082. * Execute the action and run the attached code.
  11083. */
  11084. execute(evt: ActionEvent): void;
  11085. }
  11086. /**
  11087. * This defines an action responsible to set the parent property of the target once triggered.
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11089. */
  11090. export class SetParentAction extends Action {
  11091. private _parent;
  11092. private _target;
  11093. /**
  11094. * Instantiate the action
  11095. * @param triggerOptions defines the trigger options
  11096. * @param target defines the target containing the parent property
  11097. * @param parent defines from where the animation should start (animation frame)
  11098. * @param condition defines the trigger related conditions
  11099. */
  11100. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11101. /** @hidden */
  11102. _prepare(): void;
  11103. /**
  11104. * Execute the action and set the parent property.
  11105. */
  11106. execute(): void;
  11107. /**
  11108. * Serializes the actions and its related information.
  11109. * @param parent defines the object to serialize in
  11110. * @returns the serialized object
  11111. */
  11112. serialize(parent: any): any;
  11113. }
  11114. }
  11115. declare module "babylonjs/Actions/actionManager" {
  11116. import { Nullable } from "babylonjs/types";
  11117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11118. import { Scene } from "babylonjs/scene";
  11119. import { IAction } from "babylonjs/Actions/action";
  11120. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11121. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11122. /**
  11123. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11124. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11126. */
  11127. export class ActionManager extends AbstractActionManager {
  11128. /**
  11129. * Nothing
  11130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11131. */
  11132. static readonly NothingTrigger: number;
  11133. /**
  11134. * On pick
  11135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11136. */
  11137. static readonly OnPickTrigger: number;
  11138. /**
  11139. * On left pick
  11140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11141. */
  11142. static readonly OnLeftPickTrigger: number;
  11143. /**
  11144. * On right pick
  11145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11146. */
  11147. static readonly OnRightPickTrigger: number;
  11148. /**
  11149. * On center pick
  11150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11151. */
  11152. static readonly OnCenterPickTrigger: number;
  11153. /**
  11154. * On pick down
  11155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11156. */
  11157. static readonly OnPickDownTrigger: number;
  11158. /**
  11159. * On double pick
  11160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11161. */
  11162. static readonly OnDoublePickTrigger: number;
  11163. /**
  11164. * On pick up
  11165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11166. */
  11167. static readonly OnPickUpTrigger: number;
  11168. /**
  11169. * On pick out.
  11170. * This trigger will only be raised if you also declared a OnPickDown
  11171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11172. */
  11173. static readonly OnPickOutTrigger: number;
  11174. /**
  11175. * On long press
  11176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11177. */
  11178. static readonly OnLongPressTrigger: number;
  11179. /**
  11180. * On pointer over
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11182. */
  11183. static readonly OnPointerOverTrigger: number;
  11184. /**
  11185. * On pointer out
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly OnPointerOutTrigger: number;
  11189. /**
  11190. * On every frame
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnEveryFrameTrigger: number;
  11194. /**
  11195. * On intersection enter
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11197. */
  11198. static readonly OnIntersectionEnterTrigger: number;
  11199. /**
  11200. * On intersection exit
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11202. */
  11203. static readonly OnIntersectionExitTrigger: number;
  11204. /**
  11205. * On key down
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11207. */
  11208. static readonly OnKeyDownTrigger: number;
  11209. /**
  11210. * On key up
  11211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11212. */
  11213. static readonly OnKeyUpTrigger: number;
  11214. private _scene;
  11215. /**
  11216. * Creates a new action manager
  11217. * @param scene defines the hosting scene
  11218. */
  11219. constructor(scene: Scene);
  11220. /**
  11221. * Releases all associated resources
  11222. */
  11223. dispose(): void;
  11224. /**
  11225. * Gets hosting scene
  11226. * @returns the hosting scene
  11227. */
  11228. getScene(): Scene;
  11229. /**
  11230. * Does this action manager handles actions of any of the given triggers
  11231. * @param triggers defines the triggers to be tested
  11232. * @return a boolean indicating whether one (or more) of the triggers is handled
  11233. */
  11234. hasSpecificTriggers(triggers: number[]): boolean;
  11235. /**
  11236. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11237. * speed.
  11238. * @param triggerA defines the trigger to be tested
  11239. * @param triggerB defines the trigger to be tested
  11240. * @return a boolean indicating whether one (or more) of the triggers is handled
  11241. */
  11242. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11243. /**
  11244. * Does this action manager handles actions of a given trigger
  11245. * @param trigger defines the trigger to be tested
  11246. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11247. * @return whether the trigger is handled
  11248. */
  11249. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11250. /**
  11251. * Does this action manager has pointer triggers
  11252. */
  11253. get hasPointerTriggers(): boolean;
  11254. /**
  11255. * Does this action manager has pick triggers
  11256. */
  11257. get hasPickTriggers(): boolean;
  11258. /**
  11259. * Registers an action to this action manager
  11260. * @param action defines the action to be registered
  11261. * @return the action amended (prepared) after registration
  11262. */
  11263. registerAction(action: IAction): Nullable<IAction>;
  11264. /**
  11265. * Unregisters an action to this action manager
  11266. * @param action defines the action to be unregistered
  11267. * @return a boolean indicating whether the action has been unregistered
  11268. */
  11269. unregisterAction(action: IAction): Boolean;
  11270. /**
  11271. * Process a specific trigger
  11272. * @param trigger defines the trigger to process
  11273. * @param evt defines the event details to be processed
  11274. */
  11275. processTrigger(trigger: number, evt?: IActionEvent): void;
  11276. /** @hidden */
  11277. _getEffectiveTarget(target: any, propertyPath: string): any;
  11278. /** @hidden */
  11279. _getProperty(propertyPath: string): string;
  11280. /**
  11281. * Serialize this manager to a JSON object
  11282. * @param name defines the property name to store this manager
  11283. * @returns a JSON representation of this manager
  11284. */
  11285. serialize(name: string): any;
  11286. /**
  11287. * Creates a new ActionManager from a JSON data
  11288. * @param parsedActions defines the JSON data to read from
  11289. * @param object defines the hosting mesh
  11290. * @param scene defines the hosting scene
  11291. */
  11292. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11293. /**
  11294. * Get a trigger name by index
  11295. * @param trigger defines the trigger index
  11296. * @returns a trigger name
  11297. */
  11298. static GetTriggerName(trigger: number): string;
  11299. }
  11300. }
  11301. declare module "babylonjs/Culling/ray" {
  11302. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11303. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11305. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11306. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11307. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11308. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11309. import { Plane } from "babylonjs/Maths/math.plane";
  11310. /**
  11311. * Class representing a ray with position and direction
  11312. */
  11313. export class Ray {
  11314. /** origin point */
  11315. origin: Vector3;
  11316. /** direction */
  11317. direction: Vector3;
  11318. /** length of the ray */
  11319. length: number;
  11320. private static readonly TmpVector3;
  11321. private _tmpRay;
  11322. /**
  11323. * Creates a new ray
  11324. * @param origin origin point
  11325. * @param direction direction
  11326. * @param length length of the ray
  11327. */
  11328. constructor(
  11329. /** origin point */
  11330. origin: Vector3,
  11331. /** direction */
  11332. direction: Vector3,
  11333. /** length of the ray */
  11334. length?: number);
  11335. /**
  11336. * Checks if the ray intersects a box
  11337. * @param minimum bound of the box
  11338. * @param maximum bound of the box
  11339. * @param intersectionTreshold extra extend to be added to the box in all direction
  11340. * @returns if the box was hit
  11341. */
  11342. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11343. /**
  11344. * Checks if the ray intersects a box
  11345. * @param box the bounding box to check
  11346. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11347. * @returns if the box was hit
  11348. */
  11349. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11350. /**
  11351. * If the ray hits a sphere
  11352. * @param sphere the bounding sphere to check
  11353. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11354. * @returns true if it hits the sphere
  11355. */
  11356. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11357. /**
  11358. * If the ray hits a triange
  11359. * @param vertex0 triangle vertex
  11360. * @param vertex1 triangle vertex
  11361. * @param vertex2 triangle vertex
  11362. * @returns intersection information if hit
  11363. */
  11364. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11365. /**
  11366. * Checks if ray intersects a plane
  11367. * @param plane the plane to check
  11368. * @returns the distance away it was hit
  11369. */
  11370. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11371. /**
  11372. * Calculate the intercept of a ray on a given axis
  11373. * @param axis to check 'x' | 'y' | 'z'
  11374. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11375. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11376. */
  11377. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11378. /**
  11379. * Checks if ray intersects a mesh
  11380. * @param mesh the mesh to check
  11381. * @param fastCheck if only the bounding box should checked
  11382. * @returns picking info of the intersecton
  11383. */
  11384. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11385. /**
  11386. * Checks if ray intersects a mesh
  11387. * @param meshes the meshes to check
  11388. * @param fastCheck if only the bounding box should checked
  11389. * @param results array to store result in
  11390. * @returns Array of picking infos
  11391. */
  11392. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11393. private _comparePickingInfo;
  11394. private static smallnum;
  11395. private static rayl;
  11396. /**
  11397. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11398. * @param sega the first point of the segment to test the intersection against
  11399. * @param segb the second point of the segment to test the intersection against
  11400. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11401. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11402. */
  11403. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11404. /**
  11405. * Update the ray from viewport position
  11406. * @param x position
  11407. * @param y y position
  11408. * @param viewportWidth viewport width
  11409. * @param viewportHeight viewport height
  11410. * @param world world matrix
  11411. * @param view view matrix
  11412. * @param projection projection matrix
  11413. * @returns this ray updated
  11414. */
  11415. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11416. /**
  11417. * Creates a ray with origin and direction of 0,0,0
  11418. * @returns the new ray
  11419. */
  11420. static Zero(): Ray;
  11421. /**
  11422. * Creates a new ray from screen space and viewport
  11423. * @param x position
  11424. * @param y y position
  11425. * @param viewportWidth viewport width
  11426. * @param viewportHeight viewport height
  11427. * @param world world matrix
  11428. * @param view view matrix
  11429. * @param projection projection matrix
  11430. * @returns new ray
  11431. */
  11432. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11433. /**
  11434. * 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
  11435. * transformed to the given world matrix.
  11436. * @param origin The origin point
  11437. * @param end The end point
  11438. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11439. * @returns the new ray
  11440. */
  11441. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11442. /**
  11443. * Transforms a ray by a matrix
  11444. * @param ray ray to transform
  11445. * @param matrix matrix to apply
  11446. * @returns the resulting new ray
  11447. */
  11448. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11449. /**
  11450. * Transforms a ray by a matrix
  11451. * @param ray ray to transform
  11452. * @param matrix matrix to apply
  11453. * @param result ray to store result in
  11454. */
  11455. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11456. /**
  11457. * Unproject a ray from screen space to object space
  11458. * @param sourceX defines the screen space x coordinate to use
  11459. * @param sourceY defines the screen space y coordinate to use
  11460. * @param viewportWidth defines the current width of the viewport
  11461. * @param viewportHeight defines the current height of the viewport
  11462. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11463. * @param view defines the view matrix to use
  11464. * @param projection defines the projection matrix to use
  11465. */
  11466. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11467. }
  11468. /**
  11469. * Type used to define predicate used to select faces when a mesh intersection is detected
  11470. */
  11471. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11472. module "babylonjs/scene" {
  11473. interface Scene {
  11474. /** @hidden */
  11475. _tempPickingRay: Nullable<Ray>;
  11476. /** @hidden */
  11477. _cachedRayForTransform: Ray;
  11478. /** @hidden */
  11479. _pickWithRayInverseMatrix: Matrix;
  11480. /** @hidden */
  11481. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11482. /** @hidden */
  11483. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11484. }
  11485. }
  11486. }
  11487. declare module "babylonjs/sceneComponent" {
  11488. import { Scene } from "babylonjs/scene";
  11489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11490. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11491. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11492. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11493. import { Nullable } from "babylonjs/types";
  11494. import { Camera } from "babylonjs/Cameras/camera";
  11495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11496. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11497. import { AbstractScene } from "babylonjs/abstractScene";
  11498. import { Mesh } from "babylonjs/Meshes/mesh";
  11499. /**
  11500. * Groups all the scene component constants in one place to ease maintenance.
  11501. * @hidden
  11502. */
  11503. export class SceneComponentConstants {
  11504. static readonly NAME_EFFECTLAYER: string;
  11505. static readonly NAME_LAYER: string;
  11506. static readonly NAME_LENSFLARESYSTEM: string;
  11507. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11508. static readonly NAME_PARTICLESYSTEM: string;
  11509. static readonly NAME_GAMEPAD: string;
  11510. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11511. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11512. static readonly NAME_DEPTHRENDERER: string;
  11513. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11514. static readonly NAME_SPRITE: string;
  11515. static readonly NAME_OUTLINERENDERER: string;
  11516. static readonly NAME_PROCEDURALTEXTURE: string;
  11517. static readonly NAME_SHADOWGENERATOR: string;
  11518. static readonly NAME_OCTREE: string;
  11519. static readonly NAME_PHYSICSENGINE: string;
  11520. static readonly NAME_AUDIO: string;
  11521. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11522. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11523. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11524. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11525. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11526. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11527. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11528. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11529. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11530. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11531. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11532. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11533. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11534. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11535. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11536. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11537. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11538. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11539. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11540. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11541. static readonly STEP_AFTERRENDER_AUDIO: number;
  11542. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11543. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11544. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11545. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11546. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11547. static readonly STEP_POINTERMOVE_SPRITE: number;
  11548. static readonly STEP_POINTERDOWN_SPRITE: number;
  11549. static readonly STEP_POINTERUP_SPRITE: number;
  11550. }
  11551. /**
  11552. * This represents a scene component.
  11553. *
  11554. * This is used to decouple the dependency the scene is having on the different workloads like
  11555. * layers, post processes...
  11556. */
  11557. export interface ISceneComponent {
  11558. /**
  11559. * The name of the component. Each component must have a unique name.
  11560. */
  11561. name: string;
  11562. /**
  11563. * The scene the component belongs to.
  11564. */
  11565. scene: Scene;
  11566. /**
  11567. * Register the component to one instance of a scene.
  11568. */
  11569. register(): void;
  11570. /**
  11571. * Rebuilds the elements related to this component in case of
  11572. * context lost for instance.
  11573. */
  11574. rebuild(): void;
  11575. /**
  11576. * Disposes the component and the associated ressources.
  11577. */
  11578. dispose(): void;
  11579. }
  11580. /**
  11581. * This represents a SERIALIZABLE scene component.
  11582. *
  11583. * This extends Scene Component to add Serialization methods on top.
  11584. */
  11585. export interface ISceneSerializableComponent extends ISceneComponent {
  11586. /**
  11587. * Adds all the elements from the container to the scene
  11588. * @param container the container holding the elements
  11589. */
  11590. addFromContainer(container: AbstractScene): void;
  11591. /**
  11592. * Removes all the elements in the container from the scene
  11593. * @param container contains the elements to remove
  11594. * @param dispose if the removed element should be disposed (default: false)
  11595. */
  11596. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11597. /**
  11598. * Serializes the component data to the specified json object
  11599. * @param serializationObject The object to serialize to
  11600. */
  11601. serialize(serializationObject: any): void;
  11602. }
  11603. /**
  11604. * Strong typing of a Mesh related stage step action
  11605. */
  11606. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11607. /**
  11608. * Strong typing of a Evaluate Sub Mesh related stage step action
  11609. */
  11610. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11611. /**
  11612. * Strong typing of a Active Mesh related stage step action
  11613. */
  11614. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11615. /**
  11616. * Strong typing of a Camera related stage step action
  11617. */
  11618. export type CameraStageAction = (camera: Camera) => void;
  11619. /**
  11620. * Strong typing of a Camera Frame buffer related stage step action
  11621. */
  11622. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11623. /**
  11624. * Strong typing of a Render Target related stage step action
  11625. */
  11626. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11627. /**
  11628. * Strong typing of a RenderingGroup related stage step action
  11629. */
  11630. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11631. /**
  11632. * Strong typing of a Mesh Render related stage step action
  11633. */
  11634. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11635. /**
  11636. * Strong typing of a simple stage step action
  11637. */
  11638. export type SimpleStageAction = () => void;
  11639. /**
  11640. * Strong typing of a render target action.
  11641. */
  11642. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11643. /**
  11644. * Strong typing of a pointer move action.
  11645. */
  11646. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11647. /**
  11648. * Strong typing of a pointer up/down action.
  11649. */
  11650. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11651. /**
  11652. * Representation of a stage in the scene (Basically a list of ordered steps)
  11653. * @hidden
  11654. */
  11655. export class Stage<T extends Function> extends Array<{
  11656. index: number;
  11657. component: ISceneComponent;
  11658. action: T;
  11659. }> {
  11660. /**
  11661. * Hide ctor from the rest of the world.
  11662. * @param items The items to add.
  11663. */
  11664. private constructor();
  11665. /**
  11666. * Creates a new Stage.
  11667. * @returns A new instance of a Stage
  11668. */
  11669. static Create<T extends Function>(): Stage<T>;
  11670. /**
  11671. * Registers a step in an ordered way in the targeted stage.
  11672. * @param index Defines the position to register the step in
  11673. * @param component Defines the component attached to the step
  11674. * @param action Defines the action to launch during the step
  11675. */
  11676. registerStep(index: number, component: ISceneComponent, action: T): void;
  11677. /**
  11678. * Clears all the steps from the stage.
  11679. */
  11680. clear(): void;
  11681. }
  11682. }
  11683. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11684. import { Nullable } from "babylonjs/types";
  11685. import { Observable } from "babylonjs/Misc/observable";
  11686. import { Scene } from "babylonjs/scene";
  11687. import { Sprite } from "babylonjs/Sprites/sprite";
  11688. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11689. import { Ray } from "babylonjs/Culling/ray";
  11690. import { Camera } from "babylonjs/Cameras/camera";
  11691. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11692. import { ISceneComponent } from "babylonjs/sceneComponent";
  11693. module "babylonjs/scene" {
  11694. interface Scene {
  11695. /** @hidden */
  11696. _pointerOverSprite: Nullable<Sprite>;
  11697. /** @hidden */
  11698. _pickedDownSprite: Nullable<Sprite>;
  11699. /** @hidden */
  11700. _tempSpritePickingRay: Nullable<Ray>;
  11701. /**
  11702. * All of the sprite managers added to this scene
  11703. * @see http://doc.babylonjs.com/babylon101/sprites
  11704. */
  11705. spriteManagers: Array<ISpriteManager>;
  11706. /**
  11707. * An event triggered when sprites rendering is about to start
  11708. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11709. */
  11710. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11711. /**
  11712. * An event triggered when sprites rendering is done
  11713. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11714. */
  11715. onAfterSpritesRenderingObservable: Observable<Scene>;
  11716. /** @hidden */
  11717. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11718. /** Launch a ray to try to pick a sprite in the scene
  11719. * @param x position on screen
  11720. * @param y position on screen
  11721. * @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
  11722. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11723. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11724. * @returns a PickingInfo
  11725. */
  11726. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11727. /** Use the given ray to pick a sprite in the scene
  11728. * @param ray The ray (in world space) to use to pick meshes
  11729. * @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
  11730. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11731. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11732. * @returns a PickingInfo
  11733. */
  11734. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11735. /** @hidden */
  11736. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11737. /** Launch a ray to try to pick sprites in the scene
  11738. * @param x position on screen
  11739. * @param y position on screen
  11740. * @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
  11741. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11742. * @returns a PickingInfo array
  11743. */
  11744. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11745. /** Use the given ray to pick sprites in the scene
  11746. * @param ray The ray (in world space) to use to pick meshes
  11747. * @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
  11748. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11749. * @returns a PickingInfo array
  11750. */
  11751. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11752. /**
  11753. * Force the sprite under the pointer
  11754. * @param sprite defines the sprite to use
  11755. */
  11756. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11757. /**
  11758. * Gets the sprite under the pointer
  11759. * @returns a Sprite or null if no sprite is under the pointer
  11760. */
  11761. getPointerOverSprite(): Nullable<Sprite>;
  11762. }
  11763. }
  11764. /**
  11765. * Defines the sprite scene component responsible to manage sprites
  11766. * in a given scene.
  11767. */
  11768. export class SpriteSceneComponent implements ISceneComponent {
  11769. /**
  11770. * The component name helpfull to identify the component in the list of scene components.
  11771. */
  11772. readonly name: string;
  11773. /**
  11774. * The scene the component belongs to.
  11775. */
  11776. scene: Scene;
  11777. /** @hidden */
  11778. private _spritePredicate;
  11779. /**
  11780. * Creates a new instance of the component for the given scene
  11781. * @param scene Defines the scene to register the component in
  11782. */
  11783. constructor(scene: Scene);
  11784. /**
  11785. * Registers the component in a given scene
  11786. */
  11787. register(): void;
  11788. /**
  11789. * Rebuilds the elements related to this component in case of
  11790. * context lost for instance.
  11791. */
  11792. rebuild(): void;
  11793. /**
  11794. * Disposes the component and the associated ressources.
  11795. */
  11796. dispose(): void;
  11797. private _pickSpriteButKeepRay;
  11798. private _pointerMove;
  11799. private _pointerDown;
  11800. private _pointerUp;
  11801. }
  11802. }
  11803. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11804. /** @hidden */
  11805. export var fogFragmentDeclaration: {
  11806. name: string;
  11807. shader: string;
  11808. };
  11809. }
  11810. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11811. /** @hidden */
  11812. export var fogFragment: {
  11813. name: string;
  11814. shader: string;
  11815. };
  11816. }
  11817. declare module "babylonjs/Shaders/sprites.fragment" {
  11818. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11819. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11820. /** @hidden */
  11821. export var spritesPixelShader: {
  11822. name: string;
  11823. shader: string;
  11824. };
  11825. }
  11826. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11827. /** @hidden */
  11828. export var fogVertexDeclaration: {
  11829. name: string;
  11830. shader: string;
  11831. };
  11832. }
  11833. declare module "babylonjs/Shaders/sprites.vertex" {
  11834. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11835. /** @hidden */
  11836. export var spritesVertexShader: {
  11837. name: string;
  11838. shader: string;
  11839. };
  11840. }
  11841. declare module "babylonjs/Sprites/spriteManager" {
  11842. import { IDisposable, Scene } from "babylonjs/scene";
  11843. import { Nullable } from "babylonjs/types";
  11844. import { Observable } from "babylonjs/Misc/observable";
  11845. import { Sprite } from "babylonjs/Sprites/sprite";
  11846. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11847. import { Camera } from "babylonjs/Cameras/camera";
  11848. import { Texture } from "babylonjs/Materials/Textures/texture";
  11849. import "babylonjs/Shaders/sprites.fragment";
  11850. import "babylonjs/Shaders/sprites.vertex";
  11851. import { Ray } from "babylonjs/Culling/ray";
  11852. /**
  11853. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11854. */
  11855. export interface ISpriteManager extends IDisposable {
  11856. /**
  11857. * Restricts the camera to viewing objects with the same layerMask.
  11858. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11859. */
  11860. layerMask: number;
  11861. /**
  11862. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11863. */
  11864. isPickable: boolean;
  11865. /**
  11866. * Specifies the rendering group id for this mesh (0 by default)
  11867. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11868. */
  11869. renderingGroupId: number;
  11870. /**
  11871. * Defines the list of sprites managed by the manager.
  11872. */
  11873. sprites: Array<Sprite>;
  11874. /**
  11875. * Tests the intersection of a sprite with a specific ray.
  11876. * @param ray The ray we are sending to test the collision
  11877. * @param camera The camera space we are sending rays in
  11878. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11879. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11880. * @returns picking info or null.
  11881. */
  11882. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11883. /**
  11884. * Intersects the sprites with a ray
  11885. * @param ray defines the ray to intersect with
  11886. * @param camera defines the current active camera
  11887. * @param predicate defines a predicate used to select candidate sprites
  11888. * @returns null if no hit or a PickingInfo array
  11889. */
  11890. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11891. /**
  11892. * Renders the list of sprites on screen.
  11893. */
  11894. render(): void;
  11895. }
  11896. /**
  11897. * Class used to manage multiple sprites on the same spritesheet
  11898. * @see http://doc.babylonjs.com/babylon101/sprites
  11899. */
  11900. export class SpriteManager implements ISpriteManager {
  11901. /** defines the manager's name */
  11902. name: string;
  11903. /** Gets the list of sprites */
  11904. sprites: Sprite[];
  11905. /** Gets or sets the rendering group id (0 by default) */
  11906. renderingGroupId: number;
  11907. /** Gets or sets camera layer mask */
  11908. layerMask: number;
  11909. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11910. fogEnabled: boolean;
  11911. /** Gets or sets a boolean indicating if the sprites are pickable */
  11912. isPickable: boolean;
  11913. /** Defines the default width of a cell in the spritesheet */
  11914. cellWidth: number;
  11915. /** Defines the default height of a cell in the spritesheet */
  11916. cellHeight: number;
  11917. /** Associative array from JSON sprite data file */
  11918. private _cellData;
  11919. /** Array of sprite names from JSON sprite data file */
  11920. private _spriteMap;
  11921. /** True when packed cell data from JSON file is ready*/
  11922. private _packedAndReady;
  11923. /**
  11924. * An event triggered when the manager is disposed.
  11925. */
  11926. onDisposeObservable: Observable<SpriteManager>;
  11927. private _onDisposeObserver;
  11928. /**
  11929. * Callback called when the manager is disposed
  11930. */
  11931. set onDispose(callback: () => void);
  11932. private _capacity;
  11933. private _fromPacked;
  11934. private _spriteTexture;
  11935. private _epsilon;
  11936. private _scene;
  11937. private _vertexData;
  11938. private _buffer;
  11939. private _vertexBuffers;
  11940. private _indexBuffer;
  11941. private _effectBase;
  11942. private _effectFog;
  11943. /**
  11944. * Gets or sets the spritesheet texture
  11945. */
  11946. get texture(): Texture;
  11947. set texture(value: Texture);
  11948. /**
  11949. * Creates a new sprite manager
  11950. * @param name defines the manager's name
  11951. * @param imgUrl defines the sprite sheet url
  11952. * @param capacity defines the maximum allowed number of sprites
  11953. * @param cellSize defines the size of a sprite cell
  11954. * @param scene defines the hosting scene
  11955. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11956. * @param samplingMode defines the smapling mode to use with spritesheet
  11957. * @param fromPacked set to false; do not alter
  11958. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11959. */
  11960. constructor(
  11961. /** defines the manager's name */
  11962. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11963. private _makePacked;
  11964. private _appendSpriteVertex;
  11965. /**
  11966. * Intersects the sprites with a ray
  11967. * @param ray defines the ray to intersect with
  11968. * @param camera defines the current active camera
  11969. * @param predicate defines a predicate used to select candidate sprites
  11970. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11971. * @returns null if no hit or a PickingInfo
  11972. */
  11973. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11974. /**
  11975. * Intersects the sprites with a ray
  11976. * @param ray defines the ray to intersect with
  11977. * @param camera defines the current active camera
  11978. * @param predicate defines a predicate used to select candidate sprites
  11979. * @returns null if no hit or a PickingInfo array
  11980. */
  11981. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11982. /**
  11983. * Render all child sprites
  11984. */
  11985. render(): void;
  11986. /**
  11987. * Release associated resources
  11988. */
  11989. dispose(): void;
  11990. }
  11991. }
  11992. declare module "babylonjs/Sprites/sprite" {
  11993. import { Vector3 } from "babylonjs/Maths/math.vector";
  11994. import { Nullable } from "babylonjs/types";
  11995. import { ActionManager } from "babylonjs/Actions/actionManager";
  11996. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11997. import { Color4 } from "babylonjs/Maths/math.color";
  11998. /**
  11999. * Class used to represent a sprite
  12000. * @see http://doc.babylonjs.com/babylon101/sprites
  12001. */
  12002. export class Sprite {
  12003. /** defines the name */
  12004. name: string;
  12005. /** Gets or sets the current world position */
  12006. position: Vector3;
  12007. /** Gets or sets the main color */
  12008. color: Color4;
  12009. /** Gets or sets the width */
  12010. width: number;
  12011. /** Gets or sets the height */
  12012. height: number;
  12013. /** Gets or sets rotation angle */
  12014. angle: number;
  12015. /** Gets or sets the cell index in the sprite sheet */
  12016. cellIndex: number;
  12017. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12018. cellRef: string;
  12019. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12020. invertU: number;
  12021. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12022. invertV: number;
  12023. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12024. disposeWhenFinishedAnimating: boolean;
  12025. /** Gets the list of attached animations */
  12026. animations: Animation[];
  12027. /** Gets or sets a boolean indicating if the sprite can be picked */
  12028. isPickable: boolean;
  12029. /**
  12030. * Gets or sets the associated action manager
  12031. */
  12032. actionManager: Nullable<ActionManager>;
  12033. private _animationStarted;
  12034. private _loopAnimation;
  12035. private _fromIndex;
  12036. private _toIndex;
  12037. private _delay;
  12038. private _direction;
  12039. private _manager;
  12040. private _time;
  12041. private _onAnimationEnd;
  12042. /**
  12043. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12044. */
  12045. isVisible: boolean;
  12046. /**
  12047. * Gets or sets the sprite size
  12048. */
  12049. get size(): number;
  12050. set size(value: number);
  12051. /**
  12052. * Creates a new Sprite
  12053. * @param name defines the name
  12054. * @param manager defines the manager
  12055. */
  12056. constructor(
  12057. /** defines the name */
  12058. name: string, manager: ISpriteManager);
  12059. /**
  12060. * Starts an animation
  12061. * @param from defines the initial key
  12062. * @param to defines the end key
  12063. * @param loop defines if the animation must loop
  12064. * @param delay defines the start delay (in ms)
  12065. * @param onAnimationEnd defines a callback to call when animation ends
  12066. */
  12067. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12068. /** Stops current animation (if any) */
  12069. stopAnimation(): void;
  12070. /** @hidden */
  12071. _animate(deltaTime: number): void;
  12072. /** Release associated resources */
  12073. dispose(): void;
  12074. }
  12075. }
  12076. declare module "babylonjs/Collisions/pickingInfo" {
  12077. import { Nullable } from "babylonjs/types";
  12078. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12080. import { Sprite } from "babylonjs/Sprites/sprite";
  12081. import { Ray } from "babylonjs/Culling/ray";
  12082. /**
  12083. * Information about the result of picking within a scene
  12084. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12085. */
  12086. export class PickingInfo {
  12087. /** @hidden */
  12088. _pickingUnavailable: boolean;
  12089. /**
  12090. * If the pick collided with an object
  12091. */
  12092. hit: boolean;
  12093. /**
  12094. * Distance away where the pick collided
  12095. */
  12096. distance: number;
  12097. /**
  12098. * The location of pick collision
  12099. */
  12100. pickedPoint: Nullable<Vector3>;
  12101. /**
  12102. * The mesh corresponding the the pick collision
  12103. */
  12104. pickedMesh: Nullable<AbstractMesh>;
  12105. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12106. bu: number;
  12107. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12108. bv: number;
  12109. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12110. faceId: number;
  12111. /** Id of the the submesh that was picked */
  12112. subMeshId: number;
  12113. /** If a sprite was picked, this will be the sprite the pick collided with */
  12114. pickedSprite: Nullable<Sprite>;
  12115. /**
  12116. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12117. */
  12118. originMesh: Nullable<AbstractMesh>;
  12119. /**
  12120. * The ray that was used to perform the picking.
  12121. */
  12122. ray: Nullable<Ray>;
  12123. /**
  12124. * Gets the normal correspodning to the face the pick collided with
  12125. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12126. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12127. * @returns The normal correspodning to the face the pick collided with
  12128. */
  12129. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12130. /**
  12131. * Gets the texture coordinates of where the pick occured
  12132. * @returns the vector containing the coordnates of the texture
  12133. */
  12134. getTextureCoordinates(): Nullable<Vector2>;
  12135. }
  12136. }
  12137. declare module "babylonjs/Events/pointerEvents" {
  12138. import { Nullable } from "babylonjs/types";
  12139. import { Vector2 } from "babylonjs/Maths/math.vector";
  12140. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12141. import { Ray } from "babylonjs/Culling/ray";
  12142. /**
  12143. * Gather the list of pointer event types as constants.
  12144. */
  12145. export class PointerEventTypes {
  12146. /**
  12147. * 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.
  12148. */
  12149. static readonly POINTERDOWN: number;
  12150. /**
  12151. * The pointerup event is fired when a pointer is no longer active.
  12152. */
  12153. static readonly POINTERUP: number;
  12154. /**
  12155. * The pointermove event is fired when a pointer changes coordinates.
  12156. */
  12157. static readonly POINTERMOVE: number;
  12158. /**
  12159. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12160. */
  12161. static readonly POINTERWHEEL: number;
  12162. /**
  12163. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12164. */
  12165. static readonly POINTERPICK: number;
  12166. /**
  12167. * The pointertap event is fired when a the object has been touched and released without drag.
  12168. */
  12169. static readonly POINTERTAP: number;
  12170. /**
  12171. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12172. */
  12173. static readonly POINTERDOUBLETAP: number;
  12174. }
  12175. /**
  12176. * Base class of pointer info types.
  12177. */
  12178. export class PointerInfoBase {
  12179. /**
  12180. * Defines the type of event (PointerEventTypes)
  12181. */
  12182. type: number;
  12183. /**
  12184. * Defines the related dom event
  12185. */
  12186. event: PointerEvent | MouseWheelEvent;
  12187. /**
  12188. * Instantiates the base class of pointers info.
  12189. * @param type Defines the type of event (PointerEventTypes)
  12190. * @param event Defines the related dom event
  12191. */
  12192. constructor(
  12193. /**
  12194. * Defines the type of event (PointerEventTypes)
  12195. */
  12196. type: number,
  12197. /**
  12198. * Defines the related dom event
  12199. */
  12200. event: PointerEvent | MouseWheelEvent);
  12201. }
  12202. /**
  12203. * This class is used to store pointer related info for the onPrePointerObservable event.
  12204. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12205. */
  12206. export class PointerInfoPre extends PointerInfoBase {
  12207. /**
  12208. * Ray from a pointer if availible (eg. 6dof controller)
  12209. */
  12210. ray: Nullable<Ray>;
  12211. /**
  12212. * Defines the local position of the pointer on the canvas.
  12213. */
  12214. localPosition: Vector2;
  12215. /**
  12216. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12217. */
  12218. skipOnPointerObservable: boolean;
  12219. /**
  12220. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12221. * @param type Defines the type of event (PointerEventTypes)
  12222. * @param event Defines the related dom event
  12223. * @param localX Defines the local x coordinates of the pointer when the event occured
  12224. * @param localY Defines the local y coordinates of the pointer when the event occured
  12225. */
  12226. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12227. }
  12228. /**
  12229. * This type contains all the data related to a pointer event in Babylon.js.
  12230. * 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.
  12231. */
  12232. export class PointerInfo extends PointerInfoBase {
  12233. /**
  12234. * Defines the picking info associated to the info (if any)\
  12235. */
  12236. pickInfo: Nullable<PickingInfo>;
  12237. /**
  12238. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12239. * @param type Defines the type of event (PointerEventTypes)
  12240. * @param event Defines the related dom event
  12241. * @param pickInfo Defines the picking info associated to the info (if any)\
  12242. */
  12243. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12244. /**
  12245. * Defines the picking info associated to the info (if any)\
  12246. */
  12247. pickInfo: Nullable<PickingInfo>);
  12248. }
  12249. /**
  12250. * Data relating to a touch event on the screen.
  12251. */
  12252. export interface PointerTouch {
  12253. /**
  12254. * X coordinate of touch.
  12255. */
  12256. x: number;
  12257. /**
  12258. * Y coordinate of touch.
  12259. */
  12260. y: number;
  12261. /**
  12262. * Id of touch. Unique for each finger.
  12263. */
  12264. pointerId: number;
  12265. /**
  12266. * Event type passed from DOM.
  12267. */
  12268. type: any;
  12269. }
  12270. }
  12271. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12272. import { Observable } from "babylonjs/Misc/observable";
  12273. import { Nullable } from "babylonjs/types";
  12274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12276. /**
  12277. * Manage the mouse inputs to control the movement of a free camera.
  12278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12279. */
  12280. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12281. /**
  12282. * Define if touch is enabled in the mouse input
  12283. */
  12284. touchEnabled: boolean;
  12285. /**
  12286. * Defines the camera the input is attached to.
  12287. */
  12288. camera: FreeCamera;
  12289. /**
  12290. * Defines the buttons associated with the input to handle camera move.
  12291. */
  12292. buttons: number[];
  12293. /**
  12294. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12295. */
  12296. angularSensibility: number;
  12297. private _pointerInput;
  12298. private _onMouseMove;
  12299. private _observer;
  12300. private previousPosition;
  12301. /**
  12302. * Observable for when a pointer move event occurs containing the move offset
  12303. */
  12304. onPointerMovedObservable: Observable<{
  12305. offsetX: number;
  12306. offsetY: number;
  12307. }>;
  12308. /**
  12309. * @hidden
  12310. * If the camera should be rotated automatically based on pointer movement
  12311. */
  12312. _allowCameraRotation: boolean;
  12313. /**
  12314. * Manage the mouse inputs to control the movement of a free camera.
  12315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12316. * @param touchEnabled Defines if touch is enabled or not
  12317. */
  12318. constructor(
  12319. /**
  12320. * Define if touch is enabled in the mouse input
  12321. */
  12322. touchEnabled?: boolean);
  12323. /**
  12324. * Attach the input controls to a specific dom element to get the input from.
  12325. * @param element Defines the element the controls should be listened from
  12326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12327. */
  12328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12329. /**
  12330. * Called on JS contextmenu event.
  12331. * Override this method to provide functionality.
  12332. */
  12333. protected onContextMenu(evt: PointerEvent): void;
  12334. /**
  12335. * Detach the current controls from the specified dom element.
  12336. * @param element Defines the element to stop listening the inputs from
  12337. */
  12338. detachControl(element: Nullable<HTMLElement>): void;
  12339. /**
  12340. * Gets the class name of the current intput.
  12341. * @returns the class name
  12342. */
  12343. getClassName(): string;
  12344. /**
  12345. * Get the friendly name associated with the input class.
  12346. * @returns the input friendly name
  12347. */
  12348. getSimpleName(): string;
  12349. }
  12350. }
  12351. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12352. import { Nullable } from "babylonjs/types";
  12353. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12354. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12355. /**
  12356. * Manage the touch inputs to control the movement of a free camera.
  12357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12358. */
  12359. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12360. /**
  12361. * Defines the camera the input is attached to.
  12362. */
  12363. camera: FreeCamera;
  12364. /**
  12365. * Defines the touch sensibility for rotation.
  12366. * The higher the faster.
  12367. */
  12368. touchAngularSensibility: number;
  12369. /**
  12370. * Defines the touch sensibility for move.
  12371. * The higher the faster.
  12372. */
  12373. touchMoveSensibility: number;
  12374. private _offsetX;
  12375. private _offsetY;
  12376. private _pointerPressed;
  12377. private _pointerInput;
  12378. private _observer;
  12379. private _onLostFocus;
  12380. /**
  12381. * Attach the input controls to a specific dom element to get the input from.
  12382. * @param element Defines the element the controls should be listened from
  12383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12384. */
  12385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12386. /**
  12387. * Detach the current controls from the specified dom element.
  12388. * @param element Defines the element to stop listening the inputs from
  12389. */
  12390. detachControl(element: Nullable<HTMLElement>): void;
  12391. /**
  12392. * Update the current camera state depending on the inputs that have been used this frame.
  12393. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12394. */
  12395. checkInputs(): void;
  12396. /**
  12397. * Gets the class name of the current intput.
  12398. * @returns the class name
  12399. */
  12400. getClassName(): string;
  12401. /**
  12402. * Get the friendly name associated with the input class.
  12403. * @returns the input friendly name
  12404. */
  12405. getSimpleName(): string;
  12406. }
  12407. }
  12408. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12409. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12410. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12411. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12412. import { Nullable } from "babylonjs/types";
  12413. /**
  12414. * Default Inputs manager for the FreeCamera.
  12415. * It groups all the default supported inputs for ease of use.
  12416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12417. */
  12418. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12419. /**
  12420. * @hidden
  12421. */
  12422. _mouseInput: Nullable<FreeCameraMouseInput>;
  12423. /**
  12424. * Instantiates a new FreeCameraInputsManager.
  12425. * @param camera Defines the camera the inputs belong to
  12426. */
  12427. constructor(camera: FreeCamera);
  12428. /**
  12429. * Add keyboard input support to the input manager.
  12430. * @returns the current input manager
  12431. */
  12432. addKeyboard(): FreeCameraInputsManager;
  12433. /**
  12434. * Add mouse input support to the input manager.
  12435. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12436. * @returns the current input manager
  12437. */
  12438. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12439. /**
  12440. * Removes the mouse input support from the manager
  12441. * @returns the current input manager
  12442. */
  12443. removeMouse(): FreeCameraInputsManager;
  12444. /**
  12445. * Add touch input support to the input manager.
  12446. * @returns the current input manager
  12447. */
  12448. addTouch(): FreeCameraInputsManager;
  12449. /**
  12450. * Remove all attached input methods from a camera
  12451. */
  12452. clear(): void;
  12453. }
  12454. }
  12455. declare module "babylonjs/Cameras/freeCamera" {
  12456. import { Vector3 } from "babylonjs/Maths/math.vector";
  12457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12458. import { Scene } from "babylonjs/scene";
  12459. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12460. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12461. /**
  12462. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12463. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12464. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12465. */
  12466. export class FreeCamera extends TargetCamera {
  12467. /**
  12468. * Define the collision ellipsoid of the camera.
  12469. * This is helpful to simulate a camera body like the player body around the camera
  12470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12471. */
  12472. ellipsoid: Vector3;
  12473. /**
  12474. * Define an offset for the position of the ellipsoid around the camera.
  12475. * This can be helpful to determine the center of the body near the gravity center of the body
  12476. * instead of its head.
  12477. */
  12478. ellipsoidOffset: Vector3;
  12479. /**
  12480. * Enable or disable collisions of the camera with the rest of the scene objects.
  12481. */
  12482. checkCollisions: boolean;
  12483. /**
  12484. * Enable or disable gravity on the camera.
  12485. */
  12486. applyGravity: boolean;
  12487. /**
  12488. * Define the input manager associated to the camera.
  12489. */
  12490. inputs: FreeCameraInputsManager;
  12491. /**
  12492. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12493. * Higher values reduce sensitivity.
  12494. */
  12495. get angularSensibility(): number;
  12496. /**
  12497. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12498. * Higher values reduce sensitivity.
  12499. */
  12500. set angularSensibility(value: number);
  12501. /**
  12502. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12503. */
  12504. get keysUp(): number[];
  12505. set keysUp(value: number[]);
  12506. /**
  12507. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12508. */
  12509. get keysDown(): number[];
  12510. set keysDown(value: number[]);
  12511. /**
  12512. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12513. */
  12514. get keysLeft(): number[];
  12515. set keysLeft(value: number[]);
  12516. /**
  12517. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12518. */
  12519. get keysRight(): number[];
  12520. set keysRight(value: number[]);
  12521. /**
  12522. * Event raised when the camera collide with a mesh in the scene.
  12523. */
  12524. onCollide: (collidedMesh: AbstractMesh) => void;
  12525. private _collider;
  12526. private _needMoveForGravity;
  12527. private _oldPosition;
  12528. private _diffPosition;
  12529. private _newPosition;
  12530. /** @hidden */
  12531. _localDirection: Vector3;
  12532. /** @hidden */
  12533. _transformedDirection: Vector3;
  12534. /**
  12535. * Instantiates a Free Camera.
  12536. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12537. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12538. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12539. * @param name Define the name of the camera in the scene
  12540. * @param position Define the start position of the camera in the scene
  12541. * @param scene Define the scene the camera belongs to
  12542. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12543. */
  12544. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12545. /**
  12546. * Attached controls to the current camera.
  12547. * @param element Defines the element the controls should be listened from
  12548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12549. */
  12550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12551. /**
  12552. * Detach the current controls from the camera.
  12553. * The camera will stop reacting to inputs.
  12554. * @param element Defines the element to stop listening the inputs from
  12555. */
  12556. detachControl(element: HTMLElement): void;
  12557. private _collisionMask;
  12558. /**
  12559. * Define a collision mask to limit the list of object the camera can collide with
  12560. */
  12561. get collisionMask(): number;
  12562. set collisionMask(mask: number);
  12563. /** @hidden */
  12564. _collideWithWorld(displacement: Vector3): void;
  12565. private _onCollisionPositionChange;
  12566. /** @hidden */
  12567. _checkInputs(): void;
  12568. /** @hidden */
  12569. _decideIfNeedsToMove(): boolean;
  12570. /** @hidden */
  12571. _updatePosition(): void;
  12572. /**
  12573. * Destroy the camera and release the current resources hold by it.
  12574. */
  12575. dispose(): void;
  12576. /**
  12577. * Gets the current object class name.
  12578. * @return the class name
  12579. */
  12580. getClassName(): string;
  12581. }
  12582. }
  12583. declare module "babylonjs/Gamepads/gamepad" {
  12584. import { Observable } from "babylonjs/Misc/observable";
  12585. /**
  12586. * Represents a gamepad control stick position
  12587. */
  12588. export class StickValues {
  12589. /**
  12590. * The x component of the control stick
  12591. */
  12592. x: number;
  12593. /**
  12594. * The y component of the control stick
  12595. */
  12596. y: number;
  12597. /**
  12598. * Initializes the gamepad x and y control stick values
  12599. * @param x The x component of the gamepad control stick value
  12600. * @param y The y component of the gamepad control stick value
  12601. */
  12602. constructor(
  12603. /**
  12604. * The x component of the control stick
  12605. */
  12606. x: number,
  12607. /**
  12608. * The y component of the control stick
  12609. */
  12610. y: number);
  12611. }
  12612. /**
  12613. * An interface which manages callbacks for gamepad button changes
  12614. */
  12615. export interface GamepadButtonChanges {
  12616. /**
  12617. * Called when a gamepad has been changed
  12618. */
  12619. changed: boolean;
  12620. /**
  12621. * Called when a gamepad press event has been triggered
  12622. */
  12623. pressChanged: boolean;
  12624. /**
  12625. * Called when a touch event has been triggered
  12626. */
  12627. touchChanged: boolean;
  12628. /**
  12629. * Called when a value has changed
  12630. */
  12631. valueChanged: boolean;
  12632. }
  12633. /**
  12634. * Represents a gamepad
  12635. */
  12636. export class Gamepad {
  12637. /**
  12638. * The id of the gamepad
  12639. */
  12640. id: string;
  12641. /**
  12642. * The index of the gamepad
  12643. */
  12644. index: number;
  12645. /**
  12646. * The browser gamepad
  12647. */
  12648. browserGamepad: any;
  12649. /**
  12650. * Specifies what type of gamepad this represents
  12651. */
  12652. type: number;
  12653. private _leftStick;
  12654. private _rightStick;
  12655. /** @hidden */
  12656. _isConnected: boolean;
  12657. private _leftStickAxisX;
  12658. private _leftStickAxisY;
  12659. private _rightStickAxisX;
  12660. private _rightStickAxisY;
  12661. /**
  12662. * Triggered when the left control stick has been changed
  12663. */
  12664. private _onleftstickchanged;
  12665. /**
  12666. * Triggered when the right control stick has been changed
  12667. */
  12668. private _onrightstickchanged;
  12669. /**
  12670. * Represents a gamepad controller
  12671. */
  12672. static GAMEPAD: number;
  12673. /**
  12674. * Represents a generic controller
  12675. */
  12676. static GENERIC: number;
  12677. /**
  12678. * Represents an XBox controller
  12679. */
  12680. static XBOX: number;
  12681. /**
  12682. * Represents a pose-enabled controller
  12683. */
  12684. static POSE_ENABLED: number;
  12685. /**
  12686. * Represents an Dual Shock controller
  12687. */
  12688. static DUALSHOCK: number;
  12689. /**
  12690. * Specifies whether the left control stick should be Y-inverted
  12691. */
  12692. protected _invertLeftStickY: boolean;
  12693. /**
  12694. * Specifies if the gamepad has been connected
  12695. */
  12696. get isConnected(): boolean;
  12697. /**
  12698. * Initializes the gamepad
  12699. * @param id The id of the gamepad
  12700. * @param index The index of the gamepad
  12701. * @param browserGamepad The browser gamepad
  12702. * @param leftStickX The x component of the left joystick
  12703. * @param leftStickY The y component of the left joystick
  12704. * @param rightStickX The x component of the right joystick
  12705. * @param rightStickY The y component of the right joystick
  12706. */
  12707. constructor(
  12708. /**
  12709. * The id of the gamepad
  12710. */
  12711. id: string,
  12712. /**
  12713. * The index of the gamepad
  12714. */
  12715. index: number,
  12716. /**
  12717. * The browser gamepad
  12718. */
  12719. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12720. /**
  12721. * Callback triggered when the left joystick has changed
  12722. * @param callback
  12723. */
  12724. onleftstickchanged(callback: (values: StickValues) => void): void;
  12725. /**
  12726. * Callback triggered when the right joystick has changed
  12727. * @param callback
  12728. */
  12729. onrightstickchanged(callback: (values: StickValues) => void): void;
  12730. /**
  12731. * Gets the left joystick
  12732. */
  12733. get leftStick(): StickValues;
  12734. /**
  12735. * Sets the left joystick values
  12736. */
  12737. set leftStick(newValues: StickValues);
  12738. /**
  12739. * Gets the right joystick
  12740. */
  12741. get rightStick(): StickValues;
  12742. /**
  12743. * Sets the right joystick value
  12744. */
  12745. set rightStick(newValues: StickValues);
  12746. /**
  12747. * Updates the gamepad joystick positions
  12748. */
  12749. update(): void;
  12750. /**
  12751. * Disposes the gamepad
  12752. */
  12753. dispose(): void;
  12754. }
  12755. /**
  12756. * Represents a generic gamepad
  12757. */
  12758. export class GenericPad extends Gamepad {
  12759. private _buttons;
  12760. private _onbuttondown;
  12761. private _onbuttonup;
  12762. /**
  12763. * Observable triggered when a button has been pressed
  12764. */
  12765. onButtonDownObservable: Observable<number>;
  12766. /**
  12767. * Observable triggered when a button has been released
  12768. */
  12769. onButtonUpObservable: Observable<number>;
  12770. /**
  12771. * Callback triggered when a button has been pressed
  12772. * @param callback Called when a button has been pressed
  12773. */
  12774. onbuttondown(callback: (buttonPressed: number) => void): void;
  12775. /**
  12776. * Callback triggered when a button has been released
  12777. * @param callback Called when a button has been released
  12778. */
  12779. onbuttonup(callback: (buttonReleased: number) => void): void;
  12780. /**
  12781. * Initializes the generic gamepad
  12782. * @param id The id of the generic gamepad
  12783. * @param index The index of the generic gamepad
  12784. * @param browserGamepad The browser gamepad
  12785. */
  12786. constructor(id: string, index: number, browserGamepad: any);
  12787. private _setButtonValue;
  12788. /**
  12789. * Updates the generic gamepad
  12790. */
  12791. update(): void;
  12792. /**
  12793. * Disposes the generic gamepad
  12794. */
  12795. dispose(): void;
  12796. }
  12797. }
  12798. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12799. import { Nullable } from "babylonjs/types";
  12800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12801. import { Scene } from "babylonjs/scene";
  12802. module "babylonjs/Engines/engine" {
  12803. interface Engine {
  12804. /**
  12805. * Creates a raw texture
  12806. * @param data defines the data to store in the texture
  12807. * @param width defines the width of the texture
  12808. * @param height defines the height of the texture
  12809. * @param format defines the format of the data
  12810. * @param generateMipMaps defines if the engine should generate the mip levels
  12811. * @param invertY defines if data must be stored with Y axis inverted
  12812. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12813. * @param compression defines the compression used (null by default)
  12814. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12815. * @returns the raw texture inside an InternalTexture
  12816. */
  12817. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12818. /**
  12819. * Update a raw texture
  12820. * @param texture defines the texture to update
  12821. * @param data defines the data to store in the texture
  12822. * @param format defines the format of the data
  12823. * @param invertY defines if data must be stored with Y axis inverted
  12824. */
  12825. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12826. /**
  12827. * Update a raw texture
  12828. * @param texture defines the texture to update
  12829. * @param data defines the data to store in the texture
  12830. * @param format defines the format of the data
  12831. * @param invertY defines if data must be stored with Y axis inverted
  12832. * @param compression defines the compression used (null by default)
  12833. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12834. */
  12835. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12836. /**
  12837. * Creates a new raw cube texture
  12838. * @param data defines the array of data to use to create each face
  12839. * @param size defines the size of the textures
  12840. * @param format defines the format of the data
  12841. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12842. * @param generateMipMaps defines if the engine should generate the mip levels
  12843. * @param invertY defines if data must be stored with Y axis inverted
  12844. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12845. * @param compression defines the compression used (null by default)
  12846. * @returns the cube texture as an InternalTexture
  12847. */
  12848. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12849. /**
  12850. * Update a raw cube texture
  12851. * @param texture defines the texture to udpdate
  12852. * @param data defines the data to store
  12853. * @param format defines the data format
  12854. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12855. * @param invertY defines if data must be stored with Y axis inverted
  12856. */
  12857. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12858. /**
  12859. * Update a raw cube texture
  12860. * @param texture defines the texture to udpdate
  12861. * @param data defines the data to store
  12862. * @param format defines the data format
  12863. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12864. * @param invertY defines if data must be stored with Y axis inverted
  12865. * @param compression defines the compression used (null by default)
  12866. */
  12867. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12868. /**
  12869. * Update a raw cube texture
  12870. * @param texture defines the texture to udpdate
  12871. * @param data defines the data to store
  12872. * @param format defines the data format
  12873. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12874. * @param invertY defines if data must be stored with Y axis inverted
  12875. * @param compression defines the compression used (null by default)
  12876. * @param level defines which level of the texture to update
  12877. */
  12878. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12879. /**
  12880. * Creates a new raw cube texture from a specified url
  12881. * @param url defines the url where the data is located
  12882. * @param scene defines the current scene
  12883. * @param size defines the size of the textures
  12884. * @param format defines the format of the data
  12885. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12886. * @param noMipmap defines if the engine should avoid generating the mip levels
  12887. * @param callback defines a callback used to extract texture data from loaded data
  12888. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12889. * @param onLoad defines a callback called when texture is loaded
  12890. * @param onError defines a callback called if there is an error
  12891. * @returns the cube texture as an InternalTexture
  12892. */
  12893. 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;
  12894. /**
  12895. * Creates a new raw cube texture from a specified url
  12896. * @param url defines the url where the data is located
  12897. * @param scene defines the current scene
  12898. * @param size defines the size of the textures
  12899. * @param format defines the format of the data
  12900. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12901. * @param noMipmap defines if the engine should avoid generating the mip levels
  12902. * @param callback defines a callback used to extract texture data from loaded data
  12903. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12904. * @param onLoad defines a callback called when texture is loaded
  12905. * @param onError defines a callback called if there is an error
  12906. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12907. * @param invertY defines if data must be stored with Y axis inverted
  12908. * @returns the cube texture as an InternalTexture
  12909. */
  12910. 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;
  12911. /**
  12912. * Creates a new raw 3D texture
  12913. * @param data defines the data used to create the texture
  12914. * @param width defines the width of the texture
  12915. * @param height defines the height of the texture
  12916. * @param depth defines the depth of the texture
  12917. * @param format defines the format of the texture
  12918. * @param generateMipMaps defines if the engine must generate mip levels
  12919. * @param invertY defines if data must be stored with Y axis inverted
  12920. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12921. * @param compression defines the compressed used (can be null)
  12922. * @param textureType defines the compressed used (can be null)
  12923. * @returns a new raw 3D texture (stored in an InternalTexture)
  12924. */
  12925. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12926. /**
  12927. * Update a raw 3D texture
  12928. * @param texture defines the texture to update
  12929. * @param data defines the data to store
  12930. * @param format defines the data format
  12931. * @param invertY defines if data must be stored with Y axis inverted
  12932. */
  12933. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12934. /**
  12935. * Update a raw 3D texture
  12936. * @param texture defines the texture to update
  12937. * @param data defines the data to store
  12938. * @param format defines the data format
  12939. * @param invertY defines if data must be stored with Y axis inverted
  12940. * @param compression defines the used compression (can be null)
  12941. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12942. */
  12943. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12944. /**
  12945. * Creates a new raw 2D array texture
  12946. * @param data defines the data used to create the texture
  12947. * @param width defines the width of the texture
  12948. * @param height defines the height of the texture
  12949. * @param depth defines the number of layers of the texture
  12950. * @param format defines the format of the texture
  12951. * @param generateMipMaps defines if the engine must generate mip levels
  12952. * @param invertY defines if data must be stored with Y axis inverted
  12953. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12954. * @param compression defines the compressed used (can be null)
  12955. * @param textureType defines the compressed used (can be null)
  12956. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12957. */
  12958. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12959. /**
  12960. * Update a raw 2D array texture
  12961. * @param texture defines the texture to update
  12962. * @param data defines the data to store
  12963. * @param format defines the data format
  12964. * @param invertY defines if data must be stored with Y axis inverted
  12965. */
  12966. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12967. /**
  12968. * Update a raw 2D array texture
  12969. * @param texture defines the texture to update
  12970. * @param data defines the data to store
  12971. * @param format defines the data format
  12972. * @param invertY defines if data must be stored with Y axis inverted
  12973. * @param compression defines the used compression (can be null)
  12974. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12975. */
  12976. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12977. }
  12978. }
  12979. }
  12980. declare module "babylonjs/Materials/Textures/rawTexture" {
  12981. import { Scene } from "babylonjs/scene";
  12982. import { Texture } from "babylonjs/Materials/Textures/texture";
  12983. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12984. /**
  12985. * Raw texture can help creating a texture directly from an array of data.
  12986. * This can be super useful if you either get the data from an uncompressed source or
  12987. * if you wish to create your texture pixel by pixel.
  12988. */
  12989. export class RawTexture extends Texture {
  12990. /**
  12991. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12992. */
  12993. format: number;
  12994. private _engine;
  12995. /**
  12996. * Instantiates a new RawTexture.
  12997. * Raw texture can help creating a texture directly from an array of data.
  12998. * This can be super useful if you either get the data from an uncompressed source or
  12999. * if you wish to create your texture pixel by pixel.
  13000. * @param data define the array of data to use to create the texture
  13001. * @param width define the width of the texture
  13002. * @param height define the height of the texture
  13003. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13004. * @param scene define the scene the texture belongs to
  13005. * @param generateMipMaps define whether mip maps should be generated or not
  13006. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13007. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13008. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13009. */
  13010. constructor(data: ArrayBufferView, width: number, height: number,
  13011. /**
  13012. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13013. */
  13014. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13015. /**
  13016. * Updates the texture underlying data.
  13017. * @param data Define the new data of the texture
  13018. */
  13019. update(data: ArrayBufferView): void;
  13020. /**
  13021. * Creates a luminance texture from some data.
  13022. * @param data Define the texture data
  13023. * @param width Define the width of the texture
  13024. * @param height Define the height of the texture
  13025. * @param scene Define the scene the texture belongs to
  13026. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13027. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13028. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13029. * @returns the luminance texture
  13030. */
  13031. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13032. /**
  13033. * Creates a luminance alpha texture from some data.
  13034. * @param data Define the texture data
  13035. * @param width Define the width of the texture
  13036. * @param height Define the height of the texture
  13037. * @param scene Define the scene the texture belongs to
  13038. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13039. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13040. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13041. * @returns the luminance alpha texture
  13042. */
  13043. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13044. /**
  13045. * Creates an alpha texture from some data.
  13046. * @param data Define the texture data
  13047. * @param width Define the width of the texture
  13048. * @param height Define the height of the texture
  13049. * @param scene Define the scene the texture belongs to
  13050. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13051. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13052. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13053. * @returns the alpha texture
  13054. */
  13055. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13056. /**
  13057. * Creates a RGB texture from some data.
  13058. * @param data Define the texture data
  13059. * @param width Define the width of the texture
  13060. * @param height Define the height of the texture
  13061. * @param scene Define the scene the texture belongs to
  13062. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13063. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13064. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13065. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13066. * @returns the RGB alpha texture
  13067. */
  13068. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13069. /**
  13070. * Creates a RGBA texture from some data.
  13071. * @param data Define the texture data
  13072. * @param width Define the width of the texture
  13073. * @param height Define the height of the texture
  13074. * @param scene Define the scene the texture belongs to
  13075. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13076. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13077. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13078. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13079. * @returns the RGBA texture
  13080. */
  13081. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13082. /**
  13083. * Creates a R texture from some data.
  13084. * @param data Define the texture data
  13085. * @param width Define the width of the texture
  13086. * @param height Define the height of the texture
  13087. * @param scene Define the scene the texture belongs to
  13088. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13089. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13090. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13091. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13092. * @returns the R texture
  13093. */
  13094. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13095. }
  13096. }
  13097. declare module "babylonjs/Maths/math.size" {
  13098. /**
  13099. * Interface for the size containing width and height
  13100. */
  13101. export interface ISize {
  13102. /**
  13103. * Width
  13104. */
  13105. width: number;
  13106. /**
  13107. * Heighht
  13108. */
  13109. height: number;
  13110. }
  13111. /**
  13112. * Size containing widht and height
  13113. */
  13114. export class Size implements ISize {
  13115. /**
  13116. * Width
  13117. */
  13118. width: number;
  13119. /**
  13120. * Height
  13121. */
  13122. height: number;
  13123. /**
  13124. * Creates a Size object from the given width and height (floats).
  13125. * @param width width of the new size
  13126. * @param height height of the new size
  13127. */
  13128. constructor(width: number, height: number);
  13129. /**
  13130. * Returns a string with the Size width and height
  13131. * @returns a string with the Size width and height
  13132. */
  13133. toString(): string;
  13134. /**
  13135. * "Size"
  13136. * @returns the string "Size"
  13137. */
  13138. getClassName(): string;
  13139. /**
  13140. * Returns the Size hash code.
  13141. * @returns a hash code for a unique width and height
  13142. */
  13143. getHashCode(): number;
  13144. /**
  13145. * Updates the current size from the given one.
  13146. * @param src the given size
  13147. */
  13148. copyFrom(src: Size): void;
  13149. /**
  13150. * Updates in place the current Size from the given floats.
  13151. * @param width width of the new size
  13152. * @param height height of the new size
  13153. * @returns the updated Size.
  13154. */
  13155. copyFromFloats(width: number, height: number): Size;
  13156. /**
  13157. * Updates in place the current Size from the given floats.
  13158. * @param width width to set
  13159. * @param height height to set
  13160. * @returns the updated Size.
  13161. */
  13162. set(width: number, height: number): Size;
  13163. /**
  13164. * Multiplies the width and height by numbers
  13165. * @param w factor to multiple the width by
  13166. * @param h factor to multiple the height by
  13167. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13168. */
  13169. multiplyByFloats(w: number, h: number): Size;
  13170. /**
  13171. * Clones the size
  13172. * @returns a new Size copied from the given one.
  13173. */
  13174. clone(): Size;
  13175. /**
  13176. * True if the current Size and the given one width and height are strictly equal.
  13177. * @param other the other size to compare against
  13178. * @returns True if the current Size and the given one width and height are strictly equal.
  13179. */
  13180. equals(other: Size): boolean;
  13181. /**
  13182. * The surface of the Size : width * height (float).
  13183. */
  13184. get surface(): number;
  13185. /**
  13186. * Create a new size of zero
  13187. * @returns a new Size set to (0.0, 0.0)
  13188. */
  13189. static Zero(): Size;
  13190. /**
  13191. * Sums the width and height of two sizes
  13192. * @param otherSize size to add to this size
  13193. * @returns a new Size set as the addition result of the current Size and the given one.
  13194. */
  13195. add(otherSize: Size): Size;
  13196. /**
  13197. * Subtracts the width and height of two
  13198. * @param otherSize size to subtract to this size
  13199. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13200. */
  13201. subtract(otherSize: Size): Size;
  13202. /**
  13203. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13204. * @param start starting size to lerp between
  13205. * @param end end size to lerp between
  13206. * @param amount amount to lerp between the start and end values
  13207. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13208. */
  13209. static Lerp(start: Size, end: Size, amount: number): Size;
  13210. }
  13211. }
  13212. declare module "babylonjs/Animations/runtimeAnimation" {
  13213. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13214. import { Animatable } from "babylonjs/Animations/animatable";
  13215. import { Scene } from "babylonjs/scene";
  13216. /**
  13217. * Defines a runtime animation
  13218. */
  13219. export class RuntimeAnimation {
  13220. private _events;
  13221. /**
  13222. * The current frame of the runtime animation
  13223. */
  13224. private _currentFrame;
  13225. /**
  13226. * The animation used by the runtime animation
  13227. */
  13228. private _animation;
  13229. /**
  13230. * The target of the runtime animation
  13231. */
  13232. private _target;
  13233. /**
  13234. * The initiating animatable
  13235. */
  13236. private _host;
  13237. /**
  13238. * The original value of the runtime animation
  13239. */
  13240. private _originalValue;
  13241. /**
  13242. * The original blend value of the runtime animation
  13243. */
  13244. private _originalBlendValue;
  13245. /**
  13246. * The offsets cache of the runtime animation
  13247. */
  13248. private _offsetsCache;
  13249. /**
  13250. * The high limits cache of the runtime animation
  13251. */
  13252. private _highLimitsCache;
  13253. /**
  13254. * Specifies if the runtime animation has been stopped
  13255. */
  13256. private _stopped;
  13257. /**
  13258. * The blending factor of the runtime animation
  13259. */
  13260. private _blendingFactor;
  13261. /**
  13262. * The BabylonJS scene
  13263. */
  13264. private _scene;
  13265. /**
  13266. * The current value of the runtime animation
  13267. */
  13268. private _currentValue;
  13269. /** @hidden */
  13270. _animationState: _IAnimationState;
  13271. /**
  13272. * The active target of the runtime animation
  13273. */
  13274. private _activeTargets;
  13275. private _currentActiveTarget;
  13276. private _directTarget;
  13277. /**
  13278. * The target path of the runtime animation
  13279. */
  13280. private _targetPath;
  13281. /**
  13282. * The weight of the runtime animation
  13283. */
  13284. private _weight;
  13285. /**
  13286. * The ratio offset of the runtime animation
  13287. */
  13288. private _ratioOffset;
  13289. /**
  13290. * The previous delay of the runtime animation
  13291. */
  13292. private _previousDelay;
  13293. /**
  13294. * The previous ratio of the runtime animation
  13295. */
  13296. private _previousRatio;
  13297. private _enableBlending;
  13298. private _keys;
  13299. private _minFrame;
  13300. private _maxFrame;
  13301. private _minValue;
  13302. private _maxValue;
  13303. private _targetIsArray;
  13304. /**
  13305. * Gets the current frame of the runtime animation
  13306. */
  13307. get currentFrame(): number;
  13308. /**
  13309. * Gets the weight of the runtime animation
  13310. */
  13311. get weight(): number;
  13312. /**
  13313. * Gets the current value of the runtime animation
  13314. */
  13315. get currentValue(): any;
  13316. /**
  13317. * Gets the target path of the runtime animation
  13318. */
  13319. get targetPath(): string;
  13320. /**
  13321. * Gets the actual target of the runtime animation
  13322. */
  13323. get target(): any;
  13324. /** @hidden */
  13325. _onLoop: () => void;
  13326. /**
  13327. * Create a new RuntimeAnimation object
  13328. * @param target defines the target of the animation
  13329. * @param animation defines the source animation object
  13330. * @param scene defines the hosting scene
  13331. * @param host defines the initiating Animatable
  13332. */
  13333. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13334. private _preparePath;
  13335. /**
  13336. * Gets the animation from the runtime animation
  13337. */
  13338. get animation(): Animation;
  13339. /**
  13340. * Resets the runtime animation to the beginning
  13341. * @param restoreOriginal defines whether to restore the target property to the original value
  13342. */
  13343. reset(restoreOriginal?: boolean): void;
  13344. /**
  13345. * Specifies if the runtime animation is stopped
  13346. * @returns Boolean specifying if the runtime animation is stopped
  13347. */
  13348. isStopped(): boolean;
  13349. /**
  13350. * Disposes of the runtime animation
  13351. */
  13352. dispose(): void;
  13353. /**
  13354. * Apply the interpolated value to the target
  13355. * @param currentValue defines the value computed by the animation
  13356. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13357. */
  13358. setValue(currentValue: any, weight: number): void;
  13359. private _getOriginalValues;
  13360. private _setValue;
  13361. /**
  13362. * Gets the loop pmode of the runtime animation
  13363. * @returns Loop Mode
  13364. */
  13365. private _getCorrectLoopMode;
  13366. /**
  13367. * Move the current animation to a given frame
  13368. * @param frame defines the frame to move to
  13369. */
  13370. goToFrame(frame: number): void;
  13371. /**
  13372. * @hidden Internal use only
  13373. */
  13374. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13375. /**
  13376. * Execute the current animation
  13377. * @param delay defines the delay to add to the current frame
  13378. * @param from defines the lower bound of the animation range
  13379. * @param to defines the upper bound of the animation range
  13380. * @param loop defines if the current animation must loop
  13381. * @param speedRatio defines the current speed ratio
  13382. * @param weight defines the weight of the animation (default is -1 so no weight)
  13383. * @param onLoop optional callback called when animation loops
  13384. * @returns a boolean indicating if the animation is running
  13385. */
  13386. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13387. }
  13388. }
  13389. declare module "babylonjs/Animations/animatable" {
  13390. import { Animation } from "babylonjs/Animations/animation";
  13391. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13392. import { Nullable } from "babylonjs/types";
  13393. import { Observable } from "babylonjs/Misc/observable";
  13394. import { Scene } from "babylonjs/scene";
  13395. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13396. import { Node } from "babylonjs/node";
  13397. /**
  13398. * Class used to store an actual running animation
  13399. */
  13400. export class Animatable {
  13401. /** defines the target object */
  13402. target: any;
  13403. /** defines the starting frame number (default is 0) */
  13404. fromFrame: number;
  13405. /** defines the ending frame number (default is 100) */
  13406. toFrame: number;
  13407. /** defines if the animation must loop (default is false) */
  13408. loopAnimation: boolean;
  13409. /** defines a callback to call when animation ends if it is not looping */
  13410. onAnimationEnd?: (() => void) | null | undefined;
  13411. /** defines a callback to call when animation loops */
  13412. onAnimationLoop?: (() => void) | null | undefined;
  13413. private _localDelayOffset;
  13414. private _pausedDelay;
  13415. private _runtimeAnimations;
  13416. private _paused;
  13417. private _scene;
  13418. private _speedRatio;
  13419. private _weight;
  13420. private _syncRoot;
  13421. /**
  13422. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13423. * This will only apply for non looping animation (default is true)
  13424. */
  13425. disposeOnEnd: boolean;
  13426. /**
  13427. * Gets a boolean indicating if the animation has started
  13428. */
  13429. animationStarted: boolean;
  13430. /**
  13431. * Observer raised when the animation ends
  13432. */
  13433. onAnimationEndObservable: Observable<Animatable>;
  13434. /**
  13435. * Observer raised when the animation loops
  13436. */
  13437. onAnimationLoopObservable: Observable<Animatable>;
  13438. /**
  13439. * Gets the root Animatable used to synchronize and normalize animations
  13440. */
  13441. get syncRoot(): Nullable<Animatable>;
  13442. /**
  13443. * Gets the current frame of the first RuntimeAnimation
  13444. * Used to synchronize Animatables
  13445. */
  13446. get masterFrame(): number;
  13447. /**
  13448. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13449. */
  13450. get weight(): number;
  13451. set weight(value: number);
  13452. /**
  13453. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13454. */
  13455. get speedRatio(): number;
  13456. set speedRatio(value: number);
  13457. /**
  13458. * Creates a new Animatable
  13459. * @param scene defines the hosting scene
  13460. * @param target defines the target object
  13461. * @param fromFrame defines the starting frame number (default is 0)
  13462. * @param toFrame defines the ending frame number (default is 100)
  13463. * @param loopAnimation defines if the animation must loop (default is false)
  13464. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13465. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13466. * @param animations defines a group of animation to add to the new Animatable
  13467. * @param onAnimationLoop defines a callback to call when animation loops
  13468. */
  13469. constructor(scene: Scene,
  13470. /** defines the target object */
  13471. target: any,
  13472. /** defines the starting frame number (default is 0) */
  13473. fromFrame?: number,
  13474. /** defines the ending frame number (default is 100) */
  13475. toFrame?: number,
  13476. /** defines if the animation must loop (default is false) */
  13477. loopAnimation?: boolean, speedRatio?: number,
  13478. /** defines a callback to call when animation ends if it is not looping */
  13479. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13480. /** defines a callback to call when animation loops */
  13481. onAnimationLoop?: (() => void) | null | undefined);
  13482. /**
  13483. * Synchronize and normalize current Animatable with a source Animatable
  13484. * This is useful when using animation weights and when animations are not of the same length
  13485. * @param root defines the root Animatable to synchronize with
  13486. * @returns the current Animatable
  13487. */
  13488. syncWith(root: Animatable): Animatable;
  13489. /**
  13490. * Gets the list of runtime animations
  13491. * @returns an array of RuntimeAnimation
  13492. */
  13493. getAnimations(): RuntimeAnimation[];
  13494. /**
  13495. * Adds more animations to the current animatable
  13496. * @param target defines the target of the animations
  13497. * @param animations defines the new animations to add
  13498. */
  13499. appendAnimations(target: any, animations: Animation[]): void;
  13500. /**
  13501. * Gets the source animation for a specific property
  13502. * @param property defines the propertyu to look for
  13503. * @returns null or the source animation for the given property
  13504. */
  13505. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13506. /**
  13507. * Gets the runtime animation for a specific property
  13508. * @param property defines the propertyu to look for
  13509. * @returns null or the runtime animation for the given property
  13510. */
  13511. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13512. /**
  13513. * Resets the animatable to its original state
  13514. */
  13515. reset(): void;
  13516. /**
  13517. * Allows the animatable to blend with current running animations
  13518. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13519. * @param blendingSpeed defines the blending speed to use
  13520. */
  13521. enableBlending(blendingSpeed: number): void;
  13522. /**
  13523. * Disable animation blending
  13524. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13525. */
  13526. disableBlending(): void;
  13527. /**
  13528. * Jump directly to a given frame
  13529. * @param frame defines the frame to jump to
  13530. */
  13531. goToFrame(frame: number): void;
  13532. /**
  13533. * Pause the animation
  13534. */
  13535. pause(): void;
  13536. /**
  13537. * Restart the animation
  13538. */
  13539. restart(): void;
  13540. private _raiseOnAnimationEnd;
  13541. /**
  13542. * Stop and delete the current animation
  13543. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13544. * @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)
  13545. */
  13546. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13547. /**
  13548. * Wait asynchronously for the animation to end
  13549. * @returns a promise which will be fullfilled when the animation ends
  13550. */
  13551. waitAsync(): Promise<Animatable>;
  13552. /** @hidden */
  13553. _animate(delay: number): boolean;
  13554. }
  13555. module "babylonjs/scene" {
  13556. interface Scene {
  13557. /** @hidden */
  13558. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13559. /** @hidden */
  13560. _processLateAnimationBindingsForMatrices(holder: {
  13561. totalWeight: number;
  13562. animations: RuntimeAnimation[];
  13563. originalValue: Matrix;
  13564. }): any;
  13565. /** @hidden */
  13566. _processLateAnimationBindingsForQuaternions(holder: {
  13567. totalWeight: number;
  13568. animations: RuntimeAnimation[];
  13569. originalValue: Quaternion;
  13570. }, refQuaternion: Quaternion): Quaternion;
  13571. /** @hidden */
  13572. _processLateAnimationBindings(): void;
  13573. /**
  13574. * Will start the animation sequence of a given target
  13575. * @param target defines the target
  13576. * @param from defines from which frame should animation start
  13577. * @param to defines until which frame should animation run.
  13578. * @param weight defines the weight to apply to the animation (1.0 by default)
  13579. * @param loop defines if the animation loops
  13580. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13581. * @param onAnimationEnd defines the function to be executed when the animation ends
  13582. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13583. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13584. * @param onAnimationLoop defines the callback to call when an animation loops
  13585. * @returns the animatable object created for this animation
  13586. */
  13587. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13588. /**
  13589. * Will start the animation sequence of a given target
  13590. * @param target defines the target
  13591. * @param from defines from which frame should animation start
  13592. * @param to defines until which frame should animation run.
  13593. * @param loop defines if the animation loops
  13594. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13595. * @param onAnimationEnd defines the function to be executed when the animation ends
  13596. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13597. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13598. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13599. * @param onAnimationLoop defines the callback to call when an animation loops
  13600. * @returns the animatable object created for this animation
  13601. */
  13602. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13603. /**
  13604. * Will start the animation sequence of a given target and its hierarchy
  13605. * @param target defines the target
  13606. * @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.
  13607. * @param from defines from which frame should animation start
  13608. * @param to defines until which frame should animation run.
  13609. * @param loop defines if the animation loops
  13610. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13611. * @param onAnimationEnd defines the function to be executed when the animation ends
  13612. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13613. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13614. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13615. * @param onAnimationLoop defines the callback to call when an animation loops
  13616. * @returns the list of created animatables
  13617. */
  13618. 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[];
  13619. /**
  13620. * Begin a new animation on a given node
  13621. * @param target defines the target where the animation will take place
  13622. * @param animations defines the list of animations to start
  13623. * @param from defines the initial value
  13624. * @param to defines the final value
  13625. * @param loop defines if you want animation to loop (off by default)
  13626. * @param speedRatio defines the speed ratio to apply to all animations
  13627. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13628. * @param onAnimationLoop defines the callback to call when an animation loops
  13629. * @returns the list of created animatables
  13630. */
  13631. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13632. /**
  13633. * Begin a new animation on a given node and its hierarchy
  13634. * @param target defines the root node where the animation will take place
  13635. * @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.
  13636. * @param animations defines the list of animations to start
  13637. * @param from defines the initial value
  13638. * @param to defines the final value
  13639. * @param loop defines if you want animation to loop (off by default)
  13640. * @param speedRatio defines the speed ratio to apply to all animations
  13641. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13642. * @param onAnimationLoop defines the callback to call when an animation loops
  13643. * @returns the list of animatables created for all nodes
  13644. */
  13645. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13646. /**
  13647. * Gets the animatable associated with a specific target
  13648. * @param target defines the target of the animatable
  13649. * @returns the required animatable if found
  13650. */
  13651. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13652. /**
  13653. * Gets all animatables associated with a given target
  13654. * @param target defines the target to look animatables for
  13655. * @returns an array of Animatables
  13656. */
  13657. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13658. /**
  13659. * Stops and removes all animations that have been applied to the scene
  13660. */
  13661. stopAllAnimations(): void;
  13662. /**
  13663. * Gets the current delta time used by animation engine
  13664. */
  13665. deltaTime: number;
  13666. }
  13667. }
  13668. module "babylonjs/Bones/bone" {
  13669. interface Bone {
  13670. /**
  13671. * Copy an animation range from another bone
  13672. * @param source defines the source bone
  13673. * @param rangeName defines the range name to copy
  13674. * @param frameOffset defines the frame offset
  13675. * @param rescaleAsRequired defines if rescaling must be applied if required
  13676. * @param skelDimensionsRatio defines the scaling ratio
  13677. * @returns true if operation was successful
  13678. */
  13679. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13680. }
  13681. }
  13682. }
  13683. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13684. /**
  13685. * Class used to override all child animations of a given target
  13686. */
  13687. export class AnimationPropertiesOverride {
  13688. /**
  13689. * Gets or sets a value indicating if animation blending must be used
  13690. */
  13691. enableBlending: boolean;
  13692. /**
  13693. * Gets or sets the blending speed to use when enableBlending is true
  13694. */
  13695. blendingSpeed: number;
  13696. /**
  13697. * Gets or sets the default loop mode to use
  13698. */
  13699. loopMode: number;
  13700. }
  13701. }
  13702. declare module "babylonjs/Bones/skeleton" {
  13703. import { Bone } from "babylonjs/Bones/bone";
  13704. import { Observable } from "babylonjs/Misc/observable";
  13705. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13706. import { Scene } from "babylonjs/scene";
  13707. import { Nullable } from "babylonjs/types";
  13708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13709. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13710. import { Animatable } from "babylonjs/Animations/animatable";
  13711. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13712. import { Animation } from "babylonjs/Animations/animation";
  13713. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13714. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13715. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13716. /**
  13717. * Class used to handle skinning animations
  13718. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13719. */
  13720. export class Skeleton implements IAnimatable {
  13721. /** defines the skeleton name */
  13722. name: string;
  13723. /** defines the skeleton Id */
  13724. id: string;
  13725. /**
  13726. * Defines the list of child bones
  13727. */
  13728. bones: Bone[];
  13729. /**
  13730. * Defines an estimate of the dimension of the skeleton at rest
  13731. */
  13732. dimensionsAtRest: Vector3;
  13733. /**
  13734. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13735. */
  13736. needInitialSkinMatrix: boolean;
  13737. /**
  13738. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13739. */
  13740. overrideMesh: Nullable<AbstractMesh>;
  13741. /**
  13742. * Gets the list of animations attached to this skeleton
  13743. */
  13744. animations: Array<Animation>;
  13745. private _scene;
  13746. private _isDirty;
  13747. private _transformMatrices;
  13748. private _transformMatrixTexture;
  13749. private _meshesWithPoseMatrix;
  13750. private _animatables;
  13751. private _identity;
  13752. private _synchronizedWithMesh;
  13753. private _ranges;
  13754. private _lastAbsoluteTransformsUpdateId;
  13755. private _canUseTextureForBones;
  13756. private _uniqueId;
  13757. /** @hidden */
  13758. _numBonesWithLinkedTransformNode: number;
  13759. /** @hidden */
  13760. _hasWaitingData: Nullable<boolean>;
  13761. /**
  13762. * Specifies if the skeleton should be serialized
  13763. */
  13764. doNotSerialize: boolean;
  13765. private _useTextureToStoreBoneMatrices;
  13766. /**
  13767. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13768. * Please note that this option is not available if the hardware does not support it
  13769. */
  13770. get useTextureToStoreBoneMatrices(): boolean;
  13771. set useTextureToStoreBoneMatrices(value: boolean);
  13772. private _animationPropertiesOverride;
  13773. /**
  13774. * Gets or sets the animation properties override
  13775. */
  13776. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13777. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13778. /**
  13779. * List of inspectable custom properties (used by the Inspector)
  13780. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13781. */
  13782. inspectableCustomProperties: IInspectable[];
  13783. /**
  13784. * An observable triggered before computing the skeleton's matrices
  13785. */
  13786. onBeforeComputeObservable: Observable<Skeleton>;
  13787. /**
  13788. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13789. */
  13790. get isUsingTextureForMatrices(): boolean;
  13791. /**
  13792. * Gets the unique ID of this skeleton
  13793. */
  13794. get uniqueId(): number;
  13795. /**
  13796. * Creates a new skeleton
  13797. * @param name defines the skeleton name
  13798. * @param id defines the skeleton Id
  13799. * @param scene defines the hosting scene
  13800. */
  13801. constructor(
  13802. /** defines the skeleton name */
  13803. name: string,
  13804. /** defines the skeleton Id */
  13805. id: string, scene: Scene);
  13806. /**
  13807. * Gets the current object class name.
  13808. * @return the class name
  13809. */
  13810. getClassName(): string;
  13811. /**
  13812. * Returns an array containing the root bones
  13813. * @returns an array containing the root bones
  13814. */
  13815. getChildren(): Array<Bone>;
  13816. /**
  13817. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13818. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13819. * @returns a Float32Array containing matrices data
  13820. */
  13821. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13822. /**
  13823. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13824. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13825. * @returns a raw texture containing the data
  13826. */
  13827. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13828. /**
  13829. * Gets the current hosting scene
  13830. * @returns a scene object
  13831. */
  13832. getScene(): Scene;
  13833. /**
  13834. * Gets a string representing the current skeleton data
  13835. * @param fullDetails defines a boolean indicating if we want a verbose version
  13836. * @returns a string representing the current skeleton data
  13837. */
  13838. toString(fullDetails?: boolean): string;
  13839. /**
  13840. * Get bone's index searching by name
  13841. * @param name defines bone's name to search for
  13842. * @return the indice of the bone. Returns -1 if not found
  13843. */
  13844. getBoneIndexByName(name: string): number;
  13845. /**
  13846. * Creater a new animation range
  13847. * @param name defines the name of the range
  13848. * @param from defines the start key
  13849. * @param to defines the end key
  13850. */
  13851. createAnimationRange(name: string, from: number, to: number): void;
  13852. /**
  13853. * Delete a specific animation range
  13854. * @param name defines the name of the range
  13855. * @param deleteFrames defines if frames must be removed as well
  13856. */
  13857. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13858. /**
  13859. * Gets a specific animation range
  13860. * @param name defines the name of the range to look for
  13861. * @returns the requested animation range or null if not found
  13862. */
  13863. getAnimationRange(name: string): Nullable<AnimationRange>;
  13864. /**
  13865. * Gets the list of all animation ranges defined on this skeleton
  13866. * @returns an array
  13867. */
  13868. getAnimationRanges(): Nullable<AnimationRange>[];
  13869. /**
  13870. * Copy animation range from a source skeleton.
  13871. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13872. * @param source defines the source skeleton
  13873. * @param name defines the name of the range to copy
  13874. * @param rescaleAsRequired defines if rescaling must be applied if required
  13875. * @returns true if operation was successful
  13876. */
  13877. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13878. /**
  13879. * Forces the skeleton to go to rest pose
  13880. */
  13881. returnToRest(): void;
  13882. private _getHighestAnimationFrame;
  13883. /**
  13884. * Begin a specific animation range
  13885. * @param name defines the name of the range to start
  13886. * @param loop defines if looping must be turned on (false by default)
  13887. * @param speedRatio defines the speed ratio to apply (1 by default)
  13888. * @param onAnimationEnd defines a callback which will be called when animation will end
  13889. * @returns a new animatable
  13890. */
  13891. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13892. /** @hidden */
  13893. _markAsDirty(): void;
  13894. /** @hidden */
  13895. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13896. /** @hidden */
  13897. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13898. private _computeTransformMatrices;
  13899. /**
  13900. * Build all resources required to render a skeleton
  13901. */
  13902. prepare(): void;
  13903. /**
  13904. * Gets the list of animatables currently running for this skeleton
  13905. * @returns an array of animatables
  13906. */
  13907. getAnimatables(): IAnimatable[];
  13908. /**
  13909. * Clone the current skeleton
  13910. * @param name defines the name of the new skeleton
  13911. * @param id defines the id of the new skeleton
  13912. * @returns the new skeleton
  13913. */
  13914. clone(name: string, id?: string): Skeleton;
  13915. /**
  13916. * Enable animation blending for this skeleton
  13917. * @param blendingSpeed defines the blending speed to apply
  13918. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13919. */
  13920. enableBlending(blendingSpeed?: number): void;
  13921. /**
  13922. * Releases all resources associated with the current skeleton
  13923. */
  13924. dispose(): void;
  13925. /**
  13926. * Serialize the skeleton in a JSON object
  13927. * @returns a JSON object
  13928. */
  13929. serialize(): any;
  13930. /**
  13931. * Creates a new skeleton from serialized data
  13932. * @param parsedSkeleton defines the serialized data
  13933. * @param scene defines the hosting scene
  13934. * @returns a new skeleton
  13935. */
  13936. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13937. /**
  13938. * Compute all node absolute transforms
  13939. * @param forceUpdate defines if computation must be done even if cache is up to date
  13940. */
  13941. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13942. /**
  13943. * Gets the root pose matrix
  13944. * @returns a matrix
  13945. */
  13946. getPoseMatrix(): Nullable<Matrix>;
  13947. /**
  13948. * Sorts bones per internal index
  13949. */
  13950. sortBones(): void;
  13951. private _sortBones;
  13952. }
  13953. }
  13954. declare module "babylonjs/Bones/bone" {
  13955. import { Skeleton } from "babylonjs/Bones/skeleton";
  13956. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13957. import { Nullable } from "babylonjs/types";
  13958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13959. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13960. import { Node } from "babylonjs/node";
  13961. import { Space } from "babylonjs/Maths/math.axis";
  13962. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13963. /**
  13964. * Class used to store bone information
  13965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13966. */
  13967. export class Bone extends Node {
  13968. /**
  13969. * defines the bone name
  13970. */
  13971. name: string;
  13972. private static _tmpVecs;
  13973. private static _tmpQuat;
  13974. private static _tmpMats;
  13975. /**
  13976. * Gets the list of child bones
  13977. */
  13978. children: Bone[];
  13979. /** Gets the animations associated with this bone */
  13980. animations: import("babylonjs/Animations/animation").Animation[];
  13981. /**
  13982. * Gets or sets bone length
  13983. */
  13984. length: number;
  13985. /**
  13986. * @hidden Internal only
  13987. * Set this value to map this bone to a different index in the transform matrices
  13988. * Set this value to -1 to exclude the bone from the transform matrices
  13989. */
  13990. _index: Nullable<number>;
  13991. private _skeleton;
  13992. private _localMatrix;
  13993. private _restPose;
  13994. private _baseMatrix;
  13995. private _absoluteTransform;
  13996. private _invertedAbsoluteTransform;
  13997. private _parent;
  13998. private _scalingDeterminant;
  13999. private _worldTransform;
  14000. private _localScaling;
  14001. private _localRotation;
  14002. private _localPosition;
  14003. private _needToDecompose;
  14004. private _needToCompose;
  14005. /** @hidden */
  14006. _linkedTransformNode: Nullable<TransformNode>;
  14007. /** @hidden */
  14008. _waitingTransformNodeId: Nullable<string>;
  14009. /** @hidden */
  14010. get _matrix(): Matrix;
  14011. /** @hidden */
  14012. set _matrix(value: Matrix);
  14013. /**
  14014. * Create a new bone
  14015. * @param name defines the bone name
  14016. * @param skeleton defines the parent skeleton
  14017. * @param parentBone defines the parent (can be null if the bone is the root)
  14018. * @param localMatrix defines the local matrix
  14019. * @param restPose defines the rest pose matrix
  14020. * @param baseMatrix defines the base matrix
  14021. * @param index defines index of the bone in the hiearchy
  14022. */
  14023. constructor(
  14024. /**
  14025. * defines the bone name
  14026. */
  14027. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14028. /**
  14029. * Gets the current object class name.
  14030. * @return the class name
  14031. */
  14032. getClassName(): string;
  14033. /**
  14034. * Gets the parent skeleton
  14035. * @returns a skeleton
  14036. */
  14037. getSkeleton(): Skeleton;
  14038. /**
  14039. * Gets parent bone
  14040. * @returns a bone or null if the bone is the root of the bone hierarchy
  14041. */
  14042. getParent(): Nullable<Bone>;
  14043. /**
  14044. * Returns an array containing the root bones
  14045. * @returns an array containing the root bones
  14046. */
  14047. getChildren(): Array<Bone>;
  14048. /**
  14049. * Gets the node index in matrix array generated for rendering
  14050. * @returns the node index
  14051. */
  14052. getIndex(): number;
  14053. /**
  14054. * Sets the parent bone
  14055. * @param parent defines the parent (can be null if the bone is the root)
  14056. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14057. */
  14058. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14059. /**
  14060. * Gets the local matrix
  14061. * @returns a matrix
  14062. */
  14063. getLocalMatrix(): Matrix;
  14064. /**
  14065. * Gets the base matrix (initial matrix which remains unchanged)
  14066. * @returns a matrix
  14067. */
  14068. getBaseMatrix(): Matrix;
  14069. /**
  14070. * Gets the rest pose matrix
  14071. * @returns a matrix
  14072. */
  14073. getRestPose(): Matrix;
  14074. /**
  14075. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14076. */
  14077. getWorldMatrix(): Matrix;
  14078. /**
  14079. * Sets the local matrix to rest pose matrix
  14080. */
  14081. returnToRest(): void;
  14082. /**
  14083. * Gets the inverse of the absolute transform matrix.
  14084. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14085. * @returns a matrix
  14086. */
  14087. getInvertedAbsoluteTransform(): Matrix;
  14088. /**
  14089. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14090. * @returns a matrix
  14091. */
  14092. getAbsoluteTransform(): Matrix;
  14093. /**
  14094. * Links with the given transform node.
  14095. * The local matrix of this bone is copied from the transform node every frame.
  14096. * @param transformNode defines the transform node to link to
  14097. */
  14098. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14099. /**
  14100. * Gets the node used to drive the bone's transformation
  14101. * @returns a transform node or null
  14102. */
  14103. getTransformNode(): Nullable<TransformNode>;
  14104. /** Gets or sets current position (in local space) */
  14105. get position(): Vector3;
  14106. set position(newPosition: Vector3);
  14107. /** Gets or sets current rotation (in local space) */
  14108. get rotation(): Vector3;
  14109. set rotation(newRotation: Vector3);
  14110. /** Gets or sets current rotation quaternion (in local space) */
  14111. get rotationQuaternion(): Quaternion;
  14112. set rotationQuaternion(newRotation: Quaternion);
  14113. /** Gets or sets current scaling (in local space) */
  14114. get scaling(): Vector3;
  14115. set scaling(newScaling: Vector3);
  14116. /**
  14117. * Gets the animation properties override
  14118. */
  14119. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14120. private _decompose;
  14121. private _compose;
  14122. /**
  14123. * Update the base and local matrices
  14124. * @param matrix defines the new base or local matrix
  14125. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14126. * @param updateLocalMatrix defines if the local matrix should be updated
  14127. */
  14128. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14129. /** @hidden */
  14130. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14131. /**
  14132. * Flag the bone as dirty (Forcing it to update everything)
  14133. */
  14134. markAsDirty(): void;
  14135. /** @hidden */
  14136. _markAsDirtyAndCompose(): void;
  14137. private _markAsDirtyAndDecompose;
  14138. /**
  14139. * Translate the bone in local or world space
  14140. * @param vec The amount to translate the bone
  14141. * @param space The space that the translation is in
  14142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14143. */
  14144. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14145. /**
  14146. * Set the postion of the bone in local or world space
  14147. * @param position The position to set the bone
  14148. * @param space The space that the position is in
  14149. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14150. */
  14151. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14152. /**
  14153. * Set the absolute position of the bone (world space)
  14154. * @param position The position to set the bone
  14155. * @param mesh The mesh that this bone is attached to
  14156. */
  14157. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14158. /**
  14159. * Scale the bone on the x, y and z axes (in local space)
  14160. * @param x The amount to scale the bone on the x axis
  14161. * @param y The amount to scale the bone on the y axis
  14162. * @param z The amount to scale the bone on the z axis
  14163. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14164. */
  14165. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14166. /**
  14167. * Set the bone scaling in local space
  14168. * @param scale defines the scaling vector
  14169. */
  14170. setScale(scale: Vector3): void;
  14171. /**
  14172. * Gets the current scaling in local space
  14173. * @returns the current scaling vector
  14174. */
  14175. getScale(): Vector3;
  14176. /**
  14177. * Gets the current scaling in local space and stores it in a target vector
  14178. * @param result defines the target vector
  14179. */
  14180. getScaleToRef(result: Vector3): void;
  14181. /**
  14182. * Set the yaw, pitch, and roll of the bone in local or world space
  14183. * @param yaw The rotation of the bone on the y axis
  14184. * @param pitch The rotation of the bone on the x axis
  14185. * @param roll The rotation of the bone on the z axis
  14186. * @param space The space that the axes of rotation are in
  14187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14188. */
  14189. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14190. /**
  14191. * Add a rotation to the bone on an axis in local or world space
  14192. * @param axis The axis to rotate the bone on
  14193. * @param amount The amount to rotate the bone
  14194. * @param space The space that the axis is in
  14195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14196. */
  14197. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14198. /**
  14199. * Set the rotation of the bone to a particular axis angle in local or world space
  14200. * @param axis The axis to rotate the bone on
  14201. * @param angle The angle that the bone should be rotated to
  14202. * @param space The space that the axis is in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. */
  14205. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14206. /**
  14207. * Set the euler rotation of the bone in local of world space
  14208. * @param rotation The euler rotation that the bone should be set to
  14209. * @param space The space that the rotation is in
  14210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14211. */
  14212. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14213. /**
  14214. * Set the quaternion rotation of the bone in local of world space
  14215. * @param quat The quaternion rotation that the bone should be set to
  14216. * @param space The space that the rotation is in
  14217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14218. */
  14219. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14220. /**
  14221. * Set the rotation matrix of the bone in local of world space
  14222. * @param rotMat The rotation matrix that the bone should be set to
  14223. * @param space The space that the rotation is in
  14224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14225. */
  14226. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14227. private _rotateWithMatrix;
  14228. private _getNegativeRotationToRef;
  14229. /**
  14230. * Get the position of the bone in local or world space
  14231. * @param space The space that the returned position is in
  14232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14233. * @returns The position of the bone
  14234. */
  14235. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14236. /**
  14237. * Copy the position of the bone to a vector3 in local or world space
  14238. * @param space The space that the returned position is in
  14239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14240. * @param result The vector3 to copy the position to
  14241. */
  14242. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14243. /**
  14244. * Get the absolute position of the bone (world space)
  14245. * @param mesh The mesh that this bone is attached to
  14246. * @returns The absolute position of the bone
  14247. */
  14248. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14249. /**
  14250. * Copy the absolute position of the bone (world space) to the result param
  14251. * @param mesh The mesh that this bone is attached to
  14252. * @param result The vector3 to copy the absolute position to
  14253. */
  14254. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14255. /**
  14256. * Compute the absolute transforms of this bone and its children
  14257. */
  14258. computeAbsoluteTransforms(): void;
  14259. /**
  14260. * Get the world direction from an axis that is in the local space of the bone
  14261. * @param localAxis The local direction that is used to compute the world direction
  14262. * @param mesh The mesh that this bone is attached to
  14263. * @returns The world direction
  14264. */
  14265. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14266. /**
  14267. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14268. * @param localAxis The local direction that is used to compute the world direction
  14269. * @param mesh The mesh that this bone is attached to
  14270. * @param result The vector3 that the world direction will be copied to
  14271. */
  14272. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14273. /**
  14274. * Get the euler rotation of the bone in local or world space
  14275. * @param space The space that the rotation should be in
  14276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14277. * @returns The euler rotation
  14278. */
  14279. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14280. /**
  14281. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14282. * @param space The space that the rotation should be in
  14283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14284. * @param result The vector3 that the rotation should be copied to
  14285. */
  14286. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14287. /**
  14288. * Get the quaternion rotation of the bone in either local or world space
  14289. * @param space The space that the rotation should be in
  14290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14291. * @returns The quaternion rotation
  14292. */
  14293. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14294. /**
  14295. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14296. * @param space The space that the rotation should be in
  14297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14298. * @param result The quaternion that the rotation should be copied to
  14299. */
  14300. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14301. /**
  14302. * Get the rotation matrix of the bone in local or world space
  14303. * @param space The space that the rotation should be in
  14304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14305. * @returns The rotation matrix
  14306. */
  14307. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14308. /**
  14309. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14310. * @param space The space that the rotation should be in
  14311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14312. * @param result The quaternion that the rotation should be copied to
  14313. */
  14314. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14315. /**
  14316. * Get the world position of a point that is in the local space of the bone
  14317. * @param position The local position
  14318. * @param mesh The mesh that this bone is attached to
  14319. * @returns The world position
  14320. */
  14321. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14322. /**
  14323. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14324. * @param position The local position
  14325. * @param mesh The mesh that this bone is attached to
  14326. * @param result The vector3 that the world position should be copied to
  14327. */
  14328. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14329. /**
  14330. * Get the local position of a point that is in world space
  14331. * @param position The world position
  14332. * @param mesh The mesh that this bone is attached to
  14333. * @returns The local position
  14334. */
  14335. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14336. /**
  14337. * Get the local position of a point that is in world space and copy it to the result param
  14338. * @param position The world position
  14339. * @param mesh The mesh that this bone is attached to
  14340. * @param result The vector3 that the local position should be copied to
  14341. */
  14342. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14343. }
  14344. }
  14345. declare module "babylonjs/Meshes/transformNode" {
  14346. import { DeepImmutable } from "babylonjs/types";
  14347. import { Observable } from "babylonjs/Misc/observable";
  14348. import { Nullable } from "babylonjs/types";
  14349. import { Camera } from "babylonjs/Cameras/camera";
  14350. import { Scene } from "babylonjs/scene";
  14351. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14352. import { Node } from "babylonjs/node";
  14353. import { Bone } from "babylonjs/Bones/bone";
  14354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14355. import { Space } from "babylonjs/Maths/math.axis";
  14356. /**
  14357. * 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.
  14358. * @see https://doc.babylonjs.com/how_to/transformnode
  14359. */
  14360. export class TransformNode extends Node {
  14361. /**
  14362. * Object will not rotate to face the camera
  14363. */
  14364. static BILLBOARDMODE_NONE: number;
  14365. /**
  14366. * Object will rotate to face the camera but only on the x axis
  14367. */
  14368. static BILLBOARDMODE_X: number;
  14369. /**
  14370. * Object will rotate to face the camera but only on the y axis
  14371. */
  14372. static BILLBOARDMODE_Y: number;
  14373. /**
  14374. * Object will rotate to face the camera but only on the z axis
  14375. */
  14376. static BILLBOARDMODE_Z: number;
  14377. /**
  14378. * Object will rotate to face the camera
  14379. */
  14380. static BILLBOARDMODE_ALL: number;
  14381. /**
  14382. * Object will rotate to face the camera's position instead of orientation
  14383. */
  14384. static BILLBOARDMODE_USE_POSITION: number;
  14385. private _forward;
  14386. private _forwardInverted;
  14387. private _up;
  14388. private _right;
  14389. private _rightInverted;
  14390. private _position;
  14391. private _rotation;
  14392. private _rotationQuaternion;
  14393. protected _scaling: Vector3;
  14394. protected _isDirty: boolean;
  14395. private _transformToBoneReferal;
  14396. private _isAbsoluteSynced;
  14397. private _billboardMode;
  14398. /**
  14399. * Gets or sets the billboard mode. Default is 0.
  14400. *
  14401. * | Value | Type | Description |
  14402. * | --- | --- | --- |
  14403. * | 0 | BILLBOARDMODE_NONE | |
  14404. * | 1 | BILLBOARDMODE_X | |
  14405. * | 2 | BILLBOARDMODE_Y | |
  14406. * | 4 | BILLBOARDMODE_Z | |
  14407. * | 7 | BILLBOARDMODE_ALL | |
  14408. *
  14409. */
  14410. get billboardMode(): number;
  14411. set billboardMode(value: number);
  14412. private _preserveParentRotationForBillboard;
  14413. /**
  14414. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14415. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14416. */
  14417. get preserveParentRotationForBillboard(): boolean;
  14418. set preserveParentRotationForBillboard(value: boolean);
  14419. /**
  14420. * 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
  14421. */
  14422. scalingDeterminant: number;
  14423. private _infiniteDistance;
  14424. /**
  14425. * Gets or sets the distance of the object to max, often used by skybox
  14426. */
  14427. get infiniteDistance(): boolean;
  14428. set infiniteDistance(value: boolean);
  14429. /**
  14430. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14431. * By default the system will update normals to compensate
  14432. */
  14433. ignoreNonUniformScaling: boolean;
  14434. /**
  14435. * 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
  14436. */
  14437. reIntegrateRotationIntoRotationQuaternion: boolean;
  14438. /** @hidden */
  14439. _poseMatrix: Nullable<Matrix>;
  14440. /** @hidden */
  14441. _localMatrix: Matrix;
  14442. private _usePivotMatrix;
  14443. private _absolutePosition;
  14444. private _absoluteScaling;
  14445. private _absoluteRotationQuaternion;
  14446. private _pivotMatrix;
  14447. private _pivotMatrixInverse;
  14448. protected _postMultiplyPivotMatrix: boolean;
  14449. protected _isWorldMatrixFrozen: boolean;
  14450. /** @hidden */
  14451. _indexInSceneTransformNodesArray: number;
  14452. /**
  14453. * An event triggered after the world matrix is updated
  14454. */
  14455. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14456. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14457. /**
  14458. * Gets a string identifying the name of the class
  14459. * @returns "TransformNode" string
  14460. */
  14461. getClassName(): string;
  14462. /**
  14463. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14464. */
  14465. get position(): Vector3;
  14466. set position(newPosition: Vector3);
  14467. /**
  14468. * 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)).
  14469. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14470. */
  14471. get rotation(): Vector3;
  14472. set rotation(newRotation: Vector3);
  14473. /**
  14474. * 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)).
  14475. */
  14476. get scaling(): Vector3;
  14477. set scaling(newScaling: Vector3);
  14478. /**
  14479. * 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).
  14480. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14481. */
  14482. get rotationQuaternion(): Nullable<Quaternion>;
  14483. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14484. /**
  14485. * The forward direction of that transform in world space.
  14486. */
  14487. get forward(): Vector3;
  14488. /**
  14489. * The up direction of that transform in world space.
  14490. */
  14491. get up(): Vector3;
  14492. /**
  14493. * The right direction of that transform in world space.
  14494. */
  14495. get right(): Vector3;
  14496. /**
  14497. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14498. * @param matrix the matrix to copy the pose from
  14499. * @returns this TransformNode.
  14500. */
  14501. updatePoseMatrix(matrix: Matrix): TransformNode;
  14502. /**
  14503. * Returns the mesh Pose matrix.
  14504. * @returns the pose matrix
  14505. */
  14506. getPoseMatrix(): Matrix;
  14507. /** @hidden */
  14508. _isSynchronized(): boolean;
  14509. /** @hidden */
  14510. _initCache(): void;
  14511. /**
  14512. * Flag the transform node as dirty (Forcing it to update everything)
  14513. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14514. * @returns this transform node
  14515. */
  14516. markAsDirty(property: string): TransformNode;
  14517. /**
  14518. * Returns the current mesh absolute position.
  14519. * Returns a Vector3.
  14520. */
  14521. get absolutePosition(): Vector3;
  14522. /**
  14523. * Returns the current mesh absolute scaling.
  14524. * Returns a Vector3.
  14525. */
  14526. get absoluteScaling(): Vector3;
  14527. /**
  14528. * Returns the current mesh absolute rotation.
  14529. * Returns a Quaternion.
  14530. */
  14531. get absoluteRotationQuaternion(): Quaternion;
  14532. /**
  14533. * Sets a new matrix to apply before all other transformation
  14534. * @param matrix defines the transform matrix
  14535. * @returns the current TransformNode
  14536. */
  14537. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14538. /**
  14539. * Sets a new pivot matrix to the current node
  14540. * @param matrix defines the new pivot matrix to use
  14541. * @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
  14542. * @returns the current TransformNode
  14543. */
  14544. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14545. /**
  14546. * Returns the mesh pivot matrix.
  14547. * Default : Identity.
  14548. * @returns the matrix
  14549. */
  14550. getPivotMatrix(): Matrix;
  14551. /**
  14552. * Instantiate (when possible) or clone that node with its hierarchy
  14553. * @param newParent defines the new parent to use for the instance (or clone)
  14554. * @param options defines options to configure how copy is done
  14555. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14556. * @returns an instance (or a clone) of the current node with its hiearchy
  14557. */
  14558. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14559. doNotInstantiate: boolean;
  14560. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14561. /**
  14562. * Prevents the World matrix to be computed any longer
  14563. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14564. * @returns the TransformNode.
  14565. */
  14566. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14567. /**
  14568. * Allows back the World matrix computation.
  14569. * @returns the TransformNode.
  14570. */
  14571. unfreezeWorldMatrix(): this;
  14572. /**
  14573. * True if the World matrix has been frozen.
  14574. */
  14575. get isWorldMatrixFrozen(): boolean;
  14576. /**
  14577. * Retuns the mesh absolute position in the World.
  14578. * @returns a Vector3.
  14579. */
  14580. getAbsolutePosition(): Vector3;
  14581. /**
  14582. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14583. * @param absolutePosition the absolute position to set
  14584. * @returns the TransformNode.
  14585. */
  14586. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14587. /**
  14588. * Sets the mesh position in its local space.
  14589. * @param vector3 the position to set in localspace
  14590. * @returns the TransformNode.
  14591. */
  14592. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14593. /**
  14594. * Returns the mesh position in the local space from the current World matrix values.
  14595. * @returns a new Vector3.
  14596. */
  14597. getPositionExpressedInLocalSpace(): Vector3;
  14598. /**
  14599. * Translates the mesh along the passed Vector3 in its local space.
  14600. * @param vector3 the distance to translate in localspace
  14601. * @returns the TransformNode.
  14602. */
  14603. locallyTranslate(vector3: Vector3): TransformNode;
  14604. private static _lookAtVectorCache;
  14605. /**
  14606. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14607. * @param targetPoint the position (must be in same space as current mesh) to look at
  14608. * @param yawCor optional yaw (y-axis) correction in radians
  14609. * @param pitchCor optional pitch (x-axis) correction in radians
  14610. * @param rollCor optional roll (z-axis) correction in radians
  14611. * @param space the choosen space of the target
  14612. * @returns the TransformNode.
  14613. */
  14614. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14615. /**
  14616. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14617. * This Vector3 is expressed in the World space.
  14618. * @param localAxis axis to rotate
  14619. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14620. */
  14621. getDirection(localAxis: Vector3): Vector3;
  14622. /**
  14623. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14624. * localAxis is expressed in the mesh local space.
  14625. * result is computed in the Wordl space from the mesh World matrix.
  14626. * @param localAxis axis to rotate
  14627. * @param result the resulting transformnode
  14628. * @returns this TransformNode.
  14629. */
  14630. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14631. /**
  14632. * Sets this transform node rotation to the given local axis.
  14633. * @param localAxis the axis in local space
  14634. * @param yawCor optional yaw (y-axis) correction in radians
  14635. * @param pitchCor optional pitch (x-axis) correction in radians
  14636. * @param rollCor optional roll (z-axis) correction in radians
  14637. * @returns this TransformNode
  14638. */
  14639. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14640. /**
  14641. * Sets a new pivot point to the current node
  14642. * @param point defines the new pivot point to use
  14643. * @param space defines if the point is in world or local space (local by default)
  14644. * @returns the current TransformNode
  14645. */
  14646. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14647. /**
  14648. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14649. * @returns the pivot point
  14650. */
  14651. getPivotPoint(): Vector3;
  14652. /**
  14653. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14654. * @param result the vector3 to store the result
  14655. * @returns this TransformNode.
  14656. */
  14657. getPivotPointToRef(result: Vector3): TransformNode;
  14658. /**
  14659. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14660. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14661. */
  14662. getAbsolutePivotPoint(): Vector3;
  14663. /**
  14664. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14665. * @param result vector3 to store the result
  14666. * @returns this TransformNode.
  14667. */
  14668. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14669. /**
  14670. * Defines the passed node as the parent of the current node.
  14671. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14672. * @see https://doc.babylonjs.com/how_to/parenting
  14673. * @param node the node ot set as the parent
  14674. * @returns this TransformNode.
  14675. */
  14676. setParent(node: Nullable<Node>): TransformNode;
  14677. private _nonUniformScaling;
  14678. /**
  14679. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14680. */
  14681. get nonUniformScaling(): boolean;
  14682. /** @hidden */
  14683. _updateNonUniformScalingState(value: boolean): boolean;
  14684. /**
  14685. * Attach the current TransformNode to another TransformNode associated with a bone
  14686. * @param bone Bone affecting the TransformNode
  14687. * @param affectedTransformNode TransformNode associated with the bone
  14688. * @returns this object
  14689. */
  14690. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14691. /**
  14692. * Detach the transform node if its associated with a bone
  14693. * @returns this object
  14694. */
  14695. detachFromBone(): TransformNode;
  14696. private static _rotationAxisCache;
  14697. /**
  14698. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14699. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14700. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14701. * The passed axis is also normalized.
  14702. * @param axis the axis to rotate around
  14703. * @param amount the amount to rotate in radians
  14704. * @param space Space to rotate in (Default: local)
  14705. * @returns the TransformNode.
  14706. */
  14707. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14708. /**
  14709. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14710. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14711. * The passed axis is also normalized. .
  14712. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14713. * @param point the point to rotate around
  14714. * @param axis the axis to rotate around
  14715. * @param amount the amount to rotate in radians
  14716. * @returns the TransformNode
  14717. */
  14718. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14719. /**
  14720. * Translates the mesh along the axis vector for the passed distance in the given space.
  14721. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14722. * @param axis the axis to translate in
  14723. * @param distance the distance to translate
  14724. * @param space Space to rotate in (Default: local)
  14725. * @returns the TransformNode.
  14726. */
  14727. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14728. /**
  14729. * Adds a rotation step to the mesh current rotation.
  14730. * x, y, z are Euler angles expressed in radians.
  14731. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14732. * This means this rotation is made in the mesh local space only.
  14733. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14734. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14735. * ```javascript
  14736. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14737. * ```
  14738. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14739. * 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.
  14740. * @param x Rotation to add
  14741. * @param y Rotation to add
  14742. * @param z Rotation to add
  14743. * @returns the TransformNode.
  14744. */
  14745. addRotation(x: number, y: number, z: number): TransformNode;
  14746. /**
  14747. * @hidden
  14748. */
  14749. protected _getEffectiveParent(): Nullable<Node>;
  14750. /**
  14751. * Computes the world matrix of the node
  14752. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14753. * @returns the world matrix
  14754. */
  14755. computeWorldMatrix(force?: boolean): Matrix;
  14756. protected _afterComputeWorldMatrix(): void;
  14757. /**
  14758. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14759. * @param func callback function to add
  14760. *
  14761. * @returns the TransformNode.
  14762. */
  14763. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14764. /**
  14765. * Removes a registered callback function.
  14766. * @param func callback function to remove
  14767. * @returns the TransformNode.
  14768. */
  14769. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14770. /**
  14771. * Gets the position of the current mesh in camera space
  14772. * @param camera defines the camera to use
  14773. * @returns a position
  14774. */
  14775. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14776. /**
  14777. * Returns the distance from the mesh to the active camera
  14778. * @param camera defines the camera to use
  14779. * @returns the distance
  14780. */
  14781. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14782. /**
  14783. * Clone the current transform node
  14784. * @param name Name of the new clone
  14785. * @param newParent New parent for the clone
  14786. * @param doNotCloneChildren Do not clone children hierarchy
  14787. * @returns the new transform node
  14788. */
  14789. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14790. /**
  14791. * Serializes the objects information.
  14792. * @param currentSerializationObject defines the object to serialize in
  14793. * @returns the serialized object
  14794. */
  14795. serialize(currentSerializationObject?: any): any;
  14796. /**
  14797. * Returns a new TransformNode object parsed from the source provided.
  14798. * @param parsedTransformNode is the source.
  14799. * @param scene the scne the object belongs to
  14800. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14801. * @returns a new TransformNode object parsed from the source provided.
  14802. */
  14803. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14804. /**
  14805. * Get all child-transformNodes of this node
  14806. * @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
  14807. * @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
  14808. * @returns an array of TransformNode
  14809. */
  14810. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14811. /**
  14812. * Releases resources associated with this transform node.
  14813. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14814. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14815. */
  14816. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14817. /**
  14818. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14819. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14820. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14821. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14822. * @returns the current mesh
  14823. */
  14824. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14825. private _syncAbsoluteScalingAndRotation;
  14826. }
  14827. }
  14828. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14829. import { Observable } from "babylonjs/Misc/observable";
  14830. import { Nullable } from "babylonjs/types";
  14831. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14832. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14834. import { Ray } from "babylonjs/Culling/ray";
  14835. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14836. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14837. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14838. /**
  14839. * Defines the types of pose enabled controllers that are supported
  14840. */
  14841. export enum PoseEnabledControllerType {
  14842. /**
  14843. * HTC Vive
  14844. */
  14845. VIVE = 0,
  14846. /**
  14847. * Oculus Rift
  14848. */
  14849. OCULUS = 1,
  14850. /**
  14851. * Windows mixed reality
  14852. */
  14853. WINDOWS = 2,
  14854. /**
  14855. * Samsung gear VR
  14856. */
  14857. GEAR_VR = 3,
  14858. /**
  14859. * Google Daydream
  14860. */
  14861. DAYDREAM = 4,
  14862. /**
  14863. * Generic
  14864. */
  14865. GENERIC = 5
  14866. }
  14867. /**
  14868. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14869. */
  14870. export interface MutableGamepadButton {
  14871. /**
  14872. * Value of the button/trigger
  14873. */
  14874. value: number;
  14875. /**
  14876. * If the button/trigger is currently touched
  14877. */
  14878. touched: boolean;
  14879. /**
  14880. * If the button/trigger is currently pressed
  14881. */
  14882. pressed: boolean;
  14883. }
  14884. /**
  14885. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14886. * @hidden
  14887. */
  14888. export interface ExtendedGamepadButton extends GamepadButton {
  14889. /**
  14890. * If the button/trigger is currently pressed
  14891. */
  14892. readonly pressed: boolean;
  14893. /**
  14894. * If the button/trigger is currently touched
  14895. */
  14896. readonly touched: boolean;
  14897. /**
  14898. * Value of the button/trigger
  14899. */
  14900. readonly value: number;
  14901. }
  14902. /** @hidden */
  14903. export interface _GamePadFactory {
  14904. /**
  14905. * Returns wether or not the current gamepad can be created for this type of controller.
  14906. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14907. * @returns true if it can be created, otherwise false
  14908. */
  14909. canCreate(gamepadInfo: any): boolean;
  14910. /**
  14911. * Creates a new instance of the Gamepad.
  14912. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14913. * @returns the new gamepad instance
  14914. */
  14915. create(gamepadInfo: any): Gamepad;
  14916. }
  14917. /**
  14918. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14919. */
  14920. export class PoseEnabledControllerHelper {
  14921. /** @hidden */
  14922. static _ControllerFactories: _GamePadFactory[];
  14923. /** @hidden */
  14924. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14925. /**
  14926. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14927. * @param vrGamepad the gamepad to initialized
  14928. * @returns a vr controller of the type the gamepad identified as
  14929. */
  14930. static InitiateController(vrGamepad: any): Gamepad;
  14931. }
  14932. /**
  14933. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14934. */
  14935. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14936. /**
  14937. * If the controller is used in a webXR session
  14938. */
  14939. isXR: boolean;
  14940. private _deviceRoomPosition;
  14941. private _deviceRoomRotationQuaternion;
  14942. /**
  14943. * The device position in babylon space
  14944. */
  14945. devicePosition: Vector3;
  14946. /**
  14947. * The device rotation in babylon space
  14948. */
  14949. deviceRotationQuaternion: Quaternion;
  14950. /**
  14951. * The scale factor of the device in babylon space
  14952. */
  14953. deviceScaleFactor: number;
  14954. /**
  14955. * (Likely devicePosition should be used instead) The device position in its room space
  14956. */
  14957. position: Vector3;
  14958. /**
  14959. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14960. */
  14961. rotationQuaternion: Quaternion;
  14962. /**
  14963. * The type of controller (Eg. Windows mixed reality)
  14964. */
  14965. controllerType: PoseEnabledControllerType;
  14966. protected _calculatedPosition: Vector3;
  14967. private _calculatedRotation;
  14968. /**
  14969. * The raw pose from the device
  14970. */
  14971. rawPose: DevicePose;
  14972. private _trackPosition;
  14973. private _maxRotationDistFromHeadset;
  14974. private _draggedRoomRotation;
  14975. /**
  14976. * @hidden
  14977. */
  14978. _disableTrackPosition(fixedPosition: Vector3): void;
  14979. /**
  14980. * Internal, the mesh attached to the controller
  14981. * @hidden
  14982. */
  14983. _mesh: Nullable<AbstractMesh>;
  14984. private _poseControlledCamera;
  14985. private _leftHandSystemQuaternion;
  14986. /**
  14987. * Internal, matrix used to convert room space to babylon space
  14988. * @hidden
  14989. */
  14990. _deviceToWorld: Matrix;
  14991. /**
  14992. * Node to be used when casting a ray from the controller
  14993. * @hidden
  14994. */
  14995. _pointingPoseNode: Nullable<TransformNode>;
  14996. /**
  14997. * Name of the child mesh that can be used to cast a ray from the controller
  14998. */
  14999. static readonly POINTING_POSE: string;
  15000. /**
  15001. * Creates a new PoseEnabledController from a gamepad
  15002. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15003. */
  15004. constructor(browserGamepad: any);
  15005. private _workingMatrix;
  15006. /**
  15007. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15008. */
  15009. update(): void;
  15010. /**
  15011. * Updates only the pose device and mesh without doing any button event checking
  15012. */
  15013. protected _updatePoseAndMesh(): void;
  15014. /**
  15015. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15016. * @param poseData raw pose fromthe device
  15017. */
  15018. updateFromDevice(poseData: DevicePose): void;
  15019. /**
  15020. * @hidden
  15021. */
  15022. _meshAttachedObservable: Observable<AbstractMesh>;
  15023. /**
  15024. * Attaches a mesh to the controller
  15025. * @param mesh the mesh to be attached
  15026. */
  15027. attachToMesh(mesh: AbstractMesh): void;
  15028. /**
  15029. * Attaches the controllers mesh to a camera
  15030. * @param camera the camera the mesh should be attached to
  15031. */
  15032. attachToPoseControlledCamera(camera: TargetCamera): void;
  15033. /**
  15034. * Disposes of the controller
  15035. */
  15036. dispose(): void;
  15037. /**
  15038. * The mesh that is attached to the controller
  15039. */
  15040. get mesh(): Nullable<AbstractMesh>;
  15041. /**
  15042. * Gets the ray of the controller in the direction the controller is pointing
  15043. * @param length the length the resulting ray should be
  15044. * @returns a ray in the direction the controller is pointing
  15045. */
  15046. getForwardRay(length?: number): Ray;
  15047. }
  15048. }
  15049. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15050. import { Observable } from "babylonjs/Misc/observable";
  15051. import { Scene } from "babylonjs/scene";
  15052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15053. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15054. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15055. import { Nullable } from "babylonjs/types";
  15056. /**
  15057. * Defines the WebVRController object that represents controllers tracked in 3D space
  15058. */
  15059. export abstract class WebVRController extends PoseEnabledController {
  15060. /**
  15061. * Internal, the default controller model for the controller
  15062. */
  15063. protected _defaultModel: Nullable<AbstractMesh>;
  15064. /**
  15065. * Fired when the trigger state has changed
  15066. */
  15067. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15068. /**
  15069. * Fired when the main button state has changed
  15070. */
  15071. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15072. /**
  15073. * Fired when the secondary button state has changed
  15074. */
  15075. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15076. /**
  15077. * Fired when the pad state has changed
  15078. */
  15079. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15080. /**
  15081. * Fired when controllers stick values have changed
  15082. */
  15083. onPadValuesChangedObservable: Observable<StickValues>;
  15084. /**
  15085. * Array of button availible on the controller
  15086. */
  15087. protected _buttons: Array<MutableGamepadButton>;
  15088. private _onButtonStateChange;
  15089. /**
  15090. * Fired when a controller button's state has changed
  15091. * @param callback the callback containing the button that was modified
  15092. */
  15093. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15094. /**
  15095. * X and Y axis corresponding to the controllers joystick
  15096. */
  15097. pad: StickValues;
  15098. /**
  15099. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15100. */
  15101. hand: string;
  15102. /**
  15103. * The default controller model for the controller
  15104. */
  15105. get defaultModel(): Nullable<AbstractMesh>;
  15106. /**
  15107. * Creates a new WebVRController from a gamepad
  15108. * @param vrGamepad the gamepad that the WebVRController should be created from
  15109. */
  15110. constructor(vrGamepad: any);
  15111. /**
  15112. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15113. */
  15114. update(): void;
  15115. /**
  15116. * Function to be called when a button is modified
  15117. */
  15118. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15119. /**
  15120. * Loads a mesh and attaches it to the controller
  15121. * @param scene the scene the mesh should be added to
  15122. * @param meshLoaded callback for when the mesh has been loaded
  15123. */
  15124. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15125. private _setButtonValue;
  15126. private _changes;
  15127. private _checkChanges;
  15128. /**
  15129. * Disposes of th webVRCOntroller
  15130. */
  15131. dispose(): void;
  15132. }
  15133. }
  15134. declare module "babylonjs/Lights/hemisphericLight" {
  15135. import { Nullable } from "babylonjs/types";
  15136. import { Scene } from "babylonjs/scene";
  15137. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15138. import { Color3 } from "babylonjs/Maths/math.color";
  15139. import { Effect } from "babylonjs/Materials/effect";
  15140. import { Light } from "babylonjs/Lights/light";
  15141. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15142. /**
  15143. * The HemisphericLight simulates the ambient environment light,
  15144. * so the passed direction is the light reflection direction, not the incoming direction.
  15145. */
  15146. export class HemisphericLight extends Light {
  15147. /**
  15148. * The groundColor is the light in the opposite direction to the one specified during creation.
  15149. * 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.
  15150. */
  15151. groundColor: Color3;
  15152. /**
  15153. * The light reflection direction, not the incoming direction.
  15154. */
  15155. direction: Vector3;
  15156. /**
  15157. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15158. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15159. * The HemisphericLight can't cast shadows.
  15160. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15161. * @param name The friendly name of the light
  15162. * @param direction The direction of the light reflection
  15163. * @param scene The scene the light belongs to
  15164. */
  15165. constructor(name: string, direction: Vector3, scene: Scene);
  15166. protected _buildUniformLayout(): void;
  15167. /**
  15168. * Returns the string "HemisphericLight".
  15169. * @return The class name
  15170. */
  15171. getClassName(): string;
  15172. /**
  15173. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15174. * Returns the updated direction.
  15175. * @param target The target the direction should point to
  15176. * @return The computed direction
  15177. */
  15178. setDirectionToTarget(target: Vector3): Vector3;
  15179. /**
  15180. * Returns the shadow generator associated to the light.
  15181. * @returns Always null for hemispheric lights because it does not support shadows.
  15182. */
  15183. getShadowGenerator(): Nullable<IShadowGenerator>;
  15184. /**
  15185. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15186. * @param effect The effect to update
  15187. * @param lightIndex The index of the light in the effect to update
  15188. * @returns The hemispheric light
  15189. */
  15190. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15191. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15192. /**
  15193. * Computes the world matrix of the node
  15194. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15195. * @param useWasUpdatedFlag defines a reserved property
  15196. * @returns the world matrix
  15197. */
  15198. computeWorldMatrix(): Matrix;
  15199. /**
  15200. * Returns the integer 3.
  15201. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15202. */
  15203. getTypeID(): number;
  15204. /**
  15205. * Prepares the list of defines specific to the light type.
  15206. * @param defines the list of defines
  15207. * @param lightIndex defines the index of the light for the effect
  15208. */
  15209. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15210. }
  15211. }
  15212. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15213. /** @hidden */
  15214. export var vrMultiviewToSingleviewPixelShader: {
  15215. name: string;
  15216. shader: string;
  15217. };
  15218. }
  15219. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15220. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15221. import { Scene } from "babylonjs/scene";
  15222. /**
  15223. * Renders to multiple views with a single draw call
  15224. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15225. */
  15226. export class MultiviewRenderTarget extends RenderTargetTexture {
  15227. /**
  15228. * Creates a multiview render target
  15229. * @param scene scene used with the render target
  15230. * @param size the size of the render target (used for each view)
  15231. */
  15232. constructor(scene: Scene, size?: number | {
  15233. width: number;
  15234. height: number;
  15235. } | {
  15236. ratio: number;
  15237. });
  15238. /**
  15239. * @hidden
  15240. * @param faceIndex the face index, if its a cube texture
  15241. */
  15242. _bindFrameBuffer(faceIndex?: number): void;
  15243. /**
  15244. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15245. * @returns the view count
  15246. */
  15247. getViewCount(): number;
  15248. }
  15249. }
  15250. declare module "babylonjs/Maths/math.frustum" {
  15251. import { Matrix } from "babylonjs/Maths/math.vector";
  15252. import { DeepImmutable } from "babylonjs/types";
  15253. import { Plane } from "babylonjs/Maths/math.plane";
  15254. /**
  15255. * Represents a camera frustum
  15256. */
  15257. export class Frustum {
  15258. /**
  15259. * Gets the planes representing the frustum
  15260. * @param transform matrix to be applied to the returned planes
  15261. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15262. */
  15263. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15264. /**
  15265. * Gets the near frustum plane transformed by the transform matrix
  15266. * @param transform transformation matrix to be applied to the resulting frustum plane
  15267. * @param frustumPlane the resuling frustum plane
  15268. */
  15269. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15270. /**
  15271. * Gets the far frustum plane transformed by the transform matrix
  15272. * @param transform transformation matrix to be applied to the resulting frustum plane
  15273. * @param frustumPlane the resuling frustum plane
  15274. */
  15275. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15276. /**
  15277. * Gets the left frustum plane transformed by the transform matrix
  15278. * @param transform transformation matrix to be applied to the resulting frustum plane
  15279. * @param frustumPlane the resuling frustum plane
  15280. */
  15281. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15282. /**
  15283. * Gets the right frustum plane transformed by the transform matrix
  15284. * @param transform transformation matrix to be applied to the resulting frustum plane
  15285. * @param frustumPlane the resuling frustum plane
  15286. */
  15287. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15288. /**
  15289. * Gets the top frustum plane transformed by the transform matrix
  15290. * @param transform transformation matrix to be applied to the resulting frustum plane
  15291. * @param frustumPlane the resuling frustum plane
  15292. */
  15293. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15294. /**
  15295. * Gets the bottom frustum plane transformed by the transform matrix
  15296. * @param transform transformation matrix to be applied to the resulting frustum plane
  15297. * @param frustumPlane the resuling frustum plane
  15298. */
  15299. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15300. /**
  15301. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15302. * @param transform transformation matrix to be applied to the resulting frustum planes
  15303. * @param frustumPlanes the resuling frustum planes
  15304. */
  15305. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15306. }
  15307. }
  15308. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15309. import { Camera } from "babylonjs/Cameras/camera";
  15310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15311. import { Nullable } from "babylonjs/types";
  15312. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15313. import { Matrix } from "babylonjs/Maths/math.vector";
  15314. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15315. module "babylonjs/Engines/engine" {
  15316. interface Engine {
  15317. /**
  15318. * Creates a new multiview render target
  15319. * @param width defines the width of the texture
  15320. * @param height defines the height of the texture
  15321. * @returns the created multiview texture
  15322. */
  15323. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15324. /**
  15325. * Binds a multiview framebuffer to be drawn to
  15326. * @param multiviewTexture texture to bind
  15327. */
  15328. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15329. }
  15330. }
  15331. module "babylonjs/Cameras/camera" {
  15332. interface Camera {
  15333. /**
  15334. * @hidden
  15335. * 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)
  15336. */
  15337. _useMultiviewToSingleView: boolean;
  15338. /**
  15339. * @hidden
  15340. * 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)
  15341. */
  15342. _multiviewTexture: Nullable<RenderTargetTexture>;
  15343. /**
  15344. * @hidden
  15345. * ensures the multiview texture of the camera exists and has the specified width/height
  15346. * @param width height to set on the multiview texture
  15347. * @param height width to set on the multiview texture
  15348. */
  15349. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15350. }
  15351. }
  15352. module "babylonjs/scene" {
  15353. interface Scene {
  15354. /** @hidden */
  15355. _transformMatrixR: Matrix;
  15356. /** @hidden */
  15357. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15358. /** @hidden */
  15359. _createMultiviewUbo(): void;
  15360. /** @hidden */
  15361. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15362. /** @hidden */
  15363. _renderMultiviewToSingleView(camera: Camera): void;
  15364. }
  15365. }
  15366. }
  15367. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15368. import { Camera } from "babylonjs/Cameras/camera";
  15369. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15370. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15371. import "babylonjs/Engines/Extensions/engine.multiview";
  15372. /**
  15373. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15374. * This will not be used for webXR as it supports displaying texture arrays directly
  15375. */
  15376. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15377. /**
  15378. * Initializes a VRMultiviewToSingleview
  15379. * @param name name of the post process
  15380. * @param camera camera to be applied to
  15381. * @param scaleFactor scaling factor to the size of the output texture
  15382. */
  15383. constructor(name: string, camera: Camera, scaleFactor: number);
  15384. }
  15385. }
  15386. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15387. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15388. import { Nullable } from "babylonjs/types";
  15389. import { Size } from "babylonjs/Maths/math.size";
  15390. import { Observable } from "babylonjs/Misc/observable";
  15391. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15392. /**
  15393. * Interface used to define additional presentation attributes
  15394. */
  15395. export interface IVRPresentationAttributes {
  15396. /**
  15397. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15398. */
  15399. highRefreshRate: boolean;
  15400. /**
  15401. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15402. */
  15403. foveationLevel: number;
  15404. }
  15405. module "babylonjs/Engines/engine" {
  15406. interface Engine {
  15407. /** @hidden */
  15408. _vrDisplay: any;
  15409. /** @hidden */
  15410. _vrSupported: boolean;
  15411. /** @hidden */
  15412. _oldSize: Size;
  15413. /** @hidden */
  15414. _oldHardwareScaleFactor: number;
  15415. /** @hidden */
  15416. _vrExclusivePointerMode: boolean;
  15417. /** @hidden */
  15418. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15419. /** @hidden */
  15420. _onVRDisplayPointerRestricted: () => void;
  15421. /** @hidden */
  15422. _onVRDisplayPointerUnrestricted: () => void;
  15423. /** @hidden */
  15424. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15425. /** @hidden */
  15426. _onVrDisplayDisconnect: Nullable<() => void>;
  15427. /** @hidden */
  15428. _onVrDisplayPresentChange: Nullable<() => void>;
  15429. /**
  15430. * Observable signaled when VR display mode changes
  15431. */
  15432. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15433. /**
  15434. * Observable signaled when VR request present is complete
  15435. */
  15436. onVRRequestPresentComplete: Observable<boolean>;
  15437. /**
  15438. * Observable signaled when VR request present starts
  15439. */
  15440. onVRRequestPresentStart: Observable<Engine>;
  15441. /**
  15442. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15443. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15444. */
  15445. isInVRExclusivePointerMode: boolean;
  15446. /**
  15447. * Gets a boolean indicating if a webVR device was detected
  15448. * @returns true if a webVR device was detected
  15449. */
  15450. isVRDevicePresent(): boolean;
  15451. /**
  15452. * Gets the current webVR device
  15453. * @returns the current webVR device (or null)
  15454. */
  15455. getVRDevice(): any;
  15456. /**
  15457. * Initializes a webVR display and starts listening to display change events
  15458. * The onVRDisplayChangedObservable will be notified upon these changes
  15459. * @returns A promise containing a VRDisplay and if vr is supported
  15460. */
  15461. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15462. /** @hidden */
  15463. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15464. /**
  15465. * Gets or sets the presentation attributes used to configure VR rendering
  15466. */
  15467. vrPresentationAttributes?: IVRPresentationAttributes;
  15468. /**
  15469. * Call this function to switch to webVR mode
  15470. * Will do nothing if webVR is not supported or if there is no webVR device
  15471. * @param options the webvr options provided to the camera. mainly used for multiview
  15472. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15473. */
  15474. enableVR(options: WebVROptions): void;
  15475. /** @hidden */
  15476. _onVRFullScreenTriggered(): void;
  15477. }
  15478. }
  15479. }
  15480. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15481. import { Nullable } from "babylonjs/types";
  15482. import { Observable } from "babylonjs/Misc/observable";
  15483. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15484. import { Scene } from "babylonjs/scene";
  15485. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15486. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15487. import { Node } from "babylonjs/node";
  15488. import { Ray } from "babylonjs/Culling/ray";
  15489. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15490. import "babylonjs/Engines/Extensions/engine.webVR";
  15491. /**
  15492. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15493. * IMPORTANT!! The data is right-hand data.
  15494. * @export
  15495. * @interface DevicePose
  15496. */
  15497. export interface DevicePose {
  15498. /**
  15499. * The position of the device, values in array are [x,y,z].
  15500. */
  15501. readonly position: Nullable<Float32Array>;
  15502. /**
  15503. * The linearVelocity of the device, values in array are [x,y,z].
  15504. */
  15505. readonly linearVelocity: Nullable<Float32Array>;
  15506. /**
  15507. * The linearAcceleration of the device, values in array are [x,y,z].
  15508. */
  15509. readonly linearAcceleration: Nullable<Float32Array>;
  15510. /**
  15511. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15512. */
  15513. readonly orientation: Nullable<Float32Array>;
  15514. /**
  15515. * The angularVelocity of the device, values in array are [x,y,z].
  15516. */
  15517. readonly angularVelocity: Nullable<Float32Array>;
  15518. /**
  15519. * The angularAcceleration of the device, values in array are [x,y,z].
  15520. */
  15521. readonly angularAcceleration: Nullable<Float32Array>;
  15522. }
  15523. /**
  15524. * Interface representing a pose controlled object in Babylon.
  15525. * A pose controlled object has both regular pose values as well as pose values
  15526. * from an external device such as a VR head mounted display
  15527. */
  15528. export interface PoseControlled {
  15529. /**
  15530. * The position of the object in babylon space.
  15531. */
  15532. position: Vector3;
  15533. /**
  15534. * The rotation quaternion of the object in babylon space.
  15535. */
  15536. rotationQuaternion: Quaternion;
  15537. /**
  15538. * The position of the device in babylon space.
  15539. */
  15540. devicePosition?: Vector3;
  15541. /**
  15542. * The rotation quaternion of the device in babylon space.
  15543. */
  15544. deviceRotationQuaternion: Quaternion;
  15545. /**
  15546. * The raw pose coming from the device.
  15547. */
  15548. rawPose: Nullable<DevicePose>;
  15549. /**
  15550. * The scale of the device to be used when translating from device space to babylon space.
  15551. */
  15552. deviceScaleFactor: number;
  15553. /**
  15554. * Updates the poseControlled values based on the input device pose.
  15555. * @param poseData the pose data to update the object with
  15556. */
  15557. updateFromDevice(poseData: DevicePose): void;
  15558. }
  15559. /**
  15560. * Set of options to customize the webVRCamera
  15561. */
  15562. export interface WebVROptions {
  15563. /**
  15564. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15565. */
  15566. trackPosition?: boolean;
  15567. /**
  15568. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15569. */
  15570. positionScale?: number;
  15571. /**
  15572. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15573. */
  15574. displayName?: string;
  15575. /**
  15576. * Should the native controller meshes be initialized. (default: true)
  15577. */
  15578. controllerMeshes?: boolean;
  15579. /**
  15580. * Creating a default HemiLight only on controllers. (default: true)
  15581. */
  15582. defaultLightingOnControllers?: boolean;
  15583. /**
  15584. * If you don't want to use the default VR button of the helper. (default: false)
  15585. */
  15586. useCustomVRButton?: boolean;
  15587. /**
  15588. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15589. */
  15590. customVRButton?: HTMLButtonElement;
  15591. /**
  15592. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15593. */
  15594. rayLength?: number;
  15595. /**
  15596. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15597. */
  15598. defaultHeight?: number;
  15599. /**
  15600. * If multiview should be used if availible (default: false)
  15601. */
  15602. useMultiview?: boolean;
  15603. }
  15604. /**
  15605. * This represents a WebVR camera.
  15606. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15607. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15608. */
  15609. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15610. private webVROptions;
  15611. /**
  15612. * @hidden
  15613. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15614. */
  15615. _vrDevice: any;
  15616. /**
  15617. * The rawPose of the vrDevice.
  15618. */
  15619. rawPose: Nullable<DevicePose>;
  15620. private _onVREnabled;
  15621. private _specsVersion;
  15622. private _attached;
  15623. private _frameData;
  15624. protected _descendants: Array<Node>;
  15625. private _deviceRoomPosition;
  15626. /** @hidden */
  15627. _deviceRoomRotationQuaternion: Quaternion;
  15628. private _standingMatrix;
  15629. /**
  15630. * Represents device position in babylon space.
  15631. */
  15632. devicePosition: Vector3;
  15633. /**
  15634. * Represents device rotation in babylon space.
  15635. */
  15636. deviceRotationQuaternion: Quaternion;
  15637. /**
  15638. * The scale of the device to be used when translating from device space to babylon space.
  15639. */
  15640. deviceScaleFactor: number;
  15641. private _deviceToWorld;
  15642. private _worldToDevice;
  15643. /**
  15644. * References to the webVR controllers for the vrDevice.
  15645. */
  15646. controllers: Array<WebVRController>;
  15647. /**
  15648. * Emits an event when a controller is attached.
  15649. */
  15650. onControllersAttachedObservable: Observable<WebVRController[]>;
  15651. /**
  15652. * Emits an event when a controller's mesh has been loaded;
  15653. */
  15654. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15655. /**
  15656. * Emits an event when the HMD's pose has been updated.
  15657. */
  15658. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15659. private _poseSet;
  15660. /**
  15661. * If the rig cameras be used as parent instead of this camera.
  15662. */
  15663. rigParenting: boolean;
  15664. private _lightOnControllers;
  15665. private _defaultHeight?;
  15666. /**
  15667. * Instantiates a WebVRFreeCamera.
  15668. * @param name The name of the WebVRFreeCamera
  15669. * @param position The starting anchor position for the camera
  15670. * @param scene The scene the camera belongs to
  15671. * @param webVROptions a set of customizable options for the webVRCamera
  15672. */
  15673. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15674. /**
  15675. * Gets the device distance from the ground in meters.
  15676. * @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.
  15677. */
  15678. deviceDistanceToRoomGround(): number;
  15679. /**
  15680. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15681. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15682. */
  15683. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15684. /**
  15685. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15686. * @returns A promise with a boolean set to if the standing matrix is supported.
  15687. */
  15688. useStandingMatrixAsync(): Promise<boolean>;
  15689. /**
  15690. * Disposes the camera
  15691. */
  15692. dispose(): void;
  15693. /**
  15694. * Gets a vrController by name.
  15695. * @param name The name of the controller to retreive
  15696. * @returns the controller matching the name specified or null if not found
  15697. */
  15698. getControllerByName(name: string): Nullable<WebVRController>;
  15699. private _leftController;
  15700. /**
  15701. * The controller corresponding to the users left hand.
  15702. */
  15703. get leftController(): Nullable<WebVRController>;
  15704. private _rightController;
  15705. /**
  15706. * The controller corresponding to the users right hand.
  15707. */
  15708. get rightController(): Nullable<WebVRController>;
  15709. /**
  15710. * Casts a ray forward from the vrCamera's gaze.
  15711. * @param length Length of the ray (default: 100)
  15712. * @returns the ray corresponding to the gaze
  15713. */
  15714. getForwardRay(length?: number): Ray;
  15715. /**
  15716. * @hidden
  15717. * Updates the camera based on device's frame data
  15718. */
  15719. _checkInputs(): void;
  15720. /**
  15721. * Updates the poseControlled values based on the input device pose.
  15722. * @param poseData Pose coming from the device
  15723. */
  15724. updateFromDevice(poseData: DevicePose): void;
  15725. private _htmlElementAttached;
  15726. private _detachIfAttached;
  15727. /**
  15728. * WebVR's attach control will start broadcasting frames to the device.
  15729. * Note that in certain browsers (chrome for example) this function must be called
  15730. * within a user-interaction callback. Example:
  15731. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15732. *
  15733. * @param element html element to attach the vrDevice to
  15734. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15735. */
  15736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15737. /**
  15738. * Detaches the camera from the html element and disables VR
  15739. *
  15740. * @param element html element to detach from
  15741. */
  15742. detachControl(element: HTMLElement): void;
  15743. /**
  15744. * @returns the name of this class
  15745. */
  15746. getClassName(): string;
  15747. /**
  15748. * Calls resetPose on the vrDisplay
  15749. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15750. */
  15751. resetToCurrentRotation(): void;
  15752. /**
  15753. * @hidden
  15754. * Updates the rig cameras (left and right eye)
  15755. */
  15756. _updateRigCameras(): void;
  15757. private _workingVector;
  15758. private _oneVector;
  15759. private _workingMatrix;
  15760. private updateCacheCalled;
  15761. private _correctPositionIfNotTrackPosition;
  15762. /**
  15763. * @hidden
  15764. * Updates the cached values of the camera
  15765. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15766. */
  15767. _updateCache(ignoreParentClass?: boolean): void;
  15768. /**
  15769. * @hidden
  15770. * Get current device position in babylon world
  15771. */
  15772. _computeDevicePosition(): void;
  15773. /**
  15774. * Updates the current device position and rotation in the babylon world
  15775. */
  15776. update(): void;
  15777. /**
  15778. * @hidden
  15779. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15780. * @returns an identity matrix
  15781. */
  15782. _getViewMatrix(): Matrix;
  15783. private _tmpMatrix;
  15784. /**
  15785. * This function is called by the two RIG cameras.
  15786. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15787. * @hidden
  15788. */
  15789. _getWebVRViewMatrix(): Matrix;
  15790. /** @hidden */
  15791. _getWebVRProjectionMatrix(): Matrix;
  15792. private _onGamepadConnectedObserver;
  15793. private _onGamepadDisconnectedObserver;
  15794. private _updateCacheWhenTrackingDisabledObserver;
  15795. /**
  15796. * Initializes the controllers and their meshes
  15797. */
  15798. initControllers(): void;
  15799. }
  15800. }
  15801. declare module "babylonjs/PostProcesses/postProcess" {
  15802. import { Nullable } from "babylonjs/types";
  15803. import { SmartArray } from "babylonjs/Misc/smartArray";
  15804. import { Observable } from "babylonjs/Misc/observable";
  15805. import { Vector2 } from "babylonjs/Maths/math.vector";
  15806. import { Camera } from "babylonjs/Cameras/camera";
  15807. import { Effect } from "babylonjs/Materials/effect";
  15808. import "babylonjs/Shaders/postprocess.vertex";
  15809. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15810. import { Engine } from "babylonjs/Engines/engine";
  15811. import { Color4 } from "babylonjs/Maths/math.color";
  15812. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15813. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15814. /**
  15815. * Size options for a post process
  15816. */
  15817. export type PostProcessOptions = {
  15818. width: number;
  15819. height: number;
  15820. };
  15821. /**
  15822. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15823. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15824. */
  15825. export class PostProcess {
  15826. /** Name of the PostProcess. */
  15827. name: string;
  15828. /**
  15829. * Gets or sets the unique id of the post process
  15830. */
  15831. uniqueId: number;
  15832. /**
  15833. * Width of the texture to apply the post process on
  15834. */
  15835. width: number;
  15836. /**
  15837. * Height of the texture to apply the post process on
  15838. */
  15839. height: number;
  15840. /**
  15841. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15842. * @hidden
  15843. */
  15844. _outputTexture: Nullable<InternalTexture>;
  15845. /**
  15846. * Sampling mode used by the shader
  15847. * See https://doc.babylonjs.com/classes/3.1/texture
  15848. */
  15849. renderTargetSamplingMode: number;
  15850. /**
  15851. * Clear color to use when screen clearing
  15852. */
  15853. clearColor: Color4;
  15854. /**
  15855. * If the buffer needs to be cleared before applying the post process. (default: true)
  15856. * Should be set to false if shader will overwrite all previous pixels.
  15857. */
  15858. autoClear: boolean;
  15859. /**
  15860. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15861. */
  15862. alphaMode: number;
  15863. /**
  15864. * Sets the setAlphaBlendConstants of the babylon engine
  15865. */
  15866. alphaConstants: Color4;
  15867. /**
  15868. * Animations to be used for the post processing
  15869. */
  15870. animations: import("babylonjs/Animations/animation").Animation[];
  15871. /**
  15872. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15873. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15874. */
  15875. enablePixelPerfectMode: boolean;
  15876. /**
  15877. * Force the postprocess to be applied without taking in account viewport
  15878. */
  15879. forceFullscreenViewport: boolean;
  15880. /**
  15881. * List of inspectable custom properties (used by the Inspector)
  15882. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15883. */
  15884. inspectableCustomProperties: IInspectable[];
  15885. /**
  15886. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15887. *
  15888. * | Value | Type | Description |
  15889. * | ----- | ----------------------------------- | ----------- |
  15890. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15891. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15892. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15893. *
  15894. */
  15895. scaleMode: number;
  15896. /**
  15897. * Force textures to be a power of two (default: false)
  15898. */
  15899. alwaysForcePOT: boolean;
  15900. private _samples;
  15901. /**
  15902. * Number of sample textures (default: 1)
  15903. */
  15904. get samples(): number;
  15905. set samples(n: number);
  15906. /**
  15907. * Modify the scale of the post process to be the same as the viewport (default: false)
  15908. */
  15909. adaptScaleToCurrentViewport: boolean;
  15910. private _camera;
  15911. private _scene;
  15912. private _engine;
  15913. private _options;
  15914. private _reusable;
  15915. private _textureType;
  15916. /**
  15917. * Smart array of input and output textures for the post process.
  15918. * @hidden
  15919. */
  15920. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15921. /**
  15922. * The index in _textures that corresponds to the output texture.
  15923. * @hidden
  15924. */
  15925. _currentRenderTextureInd: number;
  15926. private _effect;
  15927. private _samplers;
  15928. private _fragmentUrl;
  15929. private _vertexUrl;
  15930. private _parameters;
  15931. private _scaleRatio;
  15932. protected _indexParameters: any;
  15933. private _shareOutputWithPostProcess;
  15934. private _texelSize;
  15935. private _forcedOutputTexture;
  15936. /**
  15937. * Returns the fragment url or shader name used in the post process.
  15938. * @returns the fragment url or name in the shader store.
  15939. */
  15940. getEffectName(): string;
  15941. /**
  15942. * An event triggered when the postprocess is activated.
  15943. */
  15944. onActivateObservable: Observable<Camera>;
  15945. private _onActivateObserver;
  15946. /**
  15947. * A function that is added to the onActivateObservable
  15948. */
  15949. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15950. /**
  15951. * An event triggered when the postprocess changes its size.
  15952. */
  15953. onSizeChangedObservable: Observable<PostProcess>;
  15954. private _onSizeChangedObserver;
  15955. /**
  15956. * A function that is added to the onSizeChangedObservable
  15957. */
  15958. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15959. /**
  15960. * An event triggered when the postprocess applies its effect.
  15961. */
  15962. onApplyObservable: Observable<Effect>;
  15963. private _onApplyObserver;
  15964. /**
  15965. * A function that is added to the onApplyObservable
  15966. */
  15967. set onApply(callback: (effect: Effect) => void);
  15968. /**
  15969. * An event triggered before rendering the postprocess
  15970. */
  15971. onBeforeRenderObservable: Observable<Effect>;
  15972. private _onBeforeRenderObserver;
  15973. /**
  15974. * A function that is added to the onBeforeRenderObservable
  15975. */
  15976. set onBeforeRender(callback: (effect: Effect) => void);
  15977. /**
  15978. * An event triggered after rendering the postprocess
  15979. */
  15980. onAfterRenderObservable: Observable<Effect>;
  15981. private _onAfterRenderObserver;
  15982. /**
  15983. * A function that is added to the onAfterRenderObservable
  15984. */
  15985. set onAfterRender(callback: (efect: Effect) => void);
  15986. /**
  15987. * 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
  15988. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15989. */
  15990. get inputTexture(): InternalTexture;
  15991. set inputTexture(value: InternalTexture);
  15992. /**
  15993. * Gets the camera which post process is applied to.
  15994. * @returns The camera the post process is applied to.
  15995. */
  15996. getCamera(): Camera;
  15997. /**
  15998. * Gets the texel size of the postprocess.
  15999. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16000. */
  16001. get texelSize(): Vector2;
  16002. /**
  16003. * Creates a new instance PostProcess
  16004. * @param name The name of the PostProcess.
  16005. * @param fragmentUrl The url of the fragment shader to be used.
  16006. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16007. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16008. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16009. * @param camera The camera to apply the render pass to.
  16010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16011. * @param engine The engine which the post process will be applied. (default: current engine)
  16012. * @param reusable If the post process can be reused on the same frame. (default: false)
  16013. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16014. * @param textureType Type of textures used when performing the post process. (default: 0)
  16015. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16016. * @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
  16017. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16018. */
  16019. constructor(
  16020. /** Name of the PostProcess. */
  16021. 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);
  16022. /**
  16023. * Gets a string idenfifying the name of the class
  16024. * @returns "PostProcess" string
  16025. */
  16026. getClassName(): string;
  16027. /**
  16028. * Gets the engine which this post process belongs to.
  16029. * @returns The engine the post process was enabled with.
  16030. */
  16031. getEngine(): Engine;
  16032. /**
  16033. * The effect that is created when initializing the post process.
  16034. * @returns The created effect corresponding the the postprocess.
  16035. */
  16036. getEffect(): Effect;
  16037. /**
  16038. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16039. * @param postProcess The post process to share the output with.
  16040. * @returns This post process.
  16041. */
  16042. shareOutputWith(postProcess: PostProcess): PostProcess;
  16043. /**
  16044. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16045. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16046. */
  16047. useOwnOutput(): void;
  16048. /**
  16049. * Updates the effect with the current post process compile time values and recompiles the shader.
  16050. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16051. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16052. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16053. * @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
  16054. * @param onCompiled Called when the shader has been compiled.
  16055. * @param onError Called if there is an error when compiling a shader.
  16056. */
  16057. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16058. /**
  16059. * The post process is reusable if it can be used multiple times within one frame.
  16060. * @returns If the post process is reusable
  16061. */
  16062. isReusable(): boolean;
  16063. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16064. markTextureDirty(): void;
  16065. /**
  16066. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16067. * 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.
  16068. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16069. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16070. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16071. * @returns The target texture that was bound to be written to.
  16072. */
  16073. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16074. /**
  16075. * If the post process is supported.
  16076. */
  16077. get isSupported(): boolean;
  16078. /**
  16079. * The aspect ratio of the output texture.
  16080. */
  16081. get aspectRatio(): number;
  16082. /**
  16083. * Get a value indicating if the post-process is ready to be used
  16084. * @returns true if the post-process is ready (shader is compiled)
  16085. */
  16086. isReady(): boolean;
  16087. /**
  16088. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16089. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16090. */
  16091. apply(): Nullable<Effect>;
  16092. private _disposeTextures;
  16093. /**
  16094. * Disposes the post process.
  16095. * @param camera The camera to dispose the post process on.
  16096. */
  16097. dispose(camera?: Camera): void;
  16098. }
  16099. }
  16100. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16101. /** @hidden */
  16102. export var kernelBlurVaryingDeclaration: {
  16103. name: string;
  16104. shader: string;
  16105. };
  16106. }
  16107. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16108. /** @hidden */
  16109. export var kernelBlurFragment: {
  16110. name: string;
  16111. shader: string;
  16112. };
  16113. }
  16114. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16115. /** @hidden */
  16116. export var kernelBlurFragment2: {
  16117. name: string;
  16118. shader: string;
  16119. };
  16120. }
  16121. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16122. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16123. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16124. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16125. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16126. /** @hidden */
  16127. export var kernelBlurPixelShader: {
  16128. name: string;
  16129. shader: string;
  16130. };
  16131. }
  16132. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16133. /** @hidden */
  16134. export var kernelBlurVertex: {
  16135. name: string;
  16136. shader: string;
  16137. };
  16138. }
  16139. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16140. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16141. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16142. /** @hidden */
  16143. export var kernelBlurVertexShader: {
  16144. name: string;
  16145. shader: string;
  16146. };
  16147. }
  16148. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16149. import { Vector2 } from "babylonjs/Maths/math.vector";
  16150. import { Nullable } from "babylonjs/types";
  16151. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16152. import { Camera } from "babylonjs/Cameras/camera";
  16153. import { Effect } from "babylonjs/Materials/effect";
  16154. import { Engine } from "babylonjs/Engines/engine";
  16155. import "babylonjs/Shaders/kernelBlur.fragment";
  16156. import "babylonjs/Shaders/kernelBlur.vertex";
  16157. /**
  16158. * The Blur Post Process which blurs an image based on a kernel and direction.
  16159. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16160. */
  16161. export class BlurPostProcess extends PostProcess {
  16162. /** The direction in which to blur the image. */
  16163. direction: Vector2;
  16164. private blockCompilation;
  16165. protected _kernel: number;
  16166. protected _idealKernel: number;
  16167. protected _packedFloat: boolean;
  16168. private _staticDefines;
  16169. /**
  16170. * Sets the length in pixels of the blur sample region
  16171. */
  16172. set kernel(v: number);
  16173. /**
  16174. * Gets the length in pixels of the blur sample region
  16175. */
  16176. get kernel(): number;
  16177. /**
  16178. * Sets wether or not the blur needs to unpack/repack floats
  16179. */
  16180. set packedFloat(v: boolean);
  16181. /**
  16182. * Gets wether or not the blur is unpacking/repacking floats
  16183. */
  16184. get packedFloat(): boolean;
  16185. /**
  16186. * Creates a new instance BlurPostProcess
  16187. * @param name The name of the effect.
  16188. * @param direction The direction in which to blur the image.
  16189. * @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.
  16190. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16191. * @param camera The camera to apply the render pass to.
  16192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16193. * @param engine The engine which the post process will be applied. (default: current engine)
  16194. * @param reusable If the post process can be reused on the same frame. (default: false)
  16195. * @param textureType Type of textures used when performing the post process. (default: 0)
  16196. * @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)
  16197. */
  16198. constructor(name: string,
  16199. /** The direction in which to blur the image. */
  16200. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16201. /**
  16202. * Updates the effect with the current post process compile time values and recompiles the shader.
  16203. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16204. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16205. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16206. * @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
  16207. * @param onCompiled Called when the shader has been compiled.
  16208. * @param onError Called if there is an error when compiling a shader.
  16209. */
  16210. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16211. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16212. /**
  16213. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16214. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16215. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16216. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16217. * The gaps between physical kernels are compensated for in the weighting of the samples
  16218. * @param idealKernel Ideal blur kernel.
  16219. * @return Nearest best kernel.
  16220. */
  16221. protected _nearestBestKernel(idealKernel: number): number;
  16222. /**
  16223. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16224. * @param x The point on the Gaussian distribution to sample.
  16225. * @return the value of the Gaussian function at x.
  16226. */
  16227. protected _gaussianWeight(x: number): number;
  16228. /**
  16229. * Generates a string that can be used as a floating point number in GLSL.
  16230. * @param x Value to print.
  16231. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16232. * @return GLSL float string.
  16233. */
  16234. protected _glslFloat(x: number, decimalFigures?: number): string;
  16235. }
  16236. }
  16237. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16238. import { Scene } from "babylonjs/scene";
  16239. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16240. import { Plane } from "babylonjs/Maths/math.plane";
  16241. /**
  16242. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16243. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16244. * You can then easily use it as a reflectionTexture on a flat surface.
  16245. * In case the surface is not a plane, please consider relying on reflection probes.
  16246. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16247. */
  16248. export class MirrorTexture extends RenderTargetTexture {
  16249. private scene;
  16250. /**
  16251. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16252. * 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.
  16253. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16254. */
  16255. mirrorPlane: Plane;
  16256. /**
  16257. * Define the blur ratio used to blur the reflection if needed.
  16258. */
  16259. set blurRatio(value: number);
  16260. get blurRatio(): number;
  16261. /**
  16262. * Define the adaptive blur kernel used to blur the reflection if needed.
  16263. * This will autocompute the closest best match for the `blurKernel`
  16264. */
  16265. set adaptiveBlurKernel(value: number);
  16266. /**
  16267. * Define the blur kernel used to blur the reflection if needed.
  16268. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16269. */
  16270. set blurKernel(value: number);
  16271. /**
  16272. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16273. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16274. */
  16275. set blurKernelX(value: number);
  16276. get blurKernelX(): number;
  16277. /**
  16278. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16279. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16280. */
  16281. set blurKernelY(value: number);
  16282. get blurKernelY(): number;
  16283. private _autoComputeBlurKernel;
  16284. protected _onRatioRescale(): void;
  16285. private _updateGammaSpace;
  16286. private _imageProcessingConfigChangeObserver;
  16287. private _transformMatrix;
  16288. private _mirrorMatrix;
  16289. private _savedViewMatrix;
  16290. private _blurX;
  16291. private _blurY;
  16292. private _adaptiveBlurKernel;
  16293. private _blurKernelX;
  16294. private _blurKernelY;
  16295. private _blurRatio;
  16296. /**
  16297. * Instantiates a Mirror Texture.
  16298. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16299. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16300. * You can then easily use it as a reflectionTexture on a flat surface.
  16301. * In case the surface is not a plane, please consider relying on reflection probes.
  16302. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16303. * @param name
  16304. * @param size
  16305. * @param scene
  16306. * @param generateMipMaps
  16307. * @param type
  16308. * @param samplingMode
  16309. * @param generateDepthBuffer
  16310. */
  16311. constructor(name: string, size: number | {
  16312. width: number;
  16313. height: number;
  16314. } | {
  16315. ratio: number;
  16316. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16317. private _preparePostProcesses;
  16318. /**
  16319. * Clone the mirror texture.
  16320. * @returns the cloned texture
  16321. */
  16322. clone(): MirrorTexture;
  16323. /**
  16324. * Serialize the texture to a JSON representation you could use in Parse later on
  16325. * @returns the serialized JSON representation
  16326. */
  16327. serialize(): any;
  16328. /**
  16329. * Dispose the texture and release its associated resources.
  16330. */
  16331. dispose(): void;
  16332. }
  16333. }
  16334. declare module "babylonjs/Materials/Textures/texture" {
  16335. import { Observable } from "babylonjs/Misc/observable";
  16336. import { Nullable } from "babylonjs/types";
  16337. import { Matrix } from "babylonjs/Maths/math.vector";
  16338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16339. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16340. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16341. import { Scene } from "babylonjs/scene";
  16342. /**
  16343. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16344. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16345. */
  16346. export class Texture extends BaseTexture {
  16347. /**
  16348. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16349. */
  16350. static SerializeBuffers: boolean;
  16351. /** @hidden */
  16352. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16353. /** @hidden */
  16354. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16355. /** @hidden */
  16356. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16357. /** nearest is mag = nearest and min = nearest and mip = linear */
  16358. static readonly NEAREST_SAMPLINGMODE: number;
  16359. /** nearest is mag = nearest and min = nearest and mip = linear */
  16360. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16361. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16362. static readonly BILINEAR_SAMPLINGMODE: number;
  16363. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16364. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16365. /** Trilinear is mag = linear and min = linear and mip = linear */
  16366. static readonly TRILINEAR_SAMPLINGMODE: number;
  16367. /** Trilinear is mag = linear and min = linear and mip = linear */
  16368. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16369. /** mag = nearest and min = nearest and mip = nearest */
  16370. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16371. /** mag = nearest and min = linear and mip = nearest */
  16372. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16373. /** mag = nearest and min = linear and mip = linear */
  16374. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16375. /** mag = nearest and min = linear and mip = none */
  16376. static readonly NEAREST_LINEAR: number;
  16377. /** mag = nearest and min = nearest and mip = none */
  16378. static readonly NEAREST_NEAREST: number;
  16379. /** mag = linear and min = nearest and mip = nearest */
  16380. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16381. /** mag = linear and min = nearest and mip = linear */
  16382. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16383. /** mag = linear and min = linear and mip = none */
  16384. static readonly LINEAR_LINEAR: number;
  16385. /** mag = linear and min = nearest and mip = none */
  16386. static readonly LINEAR_NEAREST: number;
  16387. /** Explicit coordinates mode */
  16388. static readonly EXPLICIT_MODE: number;
  16389. /** Spherical coordinates mode */
  16390. static readonly SPHERICAL_MODE: number;
  16391. /** Planar coordinates mode */
  16392. static readonly PLANAR_MODE: number;
  16393. /** Cubic coordinates mode */
  16394. static readonly CUBIC_MODE: number;
  16395. /** Projection coordinates mode */
  16396. static readonly PROJECTION_MODE: number;
  16397. /** Inverse Cubic coordinates mode */
  16398. static readonly SKYBOX_MODE: number;
  16399. /** Inverse Cubic coordinates mode */
  16400. static readonly INVCUBIC_MODE: number;
  16401. /** Equirectangular coordinates mode */
  16402. static readonly EQUIRECTANGULAR_MODE: number;
  16403. /** Equirectangular Fixed coordinates mode */
  16404. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16405. /** Equirectangular Fixed Mirrored coordinates mode */
  16406. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16407. /** Texture is not repeating outside of 0..1 UVs */
  16408. static readonly CLAMP_ADDRESSMODE: number;
  16409. /** Texture is repeating outside of 0..1 UVs */
  16410. static readonly WRAP_ADDRESSMODE: number;
  16411. /** Texture is repeating and mirrored */
  16412. static readonly MIRROR_ADDRESSMODE: number;
  16413. /**
  16414. * 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
  16415. */
  16416. static UseSerializedUrlIfAny: boolean;
  16417. /**
  16418. * Define the url of the texture.
  16419. */
  16420. url: Nullable<string>;
  16421. /**
  16422. * Define an offset on the texture to offset the u coordinates of the UVs
  16423. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16424. */
  16425. uOffset: number;
  16426. /**
  16427. * Define an offset on the texture to offset the v coordinates of the UVs
  16428. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16429. */
  16430. vOffset: number;
  16431. /**
  16432. * Define an offset on the texture to scale the u coordinates of the UVs
  16433. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16434. */
  16435. uScale: number;
  16436. /**
  16437. * Define an offset on the texture to scale the v coordinates of the UVs
  16438. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16439. */
  16440. vScale: number;
  16441. /**
  16442. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16443. * @see http://doc.babylonjs.com/how_to/more_materials
  16444. */
  16445. uAng: number;
  16446. /**
  16447. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16448. * @see http://doc.babylonjs.com/how_to/more_materials
  16449. */
  16450. vAng: number;
  16451. /**
  16452. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16453. * @see http://doc.babylonjs.com/how_to/more_materials
  16454. */
  16455. wAng: number;
  16456. /**
  16457. * Defines the center of rotation (U)
  16458. */
  16459. uRotationCenter: number;
  16460. /**
  16461. * Defines the center of rotation (V)
  16462. */
  16463. vRotationCenter: number;
  16464. /**
  16465. * Defines the center of rotation (W)
  16466. */
  16467. wRotationCenter: number;
  16468. /**
  16469. * Are mip maps generated for this texture or not.
  16470. */
  16471. get noMipmap(): boolean;
  16472. /**
  16473. * List of inspectable custom properties (used by the Inspector)
  16474. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16475. */
  16476. inspectableCustomProperties: Nullable<IInspectable[]>;
  16477. private _noMipmap;
  16478. /** @hidden */
  16479. _invertY: boolean;
  16480. private _rowGenerationMatrix;
  16481. private _cachedTextureMatrix;
  16482. private _projectionModeMatrix;
  16483. private _t0;
  16484. private _t1;
  16485. private _t2;
  16486. private _cachedUOffset;
  16487. private _cachedVOffset;
  16488. private _cachedUScale;
  16489. private _cachedVScale;
  16490. private _cachedUAng;
  16491. private _cachedVAng;
  16492. private _cachedWAng;
  16493. private _cachedProjectionMatrixId;
  16494. private _cachedCoordinatesMode;
  16495. /** @hidden */
  16496. protected _initialSamplingMode: number;
  16497. /** @hidden */
  16498. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16499. private _deleteBuffer;
  16500. protected _format: Nullable<number>;
  16501. private _delayedOnLoad;
  16502. private _delayedOnError;
  16503. private _mimeType?;
  16504. /**
  16505. * Observable triggered once the texture has been loaded.
  16506. */
  16507. onLoadObservable: Observable<Texture>;
  16508. protected _isBlocking: boolean;
  16509. /**
  16510. * Is the texture preventing material to render while loading.
  16511. * If false, a default texture will be used instead of the loading one during the preparation step.
  16512. */
  16513. set isBlocking(value: boolean);
  16514. get isBlocking(): boolean;
  16515. /**
  16516. * Get the current sampling mode associated with the texture.
  16517. */
  16518. get samplingMode(): number;
  16519. /**
  16520. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16521. */
  16522. get invertY(): boolean;
  16523. /**
  16524. * Instantiates a new texture.
  16525. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16526. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16527. * @param url defines the url of the picture to load as a texture
  16528. * @param scene defines the scene or engine the texture will belong to
  16529. * @param noMipmap defines if the texture will require mip maps or not
  16530. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16531. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16532. * @param onLoad defines a callback triggered when the texture has been loaded
  16533. * @param onError defines a callback triggered when an error occurred during the loading session
  16534. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16535. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16536. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16537. * @param mimeType defines an optional mime type information
  16538. */
  16539. 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);
  16540. /**
  16541. * Update the url (and optional buffer) of this texture if url was null during construction.
  16542. * @param url the url of the texture
  16543. * @param buffer the buffer of the texture (defaults to null)
  16544. * @param onLoad callback called when the texture is loaded (defaults to null)
  16545. */
  16546. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16547. /**
  16548. * Finish the loading sequence of a texture flagged as delayed load.
  16549. * @hidden
  16550. */
  16551. delayLoad(): void;
  16552. private _prepareRowForTextureGeneration;
  16553. /**
  16554. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16555. * @returns the transform matrix of the texture.
  16556. */
  16557. getTextureMatrix(uBase?: number): Matrix;
  16558. /**
  16559. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16560. * @returns The reflection texture transform
  16561. */
  16562. getReflectionTextureMatrix(): Matrix;
  16563. /**
  16564. * Clones the texture.
  16565. * @returns the cloned texture
  16566. */
  16567. clone(): Texture;
  16568. /**
  16569. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16570. * @returns The JSON representation of the texture
  16571. */
  16572. serialize(): any;
  16573. /**
  16574. * Get the current class name of the texture useful for serialization or dynamic coding.
  16575. * @returns "Texture"
  16576. */
  16577. getClassName(): string;
  16578. /**
  16579. * Dispose the texture and release its associated resources.
  16580. */
  16581. dispose(): void;
  16582. /**
  16583. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16584. * @param parsedTexture Define the JSON representation of the texture
  16585. * @param scene Define the scene the parsed texture should be instantiated in
  16586. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16587. * @returns The parsed texture if successful
  16588. */
  16589. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16590. /**
  16591. * Creates a texture from its base 64 representation.
  16592. * @param data Define the base64 payload without the data: prefix
  16593. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16594. * @param scene Define the scene the texture should belong to
  16595. * @param noMipmap Forces the texture to not create mip map information if true
  16596. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16597. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16598. * @param onLoad define a callback triggered when the texture has been loaded
  16599. * @param onError define a callback triggered when an error occurred during the loading session
  16600. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16601. * @returns the created texture
  16602. */
  16603. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16604. /**
  16605. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16606. * @param data Define the base64 payload without the data: prefix
  16607. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16608. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16609. * @param scene Define the scene the texture should belong to
  16610. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16611. * @param noMipmap Forces the texture to not create mip map information if true
  16612. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16613. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16614. * @param onLoad define a callback triggered when the texture has been loaded
  16615. * @param onError define a callback triggered when an error occurred during the loading session
  16616. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16617. * @returns the created texture
  16618. */
  16619. 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;
  16620. }
  16621. }
  16622. declare module "babylonjs/PostProcesses/postProcessManager" {
  16623. import { Nullable } from "babylonjs/types";
  16624. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16625. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16626. import { Scene } from "babylonjs/scene";
  16627. /**
  16628. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16629. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16630. */
  16631. export class PostProcessManager {
  16632. private _scene;
  16633. private _indexBuffer;
  16634. private _vertexBuffers;
  16635. /**
  16636. * Creates a new instance PostProcess
  16637. * @param scene The scene that the post process is associated with.
  16638. */
  16639. constructor(scene: Scene);
  16640. private _prepareBuffers;
  16641. private _buildIndexBuffer;
  16642. /**
  16643. * Rebuilds the vertex buffers of the manager.
  16644. * @hidden
  16645. */
  16646. _rebuild(): void;
  16647. /**
  16648. * Prepares a frame to be run through a post process.
  16649. * @param sourceTexture The input texture to the post procesess. (default: null)
  16650. * @param postProcesses An array of post processes to be run. (default: null)
  16651. * @returns True if the post processes were able to be run.
  16652. * @hidden
  16653. */
  16654. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16655. /**
  16656. * Manually render a set of post processes to a texture.
  16657. * @param postProcesses An array of post processes to be run.
  16658. * @param targetTexture The target texture to render to.
  16659. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16660. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16661. * @param lodLevel defines which lod of the texture to render to
  16662. */
  16663. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16664. /**
  16665. * Finalize the result of the output of the postprocesses.
  16666. * @param doNotPresent If true the result will not be displayed to the screen.
  16667. * @param targetTexture The target texture to render to.
  16668. * @param faceIndex The index of the face to bind the target texture to.
  16669. * @param postProcesses The array of post processes to render.
  16670. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16671. * @hidden
  16672. */
  16673. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16674. /**
  16675. * Disposes of the post process manager.
  16676. */
  16677. dispose(): void;
  16678. }
  16679. }
  16680. declare module "babylonjs/Misc/gradients" {
  16681. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16682. /** Interface used by value gradients (color, factor, ...) */
  16683. export interface IValueGradient {
  16684. /**
  16685. * Gets or sets the gradient value (between 0 and 1)
  16686. */
  16687. gradient: number;
  16688. }
  16689. /** Class used to store color4 gradient */
  16690. export class ColorGradient implements IValueGradient {
  16691. /**
  16692. * Gets or sets the gradient value (between 0 and 1)
  16693. */
  16694. gradient: number;
  16695. /**
  16696. * Gets or sets first associated color
  16697. */
  16698. color1: Color4;
  16699. /**
  16700. * Gets or sets second associated color
  16701. */
  16702. color2?: Color4;
  16703. /**
  16704. * Will get a color picked randomly between color1 and color2.
  16705. * If color2 is undefined then color1 will be used
  16706. * @param result defines the target Color4 to store the result in
  16707. */
  16708. getColorToRef(result: Color4): void;
  16709. }
  16710. /** Class used to store color 3 gradient */
  16711. export class Color3Gradient implements IValueGradient {
  16712. /**
  16713. * Gets or sets the gradient value (between 0 and 1)
  16714. */
  16715. gradient: number;
  16716. /**
  16717. * Gets or sets the associated color
  16718. */
  16719. color: Color3;
  16720. }
  16721. /** Class used to store factor gradient */
  16722. export class FactorGradient implements IValueGradient {
  16723. /**
  16724. * Gets or sets the gradient value (between 0 and 1)
  16725. */
  16726. gradient: number;
  16727. /**
  16728. * Gets or sets first associated factor
  16729. */
  16730. factor1: number;
  16731. /**
  16732. * Gets or sets second associated factor
  16733. */
  16734. factor2?: number;
  16735. /**
  16736. * Will get a number picked randomly between factor1 and factor2.
  16737. * If factor2 is undefined then factor1 will be used
  16738. * @returns the picked number
  16739. */
  16740. getFactor(): number;
  16741. }
  16742. /**
  16743. * Helper used to simplify some generic gradient tasks
  16744. */
  16745. export class GradientHelper {
  16746. /**
  16747. * Gets the current gradient from an array of IValueGradient
  16748. * @param ratio defines the current ratio to get
  16749. * @param gradients defines the array of IValueGradient
  16750. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16751. */
  16752. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16753. }
  16754. }
  16755. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16756. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16757. import { Nullable } from "babylonjs/types";
  16758. module "babylonjs/Engines/thinEngine" {
  16759. interface ThinEngine {
  16760. /**
  16761. * Creates a dynamic texture
  16762. * @param width defines the width of the texture
  16763. * @param height defines the height of the texture
  16764. * @param generateMipMaps defines if the engine should generate the mip levels
  16765. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16766. * @returns the dynamic texture inside an InternalTexture
  16767. */
  16768. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16769. /**
  16770. * Update the content of a dynamic texture
  16771. * @param texture defines the texture to update
  16772. * @param canvas defines the canvas containing the source
  16773. * @param invertY defines if data must be stored with Y axis inverted
  16774. * @param premulAlpha defines if alpha is stored as premultiplied
  16775. * @param format defines the format of the data
  16776. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16777. */
  16778. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16779. }
  16780. }
  16781. }
  16782. declare module "babylonjs/Misc/canvasGenerator" {
  16783. /**
  16784. * Helper class used to generate a canvas to manipulate images
  16785. */
  16786. export class CanvasGenerator {
  16787. /**
  16788. * Create a new canvas (or offscreen canvas depending on the context)
  16789. * @param width defines the expected width
  16790. * @param height defines the expected height
  16791. * @return a new canvas or offscreen canvas
  16792. */
  16793. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16794. }
  16795. }
  16796. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16797. import { Scene } from "babylonjs/scene";
  16798. import { Texture } from "babylonjs/Materials/Textures/texture";
  16799. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16800. /**
  16801. * A class extending Texture allowing drawing on a texture
  16802. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16803. */
  16804. export class DynamicTexture extends Texture {
  16805. private _generateMipMaps;
  16806. private _canvas;
  16807. private _context;
  16808. private _engine;
  16809. /**
  16810. * Creates a DynamicTexture
  16811. * @param name defines the name of the texture
  16812. * @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
  16813. * @param scene defines the scene where you want the texture
  16814. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16815. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16816. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16817. */
  16818. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16819. /**
  16820. * Get the current class name of the texture useful for serialization or dynamic coding.
  16821. * @returns "DynamicTexture"
  16822. */
  16823. getClassName(): string;
  16824. /**
  16825. * Gets the current state of canRescale
  16826. */
  16827. get canRescale(): boolean;
  16828. private _recreate;
  16829. /**
  16830. * Scales the texture
  16831. * @param ratio the scale factor to apply to both width and height
  16832. */
  16833. scale(ratio: number): void;
  16834. /**
  16835. * Resizes the texture
  16836. * @param width the new width
  16837. * @param height the new height
  16838. */
  16839. scaleTo(width: number, height: number): void;
  16840. /**
  16841. * Gets the context of the canvas used by the texture
  16842. * @returns the canvas context of the dynamic texture
  16843. */
  16844. getContext(): CanvasRenderingContext2D;
  16845. /**
  16846. * Clears the texture
  16847. */
  16848. clear(): void;
  16849. /**
  16850. * Updates the texture
  16851. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16852. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16853. */
  16854. update(invertY?: boolean, premulAlpha?: boolean): void;
  16855. /**
  16856. * Draws text onto the texture
  16857. * @param text defines the text to be drawn
  16858. * @param x defines the placement of the text from the left
  16859. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16860. * @param font defines the font to be used with font-style, font-size, font-name
  16861. * @param color defines the color used for the text
  16862. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16863. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16864. * @param update defines whether texture is immediately update (default is true)
  16865. */
  16866. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16867. /**
  16868. * Clones the texture
  16869. * @returns the clone of the texture.
  16870. */
  16871. clone(): DynamicTexture;
  16872. /**
  16873. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16874. * @returns a serialized dynamic texture object
  16875. */
  16876. serialize(): any;
  16877. /** @hidden */
  16878. _rebuild(): void;
  16879. }
  16880. }
  16881. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16882. import { Scene } from "babylonjs/scene";
  16883. import { ISceneComponent } from "babylonjs/sceneComponent";
  16884. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16885. module "babylonjs/abstractScene" {
  16886. interface AbstractScene {
  16887. /**
  16888. * The list of procedural textures added to the scene
  16889. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16890. */
  16891. proceduralTextures: Array<ProceduralTexture>;
  16892. }
  16893. }
  16894. /**
  16895. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16896. * in a given scene.
  16897. */
  16898. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16899. /**
  16900. * The component name helpfull to identify the component in the list of scene components.
  16901. */
  16902. readonly name: string;
  16903. /**
  16904. * The scene the component belongs to.
  16905. */
  16906. scene: Scene;
  16907. /**
  16908. * Creates a new instance of the component for the given scene
  16909. * @param scene Defines the scene to register the component in
  16910. */
  16911. constructor(scene: Scene);
  16912. /**
  16913. * Registers the component in a given scene
  16914. */
  16915. register(): void;
  16916. /**
  16917. * Rebuilds the elements related to this component in case of
  16918. * context lost for instance.
  16919. */
  16920. rebuild(): void;
  16921. /**
  16922. * Disposes the component and the associated ressources.
  16923. */
  16924. dispose(): void;
  16925. private _beforeClear;
  16926. }
  16927. }
  16928. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16929. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16930. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16931. module "babylonjs/Engines/thinEngine" {
  16932. interface ThinEngine {
  16933. /**
  16934. * Creates a new render target cube texture
  16935. * @param size defines the size of the texture
  16936. * @param options defines the options used to create the texture
  16937. * @returns a new render target cube texture stored in an InternalTexture
  16938. */
  16939. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16940. }
  16941. }
  16942. }
  16943. declare module "babylonjs/Shaders/procedural.vertex" {
  16944. /** @hidden */
  16945. export var proceduralVertexShader: {
  16946. name: string;
  16947. shader: string;
  16948. };
  16949. }
  16950. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16951. import { Observable } from "babylonjs/Misc/observable";
  16952. import { Nullable } from "babylonjs/types";
  16953. import { Scene } from "babylonjs/scene";
  16954. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16955. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16956. import { Effect } from "babylonjs/Materials/effect";
  16957. import { Texture } from "babylonjs/Materials/Textures/texture";
  16958. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16959. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16960. import "babylonjs/Shaders/procedural.vertex";
  16961. /**
  16962. * 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.
  16963. * This is the base class of any Procedural texture and contains most of the shareable code.
  16964. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16965. */
  16966. export class ProceduralTexture extends Texture {
  16967. isCube: boolean;
  16968. /**
  16969. * Define if the texture is enabled or not (disabled texture will not render)
  16970. */
  16971. isEnabled: boolean;
  16972. /**
  16973. * Define if the texture must be cleared before rendering (default is true)
  16974. */
  16975. autoClear: boolean;
  16976. /**
  16977. * Callback called when the texture is generated
  16978. */
  16979. onGenerated: () => void;
  16980. /**
  16981. * Event raised when the texture is generated
  16982. */
  16983. onGeneratedObservable: Observable<ProceduralTexture>;
  16984. /** @hidden */
  16985. _generateMipMaps: boolean;
  16986. /** @hidden **/
  16987. _effect: Effect;
  16988. /** @hidden */
  16989. _textures: {
  16990. [key: string]: Texture;
  16991. };
  16992. private _size;
  16993. private _currentRefreshId;
  16994. private _frameId;
  16995. private _refreshRate;
  16996. private _vertexBuffers;
  16997. private _indexBuffer;
  16998. private _uniforms;
  16999. private _samplers;
  17000. private _fragment;
  17001. private _floats;
  17002. private _ints;
  17003. private _floatsArrays;
  17004. private _colors3;
  17005. private _colors4;
  17006. private _vectors2;
  17007. private _vectors3;
  17008. private _matrices;
  17009. private _fallbackTexture;
  17010. private _fallbackTextureUsed;
  17011. private _engine;
  17012. private _cachedDefines;
  17013. private _contentUpdateId;
  17014. private _contentData;
  17015. /**
  17016. * Instantiates a new procedural texture.
  17017. * 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.
  17018. * This is the base class of any Procedural texture and contains most of the shareable code.
  17019. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17020. * @param name Define the name of the texture
  17021. * @param size Define the size of the texture to create
  17022. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17023. * @param scene Define the scene the texture belongs to
  17024. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17025. * @param generateMipMaps Define if the texture should creates mip maps or not
  17026. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17027. */
  17028. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17029. /**
  17030. * The effect that is created when initializing the post process.
  17031. * @returns The created effect corresponding the the postprocess.
  17032. */
  17033. getEffect(): Effect;
  17034. /**
  17035. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17036. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17037. */
  17038. getContent(): Nullable<ArrayBufferView>;
  17039. private _createIndexBuffer;
  17040. /** @hidden */
  17041. _rebuild(): void;
  17042. /**
  17043. * Resets the texture in order to recreate its associated resources.
  17044. * This can be called in case of context loss
  17045. */
  17046. reset(): void;
  17047. protected _getDefines(): string;
  17048. /**
  17049. * Is the texture ready to be used ? (rendered at least once)
  17050. * @returns true if ready, otherwise, false.
  17051. */
  17052. isReady(): boolean;
  17053. /**
  17054. * Resets the refresh counter of the texture and start bak from scratch.
  17055. * Could be useful to regenerate the texture if it is setup to render only once.
  17056. */
  17057. resetRefreshCounter(): void;
  17058. /**
  17059. * Set the fragment shader to use in order to render the texture.
  17060. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17061. */
  17062. setFragment(fragment: any): void;
  17063. /**
  17064. * Define the refresh rate of the texture or the rendering frequency.
  17065. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17066. */
  17067. get refreshRate(): number;
  17068. set refreshRate(value: number);
  17069. /** @hidden */
  17070. _shouldRender(): boolean;
  17071. /**
  17072. * Get the size the texture is rendering at.
  17073. * @returns the size (texture is always squared)
  17074. */
  17075. getRenderSize(): number;
  17076. /**
  17077. * Resize the texture to new value.
  17078. * @param size Define the new size the texture should have
  17079. * @param generateMipMaps Define whether the new texture should create mip maps
  17080. */
  17081. resize(size: number, generateMipMaps: boolean): void;
  17082. private _checkUniform;
  17083. /**
  17084. * Set a texture in the shader program used to render.
  17085. * @param name Define the name of the uniform samplers as defined in the shader
  17086. * @param texture Define the texture to bind to this sampler
  17087. * @return the texture itself allowing "fluent" like uniform updates
  17088. */
  17089. setTexture(name: string, texture: Texture): ProceduralTexture;
  17090. /**
  17091. * Set a float in the shader.
  17092. * @param name Define the name of the uniform as defined in the shader
  17093. * @param value Define the value to give to the uniform
  17094. * @return the texture itself allowing "fluent" like uniform updates
  17095. */
  17096. setFloat(name: string, value: number): ProceduralTexture;
  17097. /**
  17098. * Set a int in the shader.
  17099. * @param name Define the name of the uniform as defined in the shader
  17100. * @param value Define the value to give to the uniform
  17101. * @return the texture itself allowing "fluent" like uniform updates
  17102. */
  17103. setInt(name: string, value: number): ProceduralTexture;
  17104. /**
  17105. * Set an array of floats in the shader.
  17106. * @param name Define the name of the uniform as defined in the shader
  17107. * @param value Define the value to give to the uniform
  17108. * @return the texture itself allowing "fluent" like uniform updates
  17109. */
  17110. setFloats(name: string, value: number[]): ProceduralTexture;
  17111. /**
  17112. * Set a vec3 in the shader from a Color3.
  17113. * @param name Define the name of the uniform as defined in the shader
  17114. * @param value Define the value to give to the uniform
  17115. * @return the texture itself allowing "fluent" like uniform updates
  17116. */
  17117. setColor3(name: string, value: Color3): ProceduralTexture;
  17118. /**
  17119. * Set a vec4 in the shader from a Color4.
  17120. * @param name Define the name of the uniform as defined in the shader
  17121. * @param value Define the value to give to the uniform
  17122. * @return the texture itself allowing "fluent" like uniform updates
  17123. */
  17124. setColor4(name: string, value: Color4): ProceduralTexture;
  17125. /**
  17126. * Set a vec2 in the shader from a Vector2.
  17127. * @param name Define the name of the uniform as defined in the shader
  17128. * @param value Define the value to give to the uniform
  17129. * @return the texture itself allowing "fluent" like uniform updates
  17130. */
  17131. setVector2(name: string, value: Vector2): ProceduralTexture;
  17132. /**
  17133. * Set a vec3 in the shader from a Vector3.
  17134. * @param name Define the name of the uniform as defined in the shader
  17135. * @param value Define the value to give to the uniform
  17136. * @return the texture itself allowing "fluent" like uniform updates
  17137. */
  17138. setVector3(name: string, value: Vector3): ProceduralTexture;
  17139. /**
  17140. * Set a mat4 in the shader from a MAtrix.
  17141. * @param name Define the name of the uniform as defined in the shader
  17142. * @param value Define the value to give to the uniform
  17143. * @return the texture itself allowing "fluent" like uniform updates
  17144. */
  17145. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17146. /**
  17147. * Render the texture to its associated render target.
  17148. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17149. */
  17150. render(useCameraPostProcess?: boolean): void;
  17151. /**
  17152. * Clone the texture.
  17153. * @returns the cloned texture
  17154. */
  17155. clone(): ProceduralTexture;
  17156. /**
  17157. * Dispose the texture and release its asoociated resources.
  17158. */
  17159. dispose(): void;
  17160. }
  17161. }
  17162. declare module "babylonjs/Particles/baseParticleSystem" {
  17163. import { Nullable } from "babylonjs/types";
  17164. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17166. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17167. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17168. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17169. import { Scene } from "babylonjs/scene";
  17170. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17171. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17172. import { Texture } from "babylonjs/Materials/Textures/texture";
  17173. import { Color4 } from "babylonjs/Maths/math.color";
  17174. import { Animation } from "babylonjs/Animations/animation";
  17175. /**
  17176. * This represents the base class for particle system in Babylon.
  17177. * 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.
  17178. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17179. * @example https://doc.babylonjs.com/babylon101/particles
  17180. */
  17181. export class BaseParticleSystem {
  17182. /**
  17183. * Source color is added to the destination color without alpha affecting the result
  17184. */
  17185. static BLENDMODE_ONEONE: number;
  17186. /**
  17187. * Blend current color and particle color using particle’s alpha
  17188. */
  17189. static BLENDMODE_STANDARD: number;
  17190. /**
  17191. * Add current color and particle color multiplied by particle’s alpha
  17192. */
  17193. static BLENDMODE_ADD: number;
  17194. /**
  17195. * Multiply current color with particle color
  17196. */
  17197. static BLENDMODE_MULTIPLY: number;
  17198. /**
  17199. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17200. */
  17201. static BLENDMODE_MULTIPLYADD: number;
  17202. /**
  17203. * List of animations used by the particle system.
  17204. */
  17205. animations: Animation[];
  17206. /**
  17207. * The id of the Particle system.
  17208. */
  17209. id: string;
  17210. /**
  17211. * The friendly name of the Particle system.
  17212. */
  17213. name: string;
  17214. /**
  17215. * The rendering group used by the Particle system to chose when to render.
  17216. */
  17217. renderingGroupId: number;
  17218. /**
  17219. * The emitter represents the Mesh or position we are attaching the particle system to.
  17220. */
  17221. emitter: Nullable<AbstractMesh | Vector3>;
  17222. /**
  17223. * The maximum number of particles to emit per frame
  17224. */
  17225. emitRate: number;
  17226. /**
  17227. * If you want to launch only a few particles at once, that can be done, as well.
  17228. */
  17229. manualEmitCount: number;
  17230. /**
  17231. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17232. */
  17233. updateSpeed: number;
  17234. /**
  17235. * The amount of time the particle system is running (depends of the overall update speed).
  17236. */
  17237. targetStopDuration: number;
  17238. /**
  17239. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17240. */
  17241. disposeOnStop: boolean;
  17242. /**
  17243. * Minimum power of emitting particles.
  17244. */
  17245. minEmitPower: number;
  17246. /**
  17247. * Maximum power of emitting particles.
  17248. */
  17249. maxEmitPower: number;
  17250. /**
  17251. * Minimum life time of emitting particles.
  17252. */
  17253. minLifeTime: number;
  17254. /**
  17255. * Maximum life time of emitting particles.
  17256. */
  17257. maxLifeTime: number;
  17258. /**
  17259. * Minimum Size of emitting particles.
  17260. */
  17261. minSize: number;
  17262. /**
  17263. * Maximum Size of emitting particles.
  17264. */
  17265. maxSize: number;
  17266. /**
  17267. * Minimum scale of emitting particles on X axis.
  17268. */
  17269. minScaleX: number;
  17270. /**
  17271. * Maximum scale of emitting particles on X axis.
  17272. */
  17273. maxScaleX: number;
  17274. /**
  17275. * Minimum scale of emitting particles on Y axis.
  17276. */
  17277. minScaleY: number;
  17278. /**
  17279. * Maximum scale of emitting particles on Y axis.
  17280. */
  17281. maxScaleY: number;
  17282. /**
  17283. * Gets or sets the minimal initial rotation in radians.
  17284. */
  17285. minInitialRotation: number;
  17286. /**
  17287. * Gets or sets the maximal initial rotation in radians.
  17288. */
  17289. maxInitialRotation: number;
  17290. /**
  17291. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17292. */
  17293. minAngularSpeed: number;
  17294. /**
  17295. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17296. */
  17297. maxAngularSpeed: number;
  17298. /**
  17299. * The texture used to render each particle. (this can be a spritesheet)
  17300. */
  17301. particleTexture: Nullable<Texture>;
  17302. /**
  17303. * The layer mask we are rendering the particles through.
  17304. */
  17305. layerMask: number;
  17306. /**
  17307. * This can help using your own shader to render the particle system.
  17308. * The according effect will be created
  17309. */
  17310. customShader: any;
  17311. /**
  17312. * By default particle system starts as soon as they are created. This prevents the
  17313. * automatic start to happen and let you decide when to start emitting particles.
  17314. */
  17315. preventAutoStart: boolean;
  17316. private _noiseTexture;
  17317. /**
  17318. * Gets or sets a texture used to add random noise to particle positions
  17319. */
  17320. get noiseTexture(): Nullable<ProceduralTexture>;
  17321. set noiseTexture(value: Nullable<ProceduralTexture>);
  17322. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17323. noiseStrength: Vector3;
  17324. /**
  17325. * Callback triggered when the particle animation is ending.
  17326. */
  17327. onAnimationEnd: Nullable<() => void>;
  17328. /**
  17329. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17330. */
  17331. blendMode: number;
  17332. /**
  17333. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17334. * to override the particles.
  17335. */
  17336. forceDepthWrite: boolean;
  17337. /** 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 */
  17338. preWarmCycles: number;
  17339. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17340. preWarmStepOffset: number;
  17341. /**
  17342. * 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)
  17343. */
  17344. spriteCellChangeSpeed: number;
  17345. /**
  17346. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17347. */
  17348. startSpriteCellID: number;
  17349. /**
  17350. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17351. */
  17352. endSpriteCellID: number;
  17353. /**
  17354. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17355. */
  17356. spriteCellWidth: number;
  17357. /**
  17358. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17359. */
  17360. spriteCellHeight: number;
  17361. /**
  17362. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17363. */
  17364. spriteRandomStartCell: boolean;
  17365. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17366. translationPivot: Vector2;
  17367. /** @hidden */
  17368. protected _isAnimationSheetEnabled: boolean;
  17369. /**
  17370. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17371. */
  17372. beginAnimationOnStart: boolean;
  17373. /**
  17374. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17375. */
  17376. beginAnimationFrom: number;
  17377. /**
  17378. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17379. */
  17380. beginAnimationTo: number;
  17381. /**
  17382. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17383. */
  17384. beginAnimationLoop: boolean;
  17385. /**
  17386. * Gets or sets a world offset applied to all particles
  17387. */
  17388. worldOffset: Vector3;
  17389. /**
  17390. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17391. */
  17392. get isAnimationSheetEnabled(): boolean;
  17393. set isAnimationSheetEnabled(value: boolean);
  17394. /**
  17395. * Get hosting scene
  17396. * @returns the scene
  17397. */
  17398. getScene(): Scene;
  17399. /**
  17400. * You can use gravity if you want to give an orientation to your particles.
  17401. */
  17402. gravity: Vector3;
  17403. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17404. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17405. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17406. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17407. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17408. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17409. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17410. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17411. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17412. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17413. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17414. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17415. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17416. /**
  17417. * Defines the delay in milliseconds before starting the system (0 by default)
  17418. */
  17419. startDelay: number;
  17420. /**
  17421. * Gets the current list of drag gradients.
  17422. * You must use addDragGradient and removeDragGradient to udpate this list
  17423. * @returns the list of drag gradients
  17424. */
  17425. getDragGradients(): Nullable<Array<FactorGradient>>;
  17426. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17427. limitVelocityDamping: number;
  17428. /**
  17429. * Gets the current list of limit velocity gradients.
  17430. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17431. * @returns the list of limit velocity gradients
  17432. */
  17433. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17434. /**
  17435. * Gets the current list of color gradients.
  17436. * You must use addColorGradient and removeColorGradient to udpate this list
  17437. * @returns the list of color gradients
  17438. */
  17439. getColorGradients(): Nullable<Array<ColorGradient>>;
  17440. /**
  17441. * Gets the current list of size gradients.
  17442. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17443. * @returns the list of size gradients
  17444. */
  17445. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17446. /**
  17447. * Gets the current list of color remap gradients.
  17448. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17449. * @returns the list of color remap gradients
  17450. */
  17451. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17452. /**
  17453. * Gets the current list of alpha remap gradients.
  17454. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17455. * @returns the list of alpha remap gradients
  17456. */
  17457. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17458. /**
  17459. * Gets the current list of life time gradients.
  17460. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17461. * @returns the list of life time gradients
  17462. */
  17463. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17464. /**
  17465. * Gets the current list of angular speed gradients.
  17466. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17467. * @returns the list of angular speed gradients
  17468. */
  17469. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17470. /**
  17471. * Gets the current list of velocity gradients.
  17472. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17473. * @returns the list of velocity gradients
  17474. */
  17475. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17476. /**
  17477. * Gets the current list of start size gradients.
  17478. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17479. * @returns the list of start size gradients
  17480. */
  17481. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17482. /**
  17483. * Gets the current list of emit rate gradients.
  17484. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17485. * @returns the list of emit rate gradients
  17486. */
  17487. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17488. /**
  17489. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17490. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17491. */
  17492. get direction1(): Vector3;
  17493. set direction1(value: Vector3);
  17494. /**
  17495. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17496. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17497. */
  17498. get direction2(): Vector3;
  17499. set direction2(value: Vector3);
  17500. /**
  17501. * 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.
  17502. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17503. */
  17504. get minEmitBox(): Vector3;
  17505. set minEmitBox(value: Vector3);
  17506. /**
  17507. * 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.
  17508. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17509. */
  17510. get maxEmitBox(): Vector3;
  17511. set maxEmitBox(value: Vector3);
  17512. /**
  17513. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17514. */
  17515. color1: Color4;
  17516. /**
  17517. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17518. */
  17519. color2: Color4;
  17520. /**
  17521. * Color the particle will have at the end of its lifetime
  17522. */
  17523. colorDead: Color4;
  17524. /**
  17525. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17526. */
  17527. textureMask: Color4;
  17528. /**
  17529. * The particle emitter type defines the emitter used by the particle system.
  17530. * It can be for example box, sphere, or cone...
  17531. */
  17532. particleEmitterType: IParticleEmitterType;
  17533. /** @hidden */
  17534. _isSubEmitter: boolean;
  17535. /**
  17536. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17537. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17538. */
  17539. billboardMode: number;
  17540. protected _isBillboardBased: boolean;
  17541. /**
  17542. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17543. */
  17544. get isBillboardBased(): boolean;
  17545. set isBillboardBased(value: boolean);
  17546. /**
  17547. * The scene the particle system belongs to.
  17548. */
  17549. protected _scene: Scene;
  17550. /**
  17551. * Local cache of defines for image processing.
  17552. */
  17553. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17554. /**
  17555. * Default configuration related to image processing available in the standard Material.
  17556. */
  17557. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17558. /**
  17559. * Gets the image processing configuration used either in this material.
  17560. */
  17561. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17562. /**
  17563. * Sets the Default image processing configuration used either in the this material.
  17564. *
  17565. * If sets to null, the scene one is in use.
  17566. */
  17567. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17568. /**
  17569. * Attaches a new image processing configuration to the Standard Material.
  17570. * @param configuration
  17571. */
  17572. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17573. /** @hidden */
  17574. protected _reset(): void;
  17575. /** @hidden */
  17576. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17577. /**
  17578. * Instantiates a particle system.
  17579. * 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.
  17580. * @param name The name of the particle system
  17581. */
  17582. constructor(name: string);
  17583. /**
  17584. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17585. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17586. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17587. * @returns the emitter
  17588. */
  17589. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17590. /**
  17591. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17592. * @param radius The radius of the hemisphere to emit from
  17593. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17594. * @returns the emitter
  17595. */
  17596. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17597. /**
  17598. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17599. * @param radius The radius of the sphere to emit from
  17600. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17601. * @returns the emitter
  17602. */
  17603. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17604. /**
  17605. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17606. * @param radius The radius of the sphere to emit from
  17607. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17608. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17609. * @returns the emitter
  17610. */
  17611. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17612. /**
  17613. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17614. * @param radius The radius of the emission cylinder
  17615. * @param height The height of the emission cylinder
  17616. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17617. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17618. * @returns the emitter
  17619. */
  17620. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17621. /**
  17622. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17623. * @param radius The radius of the cylinder to emit from
  17624. * @param height The height of the emission cylinder
  17625. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17628. * @returns the emitter
  17629. */
  17630. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17631. /**
  17632. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17633. * @param radius The radius of the cone to emit from
  17634. * @param angle The base angle of the cone
  17635. * @returns the emitter
  17636. */
  17637. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17638. /**
  17639. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17640. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17641. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17642. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17643. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17644. * @returns the emitter
  17645. */
  17646. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17647. }
  17648. }
  17649. declare module "babylonjs/Particles/subEmitter" {
  17650. import { Scene } from "babylonjs/scene";
  17651. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17652. /**
  17653. * Type of sub emitter
  17654. */
  17655. export enum SubEmitterType {
  17656. /**
  17657. * Attached to the particle over it's lifetime
  17658. */
  17659. ATTACHED = 0,
  17660. /**
  17661. * Created when the particle dies
  17662. */
  17663. END = 1
  17664. }
  17665. /**
  17666. * Sub emitter class used to emit particles from an existing particle
  17667. */
  17668. export class SubEmitter {
  17669. /**
  17670. * the particle system to be used by the sub emitter
  17671. */
  17672. particleSystem: ParticleSystem;
  17673. /**
  17674. * Type of the submitter (Default: END)
  17675. */
  17676. type: SubEmitterType;
  17677. /**
  17678. * 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)
  17679. * Note: This only is supported when using an emitter of type Mesh
  17680. */
  17681. inheritDirection: boolean;
  17682. /**
  17683. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17684. */
  17685. inheritedVelocityAmount: number;
  17686. /**
  17687. * Creates a sub emitter
  17688. * @param particleSystem the particle system to be used by the sub emitter
  17689. */
  17690. constructor(
  17691. /**
  17692. * the particle system to be used by the sub emitter
  17693. */
  17694. particleSystem: ParticleSystem);
  17695. /**
  17696. * Clones the sub emitter
  17697. * @returns the cloned sub emitter
  17698. */
  17699. clone(): SubEmitter;
  17700. /**
  17701. * Serialize current object to a JSON object
  17702. * @returns the serialized object
  17703. */
  17704. serialize(): any;
  17705. /** @hidden */
  17706. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17707. /**
  17708. * Creates a new SubEmitter from a serialized JSON version
  17709. * @param serializationObject defines the JSON object to read from
  17710. * @param scene defines the hosting scene
  17711. * @param rootUrl defines the rootUrl for data loading
  17712. * @returns a new SubEmitter
  17713. */
  17714. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17715. /** Release associated resources */
  17716. dispose(): void;
  17717. }
  17718. }
  17719. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17720. /** @hidden */
  17721. export var clipPlaneFragmentDeclaration: {
  17722. name: string;
  17723. shader: string;
  17724. };
  17725. }
  17726. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17727. /** @hidden */
  17728. export var imageProcessingDeclaration: {
  17729. name: string;
  17730. shader: string;
  17731. };
  17732. }
  17733. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17734. /** @hidden */
  17735. export var imageProcessingFunctions: {
  17736. name: string;
  17737. shader: string;
  17738. };
  17739. }
  17740. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17741. /** @hidden */
  17742. export var clipPlaneFragment: {
  17743. name: string;
  17744. shader: string;
  17745. };
  17746. }
  17747. declare module "babylonjs/Shaders/particles.fragment" {
  17748. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17749. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17750. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17751. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17752. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17753. /** @hidden */
  17754. export var particlesPixelShader: {
  17755. name: string;
  17756. shader: string;
  17757. };
  17758. }
  17759. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17760. /** @hidden */
  17761. export var clipPlaneVertexDeclaration: {
  17762. name: string;
  17763. shader: string;
  17764. };
  17765. }
  17766. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17767. /** @hidden */
  17768. export var clipPlaneVertex: {
  17769. name: string;
  17770. shader: string;
  17771. };
  17772. }
  17773. declare module "babylonjs/Shaders/particles.vertex" {
  17774. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17775. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17776. /** @hidden */
  17777. export var particlesVertexShader: {
  17778. name: string;
  17779. shader: string;
  17780. };
  17781. }
  17782. declare module "babylonjs/Particles/particleSystem" {
  17783. import { Nullable } from "babylonjs/types";
  17784. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17785. import { Observable } from "babylonjs/Misc/observable";
  17786. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17787. import { Effect } from "babylonjs/Materials/effect";
  17788. import { Scene, IDisposable } from "babylonjs/scene";
  17789. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17790. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17791. import { Particle } from "babylonjs/Particles/particle";
  17792. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17793. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17794. import "babylonjs/Shaders/particles.fragment";
  17795. import "babylonjs/Shaders/particles.vertex";
  17796. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17797. /**
  17798. * This represents a particle system in Babylon.
  17799. * 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.
  17800. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17801. * @example https://doc.babylonjs.com/babylon101/particles
  17802. */
  17803. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17804. /**
  17805. * Billboard mode will only apply to Y axis
  17806. */
  17807. static readonly BILLBOARDMODE_Y: number;
  17808. /**
  17809. * Billboard mode will apply to all axes
  17810. */
  17811. static readonly BILLBOARDMODE_ALL: number;
  17812. /**
  17813. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17814. */
  17815. static readonly BILLBOARDMODE_STRETCHED: number;
  17816. /**
  17817. * This function can be defined to provide custom update for active particles.
  17818. * This function will be called instead of regular update (age, position, color, etc.).
  17819. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17820. */
  17821. updateFunction: (particles: Particle[]) => void;
  17822. private _emitterWorldMatrix;
  17823. /**
  17824. * This function can be defined to specify initial direction for every new particle.
  17825. * It by default use the emitterType defined function
  17826. */
  17827. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17828. /**
  17829. * This function can be defined to specify initial position for every new particle.
  17830. * It by default use the emitterType defined function
  17831. */
  17832. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17833. /**
  17834. * @hidden
  17835. */
  17836. _inheritedVelocityOffset: Vector3;
  17837. /**
  17838. * An event triggered when the system is disposed
  17839. */
  17840. onDisposeObservable: Observable<ParticleSystem>;
  17841. private _onDisposeObserver;
  17842. /**
  17843. * Sets a callback that will be triggered when the system is disposed
  17844. */
  17845. set onDispose(callback: () => void);
  17846. private _particles;
  17847. private _epsilon;
  17848. private _capacity;
  17849. private _stockParticles;
  17850. private _newPartsExcess;
  17851. private _vertexData;
  17852. private _vertexBuffer;
  17853. private _vertexBuffers;
  17854. private _spriteBuffer;
  17855. private _indexBuffer;
  17856. private _effect;
  17857. private _customEffect;
  17858. private _cachedDefines;
  17859. private _scaledColorStep;
  17860. private _colorDiff;
  17861. private _scaledDirection;
  17862. private _scaledGravity;
  17863. private _currentRenderId;
  17864. private _alive;
  17865. private _useInstancing;
  17866. private _started;
  17867. private _stopped;
  17868. private _actualFrame;
  17869. private _scaledUpdateSpeed;
  17870. private _vertexBufferSize;
  17871. /** @hidden */
  17872. _currentEmitRateGradient: Nullable<FactorGradient>;
  17873. /** @hidden */
  17874. _currentEmitRate1: number;
  17875. /** @hidden */
  17876. _currentEmitRate2: number;
  17877. /** @hidden */
  17878. _currentStartSizeGradient: Nullable<FactorGradient>;
  17879. /** @hidden */
  17880. _currentStartSize1: number;
  17881. /** @hidden */
  17882. _currentStartSize2: number;
  17883. private readonly _rawTextureWidth;
  17884. private _rampGradientsTexture;
  17885. private _useRampGradients;
  17886. /** Gets or sets a boolean indicating that ramp gradients must be used
  17887. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17888. */
  17889. get useRampGradients(): boolean;
  17890. set useRampGradients(value: boolean);
  17891. /**
  17892. * 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.
  17893. * 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: [])
  17894. */
  17895. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17896. private _subEmitters;
  17897. /**
  17898. * @hidden
  17899. * If the particle systems emitter should be disposed when the particle system is disposed
  17900. */
  17901. _disposeEmitterOnDispose: boolean;
  17902. /**
  17903. * The current active Sub-systems, this property is used by the root particle system only.
  17904. */
  17905. activeSubSystems: Array<ParticleSystem>;
  17906. private _rootParticleSystem;
  17907. /**
  17908. * Gets the current list of active particles
  17909. */
  17910. get particles(): Particle[];
  17911. /**
  17912. * Returns the string "ParticleSystem"
  17913. * @returns a string containing the class name
  17914. */
  17915. getClassName(): string;
  17916. /**
  17917. * Instantiates a particle system.
  17918. * 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.
  17919. * @param name The name of the particle system
  17920. * @param capacity The max number of particles alive at the same time
  17921. * @param scene The scene the particle system belongs to
  17922. * @param customEffect a custom effect used to change the way particles are rendered by default
  17923. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17924. * @param epsilon Offset used to render the particles
  17925. */
  17926. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17927. private _addFactorGradient;
  17928. private _removeFactorGradient;
  17929. /**
  17930. * Adds a new life time gradient
  17931. * @param gradient defines the gradient to use (between 0 and 1)
  17932. * @param factor defines the life time factor to affect to the specified gradient
  17933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17934. * @returns the current particle system
  17935. */
  17936. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17937. /**
  17938. * Remove a specific life time gradient
  17939. * @param gradient defines the gradient to remove
  17940. * @returns the current particle system
  17941. */
  17942. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17943. /**
  17944. * Adds a new size gradient
  17945. * @param gradient defines the gradient to use (between 0 and 1)
  17946. * @param factor defines the size factor to affect to the specified gradient
  17947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17948. * @returns the current particle system
  17949. */
  17950. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17951. /**
  17952. * Remove a specific size gradient
  17953. * @param gradient defines the gradient to remove
  17954. * @returns the current particle system
  17955. */
  17956. removeSizeGradient(gradient: number): IParticleSystem;
  17957. /**
  17958. * Adds a new color remap gradient
  17959. * @param gradient defines the gradient to use (between 0 and 1)
  17960. * @param min defines the color remap minimal range
  17961. * @param max defines the color remap maximal range
  17962. * @returns the current particle system
  17963. */
  17964. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17965. /**
  17966. * Remove a specific color remap gradient
  17967. * @param gradient defines the gradient to remove
  17968. * @returns the current particle system
  17969. */
  17970. removeColorRemapGradient(gradient: number): IParticleSystem;
  17971. /**
  17972. * Adds a new alpha remap gradient
  17973. * @param gradient defines the gradient to use (between 0 and 1)
  17974. * @param min defines the alpha remap minimal range
  17975. * @param max defines the alpha remap maximal range
  17976. * @returns the current particle system
  17977. */
  17978. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17979. /**
  17980. * Remove a specific alpha remap gradient
  17981. * @param gradient defines the gradient to remove
  17982. * @returns the current particle system
  17983. */
  17984. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17985. /**
  17986. * Adds a new angular speed gradient
  17987. * @param gradient defines the gradient to use (between 0 and 1)
  17988. * @param factor defines the angular speed to affect to the specified gradient
  17989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17990. * @returns the current particle system
  17991. */
  17992. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17993. /**
  17994. * Remove a specific angular speed gradient
  17995. * @param gradient defines the gradient to remove
  17996. * @returns the current particle system
  17997. */
  17998. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17999. /**
  18000. * Adds a new velocity gradient
  18001. * @param gradient defines the gradient to use (between 0 and 1)
  18002. * @param factor defines the velocity to affect to the specified gradient
  18003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18004. * @returns the current particle system
  18005. */
  18006. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18007. /**
  18008. * Remove a specific velocity gradient
  18009. * @param gradient defines the gradient to remove
  18010. * @returns the current particle system
  18011. */
  18012. removeVelocityGradient(gradient: number): IParticleSystem;
  18013. /**
  18014. * Adds a new limit velocity gradient
  18015. * @param gradient defines the gradient to use (between 0 and 1)
  18016. * @param factor defines the limit velocity value to affect to the specified gradient
  18017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18018. * @returns the current particle system
  18019. */
  18020. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18021. /**
  18022. * Remove a specific limit velocity gradient
  18023. * @param gradient defines the gradient to remove
  18024. * @returns the current particle system
  18025. */
  18026. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18027. /**
  18028. * Adds a new drag gradient
  18029. * @param gradient defines the gradient to use (between 0 and 1)
  18030. * @param factor defines the drag value to affect to the specified gradient
  18031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18032. * @returns the current particle system
  18033. */
  18034. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18035. /**
  18036. * Remove a specific drag gradient
  18037. * @param gradient defines the gradient to remove
  18038. * @returns the current particle system
  18039. */
  18040. removeDragGradient(gradient: number): IParticleSystem;
  18041. /**
  18042. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18043. * @param gradient defines the gradient to use (between 0 and 1)
  18044. * @param factor defines the emit rate value to affect to the specified gradient
  18045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18046. * @returns the current particle system
  18047. */
  18048. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18049. /**
  18050. * Remove a specific emit rate gradient
  18051. * @param gradient defines the gradient to remove
  18052. * @returns the current particle system
  18053. */
  18054. removeEmitRateGradient(gradient: number): IParticleSystem;
  18055. /**
  18056. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18057. * @param gradient defines the gradient to use (between 0 and 1)
  18058. * @param factor defines the start size value to affect to the specified gradient
  18059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18060. * @returns the current particle system
  18061. */
  18062. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18063. /**
  18064. * Remove a specific start size gradient
  18065. * @param gradient defines the gradient to remove
  18066. * @returns the current particle system
  18067. */
  18068. removeStartSizeGradient(gradient: number): IParticleSystem;
  18069. private _createRampGradientTexture;
  18070. /**
  18071. * Gets the current list of ramp gradients.
  18072. * You must use addRampGradient and removeRampGradient to udpate this list
  18073. * @returns the list of ramp gradients
  18074. */
  18075. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18076. /**
  18077. * Adds a new ramp gradient used to remap particle colors
  18078. * @param gradient defines the gradient to use (between 0 and 1)
  18079. * @param color defines the color to affect to the specified gradient
  18080. * @returns the current particle system
  18081. */
  18082. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18083. /**
  18084. * Remove a specific ramp gradient
  18085. * @param gradient defines the gradient to remove
  18086. * @returns the current particle system
  18087. */
  18088. removeRampGradient(gradient: number): ParticleSystem;
  18089. /**
  18090. * Adds a new color gradient
  18091. * @param gradient defines the gradient to use (between 0 and 1)
  18092. * @param color1 defines the color to affect to the specified gradient
  18093. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18094. * @returns this particle system
  18095. */
  18096. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18097. /**
  18098. * Remove a specific color gradient
  18099. * @param gradient defines the gradient to remove
  18100. * @returns this particle system
  18101. */
  18102. removeColorGradient(gradient: number): IParticleSystem;
  18103. private _fetchR;
  18104. protected _reset(): void;
  18105. private _resetEffect;
  18106. private _createVertexBuffers;
  18107. private _createIndexBuffer;
  18108. /**
  18109. * Gets the maximum number of particles active at the same time.
  18110. * @returns The max number of active particles.
  18111. */
  18112. getCapacity(): number;
  18113. /**
  18114. * Gets whether there are still active particles in the system.
  18115. * @returns True if it is alive, otherwise false.
  18116. */
  18117. isAlive(): boolean;
  18118. /**
  18119. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18120. * @returns True if it has been started, otherwise false.
  18121. */
  18122. isStarted(): boolean;
  18123. private _prepareSubEmitterInternalArray;
  18124. /**
  18125. * Starts the particle system and begins to emit
  18126. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18127. */
  18128. start(delay?: number): void;
  18129. /**
  18130. * Stops the particle system.
  18131. * @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.
  18132. */
  18133. stop(stopSubEmitters?: boolean): void;
  18134. /**
  18135. * Remove all active particles
  18136. */
  18137. reset(): void;
  18138. /**
  18139. * @hidden (for internal use only)
  18140. */
  18141. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18142. /**
  18143. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18144. * Its lifetime will start back at 0.
  18145. */
  18146. recycleParticle: (particle: Particle) => void;
  18147. private _stopSubEmitters;
  18148. private _createParticle;
  18149. private _removeFromRoot;
  18150. private _emitFromParticle;
  18151. private _update;
  18152. /** @hidden */
  18153. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18154. /** @hidden */
  18155. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18156. /** @hidden */
  18157. private _getEffect;
  18158. /**
  18159. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18160. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18161. */
  18162. animate(preWarmOnly?: boolean): void;
  18163. private _appendParticleVertices;
  18164. /**
  18165. * Rebuilds the particle system.
  18166. */
  18167. rebuild(): void;
  18168. /**
  18169. * Is this system ready to be used/rendered
  18170. * @return true if the system is ready
  18171. */
  18172. isReady(): boolean;
  18173. private _render;
  18174. /**
  18175. * Renders the particle system in its current state.
  18176. * @returns the current number of particles
  18177. */
  18178. render(): number;
  18179. /**
  18180. * Disposes the particle system and free the associated resources
  18181. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18182. */
  18183. dispose(disposeTexture?: boolean): void;
  18184. /**
  18185. * Clones the particle system.
  18186. * @param name The name of the cloned object
  18187. * @param newEmitter The new emitter to use
  18188. * @returns the cloned particle system
  18189. */
  18190. clone(name: string, newEmitter: any): ParticleSystem;
  18191. /**
  18192. * Serializes the particle system to a JSON object.
  18193. * @returns the JSON object
  18194. */
  18195. serialize(): any;
  18196. /** @hidden */
  18197. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18198. /** @hidden */
  18199. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18200. /**
  18201. * Parses a JSON object to create a particle system.
  18202. * @param parsedParticleSystem The JSON object to parse
  18203. * @param scene The scene to create the particle system in
  18204. * @param rootUrl The root url to use to load external dependencies like texture
  18205. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18206. * @returns the Parsed particle system
  18207. */
  18208. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18209. }
  18210. }
  18211. declare module "babylonjs/Particles/particle" {
  18212. import { Nullable } from "babylonjs/types";
  18213. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18214. import { Color4 } from "babylonjs/Maths/math.color";
  18215. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18216. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18217. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18218. /**
  18219. * A particle represents one of the element emitted by a particle system.
  18220. * This is mainly define by its coordinates, direction, velocity and age.
  18221. */
  18222. export class Particle {
  18223. /**
  18224. * The particle system the particle belongs to.
  18225. */
  18226. particleSystem: ParticleSystem;
  18227. private static _Count;
  18228. /**
  18229. * Unique ID of the particle
  18230. */
  18231. id: number;
  18232. /**
  18233. * The world position of the particle in the scene.
  18234. */
  18235. position: Vector3;
  18236. /**
  18237. * The world direction of the particle in the scene.
  18238. */
  18239. direction: Vector3;
  18240. /**
  18241. * The color of the particle.
  18242. */
  18243. color: Color4;
  18244. /**
  18245. * The color change of the particle per step.
  18246. */
  18247. colorStep: Color4;
  18248. /**
  18249. * Defines how long will the life of the particle be.
  18250. */
  18251. lifeTime: number;
  18252. /**
  18253. * The current age of the particle.
  18254. */
  18255. age: number;
  18256. /**
  18257. * The current size of the particle.
  18258. */
  18259. size: number;
  18260. /**
  18261. * The current scale of the particle.
  18262. */
  18263. scale: Vector2;
  18264. /**
  18265. * The current angle of the particle.
  18266. */
  18267. angle: number;
  18268. /**
  18269. * Defines how fast is the angle changing.
  18270. */
  18271. angularSpeed: number;
  18272. /**
  18273. * Defines the cell index used by the particle to be rendered from a sprite.
  18274. */
  18275. cellIndex: number;
  18276. /**
  18277. * The information required to support color remapping
  18278. */
  18279. remapData: Vector4;
  18280. /** @hidden */
  18281. _randomCellOffset?: number;
  18282. /** @hidden */
  18283. _initialDirection: Nullable<Vector3>;
  18284. /** @hidden */
  18285. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18286. /** @hidden */
  18287. _initialStartSpriteCellID: number;
  18288. /** @hidden */
  18289. _initialEndSpriteCellID: number;
  18290. /** @hidden */
  18291. _currentColorGradient: Nullable<ColorGradient>;
  18292. /** @hidden */
  18293. _currentColor1: Color4;
  18294. /** @hidden */
  18295. _currentColor2: Color4;
  18296. /** @hidden */
  18297. _currentSizeGradient: Nullable<FactorGradient>;
  18298. /** @hidden */
  18299. _currentSize1: number;
  18300. /** @hidden */
  18301. _currentSize2: number;
  18302. /** @hidden */
  18303. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18304. /** @hidden */
  18305. _currentAngularSpeed1: number;
  18306. /** @hidden */
  18307. _currentAngularSpeed2: number;
  18308. /** @hidden */
  18309. _currentVelocityGradient: Nullable<FactorGradient>;
  18310. /** @hidden */
  18311. _currentVelocity1: number;
  18312. /** @hidden */
  18313. _currentVelocity2: number;
  18314. /** @hidden */
  18315. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18316. /** @hidden */
  18317. _currentLimitVelocity1: number;
  18318. /** @hidden */
  18319. _currentLimitVelocity2: number;
  18320. /** @hidden */
  18321. _currentDragGradient: Nullable<FactorGradient>;
  18322. /** @hidden */
  18323. _currentDrag1: number;
  18324. /** @hidden */
  18325. _currentDrag2: number;
  18326. /** @hidden */
  18327. _randomNoiseCoordinates1: Vector3;
  18328. /** @hidden */
  18329. _randomNoiseCoordinates2: Vector3;
  18330. /**
  18331. * Creates a new instance Particle
  18332. * @param particleSystem the particle system the particle belongs to
  18333. */
  18334. constructor(
  18335. /**
  18336. * The particle system the particle belongs to.
  18337. */
  18338. particleSystem: ParticleSystem);
  18339. private updateCellInfoFromSystem;
  18340. /**
  18341. * Defines how the sprite cell index is updated for the particle
  18342. */
  18343. updateCellIndex(): void;
  18344. /** @hidden */
  18345. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18346. /** @hidden */
  18347. _inheritParticleInfoToSubEmitters(): void;
  18348. /** @hidden */
  18349. _reset(): void;
  18350. /**
  18351. * Copy the properties of particle to another one.
  18352. * @param other the particle to copy the information to.
  18353. */
  18354. copyTo(other: Particle): void;
  18355. }
  18356. }
  18357. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18358. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18359. import { Effect } from "babylonjs/Materials/effect";
  18360. import { Particle } from "babylonjs/Particles/particle";
  18361. /**
  18362. * Particle emitter represents a volume emitting particles.
  18363. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18364. */
  18365. export interface IParticleEmitterType {
  18366. /**
  18367. * Called by the particle System when the direction is computed for the created particle.
  18368. * @param worldMatrix is the world matrix of the particle system
  18369. * @param directionToUpdate is the direction vector to update with the result
  18370. * @param particle is the particle we are computed the direction for
  18371. */
  18372. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18373. /**
  18374. * Called by the particle System when the position is computed for the created particle.
  18375. * @param worldMatrix is the world matrix of the particle system
  18376. * @param positionToUpdate is the position vector to update with the result
  18377. * @param particle is the particle we are computed the position for
  18378. */
  18379. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18380. /**
  18381. * Clones the current emitter and returns a copy of it
  18382. * @returns the new emitter
  18383. */
  18384. clone(): IParticleEmitterType;
  18385. /**
  18386. * Called by the GPUParticleSystem to setup the update shader
  18387. * @param effect defines the update shader
  18388. */
  18389. applyToShader(effect: Effect): void;
  18390. /**
  18391. * Returns a string to use to update the GPU particles update shader
  18392. * @returns the effect defines string
  18393. */
  18394. getEffectDefines(): string;
  18395. /**
  18396. * Returns a string representing the class name
  18397. * @returns a string containing the class name
  18398. */
  18399. getClassName(): string;
  18400. /**
  18401. * Serializes the particle system to a JSON object.
  18402. * @returns the JSON object
  18403. */
  18404. serialize(): any;
  18405. /**
  18406. * Parse properties from a JSON object
  18407. * @param serializationObject defines the JSON object
  18408. */
  18409. parse(serializationObject: any): void;
  18410. }
  18411. }
  18412. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18413. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18414. import { Effect } from "babylonjs/Materials/effect";
  18415. import { Particle } from "babylonjs/Particles/particle";
  18416. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18417. /**
  18418. * Particle emitter emitting particles from the inside of a box.
  18419. * It emits the particles randomly between 2 given directions.
  18420. */
  18421. export class BoxParticleEmitter implements IParticleEmitterType {
  18422. /**
  18423. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18424. */
  18425. direction1: Vector3;
  18426. /**
  18427. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18428. */
  18429. direction2: Vector3;
  18430. /**
  18431. * 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.
  18432. */
  18433. minEmitBox: Vector3;
  18434. /**
  18435. * 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.
  18436. */
  18437. maxEmitBox: Vector3;
  18438. /**
  18439. * Creates a new instance BoxParticleEmitter
  18440. */
  18441. constructor();
  18442. /**
  18443. * Called by the particle System when the direction is computed for the created particle.
  18444. * @param worldMatrix is the world matrix of the particle system
  18445. * @param directionToUpdate is the direction vector to update with the result
  18446. * @param particle is the particle we are computed the direction for
  18447. */
  18448. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18449. /**
  18450. * Called by the particle System when the position is computed for the created particle.
  18451. * @param worldMatrix is the world matrix of the particle system
  18452. * @param positionToUpdate is the position vector to update with the result
  18453. * @param particle is the particle we are computed the position for
  18454. */
  18455. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18456. /**
  18457. * Clones the current emitter and returns a copy of it
  18458. * @returns the new emitter
  18459. */
  18460. clone(): BoxParticleEmitter;
  18461. /**
  18462. * Called by the GPUParticleSystem to setup the update shader
  18463. * @param effect defines the update shader
  18464. */
  18465. applyToShader(effect: Effect): void;
  18466. /**
  18467. * Returns a string to use to update the GPU particles update shader
  18468. * @returns a string containng the defines string
  18469. */
  18470. getEffectDefines(): string;
  18471. /**
  18472. * Returns the string "BoxParticleEmitter"
  18473. * @returns a string containing the class name
  18474. */
  18475. getClassName(): string;
  18476. /**
  18477. * Serializes the particle system to a JSON object.
  18478. * @returns the JSON object
  18479. */
  18480. serialize(): any;
  18481. /**
  18482. * Parse properties from a JSON object
  18483. * @param serializationObject defines the JSON object
  18484. */
  18485. parse(serializationObject: any): void;
  18486. }
  18487. }
  18488. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18489. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18490. import { Effect } from "babylonjs/Materials/effect";
  18491. import { Particle } from "babylonjs/Particles/particle";
  18492. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18493. /**
  18494. * Particle emitter emitting particles from the inside of a cone.
  18495. * It emits the particles alongside the cone volume from the base to the particle.
  18496. * The emission direction might be randomized.
  18497. */
  18498. export class ConeParticleEmitter implements IParticleEmitterType {
  18499. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18500. directionRandomizer: number;
  18501. private _radius;
  18502. private _angle;
  18503. private _height;
  18504. /**
  18505. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18506. */
  18507. radiusRange: number;
  18508. /**
  18509. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18510. */
  18511. heightRange: number;
  18512. /**
  18513. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18514. */
  18515. emitFromSpawnPointOnly: boolean;
  18516. /**
  18517. * Gets or sets the radius of the emission cone
  18518. */
  18519. get radius(): number;
  18520. set radius(value: number);
  18521. /**
  18522. * Gets or sets the angle of the emission cone
  18523. */
  18524. get angle(): number;
  18525. set angle(value: number);
  18526. private _buildHeight;
  18527. /**
  18528. * Creates a new instance ConeParticleEmitter
  18529. * @param radius the radius of the emission cone (1 by default)
  18530. * @param angle the cone base angle (PI by default)
  18531. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18532. */
  18533. constructor(radius?: number, angle?: number,
  18534. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18535. directionRandomizer?: number);
  18536. /**
  18537. * Called by the particle System when the direction is computed for the created particle.
  18538. * @param worldMatrix is the world matrix of the particle system
  18539. * @param directionToUpdate is the direction vector to update with the result
  18540. * @param particle is the particle we are computed the direction for
  18541. */
  18542. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18543. /**
  18544. * Called by the particle System when the position is computed for the created particle.
  18545. * @param worldMatrix is the world matrix of the particle system
  18546. * @param positionToUpdate is the position vector to update with the result
  18547. * @param particle is the particle we are computed the position for
  18548. */
  18549. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18550. /**
  18551. * Clones the current emitter and returns a copy of it
  18552. * @returns the new emitter
  18553. */
  18554. clone(): ConeParticleEmitter;
  18555. /**
  18556. * Called by the GPUParticleSystem to setup the update shader
  18557. * @param effect defines the update shader
  18558. */
  18559. applyToShader(effect: Effect): void;
  18560. /**
  18561. * Returns a string to use to update the GPU particles update shader
  18562. * @returns a string containng the defines string
  18563. */
  18564. getEffectDefines(): string;
  18565. /**
  18566. * Returns the string "ConeParticleEmitter"
  18567. * @returns a string containing the class name
  18568. */
  18569. getClassName(): string;
  18570. /**
  18571. * Serializes the particle system to a JSON object.
  18572. * @returns the JSON object
  18573. */
  18574. serialize(): any;
  18575. /**
  18576. * Parse properties from a JSON object
  18577. * @param serializationObject defines the JSON object
  18578. */
  18579. parse(serializationObject: any): void;
  18580. }
  18581. }
  18582. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18583. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18584. import { Effect } from "babylonjs/Materials/effect";
  18585. import { Particle } from "babylonjs/Particles/particle";
  18586. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18587. /**
  18588. * Particle emitter emitting particles from the inside of a cylinder.
  18589. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18590. */
  18591. export class CylinderParticleEmitter implements IParticleEmitterType {
  18592. /**
  18593. * The radius of the emission cylinder.
  18594. */
  18595. radius: number;
  18596. /**
  18597. * The height of the emission cylinder.
  18598. */
  18599. height: number;
  18600. /**
  18601. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18602. */
  18603. radiusRange: number;
  18604. /**
  18605. * How much to randomize the particle direction [0-1].
  18606. */
  18607. directionRandomizer: number;
  18608. /**
  18609. * Creates a new instance CylinderParticleEmitter
  18610. * @param radius the radius of the emission cylinder (1 by default)
  18611. * @param height the height of the emission cylinder (1 by default)
  18612. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18613. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18614. */
  18615. constructor(
  18616. /**
  18617. * The radius of the emission cylinder.
  18618. */
  18619. radius?: number,
  18620. /**
  18621. * The height of the emission cylinder.
  18622. */
  18623. height?: number,
  18624. /**
  18625. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18626. */
  18627. radiusRange?: number,
  18628. /**
  18629. * How much to randomize the particle direction [0-1].
  18630. */
  18631. directionRandomizer?: number);
  18632. /**
  18633. * Called by the particle System when the direction is computed for the created particle.
  18634. * @param worldMatrix is the world matrix of the particle system
  18635. * @param directionToUpdate is the direction vector to update with the result
  18636. * @param particle is the particle we are computed the direction for
  18637. */
  18638. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18639. /**
  18640. * Called by the particle System when the position is computed for the created particle.
  18641. * @param worldMatrix is the world matrix of the particle system
  18642. * @param positionToUpdate is the position vector to update with the result
  18643. * @param particle is the particle we are computed the position for
  18644. */
  18645. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18646. /**
  18647. * Clones the current emitter and returns a copy of it
  18648. * @returns the new emitter
  18649. */
  18650. clone(): CylinderParticleEmitter;
  18651. /**
  18652. * Called by the GPUParticleSystem to setup the update shader
  18653. * @param effect defines the update shader
  18654. */
  18655. applyToShader(effect: Effect): void;
  18656. /**
  18657. * Returns a string to use to update the GPU particles update shader
  18658. * @returns a string containng the defines string
  18659. */
  18660. getEffectDefines(): string;
  18661. /**
  18662. * Returns the string "CylinderParticleEmitter"
  18663. * @returns a string containing the class name
  18664. */
  18665. getClassName(): string;
  18666. /**
  18667. * Serializes the particle system to a JSON object.
  18668. * @returns the JSON object
  18669. */
  18670. serialize(): any;
  18671. /**
  18672. * Parse properties from a JSON object
  18673. * @param serializationObject defines the JSON object
  18674. */
  18675. parse(serializationObject: any): void;
  18676. }
  18677. /**
  18678. * Particle emitter emitting particles from the inside of a cylinder.
  18679. * It emits the particles randomly between two vectors.
  18680. */
  18681. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18682. /**
  18683. * The min limit of the emission direction.
  18684. */
  18685. direction1: Vector3;
  18686. /**
  18687. * The max limit of the emission direction.
  18688. */
  18689. direction2: Vector3;
  18690. /**
  18691. * Creates a new instance CylinderDirectedParticleEmitter
  18692. * @param radius the radius of the emission cylinder (1 by default)
  18693. * @param height the height of the emission cylinder (1 by default)
  18694. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18695. * @param direction1 the min limit of the emission direction (up vector by default)
  18696. * @param direction2 the max limit of the emission direction (up vector by default)
  18697. */
  18698. constructor(radius?: number, height?: number, radiusRange?: number,
  18699. /**
  18700. * The min limit of the emission direction.
  18701. */
  18702. direction1?: Vector3,
  18703. /**
  18704. * The max limit of the emission direction.
  18705. */
  18706. direction2?: Vector3);
  18707. /**
  18708. * Called by the particle System when the direction is computed for the created particle.
  18709. * @param worldMatrix is the world matrix of the particle system
  18710. * @param directionToUpdate is the direction vector to update with the result
  18711. * @param particle is the particle we are computed the direction for
  18712. */
  18713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18714. /**
  18715. * Clones the current emitter and returns a copy of it
  18716. * @returns the new emitter
  18717. */
  18718. clone(): CylinderDirectedParticleEmitter;
  18719. /**
  18720. * Called by the GPUParticleSystem to setup the update shader
  18721. * @param effect defines the update shader
  18722. */
  18723. applyToShader(effect: Effect): void;
  18724. /**
  18725. * Returns a string to use to update the GPU particles update shader
  18726. * @returns a string containng the defines string
  18727. */
  18728. getEffectDefines(): string;
  18729. /**
  18730. * Returns the string "CylinderDirectedParticleEmitter"
  18731. * @returns a string containing the class name
  18732. */
  18733. getClassName(): string;
  18734. /**
  18735. * Serializes the particle system to a JSON object.
  18736. * @returns the JSON object
  18737. */
  18738. serialize(): any;
  18739. /**
  18740. * Parse properties from a JSON object
  18741. * @param serializationObject defines the JSON object
  18742. */
  18743. parse(serializationObject: any): void;
  18744. }
  18745. }
  18746. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18747. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18748. import { Effect } from "babylonjs/Materials/effect";
  18749. import { Particle } from "babylonjs/Particles/particle";
  18750. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18751. /**
  18752. * Particle emitter emitting particles from the inside of a hemisphere.
  18753. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18754. */
  18755. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18756. /**
  18757. * The radius of the emission hemisphere.
  18758. */
  18759. radius: number;
  18760. /**
  18761. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18762. */
  18763. radiusRange: number;
  18764. /**
  18765. * How much to randomize the particle direction [0-1].
  18766. */
  18767. directionRandomizer: number;
  18768. /**
  18769. * Creates a new instance HemisphericParticleEmitter
  18770. * @param radius the radius of the emission hemisphere (1 by default)
  18771. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18772. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18773. */
  18774. constructor(
  18775. /**
  18776. * The radius of the emission hemisphere.
  18777. */
  18778. radius?: number,
  18779. /**
  18780. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18781. */
  18782. radiusRange?: number,
  18783. /**
  18784. * How much to randomize the particle direction [0-1].
  18785. */
  18786. directionRandomizer?: number);
  18787. /**
  18788. * Called by the particle System when the direction is computed for the created particle.
  18789. * @param worldMatrix is the world matrix of the particle system
  18790. * @param directionToUpdate is the direction vector to update with the result
  18791. * @param particle is the particle we are computed the direction for
  18792. */
  18793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18794. /**
  18795. * Called by the particle System when the position is computed for the created particle.
  18796. * @param worldMatrix is the world matrix of the particle system
  18797. * @param positionToUpdate is the position vector to update with the result
  18798. * @param particle is the particle we are computed the position for
  18799. */
  18800. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18801. /**
  18802. * Clones the current emitter and returns a copy of it
  18803. * @returns the new emitter
  18804. */
  18805. clone(): HemisphericParticleEmitter;
  18806. /**
  18807. * Called by the GPUParticleSystem to setup the update shader
  18808. * @param effect defines the update shader
  18809. */
  18810. applyToShader(effect: Effect): void;
  18811. /**
  18812. * Returns a string to use to update the GPU particles update shader
  18813. * @returns a string containng the defines string
  18814. */
  18815. getEffectDefines(): string;
  18816. /**
  18817. * Returns the string "HemisphericParticleEmitter"
  18818. * @returns a string containing the class name
  18819. */
  18820. getClassName(): string;
  18821. /**
  18822. * Serializes the particle system to a JSON object.
  18823. * @returns the JSON object
  18824. */
  18825. serialize(): any;
  18826. /**
  18827. * Parse properties from a JSON object
  18828. * @param serializationObject defines the JSON object
  18829. */
  18830. parse(serializationObject: any): void;
  18831. }
  18832. }
  18833. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18834. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18835. import { Effect } from "babylonjs/Materials/effect";
  18836. import { Particle } from "babylonjs/Particles/particle";
  18837. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18838. /**
  18839. * Particle emitter emitting particles from a point.
  18840. * It emits the particles randomly between 2 given directions.
  18841. */
  18842. export class PointParticleEmitter implements IParticleEmitterType {
  18843. /**
  18844. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18845. */
  18846. direction1: Vector3;
  18847. /**
  18848. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18849. */
  18850. direction2: Vector3;
  18851. /**
  18852. * Creates a new instance PointParticleEmitter
  18853. */
  18854. constructor();
  18855. /**
  18856. * Called by the particle System when the direction is computed for the created particle.
  18857. * @param worldMatrix is the world matrix of the particle system
  18858. * @param directionToUpdate is the direction vector to update with the result
  18859. * @param particle is the particle we are computed the direction for
  18860. */
  18861. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18862. /**
  18863. * Called by the particle System when the position is computed for the created particle.
  18864. * @param worldMatrix is the world matrix of the particle system
  18865. * @param positionToUpdate is the position vector to update with the result
  18866. * @param particle is the particle we are computed the position for
  18867. */
  18868. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18869. /**
  18870. * Clones the current emitter and returns a copy of it
  18871. * @returns the new emitter
  18872. */
  18873. clone(): PointParticleEmitter;
  18874. /**
  18875. * Called by the GPUParticleSystem to setup the update shader
  18876. * @param effect defines the update shader
  18877. */
  18878. applyToShader(effect: Effect): void;
  18879. /**
  18880. * Returns a string to use to update the GPU particles update shader
  18881. * @returns a string containng the defines string
  18882. */
  18883. getEffectDefines(): string;
  18884. /**
  18885. * Returns the string "PointParticleEmitter"
  18886. * @returns a string containing the class name
  18887. */
  18888. getClassName(): string;
  18889. /**
  18890. * Serializes the particle system to a JSON object.
  18891. * @returns the JSON object
  18892. */
  18893. serialize(): any;
  18894. /**
  18895. * Parse properties from a JSON object
  18896. * @param serializationObject defines the JSON object
  18897. */
  18898. parse(serializationObject: any): void;
  18899. }
  18900. }
  18901. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18902. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18903. import { Effect } from "babylonjs/Materials/effect";
  18904. import { Particle } from "babylonjs/Particles/particle";
  18905. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18906. /**
  18907. * Particle emitter emitting particles from the inside of a sphere.
  18908. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18909. */
  18910. export class SphereParticleEmitter implements IParticleEmitterType {
  18911. /**
  18912. * The radius of the emission sphere.
  18913. */
  18914. radius: number;
  18915. /**
  18916. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18917. */
  18918. radiusRange: number;
  18919. /**
  18920. * How much to randomize the particle direction [0-1].
  18921. */
  18922. directionRandomizer: number;
  18923. /**
  18924. * Creates a new instance SphereParticleEmitter
  18925. * @param radius the radius of the emission sphere (1 by default)
  18926. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18927. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18928. */
  18929. constructor(
  18930. /**
  18931. * The radius of the emission sphere.
  18932. */
  18933. radius?: number,
  18934. /**
  18935. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18936. */
  18937. radiusRange?: number,
  18938. /**
  18939. * How much to randomize the particle direction [0-1].
  18940. */
  18941. directionRandomizer?: number);
  18942. /**
  18943. * Called by the particle System when the direction is computed for the created particle.
  18944. * @param worldMatrix is the world matrix of the particle system
  18945. * @param directionToUpdate is the direction vector to update with the result
  18946. * @param particle is the particle we are computed the direction for
  18947. */
  18948. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18949. /**
  18950. * Called by the particle System when the position is computed for the created particle.
  18951. * @param worldMatrix is the world matrix of the particle system
  18952. * @param positionToUpdate is the position vector to update with the result
  18953. * @param particle is the particle we are computed the position for
  18954. */
  18955. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18956. /**
  18957. * Clones the current emitter and returns a copy of it
  18958. * @returns the new emitter
  18959. */
  18960. clone(): SphereParticleEmitter;
  18961. /**
  18962. * Called by the GPUParticleSystem to setup the update shader
  18963. * @param effect defines the update shader
  18964. */
  18965. applyToShader(effect: Effect): void;
  18966. /**
  18967. * Returns a string to use to update the GPU particles update shader
  18968. * @returns a string containng the defines string
  18969. */
  18970. getEffectDefines(): string;
  18971. /**
  18972. * Returns the string "SphereParticleEmitter"
  18973. * @returns a string containing the class name
  18974. */
  18975. getClassName(): string;
  18976. /**
  18977. * Serializes the particle system to a JSON object.
  18978. * @returns the JSON object
  18979. */
  18980. serialize(): any;
  18981. /**
  18982. * Parse properties from a JSON object
  18983. * @param serializationObject defines the JSON object
  18984. */
  18985. parse(serializationObject: any): void;
  18986. }
  18987. /**
  18988. * Particle emitter emitting particles from the inside of a sphere.
  18989. * It emits the particles randomly between two vectors.
  18990. */
  18991. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18992. /**
  18993. * The min limit of the emission direction.
  18994. */
  18995. direction1: Vector3;
  18996. /**
  18997. * The max limit of the emission direction.
  18998. */
  18999. direction2: Vector3;
  19000. /**
  19001. * Creates a new instance SphereDirectedParticleEmitter
  19002. * @param radius the radius of the emission sphere (1 by default)
  19003. * @param direction1 the min limit of the emission direction (up vector by default)
  19004. * @param direction2 the max limit of the emission direction (up vector by default)
  19005. */
  19006. constructor(radius?: number,
  19007. /**
  19008. * The min limit of the emission direction.
  19009. */
  19010. direction1?: Vector3,
  19011. /**
  19012. * The max limit of the emission direction.
  19013. */
  19014. direction2?: Vector3);
  19015. /**
  19016. * Called by the particle System when the direction is computed for the created particle.
  19017. * @param worldMatrix is the world matrix of the particle system
  19018. * @param directionToUpdate is the direction vector to update with the result
  19019. * @param particle is the particle we are computed the direction for
  19020. */
  19021. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19022. /**
  19023. * Clones the current emitter and returns a copy of it
  19024. * @returns the new emitter
  19025. */
  19026. clone(): SphereDirectedParticleEmitter;
  19027. /**
  19028. * Called by the GPUParticleSystem to setup the update shader
  19029. * @param effect defines the update shader
  19030. */
  19031. applyToShader(effect: Effect): void;
  19032. /**
  19033. * Returns a string to use to update the GPU particles update shader
  19034. * @returns a string containng the defines string
  19035. */
  19036. getEffectDefines(): string;
  19037. /**
  19038. * Returns the string "SphereDirectedParticleEmitter"
  19039. * @returns a string containing the class name
  19040. */
  19041. getClassName(): string;
  19042. /**
  19043. * Serializes the particle system to a JSON object.
  19044. * @returns the JSON object
  19045. */
  19046. serialize(): any;
  19047. /**
  19048. * Parse properties from a JSON object
  19049. * @param serializationObject defines the JSON object
  19050. */
  19051. parse(serializationObject: any): void;
  19052. }
  19053. }
  19054. declare module "babylonjs/Particles/EmitterTypes/index" {
  19055. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19056. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19057. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19058. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19059. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19060. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19061. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19062. }
  19063. declare module "babylonjs/Particles/IParticleSystem" {
  19064. import { Nullable } from "babylonjs/types";
  19065. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19066. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19069. import { Texture } from "babylonjs/Materials/Textures/texture";
  19070. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19071. import { Scene } from "babylonjs/scene";
  19072. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19073. import { Animation } from "babylonjs/Animations/animation";
  19074. /**
  19075. * Interface representing a particle system in Babylon.js.
  19076. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19077. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19078. */
  19079. export interface IParticleSystem {
  19080. /**
  19081. * List of animations used by the particle system.
  19082. */
  19083. animations: Animation[];
  19084. /**
  19085. * The id of the Particle system.
  19086. */
  19087. id: string;
  19088. /**
  19089. * The name of the Particle system.
  19090. */
  19091. name: string;
  19092. /**
  19093. * The emitter represents the Mesh or position we are attaching the particle system to.
  19094. */
  19095. emitter: Nullable<AbstractMesh | Vector3>;
  19096. /**
  19097. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19098. */
  19099. isBillboardBased: boolean;
  19100. /**
  19101. * The rendering group used by the Particle system to chose when to render.
  19102. */
  19103. renderingGroupId: number;
  19104. /**
  19105. * The layer mask we are rendering the particles through.
  19106. */
  19107. layerMask: number;
  19108. /**
  19109. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19110. */
  19111. updateSpeed: number;
  19112. /**
  19113. * The amount of time the particle system is running (depends of the overall update speed).
  19114. */
  19115. targetStopDuration: number;
  19116. /**
  19117. * The texture used to render each particle. (this can be a spritesheet)
  19118. */
  19119. particleTexture: Nullable<Texture>;
  19120. /**
  19121. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19122. */
  19123. blendMode: number;
  19124. /**
  19125. * Minimum life time of emitting particles.
  19126. */
  19127. minLifeTime: number;
  19128. /**
  19129. * Maximum life time of emitting particles.
  19130. */
  19131. maxLifeTime: number;
  19132. /**
  19133. * Minimum Size of emitting particles.
  19134. */
  19135. minSize: number;
  19136. /**
  19137. * Maximum Size of emitting particles.
  19138. */
  19139. maxSize: number;
  19140. /**
  19141. * Minimum scale of emitting particles on X axis.
  19142. */
  19143. minScaleX: number;
  19144. /**
  19145. * Maximum scale of emitting particles on X axis.
  19146. */
  19147. maxScaleX: number;
  19148. /**
  19149. * Minimum scale of emitting particles on Y axis.
  19150. */
  19151. minScaleY: number;
  19152. /**
  19153. * Maximum scale of emitting particles on Y axis.
  19154. */
  19155. maxScaleY: number;
  19156. /**
  19157. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19158. */
  19159. color1: Color4;
  19160. /**
  19161. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19162. */
  19163. color2: Color4;
  19164. /**
  19165. * Color the particle will have at the end of its lifetime.
  19166. */
  19167. colorDead: Color4;
  19168. /**
  19169. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19170. */
  19171. emitRate: number;
  19172. /**
  19173. * You can use gravity if you want to give an orientation to your particles.
  19174. */
  19175. gravity: Vector3;
  19176. /**
  19177. * Minimum power of emitting particles.
  19178. */
  19179. minEmitPower: number;
  19180. /**
  19181. * Maximum power of emitting particles.
  19182. */
  19183. maxEmitPower: number;
  19184. /**
  19185. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19186. */
  19187. minAngularSpeed: number;
  19188. /**
  19189. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19190. */
  19191. maxAngularSpeed: number;
  19192. /**
  19193. * Gets or sets the minimal initial rotation in radians.
  19194. */
  19195. minInitialRotation: number;
  19196. /**
  19197. * Gets or sets the maximal initial rotation in radians.
  19198. */
  19199. maxInitialRotation: number;
  19200. /**
  19201. * The particle emitter type defines the emitter used by the particle system.
  19202. * It can be for example box, sphere, or cone...
  19203. */
  19204. particleEmitterType: Nullable<IParticleEmitterType>;
  19205. /**
  19206. * Defines the delay in milliseconds before starting the system (0 by default)
  19207. */
  19208. startDelay: number;
  19209. /**
  19210. * 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
  19211. */
  19212. preWarmCycles: number;
  19213. /**
  19214. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19215. */
  19216. preWarmStepOffset: number;
  19217. /**
  19218. * 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)
  19219. */
  19220. spriteCellChangeSpeed: number;
  19221. /**
  19222. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19223. */
  19224. startSpriteCellID: number;
  19225. /**
  19226. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19227. */
  19228. endSpriteCellID: number;
  19229. /**
  19230. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19231. */
  19232. spriteCellWidth: number;
  19233. /**
  19234. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19235. */
  19236. spriteCellHeight: number;
  19237. /**
  19238. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19239. */
  19240. spriteRandomStartCell: boolean;
  19241. /**
  19242. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19243. */
  19244. isAnimationSheetEnabled: boolean;
  19245. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19246. translationPivot: Vector2;
  19247. /**
  19248. * Gets or sets a texture used to add random noise to particle positions
  19249. */
  19250. noiseTexture: Nullable<BaseTexture>;
  19251. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19252. noiseStrength: Vector3;
  19253. /**
  19254. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19255. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19256. */
  19257. billboardMode: number;
  19258. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19259. limitVelocityDamping: number;
  19260. /**
  19261. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19262. */
  19263. beginAnimationOnStart: boolean;
  19264. /**
  19265. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19266. */
  19267. beginAnimationFrom: number;
  19268. /**
  19269. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19270. */
  19271. beginAnimationTo: number;
  19272. /**
  19273. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19274. */
  19275. beginAnimationLoop: boolean;
  19276. /**
  19277. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19278. */
  19279. disposeOnStop: boolean;
  19280. /**
  19281. * Gets the maximum number of particles active at the same time.
  19282. * @returns The max number of active particles.
  19283. */
  19284. getCapacity(): number;
  19285. /**
  19286. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19287. * @returns True if it has been started, otherwise false.
  19288. */
  19289. isStarted(): boolean;
  19290. /**
  19291. * Animates the particle system for this frame.
  19292. */
  19293. animate(): void;
  19294. /**
  19295. * Renders the particle system in its current state.
  19296. * @returns the current number of particles
  19297. */
  19298. render(): number;
  19299. /**
  19300. * Dispose the particle system and frees its associated resources.
  19301. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19302. */
  19303. dispose(disposeTexture?: boolean): void;
  19304. /**
  19305. * Clones the particle system.
  19306. * @param name The name of the cloned object
  19307. * @param newEmitter The new emitter to use
  19308. * @returns the cloned particle system
  19309. */
  19310. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19311. /**
  19312. * Serializes the particle system to a JSON object.
  19313. * @returns the JSON object
  19314. */
  19315. serialize(): any;
  19316. /**
  19317. * Rebuild the particle system
  19318. */
  19319. rebuild(): void;
  19320. /**
  19321. * Starts the particle system and begins to emit
  19322. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19323. */
  19324. start(delay?: number): void;
  19325. /**
  19326. * Stops the particle system.
  19327. */
  19328. stop(): void;
  19329. /**
  19330. * Remove all active particles
  19331. */
  19332. reset(): void;
  19333. /**
  19334. * Is this system ready to be used/rendered
  19335. * @return true if the system is ready
  19336. */
  19337. isReady(): boolean;
  19338. /**
  19339. * Adds a new color gradient
  19340. * @param gradient defines the gradient to use (between 0 and 1)
  19341. * @param color1 defines the color to affect to the specified gradient
  19342. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19343. * @returns the current particle system
  19344. */
  19345. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19346. /**
  19347. * Remove a specific color gradient
  19348. * @param gradient defines the gradient to remove
  19349. * @returns the current particle system
  19350. */
  19351. removeColorGradient(gradient: number): IParticleSystem;
  19352. /**
  19353. * Adds a new size gradient
  19354. * @param gradient defines the gradient to use (between 0 and 1)
  19355. * @param factor defines the size factor to affect to the specified gradient
  19356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19357. * @returns the current particle system
  19358. */
  19359. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19360. /**
  19361. * Remove a specific size gradient
  19362. * @param gradient defines the gradient to remove
  19363. * @returns the current particle system
  19364. */
  19365. removeSizeGradient(gradient: number): IParticleSystem;
  19366. /**
  19367. * Gets the current list of color gradients.
  19368. * You must use addColorGradient and removeColorGradient to udpate this list
  19369. * @returns the list of color gradients
  19370. */
  19371. getColorGradients(): Nullable<Array<ColorGradient>>;
  19372. /**
  19373. * Gets the current list of size gradients.
  19374. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19375. * @returns the list of size gradients
  19376. */
  19377. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19378. /**
  19379. * Gets the current list of angular speed gradients.
  19380. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19381. * @returns the list of angular speed gradients
  19382. */
  19383. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19384. /**
  19385. * Adds a new angular speed gradient
  19386. * @param gradient defines the gradient to use (between 0 and 1)
  19387. * @param factor defines the angular speed to affect to the specified gradient
  19388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19389. * @returns the current particle system
  19390. */
  19391. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19392. /**
  19393. * Remove a specific angular speed gradient
  19394. * @param gradient defines the gradient to remove
  19395. * @returns the current particle system
  19396. */
  19397. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19398. /**
  19399. * Gets the current list of velocity gradients.
  19400. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19401. * @returns the list of velocity gradients
  19402. */
  19403. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19404. /**
  19405. * Adds a new velocity gradient
  19406. * @param gradient defines the gradient to use (between 0 and 1)
  19407. * @param factor defines the velocity to affect to the specified gradient
  19408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19409. * @returns the current particle system
  19410. */
  19411. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19412. /**
  19413. * Remove a specific velocity gradient
  19414. * @param gradient defines the gradient to remove
  19415. * @returns the current particle system
  19416. */
  19417. removeVelocityGradient(gradient: number): IParticleSystem;
  19418. /**
  19419. * Gets the current list of limit velocity gradients.
  19420. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19421. * @returns the list of limit velocity gradients
  19422. */
  19423. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19424. /**
  19425. * Adds a new limit velocity gradient
  19426. * @param gradient defines the gradient to use (between 0 and 1)
  19427. * @param factor defines the limit velocity to affect to the specified gradient
  19428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19429. * @returns the current particle system
  19430. */
  19431. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19432. /**
  19433. * Remove a specific limit velocity gradient
  19434. * @param gradient defines the gradient to remove
  19435. * @returns the current particle system
  19436. */
  19437. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19438. /**
  19439. * Adds a new drag gradient
  19440. * @param gradient defines the gradient to use (between 0 and 1)
  19441. * @param factor defines the drag to affect to the specified gradient
  19442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19443. * @returns the current particle system
  19444. */
  19445. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19446. /**
  19447. * Remove a specific drag gradient
  19448. * @param gradient defines the gradient to remove
  19449. * @returns the current particle system
  19450. */
  19451. removeDragGradient(gradient: number): IParticleSystem;
  19452. /**
  19453. * Gets the current list of drag gradients.
  19454. * You must use addDragGradient and removeDragGradient to udpate this list
  19455. * @returns the list of drag gradients
  19456. */
  19457. getDragGradients(): Nullable<Array<FactorGradient>>;
  19458. /**
  19459. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19460. * @param gradient defines the gradient to use (between 0 and 1)
  19461. * @param factor defines the emit rate to affect to the specified gradient
  19462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19463. * @returns the current particle system
  19464. */
  19465. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19466. /**
  19467. * Remove a specific emit rate gradient
  19468. * @param gradient defines the gradient to remove
  19469. * @returns the current particle system
  19470. */
  19471. removeEmitRateGradient(gradient: number): IParticleSystem;
  19472. /**
  19473. * Gets the current list of emit rate gradients.
  19474. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19475. * @returns the list of emit rate gradients
  19476. */
  19477. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19478. /**
  19479. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19480. * @param gradient defines the gradient to use (between 0 and 1)
  19481. * @param factor defines the start size to affect to the specified gradient
  19482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19483. * @returns the current particle system
  19484. */
  19485. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19486. /**
  19487. * Remove a specific start size gradient
  19488. * @param gradient defines the gradient to remove
  19489. * @returns the current particle system
  19490. */
  19491. removeStartSizeGradient(gradient: number): IParticleSystem;
  19492. /**
  19493. * Gets the current list of start size gradients.
  19494. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19495. * @returns the list of start size gradients
  19496. */
  19497. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19498. /**
  19499. * Adds a new life time gradient
  19500. * @param gradient defines the gradient to use (between 0 and 1)
  19501. * @param factor defines the life time factor to affect to the specified gradient
  19502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19503. * @returns the current particle system
  19504. */
  19505. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19506. /**
  19507. * Remove a specific life time gradient
  19508. * @param gradient defines the gradient to remove
  19509. * @returns the current particle system
  19510. */
  19511. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19512. /**
  19513. * Gets the current list of life time gradients.
  19514. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19515. * @returns the list of life time gradients
  19516. */
  19517. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19518. /**
  19519. * Gets the current list of color gradients.
  19520. * You must use addColorGradient and removeColorGradient to udpate this list
  19521. * @returns the list of color gradients
  19522. */
  19523. getColorGradients(): Nullable<Array<ColorGradient>>;
  19524. /**
  19525. * Adds a new ramp gradient used to remap particle colors
  19526. * @param gradient defines the gradient to use (between 0 and 1)
  19527. * @param color defines the color to affect to the specified gradient
  19528. * @returns the current particle system
  19529. */
  19530. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19531. /**
  19532. * Gets the current list of ramp gradients.
  19533. * You must use addRampGradient and removeRampGradient to udpate this list
  19534. * @returns the list of ramp gradients
  19535. */
  19536. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19537. /** Gets or sets a boolean indicating that ramp gradients must be used
  19538. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19539. */
  19540. useRampGradients: boolean;
  19541. /**
  19542. * Adds a new color remap gradient
  19543. * @param gradient defines the gradient to use (between 0 and 1)
  19544. * @param min defines the color remap minimal range
  19545. * @param max defines the color remap maximal range
  19546. * @returns the current particle system
  19547. */
  19548. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19549. /**
  19550. * Gets the current list of color remap gradients.
  19551. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19552. * @returns the list of color remap gradients
  19553. */
  19554. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19555. /**
  19556. * Adds a new alpha remap gradient
  19557. * @param gradient defines the gradient to use (between 0 and 1)
  19558. * @param min defines the alpha remap minimal range
  19559. * @param max defines the alpha remap maximal range
  19560. * @returns the current particle system
  19561. */
  19562. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19563. /**
  19564. * Gets the current list of alpha remap gradients.
  19565. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19566. * @returns the list of alpha remap gradients
  19567. */
  19568. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19569. /**
  19570. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19573. * @returns the emitter
  19574. */
  19575. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19576. /**
  19577. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19578. * @param radius The radius of the hemisphere to emit from
  19579. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19580. * @returns the emitter
  19581. */
  19582. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19583. /**
  19584. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19585. * @param radius The radius of the sphere to emit from
  19586. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19587. * @returns the emitter
  19588. */
  19589. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19590. /**
  19591. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19592. * @param radius The radius of the sphere to emit from
  19593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19595. * @returns the emitter
  19596. */
  19597. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19598. /**
  19599. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19600. * @param radius The radius of the emission cylinder
  19601. * @param height The height of the emission cylinder
  19602. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19603. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19604. * @returns the emitter
  19605. */
  19606. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19607. /**
  19608. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19609. * @param radius The radius of the cylinder to emit from
  19610. * @param height The height of the emission cylinder
  19611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19614. * @returns the emitter
  19615. */
  19616. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19617. /**
  19618. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19619. * @param radius The radius of the cone to emit from
  19620. * @param angle The base angle of the cone
  19621. * @returns the emitter
  19622. */
  19623. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19624. /**
  19625. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19628. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19629. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19630. * @returns the emitter
  19631. */
  19632. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19633. /**
  19634. * Get hosting scene
  19635. * @returns the scene
  19636. */
  19637. getScene(): Scene;
  19638. }
  19639. }
  19640. declare module "babylonjs/Meshes/instancedMesh" {
  19641. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19642. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19643. import { Camera } from "babylonjs/Cameras/camera";
  19644. import { Node } from "babylonjs/node";
  19645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19646. import { Mesh } from "babylonjs/Meshes/mesh";
  19647. import { Material } from "babylonjs/Materials/material";
  19648. import { Skeleton } from "babylonjs/Bones/skeleton";
  19649. import { Light } from "babylonjs/Lights/light";
  19650. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19651. /**
  19652. * Creates an instance based on a source mesh.
  19653. */
  19654. export class InstancedMesh extends AbstractMesh {
  19655. private _sourceMesh;
  19656. private _currentLOD;
  19657. /** @hidden */
  19658. _indexInSourceMeshInstanceArray: number;
  19659. constructor(name: string, source: Mesh);
  19660. /**
  19661. * Returns the string "InstancedMesh".
  19662. */
  19663. getClassName(): string;
  19664. /** Gets the list of lights affecting that mesh */
  19665. get lightSources(): Light[];
  19666. _resyncLightSources(): void;
  19667. _resyncLightSource(light: Light): void;
  19668. _removeLightSource(light: Light, dispose: boolean): void;
  19669. /**
  19670. * If the source mesh receives shadows
  19671. */
  19672. get receiveShadows(): boolean;
  19673. /**
  19674. * The material of the source mesh
  19675. */
  19676. get material(): Nullable<Material>;
  19677. /**
  19678. * Visibility of the source mesh
  19679. */
  19680. get visibility(): number;
  19681. /**
  19682. * Skeleton of the source mesh
  19683. */
  19684. get skeleton(): Nullable<Skeleton>;
  19685. /**
  19686. * Rendering ground id of the source mesh
  19687. */
  19688. get renderingGroupId(): number;
  19689. set renderingGroupId(value: number);
  19690. /**
  19691. * Returns the total number of vertices (integer).
  19692. */
  19693. getTotalVertices(): number;
  19694. /**
  19695. * Returns a positive integer : the total number of indices in this mesh geometry.
  19696. * @returns the numner of indices or zero if the mesh has no geometry.
  19697. */
  19698. getTotalIndices(): number;
  19699. /**
  19700. * The source mesh of the instance
  19701. */
  19702. get sourceMesh(): Mesh;
  19703. /**
  19704. * Is this node ready to be used/rendered
  19705. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19706. * @return {boolean} is it ready
  19707. */
  19708. isReady(completeCheck?: boolean): boolean;
  19709. /**
  19710. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19711. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19712. * @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.
  19713. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19714. */
  19715. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19716. /**
  19717. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19718. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19719. * The `data` are either a numeric array either a Float32Array.
  19720. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19721. * 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).
  19722. * Note that a new underlying VertexBuffer object is created each call.
  19723. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19724. *
  19725. * Possible `kind` values :
  19726. * - VertexBuffer.PositionKind
  19727. * - VertexBuffer.UVKind
  19728. * - VertexBuffer.UV2Kind
  19729. * - VertexBuffer.UV3Kind
  19730. * - VertexBuffer.UV4Kind
  19731. * - VertexBuffer.UV5Kind
  19732. * - VertexBuffer.UV6Kind
  19733. * - VertexBuffer.ColorKind
  19734. * - VertexBuffer.MatricesIndicesKind
  19735. * - VertexBuffer.MatricesIndicesExtraKind
  19736. * - VertexBuffer.MatricesWeightsKind
  19737. * - VertexBuffer.MatricesWeightsExtraKind
  19738. *
  19739. * Returns the Mesh.
  19740. */
  19741. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19742. /**
  19743. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19744. * If the mesh has no geometry, it is simply returned as it is.
  19745. * The `data` are either a numeric array either a Float32Array.
  19746. * No new underlying VertexBuffer object is created.
  19747. * 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.
  19748. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19749. *
  19750. * Possible `kind` values :
  19751. * - VertexBuffer.PositionKind
  19752. * - VertexBuffer.UVKind
  19753. * - VertexBuffer.UV2Kind
  19754. * - VertexBuffer.UV3Kind
  19755. * - VertexBuffer.UV4Kind
  19756. * - VertexBuffer.UV5Kind
  19757. * - VertexBuffer.UV6Kind
  19758. * - VertexBuffer.ColorKind
  19759. * - VertexBuffer.MatricesIndicesKind
  19760. * - VertexBuffer.MatricesIndicesExtraKind
  19761. * - VertexBuffer.MatricesWeightsKind
  19762. * - VertexBuffer.MatricesWeightsExtraKind
  19763. *
  19764. * Returns the Mesh.
  19765. */
  19766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19767. /**
  19768. * Sets the mesh indices.
  19769. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19770. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19771. * This method creates a new index buffer each call.
  19772. * Returns the Mesh.
  19773. */
  19774. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19775. /**
  19776. * Boolean : True if the mesh owns the requested kind of data.
  19777. */
  19778. isVerticesDataPresent(kind: string): boolean;
  19779. /**
  19780. * Returns an array of indices (IndicesArray).
  19781. */
  19782. getIndices(): Nullable<IndicesArray>;
  19783. get _positions(): Nullable<Vector3[]>;
  19784. /**
  19785. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19786. * This means the mesh underlying bounding box and sphere are recomputed.
  19787. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19788. * @returns the current mesh
  19789. */
  19790. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19791. /** @hidden */
  19792. _preActivate(): InstancedMesh;
  19793. /** @hidden */
  19794. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19795. /** @hidden */
  19796. _postActivate(): void;
  19797. getWorldMatrix(): Matrix;
  19798. get isAnInstance(): boolean;
  19799. /**
  19800. * Returns the current associated LOD AbstractMesh.
  19801. */
  19802. getLOD(camera: Camera): AbstractMesh;
  19803. /** @hidden */
  19804. _syncSubMeshes(): InstancedMesh;
  19805. /** @hidden */
  19806. _generatePointsArray(): boolean;
  19807. /**
  19808. * Creates a new InstancedMesh from the current mesh.
  19809. * - name (string) : the cloned mesh name
  19810. * - newParent (optional Node) : the optional Node to parent the clone to.
  19811. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19812. *
  19813. * Returns the clone.
  19814. */
  19815. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19816. /**
  19817. * Disposes the InstancedMesh.
  19818. * Returns nothing.
  19819. */
  19820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19821. }
  19822. module "babylonjs/Meshes/mesh" {
  19823. interface Mesh {
  19824. /**
  19825. * Register a custom buffer that will be instanced
  19826. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19827. * @param kind defines the buffer kind
  19828. * @param stride defines the stride in floats
  19829. */
  19830. registerInstancedBuffer(kind: string, stride: number): void;
  19831. /** @hidden */
  19832. _userInstancedBuffersStorage: {
  19833. data: {
  19834. [key: string]: Float32Array;
  19835. };
  19836. sizes: {
  19837. [key: string]: number;
  19838. };
  19839. vertexBuffers: {
  19840. [key: string]: Nullable<VertexBuffer>;
  19841. };
  19842. strides: {
  19843. [key: string]: number;
  19844. };
  19845. };
  19846. }
  19847. }
  19848. module "babylonjs/Meshes/abstractMesh" {
  19849. interface AbstractMesh {
  19850. /**
  19851. * Object used to store instanced buffers defined by user
  19852. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19853. */
  19854. instancedBuffers: {
  19855. [key: string]: any;
  19856. };
  19857. }
  19858. }
  19859. }
  19860. declare module "babylonjs/Materials/shaderMaterial" {
  19861. import { Scene } from "babylonjs/scene";
  19862. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19864. import { Mesh } from "babylonjs/Meshes/mesh";
  19865. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19867. import { Texture } from "babylonjs/Materials/Textures/texture";
  19868. import { Material } from "babylonjs/Materials/material";
  19869. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19870. /**
  19871. * Defines the options associated with the creation of a shader material.
  19872. */
  19873. export interface IShaderMaterialOptions {
  19874. /**
  19875. * Does the material work in alpha blend mode
  19876. */
  19877. needAlphaBlending: boolean;
  19878. /**
  19879. * Does the material work in alpha test mode
  19880. */
  19881. needAlphaTesting: boolean;
  19882. /**
  19883. * The list of attribute names used in the shader
  19884. */
  19885. attributes: string[];
  19886. /**
  19887. * The list of unifrom names used in the shader
  19888. */
  19889. uniforms: string[];
  19890. /**
  19891. * The list of UBO names used in the shader
  19892. */
  19893. uniformBuffers: string[];
  19894. /**
  19895. * The list of sampler names used in the shader
  19896. */
  19897. samplers: string[];
  19898. /**
  19899. * The list of defines used in the shader
  19900. */
  19901. defines: string[];
  19902. }
  19903. /**
  19904. * 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.
  19905. *
  19906. * This returned material effects how the mesh will look based on the code in the shaders.
  19907. *
  19908. * @see http://doc.babylonjs.com/how_to/shader_material
  19909. */
  19910. export class ShaderMaterial extends Material {
  19911. private _shaderPath;
  19912. private _options;
  19913. private _textures;
  19914. private _textureArrays;
  19915. private _floats;
  19916. private _ints;
  19917. private _floatsArrays;
  19918. private _colors3;
  19919. private _colors3Arrays;
  19920. private _colors4;
  19921. private _colors4Arrays;
  19922. private _vectors2;
  19923. private _vectors3;
  19924. private _vectors4;
  19925. private _matrices;
  19926. private _matrixArrays;
  19927. private _matrices3x3;
  19928. private _matrices2x2;
  19929. private _vectors2Arrays;
  19930. private _vectors3Arrays;
  19931. private _vectors4Arrays;
  19932. private _cachedWorldViewMatrix;
  19933. private _cachedWorldViewProjectionMatrix;
  19934. private _renderId;
  19935. private _multiview;
  19936. /**
  19937. * Instantiate a new shader material.
  19938. * 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.
  19939. * This returned material effects how the mesh will look based on the code in the shaders.
  19940. * @see http://doc.babylonjs.com/how_to/shader_material
  19941. * @param name Define the name of the material in the scene
  19942. * @param scene Define the scene the material belongs to
  19943. * @param shaderPath Defines the route to the shader code in one of three ways:
  19944. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19945. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19946. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19947. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19948. * @param options Define the options used to create the shader
  19949. */
  19950. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19951. /**
  19952. * Gets the shader path used to define the shader code
  19953. * It can be modified to trigger a new compilation
  19954. */
  19955. get shaderPath(): any;
  19956. /**
  19957. * Sets the shader path used to define the shader code
  19958. * It can be modified to trigger a new compilation
  19959. */
  19960. set shaderPath(shaderPath: any);
  19961. /**
  19962. * Gets the options used to compile the shader.
  19963. * They can be modified to trigger a new compilation
  19964. */
  19965. get options(): IShaderMaterialOptions;
  19966. /**
  19967. * Gets the current class name of the material e.g. "ShaderMaterial"
  19968. * Mainly use in serialization.
  19969. * @returns the class name
  19970. */
  19971. getClassName(): string;
  19972. /**
  19973. * Specifies if the material will require alpha blending
  19974. * @returns a boolean specifying if alpha blending is needed
  19975. */
  19976. needAlphaBlending(): boolean;
  19977. /**
  19978. * Specifies if this material should be rendered in alpha test mode
  19979. * @returns a boolean specifying if an alpha test is needed.
  19980. */
  19981. needAlphaTesting(): boolean;
  19982. private _checkUniform;
  19983. /**
  19984. * Set a texture in the shader.
  19985. * @param name Define the name of the uniform samplers as defined in the shader
  19986. * @param texture Define the texture to bind to this sampler
  19987. * @return the material itself allowing "fluent" like uniform updates
  19988. */
  19989. setTexture(name: string, texture: Texture): ShaderMaterial;
  19990. /**
  19991. * Set a texture array in the shader.
  19992. * @param name Define the name of the uniform sampler array as defined in the shader
  19993. * @param textures Define the list of textures to bind to this sampler
  19994. * @return the material itself allowing "fluent" like uniform updates
  19995. */
  19996. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19997. /**
  19998. * Set a float in the shader.
  19999. * @param name Define the name of the uniform as defined in the shader
  20000. * @param value Define the value to give to the uniform
  20001. * @return the material itself allowing "fluent" like uniform updates
  20002. */
  20003. setFloat(name: string, value: number): ShaderMaterial;
  20004. /**
  20005. * Set a int in the shader.
  20006. * @param name Define the name of the uniform as defined in the shader
  20007. * @param value Define the value to give to the uniform
  20008. * @return the material itself allowing "fluent" like uniform updates
  20009. */
  20010. setInt(name: string, value: number): ShaderMaterial;
  20011. /**
  20012. * Set an array of floats in the shader.
  20013. * @param name Define the name of the uniform as defined in the shader
  20014. * @param value Define the value to give to the uniform
  20015. * @return the material itself allowing "fluent" like uniform updates
  20016. */
  20017. setFloats(name: string, value: number[]): ShaderMaterial;
  20018. /**
  20019. * Set a vec3 in the shader from a Color3.
  20020. * @param name Define the name of the uniform as defined in the shader
  20021. * @param value Define the value to give to the uniform
  20022. * @return the material itself allowing "fluent" like uniform updates
  20023. */
  20024. setColor3(name: string, value: Color3): ShaderMaterial;
  20025. /**
  20026. * Set a vec3 array in the shader from a Color3 array.
  20027. * @param name Define the name of the uniform as defined in the shader
  20028. * @param value Define the value to give to the uniform
  20029. * @return the material itself allowing "fluent" like uniform updates
  20030. */
  20031. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20032. /**
  20033. * Set a vec4 in the shader from a Color4.
  20034. * @param name Define the name of the uniform as defined in the shader
  20035. * @param value Define the value to give to the uniform
  20036. * @return the material itself allowing "fluent" like uniform updates
  20037. */
  20038. setColor4(name: string, value: Color4): ShaderMaterial;
  20039. /**
  20040. * Set a vec4 array in the shader from a Color4 array.
  20041. * @param name Define the name of the uniform as defined in the shader
  20042. * @param value Define the value to give to the uniform
  20043. * @return the material itself allowing "fluent" like uniform updates
  20044. */
  20045. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20046. /**
  20047. * Set a vec2 in the shader from a Vector2.
  20048. * @param name Define the name of the uniform as defined in the shader
  20049. * @param value Define the value to give to the uniform
  20050. * @return the material itself allowing "fluent" like uniform updates
  20051. */
  20052. setVector2(name: string, value: Vector2): ShaderMaterial;
  20053. /**
  20054. * Set a vec3 in the shader from a Vector3.
  20055. * @param name Define the name of the uniform as defined in the shader
  20056. * @param value Define the value to give to the uniform
  20057. * @return the material itself allowing "fluent" like uniform updates
  20058. */
  20059. setVector3(name: string, value: Vector3): ShaderMaterial;
  20060. /**
  20061. * Set a vec4 in the shader from a Vector4.
  20062. * @param name Define the name of the uniform as defined in the shader
  20063. * @param value Define the value to give to the uniform
  20064. * @return the material itself allowing "fluent" like uniform updates
  20065. */
  20066. setVector4(name: string, value: Vector4): ShaderMaterial;
  20067. /**
  20068. * Set a mat4 in the shader from a Matrix.
  20069. * @param name Define the name of the uniform as defined in the shader
  20070. * @param value Define the value to give to the uniform
  20071. * @return the material itself allowing "fluent" like uniform updates
  20072. */
  20073. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20074. /**
  20075. * Set a float32Array in the shader from a matrix array.
  20076. * @param name Define the name of the uniform as defined in the shader
  20077. * @param value Define the value to give to the uniform
  20078. * @return the material itself allowing "fluent" like uniform updates
  20079. */
  20080. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20081. /**
  20082. * Set a mat3 in the shader from a Float32Array.
  20083. * @param name Define the name of the uniform as defined in the shader
  20084. * @param value Define the value to give to the uniform
  20085. * @return the material itself allowing "fluent" like uniform updates
  20086. */
  20087. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20088. /**
  20089. * Set a mat2 in the shader from a Float32Array.
  20090. * @param name Define the name of the uniform as defined in the shader
  20091. * @param value Define the value to give to the uniform
  20092. * @return the material itself allowing "fluent" like uniform updates
  20093. */
  20094. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20095. /**
  20096. * Set a vec2 array in the shader from a number array.
  20097. * @param name Define the name of the uniform as defined in the shader
  20098. * @param value Define the value to give to the uniform
  20099. * @return the material itself allowing "fluent" like uniform updates
  20100. */
  20101. setArray2(name: string, value: number[]): ShaderMaterial;
  20102. /**
  20103. * Set a vec3 array in the shader from a number array.
  20104. * @param name Define the name of the uniform as defined in the shader
  20105. * @param value Define the value to give to the uniform
  20106. * @return the material itself allowing "fluent" like uniform updates
  20107. */
  20108. setArray3(name: string, value: number[]): ShaderMaterial;
  20109. /**
  20110. * Set a vec4 array in the shader from a number array.
  20111. * @param name Define the name of the uniform as defined in the shader
  20112. * @param value Define the value to give to the uniform
  20113. * @return the material itself allowing "fluent" like uniform updates
  20114. */
  20115. setArray4(name: string, value: number[]): ShaderMaterial;
  20116. private _checkCache;
  20117. /**
  20118. * Specifies that the submesh is ready to be used
  20119. * @param mesh defines the mesh to check
  20120. * @param subMesh defines which submesh to check
  20121. * @param useInstances specifies that instances should be used
  20122. * @returns a boolean indicating that the submesh is ready or not
  20123. */
  20124. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20125. /**
  20126. * Checks if the material is ready to render the requested mesh
  20127. * @param mesh Define the mesh to render
  20128. * @param useInstances Define whether or not the material is used with instances
  20129. * @returns true if ready, otherwise false
  20130. */
  20131. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20132. /**
  20133. * Binds the world matrix to the material
  20134. * @param world defines the world transformation matrix
  20135. */
  20136. bindOnlyWorldMatrix(world: Matrix): void;
  20137. /**
  20138. * Binds the material to the mesh
  20139. * @param world defines the world transformation matrix
  20140. * @param mesh defines the mesh to bind the material to
  20141. */
  20142. bind(world: Matrix, mesh?: Mesh): void;
  20143. /**
  20144. * Gets the active textures from the material
  20145. * @returns an array of textures
  20146. */
  20147. getActiveTextures(): BaseTexture[];
  20148. /**
  20149. * Specifies if the material uses a texture
  20150. * @param texture defines the texture to check against the material
  20151. * @returns a boolean specifying if the material uses the texture
  20152. */
  20153. hasTexture(texture: BaseTexture): boolean;
  20154. /**
  20155. * Makes a duplicate of the material, and gives it a new name
  20156. * @param name defines the new name for the duplicated material
  20157. * @returns the cloned material
  20158. */
  20159. clone(name: string): ShaderMaterial;
  20160. /**
  20161. * Disposes the material
  20162. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20163. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20164. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20165. */
  20166. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20167. /**
  20168. * Serializes this material in a JSON representation
  20169. * @returns the serialized material object
  20170. */
  20171. serialize(): any;
  20172. /**
  20173. * Creates a shader material from parsed shader material data
  20174. * @param source defines the JSON represnetation of the material
  20175. * @param scene defines the hosting scene
  20176. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20177. * @returns a new material
  20178. */
  20179. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20180. }
  20181. }
  20182. declare module "babylonjs/Shaders/color.fragment" {
  20183. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20184. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20185. /** @hidden */
  20186. export var colorPixelShader: {
  20187. name: string;
  20188. shader: string;
  20189. };
  20190. }
  20191. declare module "babylonjs/Shaders/color.vertex" {
  20192. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20193. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20194. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20195. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20196. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20197. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20198. /** @hidden */
  20199. export var colorVertexShader: {
  20200. name: string;
  20201. shader: string;
  20202. };
  20203. }
  20204. declare module "babylonjs/Meshes/linesMesh" {
  20205. import { Nullable } from "babylonjs/types";
  20206. import { Scene } from "babylonjs/scene";
  20207. import { Color3 } from "babylonjs/Maths/math.color";
  20208. import { Node } from "babylonjs/node";
  20209. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20210. import { Mesh } from "babylonjs/Meshes/mesh";
  20211. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20212. import { Effect } from "babylonjs/Materials/effect";
  20213. import { Material } from "babylonjs/Materials/material";
  20214. import "babylonjs/Shaders/color.fragment";
  20215. import "babylonjs/Shaders/color.vertex";
  20216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20217. /**
  20218. * Line mesh
  20219. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20220. */
  20221. export class LinesMesh extends Mesh {
  20222. /**
  20223. * If vertex color should be applied to the mesh
  20224. */
  20225. readonly useVertexColor?: boolean | undefined;
  20226. /**
  20227. * If vertex alpha should be applied to the mesh
  20228. */
  20229. readonly useVertexAlpha?: boolean | undefined;
  20230. /**
  20231. * Color of the line (Default: White)
  20232. */
  20233. color: Color3;
  20234. /**
  20235. * Alpha of the line (Default: 1)
  20236. */
  20237. alpha: number;
  20238. /**
  20239. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20240. * This margin is expressed in world space coordinates, so its value may vary.
  20241. * Default value is 0.1
  20242. */
  20243. intersectionThreshold: number;
  20244. private _colorShader;
  20245. private color4;
  20246. /**
  20247. * Creates a new LinesMesh
  20248. * @param name defines the name
  20249. * @param scene defines the hosting scene
  20250. * @param parent defines the parent mesh if any
  20251. * @param source defines the optional source LinesMesh used to clone data from
  20252. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20253. * When false, achieved by calling a clone(), also passing False.
  20254. * This will make creation of children, recursive.
  20255. * @param useVertexColor defines if this LinesMesh supports vertex color
  20256. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20257. */
  20258. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20259. /**
  20260. * If vertex color should be applied to the mesh
  20261. */
  20262. useVertexColor?: boolean | undefined,
  20263. /**
  20264. * If vertex alpha should be applied to the mesh
  20265. */
  20266. useVertexAlpha?: boolean | undefined);
  20267. private _addClipPlaneDefine;
  20268. private _removeClipPlaneDefine;
  20269. isReady(): boolean;
  20270. /**
  20271. * Returns the string "LineMesh"
  20272. */
  20273. getClassName(): string;
  20274. /**
  20275. * @hidden
  20276. */
  20277. get material(): Material;
  20278. /**
  20279. * @hidden
  20280. */
  20281. set material(value: Material);
  20282. /**
  20283. * @hidden
  20284. */
  20285. get checkCollisions(): boolean;
  20286. /** @hidden */
  20287. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20288. /** @hidden */
  20289. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20290. /**
  20291. * Disposes of the line mesh
  20292. * @param doNotRecurse If children should be disposed
  20293. */
  20294. dispose(doNotRecurse?: boolean): void;
  20295. /**
  20296. * Returns a new LineMesh object cloned from the current one.
  20297. */
  20298. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20299. /**
  20300. * Creates a new InstancedLinesMesh object from the mesh model.
  20301. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20302. * @param name defines the name of the new instance
  20303. * @returns a new InstancedLinesMesh
  20304. */
  20305. createInstance(name: string): InstancedLinesMesh;
  20306. }
  20307. /**
  20308. * Creates an instance based on a source LinesMesh
  20309. */
  20310. export class InstancedLinesMesh extends InstancedMesh {
  20311. /**
  20312. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20313. * This margin is expressed in world space coordinates, so its value may vary.
  20314. * Initilized with the intersectionThreshold value of the source LinesMesh
  20315. */
  20316. intersectionThreshold: number;
  20317. constructor(name: string, source: LinesMesh);
  20318. /**
  20319. * Returns the string "InstancedLinesMesh".
  20320. */
  20321. getClassName(): string;
  20322. }
  20323. }
  20324. declare module "babylonjs/Shaders/line.fragment" {
  20325. /** @hidden */
  20326. export var linePixelShader: {
  20327. name: string;
  20328. shader: string;
  20329. };
  20330. }
  20331. declare module "babylonjs/Shaders/line.vertex" {
  20332. /** @hidden */
  20333. export var lineVertexShader: {
  20334. name: string;
  20335. shader: string;
  20336. };
  20337. }
  20338. declare module "babylonjs/Rendering/edgesRenderer" {
  20339. import { Nullable } from "babylonjs/types";
  20340. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20342. import { Vector3 } from "babylonjs/Maths/math.vector";
  20343. import { IDisposable } from "babylonjs/scene";
  20344. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20345. import "babylonjs/Shaders/line.fragment";
  20346. import "babylonjs/Shaders/line.vertex";
  20347. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20348. module "babylonjs/Meshes/abstractMesh" {
  20349. interface AbstractMesh {
  20350. /**
  20351. * Gets the edgesRenderer associated with the mesh
  20352. */
  20353. edgesRenderer: Nullable<EdgesRenderer>;
  20354. }
  20355. }
  20356. module "babylonjs/Meshes/linesMesh" {
  20357. interface LinesMesh {
  20358. /**
  20359. * Enables the edge rendering mode on the mesh.
  20360. * This mode makes the mesh edges visible
  20361. * @param epsilon defines the maximal distance between two angles to detect a face
  20362. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20363. * @returns the currentAbstractMesh
  20364. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20365. */
  20366. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20367. }
  20368. }
  20369. module "babylonjs/Meshes/linesMesh" {
  20370. interface InstancedLinesMesh {
  20371. /**
  20372. * Enables the edge rendering mode on the mesh.
  20373. * This mode makes the mesh edges visible
  20374. * @param epsilon defines the maximal distance between two angles to detect a face
  20375. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20376. * @returns the current InstancedLinesMesh
  20377. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20378. */
  20379. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20380. }
  20381. }
  20382. /**
  20383. * Defines the minimum contract an Edges renderer should follow.
  20384. */
  20385. export interface IEdgesRenderer extends IDisposable {
  20386. /**
  20387. * Gets or sets a boolean indicating if the edgesRenderer is active
  20388. */
  20389. isEnabled: boolean;
  20390. /**
  20391. * Renders the edges of the attached mesh,
  20392. */
  20393. render(): void;
  20394. /**
  20395. * Checks wether or not the edges renderer is ready to render.
  20396. * @return true if ready, otherwise false.
  20397. */
  20398. isReady(): boolean;
  20399. }
  20400. /**
  20401. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20402. */
  20403. export class EdgesRenderer implements IEdgesRenderer {
  20404. /**
  20405. * Define the size of the edges with an orthographic camera
  20406. */
  20407. edgesWidthScalerForOrthographic: number;
  20408. /**
  20409. * Define the size of the edges with a perspective camera
  20410. */
  20411. edgesWidthScalerForPerspective: number;
  20412. protected _source: AbstractMesh;
  20413. protected _linesPositions: number[];
  20414. protected _linesNormals: number[];
  20415. protected _linesIndices: number[];
  20416. protected _epsilon: number;
  20417. protected _indicesCount: number;
  20418. protected _lineShader: ShaderMaterial;
  20419. protected _ib: DataBuffer;
  20420. protected _buffers: {
  20421. [key: string]: Nullable<VertexBuffer>;
  20422. };
  20423. protected _checkVerticesInsteadOfIndices: boolean;
  20424. private _meshRebuildObserver;
  20425. private _meshDisposeObserver;
  20426. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20427. isEnabled: boolean;
  20428. /**
  20429. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20430. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20431. * @param source Mesh used to create edges
  20432. * @param epsilon sum of angles in adjacency to check for edge
  20433. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20434. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20435. */
  20436. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20437. protected _prepareRessources(): void;
  20438. /** @hidden */
  20439. _rebuild(): void;
  20440. /**
  20441. * Releases the required resources for the edges renderer
  20442. */
  20443. dispose(): void;
  20444. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20445. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20446. /**
  20447. * Checks if the pair of p0 and p1 is en edge
  20448. * @param faceIndex
  20449. * @param edge
  20450. * @param faceNormals
  20451. * @param p0
  20452. * @param p1
  20453. * @private
  20454. */
  20455. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20456. /**
  20457. * push line into the position, normal and index buffer
  20458. * @protected
  20459. */
  20460. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20461. /**
  20462. * Generates lines edges from adjacencjes
  20463. * @private
  20464. */
  20465. _generateEdgesLines(): void;
  20466. /**
  20467. * Checks wether or not the edges renderer is ready to render.
  20468. * @return true if ready, otherwise false.
  20469. */
  20470. isReady(): boolean;
  20471. /**
  20472. * Renders the edges of the attached mesh,
  20473. */
  20474. render(): void;
  20475. }
  20476. /**
  20477. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20478. */
  20479. export class LineEdgesRenderer extends EdgesRenderer {
  20480. /**
  20481. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20482. * @param source LineMesh used to generate edges
  20483. * @param epsilon not important (specified angle for edge detection)
  20484. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20485. */
  20486. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20487. /**
  20488. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20489. */
  20490. _generateEdgesLines(): void;
  20491. }
  20492. }
  20493. declare module "babylonjs/Rendering/renderingGroup" {
  20494. import { SmartArray } from "babylonjs/Misc/smartArray";
  20495. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20497. import { Nullable } from "babylonjs/types";
  20498. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20499. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20500. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20501. import { Material } from "babylonjs/Materials/material";
  20502. import { Scene } from "babylonjs/scene";
  20503. /**
  20504. * This represents the object necessary to create a rendering group.
  20505. * This is exclusively used and created by the rendering manager.
  20506. * To modify the behavior, you use the available helpers in your scene or meshes.
  20507. * @hidden
  20508. */
  20509. export class RenderingGroup {
  20510. index: number;
  20511. private static _zeroVector;
  20512. private _scene;
  20513. private _opaqueSubMeshes;
  20514. private _transparentSubMeshes;
  20515. private _alphaTestSubMeshes;
  20516. private _depthOnlySubMeshes;
  20517. private _particleSystems;
  20518. private _spriteManagers;
  20519. private _opaqueSortCompareFn;
  20520. private _alphaTestSortCompareFn;
  20521. private _transparentSortCompareFn;
  20522. private _renderOpaque;
  20523. private _renderAlphaTest;
  20524. private _renderTransparent;
  20525. /** @hidden */
  20526. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20527. onBeforeTransparentRendering: () => void;
  20528. /**
  20529. * Set the opaque sort comparison function.
  20530. * If null the sub meshes will be render in the order they were created
  20531. */
  20532. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20533. /**
  20534. * Set the alpha test sort comparison function.
  20535. * If null the sub meshes will be render in the order they were created
  20536. */
  20537. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20538. /**
  20539. * Set the transparent sort comparison function.
  20540. * If null the sub meshes will be render in the order they were created
  20541. */
  20542. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20543. /**
  20544. * Creates a new rendering group.
  20545. * @param index The rendering group index
  20546. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20547. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20548. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20549. */
  20550. 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>);
  20551. /**
  20552. * Render all the sub meshes contained in the group.
  20553. * @param customRenderFunction Used to override the default render behaviour of the group.
  20554. * @returns true if rendered some submeshes.
  20555. */
  20556. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20557. /**
  20558. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20559. * @param subMeshes The submeshes to render
  20560. */
  20561. private renderOpaqueSorted;
  20562. /**
  20563. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20564. * @param subMeshes The submeshes to render
  20565. */
  20566. private renderAlphaTestSorted;
  20567. /**
  20568. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20569. * @param subMeshes The submeshes to render
  20570. */
  20571. private renderTransparentSorted;
  20572. /**
  20573. * Renders the submeshes in a specified order.
  20574. * @param subMeshes The submeshes to sort before render
  20575. * @param sortCompareFn The comparison function use to sort
  20576. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20577. * @param transparent Specifies to activate blending if true
  20578. */
  20579. private static renderSorted;
  20580. /**
  20581. * Renders the submeshes in the order they were dispatched (no sort applied).
  20582. * @param subMeshes The submeshes to render
  20583. */
  20584. private static renderUnsorted;
  20585. /**
  20586. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20587. * are rendered back to front if in the same alpha index.
  20588. *
  20589. * @param a The first submesh
  20590. * @param b The second submesh
  20591. * @returns The result of the comparison
  20592. */
  20593. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20594. /**
  20595. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20596. * are rendered back to front.
  20597. *
  20598. * @param a The first submesh
  20599. * @param b The second submesh
  20600. * @returns The result of the comparison
  20601. */
  20602. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20603. /**
  20604. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20605. * are rendered front to back (prevent overdraw).
  20606. *
  20607. * @param a The first submesh
  20608. * @param b The second submesh
  20609. * @returns The result of the comparison
  20610. */
  20611. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20612. /**
  20613. * Resets the different lists of submeshes to prepare a new frame.
  20614. */
  20615. prepare(): void;
  20616. dispose(): void;
  20617. /**
  20618. * Inserts the submesh in its correct queue depending on its material.
  20619. * @param subMesh The submesh to dispatch
  20620. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20621. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20622. */
  20623. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20624. dispatchSprites(spriteManager: ISpriteManager): void;
  20625. dispatchParticles(particleSystem: IParticleSystem): void;
  20626. private _renderParticles;
  20627. private _renderSprites;
  20628. }
  20629. }
  20630. declare module "babylonjs/Rendering/renderingManager" {
  20631. import { Nullable } from "babylonjs/types";
  20632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20633. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20634. import { SmartArray } from "babylonjs/Misc/smartArray";
  20635. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20636. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20637. import { Material } from "babylonjs/Materials/material";
  20638. import { Scene } from "babylonjs/scene";
  20639. import { Camera } from "babylonjs/Cameras/camera";
  20640. /**
  20641. * Interface describing the different options available in the rendering manager
  20642. * regarding Auto Clear between groups.
  20643. */
  20644. export interface IRenderingManagerAutoClearSetup {
  20645. /**
  20646. * Defines whether or not autoclear is enable.
  20647. */
  20648. autoClear: boolean;
  20649. /**
  20650. * Defines whether or not to autoclear the depth buffer.
  20651. */
  20652. depth: boolean;
  20653. /**
  20654. * Defines whether or not to autoclear the stencil buffer.
  20655. */
  20656. stencil: boolean;
  20657. }
  20658. /**
  20659. * This class is used by the onRenderingGroupObservable
  20660. */
  20661. export class RenderingGroupInfo {
  20662. /**
  20663. * The Scene that being rendered
  20664. */
  20665. scene: Scene;
  20666. /**
  20667. * The camera currently used for the rendering pass
  20668. */
  20669. camera: Nullable<Camera>;
  20670. /**
  20671. * The ID of the renderingGroup being processed
  20672. */
  20673. renderingGroupId: number;
  20674. }
  20675. /**
  20676. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20677. * It is enable to manage the different groups as well as the different necessary sort functions.
  20678. * This should not be used directly aside of the few static configurations
  20679. */
  20680. export class RenderingManager {
  20681. /**
  20682. * The max id used for rendering groups (not included)
  20683. */
  20684. static MAX_RENDERINGGROUPS: number;
  20685. /**
  20686. * The min id used for rendering groups (included)
  20687. */
  20688. static MIN_RENDERINGGROUPS: number;
  20689. /**
  20690. * Used to globally prevent autoclearing scenes.
  20691. */
  20692. static AUTOCLEAR: boolean;
  20693. /**
  20694. * @hidden
  20695. */
  20696. _useSceneAutoClearSetup: boolean;
  20697. private _scene;
  20698. private _renderingGroups;
  20699. private _depthStencilBufferAlreadyCleaned;
  20700. private _autoClearDepthStencil;
  20701. private _customOpaqueSortCompareFn;
  20702. private _customAlphaTestSortCompareFn;
  20703. private _customTransparentSortCompareFn;
  20704. private _renderingGroupInfo;
  20705. /**
  20706. * Instantiates a new rendering group for a particular scene
  20707. * @param scene Defines the scene the groups belongs to
  20708. */
  20709. constructor(scene: Scene);
  20710. private _clearDepthStencilBuffer;
  20711. /**
  20712. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20713. * @hidden
  20714. */
  20715. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20716. /**
  20717. * Resets the different information of the group to prepare a new frame
  20718. * @hidden
  20719. */
  20720. reset(): void;
  20721. /**
  20722. * Dispose and release the group and its associated resources.
  20723. * @hidden
  20724. */
  20725. dispose(): void;
  20726. /**
  20727. * Clear the info related to rendering groups preventing retention points during dispose.
  20728. */
  20729. freeRenderingGroups(): void;
  20730. private _prepareRenderingGroup;
  20731. /**
  20732. * Add a sprite manager to the rendering manager in order to render it this frame.
  20733. * @param spriteManager Define the sprite manager to render
  20734. */
  20735. dispatchSprites(spriteManager: ISpriteManager): void;
  20736. /**
  20737. * Add a particle system to the rendering manager in order to render it this frame.
  20738. * @param particleSystem Define the particle system to render
  20739. */
  20740. dispatchParticles(particleSystem: IParticleSystem): void;
  20741. /**
  20742. * Add a submesh to the manager in order to render it this frame
  20743. * @param subMesh The submesh to dispatch
  20744. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20745. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20746. */
  20747. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20748. /**
  20749. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20750. * This allowed control for front to back rendering or reversly depending of the special needs.
  20751. *
  20752. * @param renderingGroupId The rendering group id corresponding to its index
  20753. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20754. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20755. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20756. */
  20757. 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;
  20758. /**
  20759. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20760. *
  20761. * @param renderingGroupId The rendering group id corresponding to its index
  20762. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20763. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20764. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20765. */
  20766. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20767. /**
  20768. * Gets the current auto clear configuration for one rendering group of the rendering
  20769. * manager.
  20770. * @param index the rendering group index to get the information for
  20771. * @returns The auto clear setup for the requested rendering group
  20772. */
  20773. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20774. }
  20775. }
  20776. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20777. import { Observable } from "babylonjs/Misc/observable";
  20778. import { SmartArray } from "babylonjs/Misc/smartArray";
  20779. import { Nullable } from "babylonjs/types";
  20780. import { Camera } from "babylonjs/Cameras/camera";
  20781. import { Scene } from "babylonjs/scene";
  20782. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20783. import { Color4 } from "babylonjs/Maths/math.color";
  20784. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20786. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20787. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20788. import { Texture } from "babylonjs/Materials/Textures/texture";
  20789. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20790. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20791. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20792. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20793. import { Engine } from "babylonjs/Engines/engine";
  20794. /**
  20795. * This Helps creating a texture that will be created from a camera in your scene.
  20796. * It is basically a dynamic texture that could be used to create special effects for instance.
  20797. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20798. */
  20799. export class RenderTargetTexture extends Texture {
  20800. isCube: boolean;
  20801. /**
  20802. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20803. */
  20804. static readonly REFRESHRATE_RENDER_ONCE: number;
  20805. /**
  20806. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20807. */
  20808. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20809. /**
  20810. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20811. * the central point of your effect and can save a lot of performances.
  20812. */
  20813. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20814. /**
  20815. * Use this predicate to dynamically define the list of mesh you want to render.
  20816. * If set, the renderList property will be overwritten.
  20817. */
  20818. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20819. private _renderList;
  20820. /**
  20821. * Use this list to define the list of mesh you want to render.
  20822. */
  20823. get renderList(): Nullable<Array<AbstractMesh>>;
  20824. set renderList(value: Nullable<Array<AbstractMesh>>);
  20825. private _hookArray;
  20826. /**
  20827. * Define if particles should be rendered in your texture.
  20828. */
  20829. renderParticles: boolean;
  20830. /**
  20831. * Define if sprites should be rendered in your texture.
  20832. */
  20833. renderSprites: boolean;
  20834. /**
  20835. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20836. */
  20837. coordinatesMode: number;
  20838. /**
  20839. * Define the camera used to render the texture.
  20840. */
  20841. activeCamera: Nullable<Camera>;
  20842. /**
  20843. * Override the render function of the texture with your own one.
  20844. */
  20845. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20846. /**
  20847. * Define if camera post processes should be use while rendering the texture.
  20848. */
  20849. useCameraPostProcesses: boolean;
  20850. /**
  20851. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20852. */
  20853. ignoreCameraViewport: boolean;
  20854. private _postProcessManager;
  20855. private _postProcesses;
  20856. private _resizeObserver;
  20857. /**
  20858. * An event triggered when the texture is unbind.
  20859. */
  20860. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20861. /**
  20862. * An event triggered when the texture is unbind.
  20863. */
  20864. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20865. private _onAfterUnbindObserver;
  20866. /**
  20867. * Set a after unbind callback in the texture.
  20868. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20869. */
  20870. set onAfterUnbind(callback: () => void);
  20871. /**
  20872. * An event triggered before rendering the texture
  20873. */
  20874. onBeforeRenderObservable: Observable<number>;
  20875. private _onBeforeRenderObserver;
  20876. /**
  20877. * Set a before render callback in the texture.
  20878. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20879. */
  20880. set onBeforeRender(callback: (faceIndex: number) => void);
  20881. /**
  20882. * An event triggered after rendering the texture
  20883. */
  20884. onAfterRenderObservable: Observable<number>;
  20885. private _onAfterRenderObserver;
  20886. /**
  20887. * Set a after render callback in the texture.
  20888. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20889. */
  20890. set onAfterRender(callback: (faceIndex: number) => void);
  20891. /**
  20892. * An event triggered after the texture clear
  20893. */
  20894. onClearObservable: Observable<Engine>;
  20895. private _onClearObserver;
  20896. /**
  20897. * Set a clear callback in the texture.
  20898. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20899. */
  20900. set onClear(callback: (Engine: Engine) => void);
  20901. /**
  20902. * An event triggered when the texture is resized.
  20903. */
  20904. onResizeObservable: Observable<RenderTargetTexture>;
  20905. /**
  20906. * Define the clear color of the Render Target if it should be different from the scene.
  20907. */
  20908. clearColor: Color4;
  20909. protected _size: number | {
  20910. width: number;
  20911. height: number;
  20912. };
  20913. protected _initialSizeParameter: number | {
  20914. width: number;
  20915. height: number;
  20916. } | {
  20917. ratio: number;
  20918. };
  20919. protected _sizeRatio: Nullable<number>;
  20920. /** @hidden */
  20921. _generateMipMaps: boolean;
  20922. protected _renderingManager: RenderingManager;
  20923. /** @hidden */
  20924. _waitingRenderList: string[];
  20925. protected _doNotChangeAspectRatio: boolean;
  20926. protected _currentRefreshId: number;
  20927. protected _refreshRate: number;
  20928. protected _textureMatrix: Matrix;
  20929. protected _samples: number;
  20930. protected _renderTargetOptions: RenderTargetCreationOptions;
  20931. /**
  20932. * Gets render target creation options that were used.
  20933. */
  20934. get renderTargetOptions(): RenderTargetCreationOptions;
  20935. protected _engine: Engine;
  20936. protected _onRatioRescale(): void;
  20937. /**
  20938. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20939. * It must define where the camera used to render the texture is set
  20940. */
  20941. boundingBoxPosition: Vector3;
  20942. private _boundingBoxSize;
  20943. /**
  20944. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20945. * When defined, the cubemap will switch to local mode
  20946. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20947. * @example https://www.babylonjs-playground.com/#RNASML
  20948. */
  20949. set boundingBoxSize(value: Vector3);
  20950. get boundingBoxSize(): Vector3;
  20951. /**
  20952. * In case the RTT has been created with a depth texture, get the associated
  20953. * depth texture.
  20954. * Otherwise, return null.
  20955. */
  20956. depthStencilTexture: Nullable<InternalTexture>;
  20957. /**
  20958. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20959. * or used a shadow, depth texture...
  20960. * @param name The friendly name of the texture
  20961. * @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)
  20962. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20963. * @param generateMipMaps True if mip maps need to be generated after render.
  20964. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20965. * @param type The type of the buffer in the RTT (int, half float, float...)
  20966. * @param isCube True if a cube texture needs to be created
  20967. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20968. * @param generateDepthBuffer True to generate a depth buffer
  20969. * @param generateStencilBuffer True to generate a stencil buffer
  20970. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20971. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20972. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20973. */
  20974. constructor(name: string, size: number | {
  20975. width: number;
  20976. height: number;
  20977. } | {
  20978. ratio: number;
  20979. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20980. /**
  20981. * Creates a depth stencil texture.
  20982. * This is only available in WebGL 2 or with the depth texture extension available.
  20983. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20984. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20985. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20986. */
  20987. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20988. private _processSizeParameter;
  20989. /**
  20990. * Define the number of samples to use in case of MSAA.
  20991. * It defaults to one meaning no MSAA has been enabled.
  20992. */
  20993. get samples(): number;
  20994. set samples(value: number);
  20995. /**
  20996. * Resets the refresh counter of the texture and start bak from scratch.
  20997. * Could be useful to regenerate the texture if it is setup to render only once.
  20998. */
  20999. resetRefreshCounter(): void;
  21000. /**
  21001. * Define the refresh rate of the texture or the rendering frequency.
  21002. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21003. */
  21004. get refreshRate(): number;
  21005. set refreshRate(value: number);
  21006. /**
  21007. * Adds a post process to the render target rendering passes.
  21008. * @param postProcess define the post process to add
  21009. */
  21010. addPostProcess(postProcess: PostProcess): void;
  21011. /**
  21012. * Clear all the post processes attached to the render target
  21013. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21014. */
  21015. clearPostProcesses(dispose?: boolean): void;
  21016. /**
  21017. * Remove one of the post process from the list of attached post processes to the texture
  21018. * @param postProcess define the post process to remove from the list
  21019. */
  21020. removePostProcess(postProcess: PostProcess): void;
  21021. /** @hidden */
  21022. _shouldRender(): boolean;
  21023. /**
  21024. * Gets the actual render size of the texture.
  21025. * @returns the width of the render size
  21026. */
  21027. getRenderSize(): number;
  21028. /**
  21029. * Gets the actual render width of the texture.
  21030. * @returns the width of the render size
  21031. */
  21032. getRenderWidth(): number;
  21033. /**
  21034. * Gets the actual render height of the texture.
  21035. * @returns the height of the render size
  21036. */
  21037. getRenderHeight(): number;
  21038. /**
  21039. * Get if the texture can be rescaled or not.
  21040. */
  21041. get canRescale(): boolean;
  21042. /**
  21043. * Resize the texture using a ratio.
  21044. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21045. */
  21046. scale(ratio: number): void;
  21047. /**
  21048. * Get the texture reflection matrix used to rotate/transform the reflection.
  21049. * @returns the reflection matrix
  21050. */
  21051. getReflectionTextureMatrix(): Matrix;
  21052. /**
  21053. * Resize the texture to a new desired size.
  21054. * Be carrefull as it will recreate all the data in the new texture.
  21055. * @param size Define the new size. It can be:
  21056. * - a number for squared texture,
  21057. * - an object containing { width: number, height: number }
  21058. * - or an object containing a ratio { ratio: number }
  21059. */
  21060. resize(size: number | {
  21061. width: number;
  21062. height: number;
  21063. } | {
  21064. ratio: number;
  21065. }): void;
  21066. /**
  21067. * Renders all the objects from the render list into the texture.
  21068. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21069. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21070. */
  21071. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21072. private _bestReflectionRenderTargetDimension;
  21073. /**
  21074. * @hidden
  21075. * @param faceIndex face index to bind to if this is a cubetexture
  21076. */
  21077. _bindFrameBuffer(faceIndex?: number): void;
  21078. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21079. private renderToTarget;
  21080. /**
  21081. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21082. * This allowed control for front to back rendering or reversly depending of the special needs.
  21083. *
  21084. * @param renderingGroupId The rendering group id corresponding to its index
  21085. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21086. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21087. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21088. */
  21089. 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;
  21090. /**
  21091. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21092. *
  21093. * @param renderingGroupId The rendering group id corresponding to its index
  21094. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21095. */
  21096. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21097. /**
  21098. * Clones the texture.
  21099. * @returns the cloned texture
  21100. */
  21101. clone(): RenderTargetTexture;
  21102. /**
  21103. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21104. * @returns The JSON representation of the texture
  21105. */
  21106. serialize(): any;
  21107. /**
  21108. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21109. */
  21110. disposeFramebufferObjects(): void;
  21111. /**
  21112. * Dispose the texture and release its associated resources.
  21113. */
  21114. dispose(): void;
  21115. /** @hidden */
  21116. _rebuild(): void;
  21117. /**
  21118. * Clear the info related to rendering groups preventing retention point in material dispose.
  21119. */
  21120. freeRenderingGroups(): void;
  21121. /**
  21122. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21123. * @returns the view count
  21124. */
  21125. getViewCount(): number;
  21126. }
  21127. }
  21128. declare module "babylonjs/Materials/material" {
  21129. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21130. import { SmartArray } from "babylonjs/Misc/smartArray";
  21131. import { Observable } from "babylonjs/Misc/observable";
  21132. import { Nullable } from "babylonjs/types";
  21133. import { Scene } from "babylonjs/scene";
  21134. import { Matrix } from "babylonjs/Maths/math.vector";
  21135. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21137. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21138. import { Effect } from "babylonjs/Materials/effect";
  21139. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21140. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21141. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21142. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21143. import { Mesh } from "babylonjs/Meshes/mesh";
  21144. import { Animation } from "babylonjs/Animations/animation";
  21145. /**
  21146. * Options for compiling materials.
  21147. */
  21148. export interface IMaterialCompilationOptions {
  21149. /**
  21150. * Defines whether clip planes are enabled.
  21151. */
  21152. clipPlane: boolean;
  21153. /**
  21154. * Defines whether instances are enabled.
  21155. */
  21156. useInstances: boolean;
  21157. }
  21158. /**
  21159. * Base class for the main features of a material in Babylon.js
  21160. */
  21161. export class Material implements IAnimatable {
  21162. /**
  21163. * Returns the triangle fill mode
  21164. */
  21165. static readonly TriangleFillMode: number;
  21166. /**
  21167. * Returns the wireframe mode
  21168. */
  21169. static readonly WireFrameFillMode: number;
  21170. /**
  21171. * Returns the point fill mode
  21172. */
  21173. static readonly PointFillMode: number;
  21174. /**
  21175. * Returns the point list draw mode
  21176. */
  21177. static readonly PointListDrawMode: number;
  21178. /**
  21179. * Returns the line list draw mode
  21180. */
  21181. static readonly LineListDrawMode: number;
  21182. /**
  21183. * Returns the line loop draw mode
  21184. */
  21185. static readonly LineLoopDrawMode: number;
  21186. /**
  21187. * Returns the line strip draw mode
  21188. */
  21189. static readonly LineStripDrawMode: number;
  21190. /**
  21191. * Returns the triangle strip draw mode
  21192. */
  21193. static readonly TriangleStripDrawMode: number;
  21194. /**
  21195. * Returns the triangle fan draw mode
  21196. */
  21197. static readonly TriangleFanDrawMode: number;
  21198. /**
  21199. * Stores the clock-wise side orientation
  21200. */
  21201. static readonly ClockWiseSideOrientation: number;
  21202. /**
  21203. * Stores the counter clock-wise side orientation
  21204. */
  21205. static readonly CounterClockWiseSideOrientation: number;
  21206. /**
  21207. * The dirty texture flag value
  21208. */
  21209. static readonly TextureDirtyFlag: number;
  21210. /**
  21211. * The dirty light flag value
  21212. */
  21213. static readonly LightDirtyFlag: number;
  21214. /**
  21215. * The dirty fresnel flag value
  21216. */
  21217. static readonly FresnelDirtyFlag: number;
  21218. /**
  21219. * The dirty attribute flag value
  21220. */
  21221. static readonly AttributesDirtyFlag: number;
  21222. /**
  21223. * The dirty misc flag value
  21224. */
  21225. static readonly MiscDirtyFlag: number;
  21226. /**
  21227. * The all dirty flag value
  21228. */
  21229. static readonly AllDirtyFlag: number;
  21230. /**
  21231. * The ID of the material
  21232. */
  21233. id: string;
  21234. /**
  21235. * Gets or sets the unique id of the material
  21236. */
  21237. uniqueId: number;
  21238. /**
  21239. * The name of the material
  21240. */
  21241. name: string;
  21242. /**
  21243. * Gets or sets user defined metadata
  21244. */
  21245. metadata: any;
  21246. /**
  21247. * For internal use only. Please do not use.
  21248. */
  21249. reservedDataStore: any;
  21250. /**
  21251. * Specifies if the ready state should be checked on each call
  21252. */
  21253. checkReadyOnEveryCall: boolean;
  21254. /**
  21255. * Specifies if the ready state should be checked once
  21256. */
  21257. checkReadyOnlyOnce: boolean;
  21258. /**
  21259. * The state of the material
  21260. */
  21261. state: string;
  21262. /**
  21263. * The alpha value of the material
  21264. */
  21265. protected _alpha: number;
  21266. /**
  21267. * List of inspectable custom properties (used by the Inspector)
  21268. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21269. */
  21270. inspectableCustomProperties: IInspectable[];
  21271. /**
  21272. * Sets the alpha value of the material
  21273. */
  21274. set alpha(value: number);
  21275. /**
  21276. * Gets the alpha value of the material
  21277. */
  21278. get alpha(): number;
  21279. /**
  21280. * Specifies if back face culling is enabled
  21281. */
  21282. protected _backFaceCulling: boolean;
  21283. /**
  21284. * Sets the back-face culling state
  21285. */
  21286. set backFaceCulling(value: boolean);
  21287. /**
  21288. * Gets the back-face culling state
  21289. */
  21290. get backFaceCulling(): boolean;
  21291. /**
  21292. * Stores the value for side orientation
  21293. */
  21294. sideOrientation: number;
  21295. /**
  21296. * Callback triggered when the material is compiled
  21297. */
  21298. onCompiled: Nullable<(effect: Effect) => void>;
  21299. /**
  21300. * Callback triggered when an error occurs
  21301. */
  21302. onError: Nullable<(effect: Effect, errors: string) => void>;
  21303. /**
  21304. * Callback triggered to get the render target textures
  21305. */
  21306. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21307. /**
  21308. * Gets a boolean indicating that current material needs to register RTT
  21309. */
  21310. get hasRenderTargetTextures(): boolean;
  21311. /**
  21312. * Specifies if the material should be serialized
  21313. */
  21314. doNotSerialize: boolean;
  21315. /**
  21316. * @hidden
  21317. */
  21318. _storeEffectOnSubMeshes: boolean;
  21319. /**
  21320. * Stores the animations for the material
  21321. */
  21322. animations: Nullable<Array<Animation>>;
  21323. /**
  21324. * An event triggered when the material is disposed
  21325. */
  21326. onDisposeObservable: Observable<Material>;
  21327. /**
  21328. * An observer which watches for dispose events
  21329. */
  21330. private _onDisposeObserver;
  21331. private _onUnBindObservable;
  21332. /**
  21333. * Called during a dispose event
  21334. */
  21335. set onDispose(callback: () => void);
  21336. private _onBindObservable;
  21337. /**
  21338. * An event triggered when the material is bound
  21339. */
  21340. get onBindObservable(): Observable<AbstractMesh>;
  21341. /**
  21342. * An observer which watches for bind events
  21343. */
  21344. private _onBindObserver;
  21345. /**
  21346. * Called during a bind event
  21347. */
  21348. set onBind(callback: (Mesh: AbstractMesh) => void);
  21349. /**
  21350. * An event triggered when the material is unbound
  21351. */
  21352. get onUnBindObservable(): Observable<Material>;
  21353. /**
  21354. * Stores the value of the alpha mode
  21355. */
  21356. private _alphaMode;
  21357. /**
  21358. * Sets the value of the alpha mode.
  21359. *
  21360. * | Value | Type | Description |
  21361. * | --- | --- | --- |
  21362. * | 0 | ALPHA_DISABLE | |
  21363. * | 1 | ALPHA_ADD | |
  21364. * | 2 | ALPHA_COMBINE | |
  21365. * | 3 | ALPHA_SUBTRACT | |
  21366. * | 4 | ALPHA_MULTIPLY | |
  21367. * | 5 | ALPHA_MAXIMIZED | |
  21368. * | 6 | ALPHA_ONEONE | |
  21369. * | 7 | ALPHA_PREMULTIPLIED | |
  21370. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21371. * | 9 | ALPHA_INTERPOLATE | |
  21372. * | 10 | ALPHA_SCREENMODE | |
  21373. *
  21374. */
  21375. set alphaMode(value: number);
  21376. /**
  21377. * Gets the value of the alpha mode
  21378. */
  21379. get alphaMode(): number;
  21380. /**
  21381. * Stores the state of the need depth pre-pass value
  21382. */
  21383. private _needDepthPrePass;
  21384. /**
  21385. * Sets the need depth pre-pass value
  21386. */
  21387. set needDepthPrePass(value: boolean);
  21388. /**
  21389. * Gets the depth pre-pass value
  21390. */
  21391. get needDepthPrePass(): boolean;
  21392. /**
  21393. * Specifies if depth writing should be disabled
  21394. */
  21395. disableDepthWrite: boolean;
  21396. /**
  21397. * Specifies if depth writing should be forced
  21398. */
  21399. forceDepthWrite: boolean;
  21400. /**
  21401. * Specifies the depth function that should be used. 0 means the default engine function
  21402. */
  21403. depthFunction: number;
  21404. /**
  21405. * Specifies if there should be a separate pass for culling
  21406. */
  21407. separateCullingPass: boolean;
  21408. /**
  21409. * Stores the state specifing if fog should be enabled
  21410. */
  21411. private _fogEnabled;
  21412. /**
  21413. * Sets the state for enabling fog
  21414. */
  21415. set fogEnabled(value: boolean);
  21416. /**
  21417. * Gets the value of the fog enabled state
  21418. */
  21419. get fogEnabled(): boolean;
  21420. /**
  21421. * Stores the size of points
  21422. */
  21423. pointSize: number;
  21424. /**
  21425. * Stores the z offset value
  21426. */
  21427. zOffset: number;
  21428. /**
  21429. * Gets a value specifying if wireframe mode is enabled
  21430. */
  21431. get wireframe(): boolean;
  21432. /**
  21433. * Sets the state of wireframe mode
  21434. */
  21435. set wireframe(value: boolean);
  21436. /**
  21437. * Gets the value specifying if point clouds are enabled
  21438. */
  21439. get pointsCloud(): boolean;
  21440. /**
  21441. * Sets the state of point cloud mode
  21442. */
  21443. set pointsCloud(value: boolean);
  21444. /**
  21445. * Gets the material fill mode
  21446. */
  21447. get fillMode(): number;
  21448. /**
  21449. * Sets the material fill mode
  21450. */
  21451. set fillMode(value: number);
  21452. /**
  21453. * @hidden
  21454. * Stores the effects for the material
  21455. */
  21456. _effect: Nullable<Effect>;
  21457. /**
  21458. * @hidden
  21459. * Specifies if the material was previously ready
  21460. */
  21461. _wasPreviouslyReady: boolean;
  21462. /**
  21463. * Specifies if uniform buffers should be used
  21464. */
  21465. private _useUBO;
  21466. /**
  21467. * Stores a reference to the scene
  21468. */
  21469. private _scene;
  21470. /**
  21471. * Stores the fill mode state
  21472. */
  21473. private _fillMode;
  21474. /**
  21475. * Specifies if the depth write state should be cached
  21476. */
  21477. private _cachedDepthWriteState;
  21478. /**
  21479. * Specifies if the depth function state should be cached
  21480. */
  21481. private _cachedDepthFunctionState;
  21482. /**
  21483. * Stores the uniform buffer
  21484. */
  21485. protected _uniformBuffer: UniformBuffer;
  21486. /** @hidden */
  21487. _indexInSceneMaterialArray: number;
  21488. /** @hidden */
  21489. meshMap: Nullable<{
  21490. [id: string]: AbstractMesh | undefined;
  21491. }>;
  21492. /**
  21493. * Creates a material instance
  21494. * @param name defines the name of the material
  21495. * @param scene defines the scene to reference
  21496. * @param doNotAdd specifies if the material should be added to the scene
  21497. */
  21498. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21499. /**
  21500. * Returns a string representation of the current material
  21501. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21502. * @returns a string with material information
  21503. */
  21504. toString(fullDetails?: boolean): string;
  21505. /**
  21506. * Gets the class name of the material
  21507. * @returns a string with the class name of the material
  21508. */
  21509. getClassName(): string;
  21510. /**
  21511. * Specifies if updates for the material been locked
  21512. */
  21513. get isFrozen(): boolean;
  21514. /**
  21515. * Locks updates for the material
  21516. */
  21517. freeze(): void;
  21518. /**
  21519. * Unlocks updates for the material
  21520. */
  21521. unfreeze(): void;
  21522. /**
  21523. * Specifies if the material is ready to be used
  21524. * @param mesh defines the mesh to check
  21525. * @param useInstances specifies if instances should be used
  21526. * @returns a boolean indicating if the material is ready to be used
  21527. */
  21528. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21529. /**
  21530. * Specifies that the submesh is ready to be used
  21531. * @param mesh defines the mesh to check
  21532. * @param subMesh defines which submesh to check
  21533. * @param useInstances specifies that instances should be used
  21534. * @returns a boolean indicating that the submesh is ready or not
  21535. */
  21536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21537. /**
  21538. * Returns the material effect
  21539. * @returns the effect associated with the material
  21540. */
  21541. getEffect(): Nullable<Effect>;
  21542. /**
  21543. * Returns the current scene
  21544. * @returns a Scene
  21545. */
  21546. getScene(): Scene;
  21547. /**
  21548. * Specifies if the material will require alpha blending
  21549. * @returns a boolean specifying if alpha blending is needed
  21550. */
  21551. needAlphaBlending(): boolean;
  21552. /**
  21553. * Specifies if the mesh will require alpha blending
  21554. * @param mesh defines the mesh to check
  21555. * @returns a boolean specifying if alpha blending is needed for the mesh
  21556. */
  21557. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21558. /**
  21559. * Specifies if this material should be rendered in alpha test mode
  21560. * @returns a boolean specifying if an alpha test is needed.
  21561. */
  21562. needAlphaTesting(): boolean;
  21563. /**
  21564. * Gets the texture used for the alpha test
  21565. * @returns the texture to use for alpha testing
  21566. */
  21567. getAlphaTestTexture(): Nullable<BaseTexture>;
  21568. /**
  21569. * Marks the material to indicate that it needs to be re-calculated
  21570. */
  21571. markDirty(): void;
  21572. /** @hidden */
  21573. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21574. /**
  21575. * Binds the material to the mesh
  21576. * @param world defines the world transformation matrix
  21577. * @param mesh defines the mesh to bind the material to
  21578. */
  21579. bind(world: Matrix, mesh?: Mesh): void;
  21580. /**
  21581. * Binds the submesh to the material
  21582. * @param world defines the world transformation matrix
  21583. * @param mesh defines the mesh containing the submesh
  21584. * @param subMesh defines the submesh to bind the material to
  21585. */
  21586. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21587. /**
  21588. * Binds the world matrix to the material
  21589. * @param world defines the world transformation matrix
  21590. */
  21591. bindOnlyWorldMatrix(world: Matrix): void;
  21592. /**
  21593. * Binds the scene's uniform buffer to the effect.
  21594. * @param effect defines the effect to bind to the scene uniform buffer
  21595. * @param sceneUbo defines the uniform buffer storing scene data
  21596. */
  21597. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21598. /**
  21599. * Binds the view matrix to the effect
  21600. * @param effect defines the effect to bind the view matrix to
  21601. */
  21602. bindView(effect: Effect): void;
  21603. /**
  21604. * Binds the view projection matrix to the effect
  21605. * @param effect defines the effect to bind the view projection matrix to
  21606. */
  21607. bindViewProjection(effect: Effect): void;
  21608. /**
  21609. * Specifies if material alpha testing should be turned on for the mesh
  21610. * @param mesh defines the mesh to check
  21611. */
  21612. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21613. /**
  21614. * Processes to execute after binding the material to a mesh
  21615. * @param mesh defines the rendered mesh
  21616. */
  21617. protected _afterBind(mesh?: Mesh): void;
  21618. /**
  21619. * Unbinds the material from the mesh
  21620. */
  21621. unbind(): void;
  21622. /**
  21623. * Gets the active textures from the material
  21624. * @returns an array of textures
  21625. */
  21626. getActiveTextures(): BaseTexture[];
  21627. /**
  21628. * Specifies if the material uses a texture
  21629. * @param texture defines the texture to check against the material
  21630. * @returns a boolean specifying if the material uses the texture
  21631. */
  21632. hasTexture(texture: BaseTexture): boolean;
  21633. /**
  21634. * Makes a duplicate of the material, and gives it a new name
  21635. * @param name defines the new name for the duplicated material
  21636. * @returns the cloned material
  21637. */
  21638. clone(name: string): Nullable<Material>;
  21639. /**
  21640. * Gets the meshes bound to the material
  21641. * @returns an array of meshes bound to the material
  21642. */
  21643. getBindedMeshes(): AbstractMesh[];
  21644. /**
  21645. * Force shader compilation
  21646. * @param mesh defines the mesh associated with this material
  21647. * @param onCompiled defines a function to execute once the material is compiled
  21648. * @param options defines the options to configure the compilation
  21649. * @param onError defines a function to execute if the material fails compiling
  21650. */
  21651. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21652. /**
  21653. * Force shader compilation
  21654. * @param mesh defines the mesh that will use this material
  21655. * @param options defines additional options for compiling the shaders
  21656. * @returns a promise that resolves when the compilation completes
  21657. */
  21658. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21659. private static readonly _AllDirtyCallBack;
  21660. private static readonly _ImageProcessingDirtyCallBack;
  21661. private static readonly _TextureDirtyCallBack;
  21662. private static readonly _FresnelDirtyCallBack;
  21663. private static readonly _MiscDirtyCallBack;
  21664. private static readonly _LightsDirtyCallBack;
  21665. private static readonly _AttributeDirtyCallBack;
  21666. private static _FresnelAndMiscDirtyCallBack;
  21667. private static _TextureAndMiscDirtyCallBack;
  21668. private static readonly _DirtyCallbackArray;
  21669. private static readonly _RunDirtyCallBacks;
  21670. /**
  21671. * Marks a define in the material to indicate that it needs to be re-computed
  21672. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21673. */
  21674. markAsDirty(flag: number): void;
  21675. /**
  21676. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21677. * @param func defines a function which checks material defines against the submeshes
  21678. */
  21679. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21680. /**
  21681. * Indicates that we need to re-calculated for all submeshes
  21682. */
  21683. protected _markAllSubMeshesAsAllDirty(): void;
  21684. /**
  21685. * Indicates that image processing needs to be re-calculated for all submeshes
  21686. */
  21687. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21688. /**
  21689. * Indicates that textures need to be re-calculated for all submeshes
  21690. */
  21691. protected _markAllSubMeshesAsTexturesDirty(): void;
  21692. /**
  21693. * Indicates that fresnel needs to be re-calculated for all submeshes
  21694. */
  21695. protected _markAllSubMeshesAsFresnelDirty(): void;
  21696. /**
  21697. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21698. */
  21699. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21700. /**
  21701. * Indicates that lights need to be re-calculated for all submeshes
  21702. */
  21703. protected _markAllSubMeshesAsLightsDirty(): void;
  21704. /**
  21705. * Indicates that attributes need to be re-calculated for all submeshes
  21706. */
  21707. protected _markAllSubMeshesAsAttributesDirty(): void;
  21708. /**
  21709. * Indicates that misc needs to be re-calculated for all submeshes
  21710. */
  21711. protected _markAllSubMeshesAsMiscDirty(): void;
  21712. /**
  21713. * Indicates that textures and misc need to be re-calculated for all submeshes
  21714. */
  21715. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21716. /**
  21717. * Disposes the material
  21718. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21719. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21720. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21721. */
  21722. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21723. /** @hidden */
  21724. private releaseVertexArrayObject;
  21725. /**
  21726. * Serializes this material
  21727. * @returns the serialized material object
  21728. */
  21729. serialize(): any;
  21730. /**
  21731. * Creates a material from parsed material data
  21732. * @param parsedMaterial defines parsed material data
  21733. * @param scene defines the hosting scene
  21734. * @param rootUrl defines the root URL to use to load textures
  21735. * @returns a new material
  21736. */
  21737. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21738. }
  21739. }
  21740. declare module "babylonjs/Materials/multiMaterial" {
  21741. import { Nullable } from "babylonjs/types";
  21742. import { Scene } from "babylonjs/scene";
  21743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21744. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21745. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21746. import { Material } from "babylonjs/Materials/material";
  21747. /**
  21748. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21749. * separate meshes. This can be use to improve performances.
  21750. * @see http://doc.babylonjs.com/how_to/multi_materials
  21751. */
  21752. export class MultiMaterial extends Material {
  21753. private _subMaterials;
  21754. /**
  21755. * Gets or Sets the list of Materials used within the multi material.
  21756. * They need to be ordered according to the submeshes order in the associated mesh
  21757. */
  21758. get subMaterials(): Nullable<Material>[];
  21759. set subMaterials(value: Nullable<Material>[]);
  21760. /**
  21761. * Function used to align with Node.getChildren()
  21762. * @returns the list of Materials used within the multi material
  21763. */
  21764. getChildren(): Nullable<Material>[];
  21765. /**
  21766. * Instantiates a new Multi Material
  21767. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21768. * separate meshes. This can be use to improve performances.
  21769. * @see http://doc.babylonjs.com/how_to/multi_materials
  21770. * @param name Define the name in the scene
  21771. * @param scene Define the scene the material belongs to
  21772. */
  21773. constructor(name: string, scene: Scene);
  21774. private _hookArray;
  21775. /**
  21776. * Get one of the submaterial by its index in the submaterials array
  21777. * @param index The index to look the sub material at
  21778. * @returns The Material if the index has been defined
  21779. */
  21780. getSubMaterial(index: number): Nullable<Material>;
  21781. /**
  21782. * Get the list of active textures for the whole sub materials list.
  21783. * @returns All the textures that will be used during the rendering
  21784. */
  21785. getActiveTextures(): BaseTexture[];
  21786. /**
  21787. * Gets the current class name of the material e.g. "MultiMaterial"
  21788. * Mainly use in serialization.
  21789. * @returns the class name
  21790. */
  21791. getClassName(): string;
  21792. /**
  21793. * Checks if the material is ready to render the requested sub mesh
  21794. * @param mesh Define the mesh the submesh belongs to
  21795. * @param subMesh Define the sub mesh to look readyness for
  21796. * @param useInstances Define whether or not the material is used with instances
  21797. * @returns true if ready, otherwise false
  21798. */
  21799. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21800. /**
  21801. * Clones the current material and its related sub materials
  21802. * @param name Define the name of the newly cloned material
  21803. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21804. * @returns the cloned material
  21805. */
  21806. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21807. /**
  21808. * Serializes the materials into a JSON representation.
  21809. * @returns the JSON representation
  21810. */
  21811. serialize(): any;
  21812. /**
  21813. * Dispose the material and release its associated resources
  21814. * @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)
  21815. * @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)
  21816. * @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)
  21817. */
  21818. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21819. /**
  21820. * Creates a MultiMaterial from parsed MultiMaterial data.
  21821. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21822. * @param scene defines the hosting scene
  21823. * @returns a new MultiMaterial
  21824. */
  21825. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21826. }
  21827. }
  21828. declare module "babylonjs/Meshes/subMesh" {
  21829. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21830. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21831. import { Engine } from "babylonjs/Engines/engine";
  21832. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21833. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21834. import { Effect } from "babylonjs/Materials/effect";
  21835. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21836. import { Plane } from "babylonjs/Maths/math.plane";
  21837. import { Collider } from "babylonjs/Collisions/collider";
  21838. import { Material } from "babylonjs/Materials/material";
  21839. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21841. import { Mesh } from "babylonjs/Meshes/mesh";
  21842. import { Ray } from "babylonjs/Culling/ray";
  21843. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21844. /**
  21845. * Base class for submeshes
  21846. */
  21847. export class BaseSubMesh {
  21848. /** @hidden */
  21849. _materialDefines: Nullable<MaterialDefines>;
  21850. /** @hidden */
  21851. _materialEffect: Nullable<Effect>;
  21852. /**
  21853. * Gets material defines used by the effect associated to the sub mesh
  21854. */
  21855. get materialDefines(): Nullable<MaterialDefines>;
  21856. /**
  21857. * Sets material defines used by the effect associated to the sub mesh
  21858. */
  21859. set materialDefines(defines: Nullable<MaterialDefines>);
  21860. /**
  21861. * Gets associated effect
  21862. */
  21863. get effect(): Nullable<Effect>;
  21864. /**
  21865. * Sets associated effect (effect used to render this submesh)
  21866. * @param effect defines the effect to associate with
  21867. * @param defines defines the set of defines used to compile this effect
  21868. */
  21869. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21870. }
  21871. /**
  21872. * Defines a subdivision inside a mesh
  21873. */
  21874. export class SubMesh extends BaseSubMesh implements ICullable {
  21875. /** the material index to use */
  21876. materialIndex: number;
  21877. /** vertex index start */
  21878. verticesStart: number;
  21879. /** vertices count */
  21880. verticesCount: number;
  21881. /** index start */
  21882. indexStart: number;
  21883. /** indices count */
  21884. indexCount: number;
  21885. /** @hidden */
  21886. _linesIndexCount: number;
  21887. private _mesh;
  21888. private _renderingMesh;
  21889. private _boundingInfo;
  21890. private _linesIndexBuffer;
  21891. /** @hidden */
  21892. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21893. /** @hidden */
  21894. _trianglePlanes: Plane[];
  21895. /** @hidden */
  21896. _lastColliderTransformMatrix: Nullable<Matrix>;
  21897. /** @hidden */
  21898. _renderId: number;
  21899. /** @hidden */
  21900. _alphaIndex: number;
  21901. /** @hidden */
  21902. _distanceToCamera: number;
  21903. /** @hidden */
  21904. _id: number;
  21905. private _currentMaterial;
  21906. /**
  21907. * Add a new submesh to a mesh
  21908. * @param materialIndex defines the material index to use
  21909. * @param verticesStart defines vertex index start
  21910. * @param verticesCount defines vertices count
  21911. * @param indexStart defines index start
  21912. * @param indexCount defines indices count
  21913. * @param mesh defines the parent mesh
  21914. * @param renderingMesh defines an optional rendering mesh
  21915. * @param createBoundingBox defines if bounding box should be created for this submesh
  21916. * @returns the new submesh
  21917. */
  21918. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21919. /**
  21920. * Creates a new submesh
  21921. * @param materialIndex defines the material index to use
  21922. * @param verticesStart defines vertex index start
  21923. * @param verticesCount defines vertices count
  21924. * @param indexStart defines index start
  21925. * @param indexCount defines indices count
  21926. * @param mesh defines the parent mesh
  21927. * @param renderingMesh defines an optional rendering mesh
  21928. * @param createBoundingBox defines if bounding box should be created for this submesh
  21929. */
  21930. constructor(
  21931. /** the material index to use */
  21932. materialIndex: number,
  21933. /** vertex index start */
  21934. verticesStart: number,
  21935. /** vertices count */
  21936. verticesCount: number,
  21937. /** index start */
  21938. indexStart: number,
  21939. /** indices count */
  21940. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21941. /**
  21942. * Returns true if this submesh covers the entire parent mesh
  21943. * @ignorenaming
  21944. */
  21945. get IsGlobal(): boolean;
  21946. /**
  21947. * Returns the submesh BoudingInfo object
  21948. * @returns current bounding info (or mesh's one if the submesh is global)
  21949. */
  21950. getBoundingInfo(): BoundingInfo;
  21951. /**
  21952. * Sets the submesh BoundingInfo
  21953. * @param boundingInfo defines the new bounding info to use
  21954. * @returns the SubMesh
  21955. */
  21956. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21957. /**
  21958. * Returns the mesh of the current submesh
  21959. * @return the parent mesh
  21960. */
  21961. getMesh(): AbstractMesh;
  21962. /**
  21963. * Returns the rendering mesh of the submesh
  21964. * @returns the rendering mesh (could be different from parent mesh)
  21965. */
  21966. getRenderingMesh(): Mesh;
  21967. /**
  21968. * Returns the submesh material
  21969. * @returns null or the current material
  21970. */
  21971. getMaterial(): Nullable<Material>;
  21972. /**
  21973. * Sets a new updated BoundingInfo object to the submesh
  21974. * @param data defines an optional position array to use to determine the bounding info
  21975. * @returns the SubMesh
  21976. */
  21977. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21978. /** @hidden */
  21979. _checkCollision(collider: Collider): boolean;
  21980. /**
  21981. * Updates the submesh BoundingInfo
  21982. * @param world defines the world matrix to use to update the bounding info
  21983. * @returns the submesh
  21984. */
  21985. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21986. /**
  21987. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21988. * @param frustumPlanes defines the frustum planes
  21989. * @returns true if the submesh is intersecting with the frustum
  21990. */
  21991. isInFrustum(frustumPlanes: Plane[]): boolean;
  21992. /**
  21993. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21994. * @param frustumPlanes defines the frustum planes
  21995. * @returns true if the submesh is inside the frustum
  21996. */
  21997. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21998. /**
  21999. * Renders the submesh
  22000. * @param enableAlphaMode defines if alpha needs to be used
  22001. * @returns the submesh
  22002. */
  22003. render(enableAlphaMode: boolean): SubMesh;
  22004. /**
  22005. * @hidden
  22006. */
  22007. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22008. /**
  22009. * Checks if the submesh intersects with a ray
  22010. * @param ray defines the ray to test
  22011. * @returns true is the passed ray intersects the submesh bounding box
  22012. */
  22013. canIntersects(ray: Ray): boolean;
  22014. /**
  22015. * Intersects current submesh with a ray
  22016. * @param ray defines the ray to test
  22017. * @param positions defines mesh's positions array
  22018. * @param indices defines mesh's indices array
  22019. * @param fastCheck defines if only bounding info should be used
  22020. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22021. * @returns intersection info or null if no intersection
  22022. */
  22023. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22024. /** @hidden */
  22025. private _intersectLines;
  22026. /** @hidden */
  22027. private _intersectUnIndexedLines;
  22028. /** @hidden */
  22029. private _intersectTriangles;
  22030. /** @hidden */
  22031. private _intersectUnIndexedTriangles;
  22032. /** @hidden */
  22033. _rebuild(): void;
  22034. /**
  22035. * Creates a new submesh from the passed mesh
  22036. * @param newMesh defines the new hosting mesh
  22037. * @param newRenderingMesh defines an optional rendering mesh
  22038. * @returns the new submesh
  22039. */
  22040. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22041. /**
  22042. * Release associated resources
  22043. */
  22044. dispose(): void;
  22045. /**
  22046. * Gets the class name
  22047. * @returns the string "SubMesh".
  22048. */
  22049. getClassName(): string;
  22050. /**
  22051. * Creates a new submesh from indices data
  22052. * @param materialIndex the index of the main mesh material
  22053. * @param startIndex the index where to start the copy in the mesh indices array
  22054. * @param indexCount the number of indices to copy then from the startIndex
  22055. * @param mesh the main mesh to create the submesh from
  22056. * @param renderingMesh the optional rendering mesh
  22057. * @returns a new submesh
  22058. */
  22059. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22060. }
  22061. }
  22062. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22063. /**
  22064. * Class used to represent data loading progression
  22065. */
  22066. export class SceneLoaderFlags {
  22067. private static _ForceFullSceneLoadingForIncremental;
  22068. private static _ShowLoadingScreen;
  22069. private static _CleanBoneMatrixWeights;
  22070. private static _loggingLevel;
  22071. /**
  22072. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22073. */
  22074. static get ForceFullSceneLoadingForIncremental(): boolean;
  22075. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22076. /**
  22077. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22078. */
  22079. static get ShowLoadingScreen(): boolean;
  22080. static set ShowLoadingScreen(value: boolean);
  22081. /**
  22082. * Defines the current logging level (while loading the scene)
  22083. * @ignorenaming
  22084. */
  22085. static get loggingLevel(): number;
  22086. static set loggingLevel(value: number);
  22087. /**
  22088. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22089. */
  22090. static get CleanBoneMatrixWeights(): boolean;
  22091. static set CleanBoneMatrixWeights(value: boolean);
  22092. }
  22093. }
  22094. declare module "babylonjs/Meshes/geometry" {
  22095. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22096. import { Scene } from "babylonjs/scene";
  22097. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22098. import { Engine } from "babylonjs/Engines/engine";
  22099. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22100. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22101. import { Effect } from "babylonjs/Materials/effect";
  22102. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22103. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22104. import { Mesh } from "babylonjs/Meshes/mesh";
  22105. /**
  22106. * Class used to store geometry data (vertex buffers + index buffer)
  22107. */
  22108. export class Geometry implements IGetSetVerticesData {
  22109. /**
  22110. * Gets or sets the ID of the geometry
  22111. */
  22112. id: string;
  22113. /**
  22114. * Gets or sets the unique ID of the geometry
  22115. */
  22116. uniqueId: number;
  22117. /**
  22118. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22119. */
  22120. delayLoadState: number;
  22121. /**
  22122. * Gets the file containing the data to load when running in delay load state
  22123. */
  22124. delayLoadingFile: Nullable<string>;
  22125. /**
  22126. * Callback called when the geometry is updated
  22127. */
  22128. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22129. private _scene;
  22130. private _engine;
  22131. private _meshes;
  22132. private _totalVertices;
  22133. /** @hidden */
  22134. _indices: IndicesArray;
  22135. /** @hidden */
  22136. _vertexBuffers: {
  22137. [key: string]: VertexBuffer;
  22138. };
  22139. private _isDisposed;
  22140. private _extend;
  22141. private _boundingBias;
  22142. /** @hidden */
  22143. _delayInfo: Array<string>;
  22144. private _indexBuffer;
  22145. private _indexBufferIsUpdatable;
  22146. /** @hidden */
  22147. _boundingInfo: Nullable<BoundingInfo>;
  22148. /** @hidden */
  22149. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22150. /** @hidden */
  22151. _softwareSkinningFrameId: number;
  22152. private _vertexArrayObjects;
  22153. private _updatable;
  22154. /** @hidden */
  22155. _positions: Nullable<Vector3[]>;
  22156. /**
  22157. * 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
  22158. */
  22159. get boundingBias(): Vector2;
  22160. /**
  22161. * 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
  22162. */
  22163. set boundingBias(value: Vector2);
  22164. /**
  22165. * Static function used to attach a new empty geometry to a mesh
  22166. * @param mesh defines the mesh to attach the geometry to
  22167. * @returns the new Geometry
  22168. */
  22169. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22170. /**
  22171. * Creates a new geometry
  22172. * @param id defines the unique ID
  22173. * @param scene defines the hosting scene
  22174. * @param vertexData defines the VertexData used to get geometry data
  22175. * @param updatable defines if geometry must be updatable (false by default)
  22176. * @param mesh defines the mesh that will be associated with the geometry
  22177. */
  22178. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22179. /**
  22180. * Gets the current extend of the geometry
  22181. */
  22182. get extend(): {
  22183. minimum: Vector3;
  22184. maximum: Vector3;
  22185. };
  22186. /**
  22187. * Gets the hosting scene
  22188. * @returns the hosting Scene
  22189. */
  22190. getScene(): Scene;
  22191. /**
  22192. * Gets the hosting engine
  22193. * @returns the hosting Engine
  22194. */
  22195. getEngine(): Engine;
  22196. /**
  22197. * Defines if the geometry is ready to use
  22198. * @returns true if the geometry is ready to be used
  22199. */
  22200. isReady(): boolean;
  22201. /**
  22202. * Gets a value indicating that the geometry should not be serialized
  22203. */
  22204. get doNotSerialize(): boolean;
  22205. /** @hidden */
  22206. _rebuild(): void;
  22207. /**
  22208. * Affects all geometry data in one call
  22209. * @param vertexData defines the geometry data
  22210. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22211. */
  22212. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22213. /**
  22214. * Set specific vertex data
  22215. * @param kind defines the data kind (Position, normal, etc...)
  22216. * @param data defines the vertex data to use
  22217. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22218. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22219. */
  22220. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22221. /**
  22222. * Removes a specific vertex data
  22223. * @param kind defines the data kind (Position, normal, etc...)
  22224. */
  22225. removeVerticesData(kind: string): void;
  22226. /**
  22227. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22228. * @param buffer defines the vertex buffer to use
  22229. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22230. */
  22231. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22232. /**
  22233. * Update a specific vertex buffer
  22234. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22235. * It will do nothing if the buffer is not updatable
  22236. * @param kind defines the data kind (Position, normal, etc...)
  22237. * @param data defines the data to use
  22238. * @param offset defines the offset in the target buffer where to store the data
  22239. * @param useBytes set to true if the offset is in bytes
  22240. */
  22241. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22242. /**
  22243. * Update a specific vertex buffer
  22244. * This function will create a new buffer if the current one is not updatable
  22245. * @param kind defines the data kind (Position, normal, etc...)
  22246. * @param data defines the data to use
  22247. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22248. */
  22249. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22250. private _updateBoundingInfo;
  22251. /** @hidden */
  22252. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22253. /**
  22254. * Gets total number of vertices
  22255. * @returns the total number of vertices
  22256. */
  22257. getTotalVertices(): number;
  22258. /**
  22259. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22260. * @param kind defines the data kind (Position, normal, etc...)
  22261. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22262. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22263. * @returns a float array containing vertex data
  22264. */
  22265. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22266. /**
  22267. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22268. * @param kind defines the data kind (Position, normal, etc...)
  22269. * @returns true if the vertex buffer with the specified kind is updatable
  22270. */
  22271. isVertexBufferUpdatable(kind: string): boolean;
  22272. /**
  22273. * Gets a specific vertex buffer
  22274. * @param kind defines the data kind (Position, normal, etc...)
  22275. * @returns a VertexBuffer
  22276. */
  22277. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22278. /**
  22279. * Returns all vertex buffers
  22280. * @return an object holding all vertex buffers indexed by kind
  22281. */
  22282. getVertexBuffers(): Nullable<{
  22283. [key: string]: VertexBuffer;
  22284. }>;
  22285. /**
  22286. * Gets a boolean indicating if specific vertex buffer is present
  22287. * @param kind defines the data kind (Position, normal, etc...)
  22288. * @returns true if data is present
  22289. */
  22290. isVerticesDataPresent(kind: string): boolean;
  22291. /**
  22292. * Gets a list of all attached data kinds (Position, normal, etc...)
  22293. * @returns a list of string containing all kinds
  22294. */
  22295. getVerticesDataKinds(): string[];
  22296. /**
  22297. * Update index buffer
  22298. * @param indices defines the indices to store in the index buffer
  22299. * @param offset defines the offset in the target buffer where to store the data
  22300. * @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)
  22301. */
  22302. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22303. /**
  22304. * Creates a new index buffer
  22305. * @param indices defines the indices to store in the index buffer
  22306. * @param totalVertices defines the total number of vertices (could be null)
  22307. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22308. */
  22309. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22310. /**
  22311. * Return the total number of indices
  22312. * @returns the total number of indices
  22313. */
  22314. getTotalIndices(): number;
  22315. /**
  22316. * Gets the index buffer array
  22317. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22318. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22319. * @returns the index buffer array
  22320. */
  22321. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22322. /**
  22323. * Gets the index buffer
  22324. * @return the index buffer
  22325. */
  22326. getIndexBuffer(): Nullable<DataBuffer>;
  22327. /** @hidden */
  22328. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22329. /**
  22330. * Release the associated resources for a specific mesh
  22331. * @param mesh defines the source mesh
  22332. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22333. */
  22334. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22335. /**
  22336. * Apply current geometry to a given mesh
  22337. * @param mesh defines the mesh to apply geometry to
  22338. */
  22339. applyToMesh(mesh: Mesh): void;
  22340. private _updateExtend;
  22341. private _applyToMesh;
  22342. private notifyUpdate;
  22343. /**
  22344. * Load the geometry if it was flagged as delay loaded
  22345. * @param scene defines the hosting scene
  22346. * @param onLoaded defines a callback called when the geometry is loaded
  22347. */
  22348. load(scene: Scene, onLoaded?: () => void): void;
  22349. private _queueLoad;
  22350. /**
  22351. * Invert the geometry to move from a right handed system to a left handed one.
  22352. */
  22353. toLeftHanded(): void;
  22354. /** @hidden */
  22355. _resetPointsArrayCache(): void;
  22356. /** @hidden */
  22357. _generatePointsArray(): boolean;
  22358. /**
  22359. * Gets a value indicating if the geometry is disposed
  22360. * @returns true if the geometry was disposed
  22361. */
  22362. isDisposed(): boolean;
  22363. private _disposeVertexArrayObjects;
  22364. /**
  22365. * Free all associated resources
  22366. */
  22367. dispose(): void;
  22368. /**
  22369. * Clone the current geometry into a new geometry
  22370. * @param id defines the unique ID of the new geometry
  22371. * @returns a new geometry object
  22372. */
  22373. copy(id: string): Geometry;
  22374. /**
  22375. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22376. * @return a JSON representation of the current geometry data (without the vertices data)
  22377. */
  22378. serialize(): any;
  22379. private toNumberArray;
  22380. /**
  22381. * Serialize all vertices data into a JSON oject
  22382. * @returns a JSON representation of the current geometry data
  22383. */
  22384. serializeVerticeData(): any;
  22385. /**
  22386. * Extracts a clone of a mesh geometry
  22387. * @param mesh defines the source mesh
  22388. * @param id defines the unique ID of the new geometry object
  22389. * @returns the new geometry object
  22390. */
  22391. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22392. /**
  22393. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22394. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22395. * Be aware Math.random() could cause collisions, but:
  22396. * "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"
  22397. * @returns a string containing a new GUID
  22398. */
  22399. static RandomId(): string;
  22400. /** @hidden */
  22401. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22402. private static _CleanMatricesWeights;
  22403. /**
  22404. * Create a new geometry from persisted data (Using .babylon file format)
  22405. * @param parsedVertexData defines the persisted data
  22406. * @param scene defines the hosting scene
  22407. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22408. * @returns the new geometry object
  22409. */
  22410. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22411. }
  22412. }
  22413. declare module "babylonjs/Meshes/mesh.vertexData" {
  22414. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22415. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22416. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22417. import { Geometry } from "babylonjs/Meshes/geometry";
  22418. import { Mesh } from "babylonjs/Meshes/mesh";
  22419. /**
  22420. * Define an interface for all classes that will get and set the data on vertices
  22421. */
  22422. export interface IGetSetVerticesData {
  22423. /**
  22424. * Gets a boolean indicating if specific vertex data is present
  22425. * @param kind defines the vertex data kind to use
  22426. * @returns true is data kind is present
  22427. */
  22428. isVerticesDataPresent(kind: string): boolean;
  22429. /**
  22430. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22431. * @param kind defines the data kind (Position, normal, etc...)
  22432. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22433. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22434. * @returns a float array containing vertex data
  22435. */
  22436. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22437. /**
  22438. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22439. * @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.
  22440. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22441. * @returns the indices array or an empty array if the mesh has no geometry
  22442. */
  22443. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22444. /**
  22445. * Set specific vertex data
  22446. * @param kind defines the data kind (Position, normal, etc...)
  22447. * @param data defines the vertex data to use
  22448. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22449. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22450. */
  22451. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22452. /**
  22453. * Update a specific associated vertex buffer
  22454. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22455. * - VertexBuffer.PositionKind
  22456. * - VertexBuffer.UVKind
  22457. * - VertexBuffer.UV2Kind
  22458. * - VertexBuffer.UV3Kind
  22459. * - VertexBuffer.UV4Kind
  22460. * - VertexBuffer.UV5Kind
  22461. * - VertexBuffer.UV6Kind
  22462. * - VertexBuffer.ColorKind
  22463. * - VertexBuffer.MatricesIndicesKind
  22464. * - VertexBuffer.MatricesIndicesExtraKind
  22465. * - VertexBuffer.MatricesWeightsKind
  22466. * - VertexBuffer.MatricesWeightsExtraKind
  22467. * @param data defines the data source
  22468. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22469. * @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)
  22470. */
  22471. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22472. /**
  22473. * Creates a new index buffer
  22474. * @param indices defines the indices to store in the index buffer
  22475. * @param totalVertices defines the total number of vertices (could be null)
  22476. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22477. */
  22478. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22479. }
  22480. /**
  22481. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22482. */
  22483. export class VertexData {
  22484. /**
  22485. * Mesh side orientation : usually the external or front surface
  22486. */
  22487. static readonly FRONTSIDE: number;
  22488. /**
  22489. * Mesh side orientation : usually the internal or back surface
  22490. */
  22491. static readonly BACKSIDE: number;
  22492. /**
  22493. * Mesh side orientation : both internal and external or front and back surfaces
  22494. */
  22495. static readonly DOUBLESIDE: number;
  22496. /**
  22497. * Mesh side orientation : by default, `FRONTSIDE`
  22498. */
  22499. static readonly DEFAULTSIDE: number;
  22500. /**
  22501. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22502. */
  22503. positions: Nullable<FloatArray>;
  22504. /**
  22505. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22506. */
  22507. normals: Nullable<FloatArray>;
  22508. /**
  22509. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22510. */
  22511. tangents: Nullable<FloatArray>;
  22512. /**
  22513. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22514. */
  22515. uvs: Nullable<FloatArray>;
  22516. /**
  22517. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22518. */
  22519. uvs2: Nullable<FloatArray>;
  22520. /**
  22521. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22522. */
  22523. uvs3: Nullable<FloatArray>;
  22524. /**
  22525. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22526. */
  22527. uvs4: Nullable<FloatArray>;
  22528. /**
  22529. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22530. */
  22531. uvs5: Nullable<FloatArray>;
  22532. /**
  22533. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22534. */
  22535. uvs6: Nullable<FloatArray>;
  22536. /**
  22537. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22538. */
  22539. colors: Nullable<FloatArray>;
  22540. /**
  22541. * 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).
  22542. */
  22543. matricesIndices: Nullable<FloatArray>;
  22544. /**
  22545. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22546. */
  22547. matricesWeights: Nullable<FloatArray>;
  22548. /**
  22549. * An array extending the number of possible indices
  22550. */
  22551. matricesIndicesExtra: Nullable<FloatArray>;
  22552. /**
  22553. * An array extending the number of possible weights when the number of indices is extended
  22554. */
  22555. matricesWeightsExtra: Nullable<FloatArray>;
  22556. /**
  22557. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22558. */
  22559. indices: Nullable<IndicesArray>;
  22560. /**
  22561. * Uses the passed data array to set the set the values for the specified kind of data
  22562. * @param data a linear array of floating numbers
  22563. * @param kind the type of data that is being set, eg positions, colors etc
  22564. */
  22565. set(data: FloatArray, kind: string): void;
  22566. /**
  22567. * Associates the vertexData to the passed Mesh.
  22568. * Sets it as updatable or not (default `false`)
  22569. * @param mesh the mesh the vertexData is applied to
  22570. * @param updatable when used and having the value true allows new data to update the vertexData
  22571. * @returns the VertexData
  22572. */
  22573. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22574. /**
  22575. * Associates the vertexData to the passed Geometry.
  22576. * Sets it as updatable or not (default `false`)
  22577. * @param geometry the geometry the vertexData is applied to
  22578. * @param updatable when used and having the value true allows new data to update the vertexData
  22579. * @returns VertexData
  22580. */
  22581. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22582. /**
  22583. * Updates the associated mesh
  22584. * @param mesh the mesh to be updated
  22585. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22586. * @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
  22587. * @returns VertexData
  22588. */
  22589. updateMesh(mesh: Mesh): VertexData;
  22590. /**
  22591. * Updates the associated geometry
  22592. * @param geometry the geometry to be updated
  22593. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22594. * @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
  22595. * @returns VertexData.
  22596. */
  22597. updateGeometry(geometry: Geometry): VertexData;
  22598. private _applyTo;
  22599. private _update;
  22600. /**
  22601. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22602. * @param matrix the transforming matrix
  22603. * @returns the VertexData
  22604. */
  22605. transform(matrix: Matrix): VertexData;
  22606. /**
  22607. * Merges the passed VertexData into the current one
  22608. * @param other the VertexData to be merged into the current one
  22609. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22610. * @returns the modified VertexData
  22611. */
  22612. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22613. private _mergeElement;
  22614. private _validate;
  22615. /**
  22616. * Serializes the VertexData
  22617. * @returns a serialized object
  22618. */
  22619. serialize(): any;
  22620. /**
  22621. * Extracts the vertexData from a mesh
  22622. * @param mesh the mesh from which to extract the VertexData
  22623. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22624. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22625. * @returns the object VertexData associated to the passed mesh
  22626. */
  22627. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22628. /**
  22629. * Extracts the vertexData from the geometry
  22630. * @param geometry the geometry from which to extract the VertexData
  22631. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22632. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22633. * @returns the object VertexData associated to the passed mesh
  22634. */
  22635. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22636. private static _ExtractFrom;
  22637. /**
  22638. * Creates the VertexData for a Ribbon
  22639. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22640. * * pathArray array of paths, each of which an array of successive Vector3
  22641. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22642. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22643. * * 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
  22644. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22645. * * 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)
  22646. * * 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)
  22647. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22648. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22649. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22650. * @returns the VertexData of the ribbon
  22651. */
  22652. static CreateRibbon(options: {
  22653. pathArray: Vector3[][];
  22654. closeArray?: boolean;
  22655. closePath?: boolean;
  22656. offset?: number;
  22657. sideOrientation?: number;
  22658. frontUVs?: Vector4;
  22659. backUVs?: Vector4;
  22660. invertUV?: boolean;
  22661. uvs?: Vector2[];
  22662. colors?: Color4[];
  22663. }): VertexData;
  22664. /**
  22665. * Creates the VertexData for a box
  22666. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22667. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22668. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22669. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22670. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22671. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22672. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22673. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22674. * * 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)
  22675. * * 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)
  22676. * @returns the VertexData of the box
  22677. */
  22678. static CreateBox(options: {
  22679. size?: number;
  22680. width?: number;
  22681. height?: number;
  22682. depth?: number;
  22683. faceUV?: Vector4[];
  22684. faceColors?: Color4[];
  22685. sideOrientation?: number;
  22686. frontUVs?: Vector4;
  22687. backUVs?: Vector4;
  22688. }): VertexData;
  22689. /**
  22690. * Creates the VertexData for a tiled box
  22691. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22692. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22693. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22694. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22695. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22696. * @returns the VertexData of the box
  22697. */
  22698. static CreateTiledBox(options: {
  22699. pattern?: number;
  22700. width?: number;
  22701. height?: number;
  22702. depth?: number;
  22703. tileSize?: number;
  22704. tileWidth?: number;
  22705. tileHeight?: number;
  22706. alignHorizontal?: number;
  22707. alignVertical?: number;
  22708. faceUV?: Vector4[];
  22709. faceColors?: Color4[];
  22710. sideOrientation?: number;
  22711. }): VertexData;
  22712. /**
  22713. * Creates the VertexData for a tiled plane
  22714. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22715. * * pattern a limited pattern arrangement depending on the number
  22716. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22717. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22718. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22720. * * 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)
  22721. * * 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)
  22722. * @returns the VertexData of the tiled plane
  22723. */
  22724. static CreateTiledPlane(options: {
  22725. pattern?: number;
  22726. tileSize?: number;
  22727. tileWidth?: number;
  22728. tileHeight?: number;
  22729. size?: number;
  22730. width?: number;
  22731. height?: number;
  22732. alignHorizontal?: number;
  22733. alignVertical?: number;
  22734. sideOrientation?: number;
  22735. frontUVs?: Vector4;
  22736. backUVs?: Vector4;
  22737. }): VertexData;
  22738. /**
  22739. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22740. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22741. * * segments sets the number of horizontal strips optional, default 32
  22742. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22743. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22744. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22745. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22746. * * 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
  22747. * * 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
  22748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22749. * * 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)
  22750. * * 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)
  22751. * @returns the VertexData of the ellipsoid
  22752. */
  22753. static CreateSphere(options: {
  22754. segments?: number;
  22755. diameter?: number;
  22756. diameterX?: number;
  22757. diameterY?: number;
  22758. diameterZ?: number;
  22759. arc?: number;
  22760. slice?: number;
  22761. sideOrientation?: number;
  22762. frontUVs?: Vector4;
  22763. backUVs?: Vector4;
  22764. }): VertexData;
  22765. /**
  22766. * Creates the VertexData for a cylinder, cone or prism
  22767. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22768. * * height sets the height (y direction) of the cylinder, optional, default 2
  22769. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22770. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22771. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22772. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22773. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22774. * * 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
  22775. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22776. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22777. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22778. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22780. * * 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)
  22781. * * 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)
  22782. * @returns the VertexData of the cylinder, cone or prism
  22783. */
  22784. static CreateCylinder(options: {
  22785. height?: number;
  22786. diameterTop?: number;
  22787. diameterBottom?: number;
  22788. diameter?: number;
  22789. tessellation?: number;
  22790. subdivisions?: number;
  22791. arc?: number;
  22792. faceColors?: Color4[];
  22793. faceUV?: Vector4[];
  22794. hasRings?: boolean;
  22795. enclose?: boolean;
  22796. sideOrientation?: number;
  22797. frontUVs?: Vector4;
  22798. backUVs?: Vector4;
  22799. }): VertexData;
  22800. /**
  22801. * Creates the VertexData for a torus
  22802. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22803. * * diameter the diameter of the torus, optional default 1
  22804. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22805. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22806. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22807. * * 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)
  22808. * * 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)
  22809. * @returns the VertexData of the torus
  22810. */
  22811. static CreateTorus(options: {
  22812. diameter?: number;
  22813. thickness?: number;
  22814. tessellation?: number;
  22815. sideOrientation?: number;
  22816. frontUVs?: Vector4;
  22817. backUVs?: Vector4;
  22818. }): VertexData;
  22819. /**
  22820. * Creates the VertexData of the LineSystem
  22821. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22822. * - lines an array of lines, each line being an array of successive Vector3
  22823. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22824. * @returns the VertexData of the LineSystem
  22825. */
  22826. static CreateLineSystem(options: {
  22827. lines: Vector3[][];
  22828. colors?: Nullable<Color4[][]>;
  22829. }): VertexData;
  22830. /**
  22831. * Create the VertexData for a DashedLines
  22832. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22833. * - points an array successive Vector3
  22834. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22835. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22836. * - dashNb the intended total number of dashes, optional, default 200
  22837. * @returns the VertexData for the DashedLines
  22838. */
  22839. static CreateDashedLines(options: {
  22840. points: Vector3[];
  22841. dashSize?: number;
  22842. gapSize?: number;
  22843. dashNb?: number;
  22844. }): VertexData;
  22845. /**
  22846. * Creates the VertexData for a Ground
  22847. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22848. * - width the width (x direction) of the ground, optional, default 1
  22849. * - height the height (z direction) of the ground, optional, default 1
  22850. * - subdivisions the number of subdivisions per side, optional, default 1
  22851. * @returns the VertexData of the Ground
  22852. */
  22853. static CreateGround(options: {
  22854. width?: number;
  22855. height?: number;
  22856. subdivisions?: number;
  22857. subdivisionsX?: number;
  22858. subdivisionsY?: number;
  22859. }): VertexData;
  22860. /**
  22861. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22862. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22863. * * xmin the ground minimum X coordinate, optional, default -1
  22864. * * zmin the ground minimum Z coordinate, optional, default -1
  22865. * * xmax the ground maximum X coordinate, optional, default 1
  22866. * * zmax the ground maximum Z coordinate, optional, default 1
  22867. * * 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}
  22868. * * 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}
  22869. * @returns the VertexData of the TiledGround
  22870. */
  22871. static CreateTiledGround(options: {
  22872. xmin: number;
  22873. zmin: number;
  22874. xmax: number;
  22875. zmax: number;
  22876. subdivisions?: {
  22877. w: number;
  22878. h: number;
  22879. };
  22880. precision?: {
  22881. w: number;
  22882. h: number;
  22883. };
  22884. }): VertexData;
  22885. /**
  22886. * Creates the VertexData of the Ground designed from a heightmap
  22887. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22888. * * width the width (x direction) of the ground
  22889. * * height the height (z direction) of the ground
  22890. * * subdivisions the number of subdivisions per side
  22891. * * minHeight the minimum altitude on the ground, optional, default 0
  22892. * * maxHeight the maximum altitude on the ground, optional default 1
  22893. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22894. * * buffer the array holding the image color data
  22895. * * bufferWidth the width of image
  22896. * * bufferHeight the height of image
  22897. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22898. * @returns the VertexData of the Ground designed from a heightmap
  22899. */
  22900. static CreateGroundFromHeightMap(options: {
  22901. width: number;
  22902. height: number;
  22903. subdivisions: number;
  22904. minHeight: number;
  22905. maxHeight: number;
  22906. colorFilter: Color3;
  22907. buffer: Uint8Array;
  22908. bufferWidth: number;
  22909. bufferHeight: number;
  22910. alphaFilter: number;
  22911. }): VertexData;
  22912. /**
  22913. * Creates the VertexData for a Plane
  22914. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22915. * * size sets the width and height of the plane to the value of size, optional default 1
  22916. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22917. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22918. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22919. * * 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)
  22920. * * 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)
  22921. * @returns the VertexData of the box
  22922. */
  22923. static CreatePlane(options: {
  22924. size?: number;
  22925. width?: number;
  22926. height?: number;
  22927. sideOrientation?: number;
  22928. frontUVs?: Vector4;
  22929. backUVs?: Vector4;
  22930. }): VertexData;
  22931. /**
  22932. * Creates the VertexData of the Disc or regular Polygon
  22933. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22934. * * radius the radius of the disc, optional default 0.5
  22935. * * tessellation the number of polygon sides, optional, default 64
  22936. * * 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
  22937. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22938. * * 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)
  22939. * * 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)
  22940. * @returns the VertexData of the box
  22941. */
  22942. static CreateDisc(options: {
  22943. radius?: number;
  22944. tessellation?: number;
  22945. arc?: number;
  22946. sideOrientation?: number;
  22947. frontUVs?: Vector4;
  22948. backUVs?: Vector4;
  22949. }): VertexData;
  22950. /**
  22951. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22952. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22953. * @param polygon a mesh built from polygonTriangulation.build()
  22954. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22955. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22956. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22957. * @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)
  22958. * @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)
  22959. * @returns the VertexData of the Polygon
  22960. */
  22961. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22962. /**
  22963. * Creates the VertexData of the IcoSphere
  22964. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22965. * * radius the radius of the IcoSphere, optional default 1
  22966. * * radiusX allows stretching in the x direction, optional, default radius
  22967. * * radiusY allows stretching in the y direction, optional, default radius
  22968. * * radiusZ allows stretching in the z direction, optional, default radius
  22969. * * flat when true creates a flat shaded mesh, optional, default true
  22970. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22972. * * 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)
  22973. * * 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)
  22974. * @returns the VertexData of the IcoSphere
  22975. */
  22976. static CreateIcoSphere(options: {
  22977. radius?: number;
  22978. radiusX?: number;
  22979. radiusY?: number;
  22980. radiusZ?: number;
  22981. flat?: boolean;
  22982. subdivisions?: number;
  22983. sideOrientation?: number;
  22984. frontUVs?: Vector4;
  22985. backUVs?: Vector4;
  22986. }): VertexData;
  22987. /**
  22988. * Creates the VertexData for a Polyhedron
  22989. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22990. * * type provided types are:
  22991. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22992. * * 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)
  22993. * * size the size of the IcoSphere, optional default 1
  22994. * * sizeX allows stretching in the x direction, optional, default size
  22995. * * sizeY allows stretching in the y direction, optional, default size
  22996. * * sizeZ allows stretching in the z direction, optional, default size
  22997. * * 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
  22998. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22999. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23000. * * flat when true creates a flat shaded mesh, optional, default true
  23001. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23002. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23003. * * 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)
  23004. * * 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)
  23005. * @returns the VertexData of the Polyhedron
  23006. */
  23007. static CreatePolyhedron(options: {
  23008. type?: number;
  23009. size?: number;
  23010. sizeX?: number;
  23011. sizeY?: number;
  23012. sizeZ?: number;
  23013. custom?: any;
  23014. faceUV?: Vector4[];
  23015. faceColors?: Color4[];
  23016. flat?: boolean;
  23017. sideOrientation?: number;
  23018. frontUVs?: Vector4;
  23019. backUVs?: Vector4;
  23020. }): VertexData;
  23021. /**
  23022. * Creates the VertexData for a TorusKnot
  23023. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23024. * * radius the radius of the torus knot, optional, default 2
  23025. * * tube the thickness of the tube, optional, default 0.5
  23026. * * radialSegments the number of sides on each tube segments, optional, default 32
  23027. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23028. * * p the number of windings around the z axis, optional, default 2
  23029. * * q the number of windings around the x axis, optional, default 3
  23030. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23031. * * 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)
  23032. * * 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)
  23033. * @returns the VertexData of the Torus Knot
  23034. */
  23035. static CreateTorusKnot(options: {
  23036. radius?: number;
  23037. tube?: number;
  23038. radialSegments?: number;
  23039. tubularSegments?: number;
  23040. p?: number;
  23041. q?: number;
  23042. sideOrientation?: number;
  23043. frontUVs?: Vector4;
  23044. backUVs?: Vector4;
  23045. }): VertexData;
  23046. /**
  23047. * Compute normals for given positions and indices
  23048. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23049. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23050. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23051. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23052. * * facetNormals : optional array of facet normals (vector3)
  23053. * * facetPositions : optional array of facet positions (vector3)
  23054. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23055. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23056. * * bInfo : optional bounding info, required for facetPartitioning computation
  23057. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23058. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23059. * * useRightHandedSystem: optional boolean to for right handed system computation
  23060. * * depthSort : optional boolean to enable the facet depth sort computation
  23061. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23062. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23063. */
  23064. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23065. facetNormals?: any;
  23066. facetPositions?: any;
  23067. facetPartitioning?: any;
  23068. ratio?: number;
  23069. bInfo?: any;
  23070. bbSize?: Vector3;
  23071. subDiv?: any;
  23072. useRightHandedSystem?: boolean;
  23073. depthSort?: boolean;
  23074. distanceTo?: Vector3;
  23075. depthSortedFacets?: any;
  23076. }): void;
  23077. /** @hidden */
  23078. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23079. /**
  23080. * Applies VertexData created from the imported parameters to the geometry
  23081. * @param parsedVertexData the parsed data from an imported file
  23082. * @param geometry the geometry to apply the VertexData to
  23083. */
  23084. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23085. }
  23086. }
  23087. declare module "babylonjs/Morph/morphTarget" {
  23088. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23089. import { Observable } from "babylonjs/Misc/observable";
  23090. import { Nullable, FloatArray } from "babylonjs/types";
  23091. import { Scene } from "babylonjs/scene";
  23092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23093. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23094. /**
  23095. * Defines a target to use with MorphTargetManager
  23096. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23097. */
  23098. export class MorphTarget implements IAnimatable {
  23099. /** defines the name of the target */
  23100. name: string;
  23101. /**
  23102. * Gets or sets the list of animations
  23103. */
  23104. animations: import("babylonjs/Animations/animation").Animation[];
  23105. private _scene;
  23106. private _positions;
  23107. private _normals;
  23108. private _tangents;
  23109. private _uvs;
  23110. private _influence;
  23111. private _uniqueId;
  23112. /**
  23113. * Observable raised when the influence changes
  23114. */
  23115. onInfluenceChanged: Observable<boolean>;
  23116. /** @hidden */
  23117. _onDataLayoutChanged: Observable<void>;
  23118. /**
  23119. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23120. */
  23121. get influence(): number;
  23122. set influence(influence: number);
  23123. /**
  23124. * Gets or sets the id of the morph Target
  23125. */
  23126. id: string;
  23127. private _animationPropertiesOverride;
  23128. /**
  23129. * Gets or sets the animation properties override
  23130. */
  23131. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23132. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23133. /**
  23134. * Creates a new MorphTarget
  23135. * @param name defines the name of the target
  23136. * @param influence defines the influence to use
  23137. * @param scene defines the scene the morphtarget belongs to
  23138. */
  23139. constructor(
  23140. /** defines the name of the target */
  23141. name: string, influence?: number, scene?: Nullable<Scene>);
  23142. /**
  23143. * Gets the unique ID of this manager
  23144. */
  23145. get uniqueId(): number;
  23146. /**
  23147. * Gets a boolean defining if the target contains position data
  23148. */
  23149. get hasPositions(): boolean;
  23150. /**
  23151. * Gets a boolean defining if the target contains normal data
  23152. */
  23153. get hasNormals(): boolean;
  23154. /**
  23155. * Gets a boolean defining if the target contains tangent data
  23156. */
  23157. get hasTangents(): boolean;
  23158. /**
  23159. * Gets a boolean defining if the target contains texture coordinates data
  23160. */
  23161. get hasUVs(): boolean;
  23162. /**
  23163. * Affects position data to this target
  23164. * @param data defines the position data to use
  23165. */
  23166. setPositions(data: Nullable<FloatArray>): void;
  23167. /**
  23168. * Gets the position data stored in this target
  23169. * @returns a FloatArray containing the position data (or null if not present)
  23170. */
  23171. getPositions(): Nullable<FloatArray>;
  23172. /**
  23173. * Affects normal data to this target
  23174. * @param data defines the normal data to use
  23175. */
  23176. setNormals(data: Nullable<FloatArray>): void;
  23177. /**
  23178. * Gets the normal data stored in this target
  23179. * @returns a FloatArray containing the normal data (or null if not present)
  23180. */
  23181. getNormals(): Nullable<FloatArray>;
  23182. /**
  23183. * Affects tangent data to this target
  23184. * @param data defines the tangent data to use
  23185. */
  23186. setTangents(data: Nullable<FloatArray>): void;
  23187. /**
  23188. * Gets the tangent data stored in this target
  23189. * @returns a FloatArray containing the tangent data (or null if not present)
  23190. */
  23191. getTangents(): Nullable<FloatArray>;
  23192. /**
  23193. * Affects texture coordinates data to this target
  23194. * @param data defines the texture coordinates data to use
  23195. */
  23196. setUVs(data: Nullable<FloatArray>): void;
  23197. /**
  23198. * Gets the texture coordinates data stored in this target
  23199. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23200. */
  23201. getUVs(): Nullable<FloatArray>;
  23202. /**
  23203. * Clone the current target
  23204. * @returns a new MorphTarget
  23205. */
  23206. clone(): MorphTarget;
  23207. /**
  23208. * Serializes the current target into a Serialization object
  23209. * @returns the serialized object
  23210. */
  23211. serialize(): any;
  23212. /**
  23213. * Returns the string "MorphTarget"
  23214. * @returns "MorphTarget"
  23215. */
  23216. getClassName(): string;
  23217. /**
  23218. * Creates a new target from serialized data
  23219. * @param serializationObject defines the serialized data to use
  23220. * @returns a new MorphTarget
  23221. */
  23222. static Parse(serializationObject: any): MorphTarget;
  23223. /**
  23224. * Creates a MorphTarget from mesh data
  23225. * @param mesh defines the source mesh
  23226. * @param name defines the name to use for the new target
  23227. * @param influence defines the influence to attach to the target
  23228. * @returns a new MorphTarget
  23229. */
  23230. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23231. }
  23232. }
  23233. declare module "babylonjs/Morph/morphTargetManager" {
  23234. import { Nullable } from "babylonjs/types";
  23235. import { Scene } from "babylonjs/scene";
  23236. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23237. /**
  23238. * This class is used to deform meshes using morphing between different targets
  23239. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23240. */
  23241. export class MorphTargetManager {
  23242. private _targets;
  23243. private _targetInfluenceChangedObservers;
  23244. private _targetDataLayoutChangedObservers;
  23245. private _activeTargets;
  23246. private _scene;
  23247. private _influences;
  23248. private _supportsNormals;
  23249. private _supportsTangents;
  23250. private _supportsUVs;
  23251. private _vertexCount;
  23252. private _uniqueId;
  23253. private _tempInfluences;
  23254. /**
  23255. * Gets or sets a boolean indicating if normals must be morphed
  23256. */
  23257. enableNormalMorphing: boolean;
  23258. /**
  23259. * Gets or sets a boolean indicating if tangents must be morphed
  23260. */
  23261. enableTangentMorphing: boolean;
  23262. /**
  23263. * Gets or sets a boolean indicating if UV must be morphed
  23264. */
  23265. enableUVMorphing: boolean;
  23266. /**
  23267. * Creates a new MorphTargetManager
  23268. * @param scene defines the current scene
  23269. */
  23270. constructor(scene?: Nullable<Scene>);
  23271. /**
  23272. * Gets the unique ID of this manager
  23273. */
  23274. get uniqueId(): number;
  23275. /**
  23276. * Gets the number of vertices handled by this manager
  23277. */
  23278. get vertexCount(): number;
  23279. /**
  23280. * Gets a boolean indicating if this manager supports morphing of normals
  23281. */
  23282. get supportsNormals(): boolean;
  23283. /**
  23284. * Gets a boolean indicating if this manager supports morphing of tangents
  23285. */
  23286. get supportsTangents(): boolean;
  23287. /**
  23288. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23289. */
  23290. get supportsUVs(): boolean;
  23291. /**
  23292. * Gets the number of targets stored in this manager
  23293. */
  23294. get numTargets(): number;
  23295. /**
  23296. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23297. */
  23298. get numInfluencers(): number;
  23299. /**
  23300. * Gets the list of influences (one per target)
  23301. */
  23302. get influences(): Float32Array;
  23303. /**
  23304. * Gets the active target at specified index. An active target is a target with an influence > 0
  23305. * @param index defines the index to check
  23306. * @returns the requested target
  23307. */
  23308. getActiveTarget(index: number): MorphTarget;
  23309. /**
  23310. * Gets the target at specified index
  23311. * @param index defines the index to check
  23312. * @returns the requested target
  23313. */
  23314. getTarget(index: number): MorphTarget;
  23315. /**
  23316. * Add a new target to this manager
  23317. * @param target defines the target to add
  23318. */
  23319. addTarget(target: MorphTarget): void;
  23320. /**
  23321. * Removes a target from the manager
  23322. * @param target defines the target to remove
  23323. */
  23324. removeTarget(target: MorphTarget): void;
  23325. /**
  23326. * Clone the current manager
  23327. * @returns a new MorphTargetManager
  23328. */
  23329. clone(): MorphTargetManager;
  23330. /**
  23331. * Serializes the current manager into a Serialization object
  23332. * @returns the serialized object
  23333. */
  23334. serialize(): any;
  23335. private _syncActiveTargets;
  23336. /**
  23337. * Syncrhonize the targets with all the meshes using this morph target manager
  23338. */
  23339. synchronize(): void;
  23340. /**
  23341. * Creates a new MorphTargetManager from serialized data
  23342. * @param serializationObject defines the serialized data
  23343. * @param scene defines the hosting scene
  23344. * @returns the new MorphTargetManager
  23345. */
  23346. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23347. }
  23348. }
  23349. declare module "babylonjs/Meshes/meshLODLevel" {
  23350. import { Mesh } from "babylonjs/Meshes/mesh";
  23351. import { Nullable } from "babylonjs/types";
  23352. /**
  23353. * Class used to represent a specific level of detail of a mesh
  23354. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23355. */
  23356. export class MeshLODLevel {
  23357. /** Defines the distance where this level should start being displayed */
  23358. distance: number;
  23359. /** Defines the mesh to use to render this level */
  23360. mesh: Nullable<Mesh>;
  23361. /**
  23362. * Creates a new LOD level
  23363. * @param distance defines the distance where this level should star being displayed
  23364. * @param mesh defines the mesh to use to render this level
  23365. */
  23366. constructor(
  23367. /** Defines the distance where this level should start being displayed */
  23368. distance: number,
  23369. /** Defines the mesh to use to render this level */
  23370. mesh: Nullable<Mesh>);
  23371. }
  23372. }
  23373. declare module "babylonjs/Meshes/groundMesh" {
  23374. import { Scene } from "babylonjs/scene";
  23375. import { Vector3 } from "babylonjs/Maths/math.vector";
  23376. import { Mesh } from "babylonjs/Meshes/mesh";
  23377. /**
  23378. * Mesh representing the gorund
  23379. */
  23380. export class GroundMesh extends Mesh {
  23381. /** If octree should be generated */
  23382. generateOctree: boolean;
  23383. private _heightQuads;
  23384. /** @hidden */
  23385. _subdivisionsX: number;
  23386. /** @hidden */
  23387. _subdivisionsY: number;
  23388. /** @hidden */
  23389. _width: number;
  23390. /** @hidden */
  23391. _height: number;
  23392. /** @hidden */
  23393. _minX: number;
  23394. /** @hidden */
  23395. _maxX: number;
  23396. /** @hidden */
  23397. _minZ: number;
  23398. /** @hidden */
  23399. _maxZ: number;
  23400. constructor(name: string, scene: Scene);
  23401. /**
  23402. * "GroundMesh"
  23403. * @returns "GroundMesh"
  23404. */
  23405. getClassName(): string;
  23406. /**
  23407. * The minimum of x and y subdivisions
  23408. */
  23409. get subdivisions(): number;
  23410. /**
  23411. * X subdivisions
  23412. */
  23413. get subdivisionsX(): number;
  23414. /**
  23415. * Y subdivisions
  23416. */
  23417. get subdivisionsY(): number;
  23418. /**
  23419. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23420. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23421. * @param chunksCount the number of subdivisions for x and y
  23422. * @param octreeBlocksSize (Default: 32)
  23423. */
  23424. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23425. /**
  23426. * Returns a height (y) value in the Worl system :
  23427. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23428. * @param x x coordinate
  23429. * @param z z coordinate
  23430. * @returns the ground y position if (x, z) are outside the ground surface.
  23431. */
  23432. getHeightAtCoordinates(x: number, z: number): number;
  23433. /**
  23434. * Returns a normalized vector (Vector3) orthogonal to the ground
  23435. * at the ground coordinates (x, z) expressed in the World system.
  23436. * @param x x coordinate
  23437. * @param z z coordinate
  23438. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23439. */
  23440. getNormalAtCoordinates(x: number, z: number): Vector3;
  23441. /**
  23442. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23443. * at the ground coordinates (x, z) expressed in the World system.
  23444. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23445. * @param x x coordinate
  23446. * @param z z coordinate
  23447. * @param ref vector to store the result
  23448. * @returns the GroundMesh.
  23449. */
  23450. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23451. /**
  23452. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23453. * if the ground has been updated.
  23454. * This can be used in the render loop.
  23455. * @returns the GroundMesh.
  23456. */
  23457. updateCoordinateHeights(): GroundMesh;
  23458. private _getFacetAt;
  23459. private _initHeightQuads;
  23460. private _computeHeightQuads;
  23461. /**
  23462. * Serializes this ground mesh
  23463. * @param serializationObject object to write serialization to
  23464. */
  23465. serialize(serializationObject: any): void;
  23466. /**
  23467. * Parses a serialized ground mesh
  23468. * @param parsedMesh the serialized mesh
  23469. * @param scene the scene to create the ground mesh in
  23470. * @returns the created ground mesh
  23471. */
  23472. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23473. }
  23474. }
  23475. declare module "babylonjs/Physics/physicsJoint" {
  23476. import { Vector3 } from "babylonjs/Maths/math.vector";
  23477. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23478. /**
  23479. * Interface for Physics-Joint data
  23480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23481. */
  23482. export interface PhysicsJointData {
  23483. /**
  23484. * The main pivot of the joint
  23485. */
  23486. mainPivot?: Vector3;
  23487. /**
  23488. * The connected pivot of the joint
  23489. */
  23490. connectedPivot?: Vector3;
  23491. /**
  23492. * The main axis of the joint
  23493. */
  23494. mainAxis?: Vector3;
  23495. /**
  23496. * The connected axis of the joint
  23497. */
  23498. connectedAxis?: Vector3;
  23499. /**
  23500. * The collision of the joint
  23501. */
  23502. collision?: boolean;
  23503. /**
  23504. * Native Oimo/Cannon/Energy data
  23505. */
  23506. nativeParams?: any;
  23507. }
  23508. /**
  23509. * This is a holder class for the physics joint created by the physics plugin
  23510. * It holds a set of functions to control the underlying joint
  23511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23512. */
  23513. export class PhysicsJoint {
  23514. /**
  23515. * The type of the physics joint
  23516. */
  23517. type: number;
  23518. /**
  23519. * The data for the physics joint
  23520. */
  23521. jointData: PhysicsJointData;
  23522. private _physicsJoint;
  23523. protected _physicsPlugin: IPhysicsEnginePlugin;
  23524. /**
  23525. * Initializes the physics joint
  23526. * @param type The type of the physics joint
  23527. * @param jointData The data for the physics joint
  23528. */
  23529. constructor(
  23530. /**
  23531. * The type of the physics joint
  23532. */
  23533. type: number,
  23534. /**
  23535. * The data for the physics joint
  23536. */
  23537. jointData: PhysicsJointData);
  23538. /**
  23539. * Gets the physics joint
  23540. */
  23541. get physicsJoint(): any;
  23542. /**
  23543. * Sets the physics joint
  23544. */
  23545. set physicsJoint(newJoint: any);
  23546. /**
  23547. * Sets the physics plugin
  23548. */
  23549. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23550. /**
  23551. * Execute a function that is physics-plugin specific.
  23552. * @param {Function} func the function that will be executed.
  23553. * It accepts two parameters: the physics world and the physics joint
  23554. */
  23555. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23556. /**
  23557. * Distance-Joint type
  23558. */
  23559. static DistanceJoint: number;
  23560. /**
  23561. * Hinge-Joint type
  23562. */
  23563. static HingeJoint: number;
  23564. /**
  23565. * Ball-and-Socket joint type
  23566. */
  23567. static BallAndSocketJoint: number;
  23568. /**
  23569. * Wheel-Joint type
  23570. */
  23571. static WheelJoint: number;
  23572. /**
  23573. * Slider-Joint type
  23574. */
  23575. static SliderJoint: number;
  23576. /**
  23577. * Prismatic-Joint type
  23578. */
  23579. static PrismaticJoint: number;
  23580. /**
  23581. * Universal-Joint type
  23582. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23583. */
  23584. static UniversalJoint: number;
  23585. /**
  23586. * Hinge-Joint 2 type
  23587. */
  23588. static Hinge2Joint: number;
  23589. /**
  23590. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23591. */
  23592. static PointToPointJoint: number;
  23593. /**
  23594. * Spring-Joint type
  23595. */
  23596. static SpringJoint: number;
  23597. /**
  23598. * Lock-Joint type
  23599. */
  23600. static LockJoint: number;
  23601. }
  23602. /**
  23603. * A class representing a physics distance joint
  23604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23605. */
  23606. export class DistanceJoint extends PhysicsJoint {
  23607. /**
  23608. *
  23609. * @param jointData The data for the Distance-Joint
  23610. */
  23611. constructor(jointData: DistanceJointData);
  23612. /**
  23613. * Update the predefined distance.
  23614. * @param maxDistance The maximum preferred distance
  23615. * @param minDistance The minimum preferred distance
  23616. */
  23617. updateDistance(maxDistance: number, minDistance?: number): void;
  23618. }
  23619. /**
  23620. * Represents a Motor-Enabled Joint
  23621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23622. */
  23623. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23624. /**
  23625. * Initializes the Motor-Enabled Joint
  23626. * @param type The type of the joint
  23627. * @param jointData The physica joint data for the joint
  23628. */
  23629. constructor(type: number, jointData: PhysicsJointData);
  23630. /**
  23631. * Set the motor values.
  23632. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23633. * @param force the force to apply
  23634. * @param maxForce max force for this motor.
  23635. */
  23636. setMotor(force?: number, maxForce?: number): void;
  23637. /**
  23638. * Set the motor's limits.
  23639. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23640. * @param upperLimit The upper limit of the motor
  23641. * @param lowerLimit The lower limit of the motor
  23642. */
  23643. setLimit(upperLimit: number, lowerLimit?: number): void;
  23644. }
  23645. /**
  23646. * This class represents a single physics Hinge-Joint
  23647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23648. */
  23649. export class HingeJoint extends MotorEnabledJoint {
  23650. /**
  23651. * Initializes the Hinge-Joint
  23652. * @param jointData The joint data for the Hinge-Joint
  23653. */
  23654. constructor(jointData: PhysicsJointData);
  23655. /**
  23656. * Set the motor values.
  23657. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23658. * @param {number} force the force to apply
  23659. * @param {number} maxForce max force for this motor.
  23660. */
  23661. setMotor(force?: number, maxForce?: number): void;
  23662. /**
  23663. * Set the motor's limits.
  23664. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23665. * @param upperLimit The upper limit of the motor
  23666. * @param lowerLimit The lower limit of the motor
  23667. */
  23668. setLimit(upperLimit: number, lowerLimit?: number): void;
  23669. }
  23670. /**
  23671. * This class represents a dual hinge physics joint (same as wheel joint)
  23672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23673. */
  23674. export class Hinge2Joint extends MotorEnabledJoint {
  23675. /**
  23676. * Initializes the Hinge2-Joint
  23677. * @param jointData The joint data for the Hinge2-Joint
  23678. */
  23679. constructor(jointData: PhysicsJointData);
  23680. /**
  23681. * Set the motor values.
  23682. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23683. * @param {number} targetSpeed the speed the motor is to reach
  23684. * @param {number} maxForce max force for this motor.
  23685. * @param {motorIndex} the motor's index, 0 or 1.
  23686. */
  23687. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23688. /**
  23689. * Set the motor limits.
  23690. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23691. * @param {number} upperLimit the upper limit
  23692. * @param {number} lowerLimit lower limit
  23693. * @param {motorIndex} the motor's index, 0 or 1.
  23694. */
  23695. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23696. }
  23697. /**
  23698. * Interface for a motor enabled joint
  23699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23700. */
  23701. export interface IMotorEnabledJoint {
  23702. /**
  23703. * Physics joint
  23704. */
  23705. physicsJoint: any;
  23706. /**
  23707. * Sets the motor of the motor-enabled joint
  23708. * @param force The force of the motor
  23709. * @param maxForce The maximum force of the motor
  23710. * @param motorIndex The index of the motor
  23711. */
  23712. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23713. /**
  23714. * Sets the limit of the motor
  23715. * @param upperLimit The upper limit of the motor
  23716. * @param lowerLimit The lower limit of the motor
  23717. * @param motorIndex The index of the motor
  23718. */
  23719. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23720. }
  23721. /**
  23722. * Joint data for a Distance-Joint
  23723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23724. */
  23725. export interface DistanceJointData extends PhysicsJointData {
  23726. /**
  23727. * Max distance the 2 joint objects can be apart
  23728. */
  23729. maxDistance: number;
  23730. }
  23731. /**
  23732. * Joint data from a spring joint
  23733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23734. */
  23735. export interface SpringJointData extends PhysicsJointData {
  23736. /**
  23737. * Length of the spring
  23738. */
  23739. length: number;
  23740. /**
  23741. * Stiffness of the spring
  23742. */
  23743. stiffness: number;
  23744. /**
  23745. * Damping of the spring
  23746. */
  23747. damping: number;
  23748. /** this callback will be called when applying the force to the impostors. */
  23749. forceApplicationCallback: () => void;
  23750. }
  23751. }
  23752. declare module "babylonjs/Physics/physicsRaycastResult" {
  23753. import { Vector3 } from "babylonjs/Maths/math.vector";
  23754. /**
  23755. * Holds the data for the raycast result
  23756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23757. */
  23758. export class PhysicsRaycastResult {
  23759. private _hasHit;
  23760. private _hitDistance;
  23761. private _hitNormalWorld;
  23762. private _hitPointWorld;
  23763. private _rayFromWorld;
  23764. private _rayToWorld;
  23765. /**
  23766. * Gets if there was a hit
  23767. */
  23768. get hasHit(): boolean;
  23769. /**
  23770. * Gets the distance from the hit
  23771. */
  23772. get hitDistance(): number;
  23773. /**
  23774. * Gets the hit normal/direction in the world
  23775. */
  23776. get hitNormalWorld(): Vector3;
  23777. /**
  23778. * Gets the hit point in the world
  23779. */
  23780. get hitPointWorld(): Vector3;
  23781. /**
  23782. * Gets the ray "start point" of the ray in the world
  23783. */
  23784. get rayFromWorld(): Vector3;
  23785. /**
  23786. * Gets the ray "end point" of the ray in the world
  23787. */
  23788. get rayToWorld(): Vector3;
  23789. /**
  23790. * Sets the hit data (normal & point in world space)
  23791. * @param hitNormalWorld defines the normal in world space
  23792. * @param hitPointWorld defines the point in world space
  23793. */
  23794. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23795. /**
  23796. * Sets the distance from the start point to the hit point
  23797. * @param distance
  23798. */
  23799. setHitDistance(distance: number): void;
  23800. /**
  23801. * Calculates the distance manually
  23802. */
  23803. calculateHitDistance(): void;
  23804. /**
  23805. * Resets all the values to default
  23806. * @param from The from point on world space
  23807. * @param to The to point on world space
  23808. */
  23809. reset(from?: Vector3, to?: Vector3): void;
  23810. }
  23811. /**
  23812. * Interface for the size containing width and height
  23813. */
  23814. interface IXYZ {
  23815. /**
  23816. * X
  23817. */
  23818. x: number;
  23819. /**
  23820. * Y
  23821. */
  23822. y: number;
  23823. /**
  23824. * Z
  23825. */
  23826. z: number;
  23827. }
  23828. }
  23829. declare module "babylonjs/Physics/IPhysicsEngine" {
  23830. import { Nullable } from "babylonjs/types";
  23831. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23833. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23834. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23835. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23836. /**
  23837. * Interface used to describe a physics joint
  23838. */
  23839. export interface PhysicsImpostorJoint {
  23840. /** Defines the main impostor to which the joint is linked */
  23841. mainImpostor: PhysicsImpostor;
  23842. /** Defines the impostor that is connected to the main impostor using this joint */
  23843. connectedImpostor: PhysicsImpostor;
  23844. /** Defines the joint itself */
  23845. joint: PhysicsJoint;
  23846. }
  23847. /** @hidden */
  23848. export interface IPhysicsEnginePlugin {
  23849. world: any;
  23850. name: string;
  23851. setGravity(gravity: Vector3): void;
  23852. setTimeStep(timeStep: number): void;
  23853. getTimeStep(): number;
  23854. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23855. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23856. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23857. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23858. removePhysicsBody(impostor: PhysicsImpostor): void;
  23859. generateJoint(joint: PhysicsImpostorJoint): void;
  23860. removeJoint(joint: PhysicsImpostorJoint): void;
  23861. isSupported(): boolean;
  23862. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23863. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23864. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23865. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23866. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23867. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23868. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23869. getBodyMass(impostor: PhysicsImpostor): number;
  23870. getBodyFriction(impostor: PhysicsImpostor): number;
  23871. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23872. getBodyRestitution(impostor: PhysicsImpostor): number;
  23873. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23874. getBodyPressure?(impostor: PhysicsImpostor): number;
  23875. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23876. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23877. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23878. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23879. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23880. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23881. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23882. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23883. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23884. sleepBody(impostor: PhysicsImpostor): void;
  23885. wakeUpBody(impostor: PhysicsImpostor): void;
  23886. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23887. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23888. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23889. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23890. getRadius(impostor: PhysicsImpostor): number;
  23891. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23892. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23893. dispose(): void;
  23894. }
  23895. /**
  23896. * Interface used to define a physics engine
  23897. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23898. */
  23899. export interface IPhysicsEngine {
  23900. /**
  23901. * Gets the gravity vector used by the simulation
  23902. */
  23903. gravity: Vector3;
  23904. /**
  23905. * Sets the gravity vector used by the simulation
  23906. * @param gravity defines the gravity vector to use
  23907. */
  23908. setGravity(gravity: Vector3): void;
  23909. /**
  23910. * Set the time step of the physics engine.
  23911. * Default is 1/60.
  23912. * To slow it down, enter 1/600 for example.
  23913. * To speed it up, 1/30
  23914. * @param newTimeStep the new timestep to apply to this world.
  23915. */
  23916. setTimeStep(newTimeStep: number): void;
  23917. /**
  23918. * Get the time step of the physics engine.
  23919. * @returns the current time step
  23920. */
  23921. getTimeStep(): number;
  23922. /**
  23923. * Set the sub time step of the physics engine.
  23924. * Default is 0 meaning there is no sub steps
  23925. * To increase physics resolution precision, set a small value (like 1 ms)
  23926. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23927. */
  23928. setSubTimeStep(subTimeStep: number): void;
  23929. /**
  23930. * Get the sub time step of the physics engine.
  23931. * @returns the current sub time step
  23932. */
  23933. getSubTimeStep(): number;
  23934. /**
  23935. * Release all resources
  23936. */
  23937. dispose(): void;
  23938. /**
  23939. * Gets the name of the current physics plugin
  23940. * @returns the name of the plugin
  23941. */
  23942. getPhysicsPluginName(): string;
  23943. /**
  23944. * Adding a new impostor for the impostor tracking.
  23945. * This will be done by the impostor itself.
  23946. * @param impostor the impostor to add
  23947. */
  23948. addImpostor(impostor: PhysicsImpostor): void;
  23949. /**
  23950. * Remove an impostor from the engine.
  23951. * This impostor and its mesh will not longer be updated by the physics engine.
  23952. * @param impostor the impostor to remove
  23953. */
  23954. removeImpostor(impostor: PhysicsImpostor): void;
  23955. /**
  23956. * Add a joint to the physics engine
  23957. * @param mainImpostor defines the main impostor to which the joint is added.
  23958. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23959. * @param joint defines the joint that will connect both impostors.
  23960. */
  23961. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23962. /**
  23963. * Removes a joint from the simulation
  23964. * @param mainImpostor defines the impostor used with the joint
  23965. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23966. * @param joint defines the joint to remove
  23967. */
  23968. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23969. /**
  23970. * Gets the current plugin used to run the simulation
  23971. * @returns current plugin
  23972. */
  23973. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23974. /**
  23975. * Gets the list of physic impostors
  23976. * @returns an array of PhysicsImpostor
  23977. */
  23978. getImpostors(): Array<PhysicsImpostor>;
  23979. /**
  23980. * Gets the impostor for a physics enabled object
  23981. * @param object defines the object impersonated by the impostor
  23982. * @returns the PhysicsImpostor or null if not found
  23983. */
  23984. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23985. /**
  23986. * Gets the impostor for a physics body object
  23987. * @param body defines physics body used by the impostor
  23988. * @returns the PhysicsImpostor or null if not found
  23989. */
  23990. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23991. /**
  23992. * Does a raycast in the physics world
  23993. * @param from when should the ray start?
  23994. * @param to when should the ray end?
  23995. * @returns PhysicsRaycastResult
  23996. */
  23997. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23998. /**
  23999. * Called by the scene. No need to call it.
  24000. * @param delta defines the timespam between frames
  24001. */
  24002. _step(delta: number): void;
  24003. }
  24004. }
  24005. declare module "babylonjs/Physics/physicsImpostor" {
  24006. import { Nullable, IndicesArray } from "babylonjs/types";
  24007. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24008. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24010. import { Scene } from "babylonjs/scene";
  24011. import { Bone } from "babylonjs/Bones/bone";
  24012. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24013. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24014. import { Space } from "babylonjs/Maths/math.axis";
  24015. /**
  24016. * The interface for the physics imposter parameters
  24017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24018. */
  24019. export interface PhysicsImpostorParameters {
  24020. /**
  24021. * The mass of the physics imposter
  24022. */
  24023. mass: number;
  24024. /**
  24025. * The friction of the physics imposter
  24026. */
  24027. friction?: number;
  24028. /**
  24029. * The coefficient of restitution of the physics imposter
  24030. */
  24031. restitution?: number;
  24032. /**
  24033. * The native options of the physics imposter
  24034. */
  24035. nativeOptions?: any;
  24036. /**
  24037. * Specifies if the parent should be ignored
  24038. */
  24039. ignoreParent?: boolean;
  24040. /**
  24041. * Specifies if bi-directional transformations should be disabled
  24042. */
  24043. disableBidirectionalTransformation?: boolean;
  24044. /**
  24045. * The pressure inside the physics imposter, soft object only
  24046. */
  24047. pressure?: number;
  24048. /**
  24049. * The stiffness the physics imposter, soft object only
  24050. */
  24051. stiffness?: number;
  24052. /**
  24053. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24054. */
  24055. velocityIterations?: number;
  24056. /**
  24057. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24058. */
  24059. positionIterations?: number;
  24060. /**
  24061. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24062. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24063. * Add to fix multiple points
  24064. */
  24065. fixedPoints?: number;
  24066. /**
  24067. * The collision margin around a soft object
  24068. */
  24069. margin?: number;
  24070. /**
  24071. * The collision margin around a soft object
  24072. */
  24073. damping?: number;
  24074. /**
  24075. * The path for a rope based on an extrusion
  24076. */
  24077. path?: any;
  24078. /**
  24079. * The shape of an extrusion used for a rope based on an extrusion
  24080. */
  24081. shape?: any;
  24082. }
  24083. /**
  24084. * Interface for a physics-enabled object
  24085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24086. */
  24087. export interface IPhysicsEnabledObject {
  24088. /**
  24089. * The position of the physics-enabled object
  24090. */
  24091. position: Vector3;
  24092. /**
  24093. * The rotation of the physics-enabled object
  24094. */
  24095. rotationQuaternion: Nullable<Quaternion>;
  24096. /**
  24097. * The scale of the physics-enabled object
  24098. */
  24099. scaling: Vector3;
  24100. /**
  24101. * The rotation of the physics-enabled object
  24102. */
  24103. rotation?: Vector3;
  24104. /**
  24105. * The parent of the physics-enabled object
  24106. */
  24107. parent?: any;
  24108. /**
  24109. * The bounding info of the physics-enabled object
  24110. * @returns The bounding info of the physics-enabled object
  24111. */
  24112. getBoundingInfo(): BoundingInfo;
  24113. /**
  24114. * Computes the world matrix
  24115. * @param force Specifies if the world matrix should be computed by force
  24116. * @returns A world matrix
  24117. */
  24118. computeWorldMatrix(force: boolean): Matrix;
  24119. /**
  24120. * Gets the world matrix
  24121. * @returns A world matrix
  24122. */
  24123. getWorldMatrix?(): Matrix;
  24124. /**
  24125. * Gets the child meshes
  24126. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24127. * @returns An array of abstract meshes
  24128. */
  24129. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24130. /**
  24131. * Gets the vertex data
  24132. * @param kind The type of vertex data
  24133. * @returns A nullable array of numbers, or a float32 array
  24134. */
  24135. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24136. /**
  24137. * Gets the indices from the mesh
  24138. * @returns A nullable array of index arrays
  24139. */
  24140. getIndices?(): Nullable<IndicesArray>;
  24141. /**
  24142. * Gets the scene from the mesh
  24143. * @returns the indices array or null
  24144. */
  24145. getScene?(): Scene;
  24146. /**
  24147. * Gets the absolute position from the mesh
  24148. * @returns the absolute position
  24149. */
  24150. getAbsolutePosition(): Vector3;
  24151. /**
  24152. * Gets the absolute pivot point from the mesh
  24153. * @returns the absolute pivot point
  24154. */
  24155. getAbsolutePivotPoint(): Vector3;
  24156. /**
  24157. * Rotates the mesh
  24158. * @param axis The axis of rotation
  24159. * @param amount The amount of rotation
  24160. * @param space The space of the rotation
  24161. * @returns The rotation transform node
  24162. */
  24163. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24164. /**
  24165. * Translates the mesh
  24166. * @param axis The axis of translation
  24167. * @param distance The distance of translation
  24168. * @param space The space of the translation
  24169. * @returns The transform node
  24170. */
  24171. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24172. /**
  24173. * Sets the absolute position of the mesh
  24174. * @param absolutePosition The absolute position of the mesh
  24175. * @returns The transform node
  24176. */
  24177. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24178. /**
  24179. * Gets the class name of the mesh
  24180. * @returns The class name
  24181. */
  24182. getClassName(): string;
  24183. }
  24184. /**
  24185. * Represents a physics imposter
  24186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24187. */
  24188. export class PhysicsImpostor {
  24189. /**
  24190. * The physics-enabled object used as the physics imposter
  24191. */
  24192. object: IPhysicsEnabledObject;
  24193. /**
  24194. * The type of the physics imposter
  24195. */
  24196. type: number;
  24197. private _options;
  24198. private _scene?;
  24199. /**
  24200. * The default object size of the imposter
  24201. */
  24202. static DEFAULT_OBJECT_SIZE: Vector3;
  24203. /**
  24204. * The identity quaternion of the imposter
  24205. */
  24206. static IDENTITY_QUATERNION: Quaternion;
  24207. /** @hidden */
  24208. _pluginData: any;
  24209. private _physicsEngine;
  24210. private _physicsBody;
  24211. private _bodyUpdateRequired;
  24212. private _onBeforePhysicsStepCallbacks;
  24213. private _onAfterPhysicsStepCallbacks;
  24214. /** @hidden */
  24215. _onPhysicsCollideCallbacks: Array<{
  24216. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24217. otherImpostors: Array<PhysicsImpostor>;
  24218. }>;
  24219. private _deltaPosition;
  24220. private _deltaRotation;
  24221. private _deltaRotationConjugated;
  24222. /** @hidden */
  24223. _isFromLine: boolean;
  24224. private _parent;
  24225. private _isDisposed;
  24226. private static _tmpVecs;
  24227. private static _tmpQuat;
  24228. /**
  24229. * Specifies if the physics imposter is disposed
  24230. */
  24231. get isDisposed(): boolean;
  24232. /**
  24233. * Gets the mass of the physics imposter
  24234. */
  24235. get mass(): number;
  24236. set mass(value: number);
  24237. /**
  24238. * Gets the coefficient of friction
  24239. */
  24240. get friction(): number;
  24241. /**
  24242. * Sets the coefficient of friction
  24243. */
  24244. set friction(value: number);
  24245. /**
  24246. * Gets the coefficient of restitution
  24247. */
  24248. get restitution(): number;
  24249. /**
  24250. * Sets the coefficient of restitution
  24251. */
  24252. set restitution(value: number);
  24253. /**
  24254. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24255. */
  24256. get pressure(): number;
  24257. /**
  24258. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24259. */
  24260. set pressure(value: number);
  24261. /**
  24262. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24263. */
  24264. get stiffness(): number;
  24265. /**
  24266. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24267. */
  24268. set stiffness(value: number);
  24269. /**
  24270. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24271. */
  24272. get velocityIterations(): number;
  24273. /**
  24274. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24275. */
  24276. set velocityIterations(value: number);
  24277. /**
  24278. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24279. */
  24280. get positionIterations(): number;
  24281. /**
  24282. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24283. */
  24284. set positionIterations(value: number);
  24285. /**
  24286. * The unique id of the physics imposter
  24287. * set by the physics engine when adding this impostor to the array
  24288. */
  24289. uniqueId: number;
  24290. /**
  24291. * @hidden
  24292. */
  24293. soft: boolean;
  24294. /**
  24295. * @hidden
  24296. */
  24297. segments: number;
  24298. private _joints;
  24299. /**
  24300. * Initializes the physics imposter
  24301. * @param object The physics-enabled object used as the physics imposter
  24302. * @param type The type of the physics imposter
  24303. * @param _options The options for the physics imposter
  24304. * @param _scene The Babylon scene
  24305. */
  24306. constructor(
  24307. /**
  24308. * The physics-enabled object used as the physics imposter
  24309. */
  24310. object: IPhysicsEnabledObject,
  24311. /**
  24312. * The type of the physics imposter
  24313. */
  24314. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24315. /**
  24316. * This function will completly initialize this impostor.
  24317. * It will create a new body - but only if this mesh has no parent.
  24318. * If it has, this impostor will not be used other than to define the impostor
  24319. * of the child mesh.
  24320. * @hidden
  24321. */
  24322. _init(): void;
  24323. private _getPhysicsParent;
  24324. /**
  24325. * Should a new body be generated.
  24326. * @returns boolean specifying if body initialization is required
  24327. */
  24328. isBodyInitRequired(): boolean;
  24329. /**
  24330. * Sets the updated scaling
  24331. * @param updated Specifies if the scaling is updated
  24332. */
  24333. setScalingUpdated(): void;
  24334. /**
  24335. * Force a regeneration of this or the parent's impostor's body.
  24336. * Use under cautious - This will remove all joints already implemented.
  24337. */
  24338. forceUpdate(): void;
  24339. /**
  24340. * Gets the body that holds this impostor. Either its own, or its parent.
  24341. */
  24342. get physicsBody(): any;
  24343. /**
  24344. * Get the parent of the physics imposter
  24345. * @returns Physics imposter or null
  24346. */
  24347. get parent(): Nullable<PhysicsImpostor>;
  24348. /**
  24349. * Sets the parent of the physics imposter
  24350. */
  24351. set parent(value: Nullable<PhysicsImpostor>);
  24352. /**
  24353. * Set the physics body. Used mainly by the physics engine/plugin
  24354. */
  24355. set physicsBody(physicsBody: any);
  24356. /**
  24357. * Resets the update flags
  24358. */
  24359. resetUpdateFlags(): void;
  24360. /**
  24361. * Gets the object extend size
  24362. * @returns the object extend size
  24363. */
  24364. getObjectExtendSize(): Vector3;
  24365. /**
  24366. * Gets the object center
  24367. * @returns The object center
  24368. */
  24369. getObjectCenter(): Vector3;
  24370. /**
  24371. * Get a specific parametes from the options parameter
  24372. * @param paramName The object parameter name
  24373. * @returns The object parameter
  24374. */
  24375. getParam(paramName: string): any;
  24376. /**
  24377. * Sets a specific parameter in the options given to the physics plugin
  24378. * @param paramName The parameter name
  24379. * @param value The value of the parameter
  24380. */
  24381. setParam(paramName: string, value: number): void;
  24382. /**
  24383. * Specifically change the body's mass option. Won't recreate the physics body object
  24384. * @param mass The mass of the physics imposter
  24385. */
  24386. setMass(mass: number): void;
  24387. /**
  24388. * Gets the linear velocity
  24389. * @returns linear velocity or null
  24390. */
  24391. getLinearVelocity(): Nullable<Vector3>;
  24392. /**
  24393. * Sets the linear velocity
  24394. * @param velocity linear velocity or null
  24395. */
  24396. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24397. /**
  24398. * Gets the angular velocity
  24399. * @returns angular velocity or null
  24400. */
  24401. getAngularVelocity(): Nullable<Vector3>;
  24402. /**
  24403. * Sets the angular velocity
  24404. * @param velocity The velocity or null
  24405. */
  24406. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24407. /**
  24408. * Execute a function with the physics plugin native code
  24409. * Provide a function the will have two variables - the world object and the physics body object
  24410. * @param func The function to execute with the physics plugin native code
  24411. */
  24412. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24413. /**
  24414. * Register a function that will be executed before the physics world is stepping forward
  24415. * @param func The function to execute before the physics world is stepped forward
  24416. */
  24417. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24418. /**
  24419. * Unregister a function that will be executed before the physics world is stepping forward
  24420. * @param func The function to execute before the physics world is stepped forward
  24421. */
  24422. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24423. /**
  24424. * Register a function that will be executed after the physics step
  24425. * @param func The function to execute after physics step
  24426. */
  24427. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24428. /**
  24429. * Unregisters a function that will be executed after the physics step
  24430. * @param func The function to execute after physics step
  24431. */
  24432. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24433. /**
  24434. * register a function that will be executed when this impostor collides against a different body
  24435. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24436. * @param func Callback that is executed on collision
  24437. */
  24438. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24439. /**
  24440. * Unregisters the physics imposter on contact
  24441. * @param collideAgainst The physics object to collide against
  24442. * @param func Callback to execute on collision
  24443. */
  24444. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24445. private _tmpQuat;
  24446. private _tmpQuat2;
  24447. /**
  24448. * Get the parent rotation
  24449. * @returns The parent rotation
  24450. */
  24451. getParentsRotation(): Quaternion;
  24452. /**
  24453. * this function is executed by the physics engine.
  24454. */
  24455. beforeStep: () => void;
  24456. /**
  24457. * this function is executed by the physics engine
  24458. */
  24459. afterStep: () => void;
  24460. /**
  24461. * Legacy collision detection event support
  24462. */
  24463. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24464. /**
  24465. * event and body object due to cannon's event-based architecture.
  24466. */
  24467. onCollide: (e: {
  24468. body: any;
  24469. }) => void;
  24470. /**
  24471. * Apply a force
  24472. * @param force The force to apply
  24473. * @param contactPoint The contact point for the force
  24474. * @returns The physics imposter
  24475. */
  24476. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24477. /**
  24478. * Apply an impulse
  24479. * @param force The impulse force
  24480. * @param contactPoint The contact point for the impulse force
  24481. * @returns The physics imposter
  24482. */
  24483. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24484. /**
  24485. * A help function to create a joint
  24486. * @param otherImpostor A physics imposter used to create a joint
  24487. * @param jointType The type of joint
  24488. * @param jointData The data for the joint
  24489. * @returns The physics imposter
  24490. */
  24491. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24492. /**
  24493. * Add a joint to this impostor with a different impostor
  24494. * @param otherImpostor A physics imposter used to add a joint
  24495. * @param joint The joint to add
  24496. * @returns The physics imposter
  24497. */
  24498. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24499. /**
  24500. * Add an anchor to a cloth impostor
  24501. * @param otherImpostor rigid impostor to anchor to
  24502. * @param width ratio across width from 0 to 1
  24503. * @param height ratio up height from 0 to 1
  24504. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24505. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24506. * @returns impostor the soft imposter
  24507. */
  24508. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24509. /**
  24510. * Add a hook to a rope impostor
  24511. * @param otherImpostor rigid impostor to anchor to
  24512. * @param length ratio across rope from 0 to 1
  24513. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24514. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24515. * @returns impostor the rope imposter
  24516. */
  24517. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24518. /**
  24519. * Will keep this body still, in a sleep mode.
  24520. * @returns the physics imposter
  24521. */
  24522. sleep(): PhysicsImpostor;
  24523. /**
  24524. * Wake the body up.
  24525. * @returns The physics imposter
  24526. */
  24527. wakeUp(): PhysicsImpostor;
  24528. /**
  24529. * Clones the physics imposter
  24530. * @param newObject The physics imposter clones to this physics-enabled object
  24531. * @returns A nullable physics imposter
  24532. */
  24533. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24534. /**
  24535. * Disposes the physics imposter
  24536. */
  24537. dispose(): void;
  24538. /**
  24539. * Sets the delta position
  24540. * @param position The delta position amount
  24541. */
  24542. setDeltaPosition(position: Vector3): void;
  24543. /**
  24544. * Sets the delta rotation
  24545. * @param rotation The delta rotation amount
  24546. */
  24547. setDeltaRotation(rotation: Quaternion): void;
  24548. /**
  24549. * Gets the box size of the physics imposter and stores the result in the input parameter
  24550. * @param result Stores the box size
  24551. * @returns The physics imposter
  24552. */
  24553. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24554. /**
  24555. * Gets the radius of the physics imposter
  24556. * @returns Radius of the physics imposter
  24557. */
  24558. getRadius(): number;
  24559. /**
  24560. * Sync a bone with this impostor
  24561. * @param bone The bone to sync to the impostor.
  24562. * @param boneMesh The mesh that the bone is influencing.
  24563. * @param jointPivot The pivot of the joint / bone in local space.
  24564. * @param distToJoint Optional distance from the impostor to the joint.
  24565. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24566. */
  24567. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24568. /**
  24569. * Sync impostor to a bone
  24570. * @param bone The bone that the impostor will be synced to.
  24571. * @param boneMesh The mesh that the bone is influencing.
  24572. * @param jointPivot The pivot of the joint / bone in local space.
  24573. * @param distToJoint Optional distance from the impostor to the joint.
  24574. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24575. * @param boneAxis Optional vector3 axis the bone is aligned with
  24576. */
  24577. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24578. /**
  24579. * No-Imposter type
  24580. */
  24581. static NoImpostor: number;
  24582. /**
  24583. * Sphere-Imposter type
  24584. */
  24585. static SphereImpostor: number;
  24586. /**
  24587. * Box-Imposter type
  24588. */
  24589. static BoxImpostor: number;
  24590. /**
  24591. * Plane-Imposter type
  24592. */
  24593. static PlaneImpostor: number;
  24594. /**
  24595. * Mesh-imposter type
  24596. */
  24597. static MeshImpostor: number;
  24598. /**
  24599. * Capsule-Impostor type (Ammo.js plugin only)
  24600. */
  24601. static CapsuleImpostor: number;
  24602. /**
  24603. * Cylinder-Imposter type
  24604. */
  24605. static CylinderImpostor: number;
  24606. /**
  24607. * Particle-Imposter type
  24608. */
  24609. static ParticleImpostor: number;
  24610. /**
  24611. * Heightmap-Imposter type
  24612. */
  24613. static HeightmapImpostor: number;
  24614. /**
  24615. * ConvexHull-Impostor type (Ammo.js plugin only)
  24616. */
  24617. static ConvexHullImpostor: number;
  24618. /**
  24619. * Custom-Imposter type (Ammo.js plugin only)
  24620. */
  24621. static CustomImpostor: number;
  24622. /**
  24623. * Rope-Imposter type
  24624. */
  24625. static RopeImpostor: number;
  24626. /**
  24627. * Cloth-Imposter type
  24628. */
  24629. static ClothImpostor: number;
  24630. /**
  24631. * Softbody-Imposter type
  24632. */
  24633. static SoftbodyImpostor: number;
  24634. }
  24635. }
  24636. declare module "babylonjs/Meshes/mesh" {
  24637. import { Observable } from "babylonjs/Misc/observable";
  24638. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24639. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24640. import { Camera } from "babylonjs/Cameras/camera";
  24641. import { Scene } from "babylonjs/scene";
  24642. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24643. import { Color4 } from "babylonjs/Maths/math.color";
  24644. import { Engine } from "babylonjs/Engines/engine";
  24645. import { Node } from "babylonjs/node";
  24646. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24647. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24648. import { Buffer } from "babylonjs/Meshes/buffer";
  24649. import { Geometry } from "babylonjs/Meshes/geometry";
  24650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24651. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24652. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24653. import { Effect } from "babylonjs/Materials/effect";
  24654. import { Material } from "babylonjs/Materials/material";
  24655. import { Skeleton } from "babylonjs/Bones/skeleton";
  24656. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24657. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24658. import { Path3D } from "babylonjs/Maths/math.path";
  24659. import { Plane } from "babylonjs/Maths/math.plane";
  24660. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24661. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24662. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24663. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24664. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24665. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24666. /**
  24667. * @hidden
  24668. **/
  24669. export class _CreationDataStorage {
  24670. closePath?: boolean;
  24671. closeArray?: boolean;
  24672. idx: number[];
  24673. dashSize: number;
  24674. gapSize: number;
  24675. path3D: Path3D;
  24676. pathArray: Vector3[][];
  24677. arc: number;
  24678. radius: number;
  24679. cap: number;
  24680. tessellation: number;
  24681. }
  24682. /**
  24683. * @hidden
  24684. **/
  24685. class _InstanceDataStorage {
  24686. visibleInstances: any;
  24687. batchCache: _InstancesBatch;
  24688. instancesBufferSize: number;
  24689. instancesBuffer: Nullable<Buffer>;
  24690. instancesData: Float32Array;
  24691. overridenInstanceCount: number;
  24692. isFrozen: boolean;
  24693. previousBatch: Nullable<_InstancesBatch>;
  24694. hardwareInstancedRendering: boolean;
  24695. sideOrientation: number;
  24696. manualUpdate: boolean;
  24697. }
  24698. /**
  24699. * @hidden
  24700. **/
  24701. export class _InstancesBatch {
  24702. mustReturn: boolean;
  24703. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24704. renderSelf: boolean[];
  24705. hardwareInstancedRendering: boolean[];
  24706. }
  24707. /**
  24708. * Class used to represent renderable models
  24709. */
  24710. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24711. /**
  24712. * Mesh side orientation : usually the external or front surface
  24713. */
  24714. static readonly FRONTSIDE: number;
  24715. /**
  24716. * Mesh side orientation : usually the internal or back surface
  24717. */
  24718. static readonly BACKSIDE: number;
  24719. /**
  24720. * Mesh side orientation : both internal and external or front and back surfaces
  24721. */
  24722. static readonly DOUBLESIDE: number;
  24723. /**
  24724. * Mesh side orientation : by default, `FRONTSIDE`
  24725. */
  24726. static readonly DEFAULTSIDE: number;
  24727. /**
  24728. * Mesh cap setting : no cap
  24729. */
  24730. static readonly NO_CAP: number;
  24731. /**
  24732. * Mesh cap setting : one cap at the beginning of the mesh
  24733. */
  24734. static readonly CAP_START: number;
  24735. /**
  24736. * Mesh cap setting : one cap at the end of the mesh
  24737. */
  24738. static readonly CAP_END: number;
  24739. /**
  24740. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24741. */
  24742. static readonly CAP_ALL: number;
  24743. /**
  24744. * Mesh pattern setting : no flip or rotate
  24745. */
  24746. static readonly NO_FLIP: number;
  24747. /**
  24748. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24749. */
  24750. static readonly FLIP_TILE: number;
  24751. /**
  24752. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24753. */
  24754. static readonly ROTATE_TILE: number;
  24755. /**
  24756. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24757. */
  24758. static readonly FLIP_ROW: number;
  24759. /**
  24760. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24761. */
  24762. static readonly ROTATE_ROW: number;
  24763. /**
  24764. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24765. */
  24766. static readonly FLIP_N_ROTATE_TILE: number;
  24767. /**
  24768. * Mesh pattern setting : rotate pattern and rotate
  24769. */
  24770. static readonly FLIP_N_ROTATE_ROW: number;
  24771. /**
  24772. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24773. */
  24774. static readonly CENTER: number;
  24775. /**
  24776. * Mesh tile positioning : part tiles on left
  24777. */
  24778. static readonly LEFT: number;
  24779. /**
  24780. * Mesh tile positioning : part tiles on right
  24781. */
  24782. static readonly RIGHT: number;
  24783. /**
  24784. * Mesh tile positioning : part tiles on top
  24785. */
  24786. static readonly TOP: number;
  24787. /**
  24788. * Mesh tile positioning : part tiles on bottom
  24789. */
  24790. static readonly BOTTOM: number;
  24791. /**
  24792. * Gets the default side orientation.
  24793. * @param orientation the orientation to value to attempt to get
  24794. * @returns the default orientation
  24795. * @hidden
  24796. */
  24797. static _GetDefaultSideOrientation(orientation?: number): number;
  24798. private _internalMeshDataInfo;
  24799. /**
  24800. * An event triggered before rendering the mesh
  24801. */
  24802. get onBeforeRenderObservable(): Observable<Mesh>;
  24803. /**
  24804. * An event triggered before binding the mesh
  24805. */
  24806. get onBeforeBindObservable(): Observable<Mesh>;
  24807. /**
  24808. * An event triggered after rendering the mesh
  24809. */
  24810. get onAfterRenderObservable(): Observable<Mesh>;
  24811. /**
  24812. * An event triggered before drawing the mesh
  24813. */
  24814. get onBeforeDrawObservable(): Observable<Mesh>;
  24815. private _onBeforeDrawObserver;
  24816. /**
  24817. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24818. */
  24819. set onBeforeDraw(callback: () => void);
  24820. get hasInstances(): boolean;
  24821. /**
  24822. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24823. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24824. */
  24825. delayLoadState: number;
  24826. /**
  24827. * Gets the list of instances created from this mesh
  24828. * it is not supposed to be modified manually.
  24829. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24830. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24831. */
  24832. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24833. /**
  24834. * Gets the file containing delay loading data for this mesh
  24835. */
  24836. delayLoadingFile: string;
  24837. /** @hidden */
  24838. _binaryInfo: any;
  24839. /**
  24840. * User defined function used to change how LOD level selection is done
  24841. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24842. */
  24843. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24844. /**
  24845. * Gets or sets the morph target manager
  24846. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24847. */
  24848. get morphTargetManager(): Nullable<MorphTargetManager>;
  24849. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24850. /** @hidden */
  24851. _creationDataStorage: Nullable<_CreationDataStorage>;
  24852. /** @hidden */
  24853. _geometry: Nullable<Geometry>;
  24854. /** @hidden */
  24855. _delayInfo: Array<string>;
  24856. /** @hidden */
  24857. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24858. /** @hidden */
  24859. _instanceDataStorage: _InstanceDataStorage;
  24860. private _effectiveMaterial;
  24861. /** @hidden */
  24862. _shouldGenerateFlatShading: boolean;
  24863. /** @hidden */
  24864. _originalBuilderSideOrientation: number;
  24865. /**
  24866. * Use this property to change the original side orientation defined at construction time
  24867. */
  24868. overrideMaterialSideOrientation: Nullable<number>;
  24869. /**
  24870. * Gets the source mesh (the one used to clone this one from)
  24871. */
  24872. get source(): Nullable<Mesh>;
  24873. /**
  24874. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24875. */
  24876. get isUnIndexed(): boolean;
  24877. set isUnIndexed(value: boolean);
  24878. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24879. get worldMatrixInstancedBuffer(): Float32Array;
  24880. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24881. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24882. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24883. /**
  24884. * @constructor
  24885. * @param name The value used by scene.getMeshByName() to do a lookup.
  24886. * @param scene The scene to add this mesh to.
  24887. * @param parent The parent of this mesh, if it has one
  24888. * @param source An optional Mesh from which geometry is shared, cloned.
  24889. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24890. * When false, achieved by calling a clone(), also passing False.
  24891. * This will make creation of children, recursive.
  24892. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24893. */
  24894. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24895. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24896. doNotInstantiate: boolean;
  24897. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24898. /**
  24899. * Gets the class name
  24900. * @returns the string "Mesh".
  24901. */
  24902. getClassName(): string;
  24903. /** @hidden */
  24904. get _isMesh(): boolean;
  24905. /**
  24906. * Returns a description of this mesh
  24907. * @param fullDetails define if full details about this mesh must be used
  24908. * @returns a descriptive string representing this mesh
  24909. */
  24910. toString(fullDetails?: boolean): string;
  24911. /** @hidden */
  24912. _unBindEffect(): void;
  24913. /**
  24914. * Gets a boolean indicating if this mesh has LOD
  24915. */
  24916. get hasLODLevels(): boolean;
  24917. /**
  24918. * Gets the list of MeshLODLevel associated with the current mesh
  24919. * @returns an array of MeshLODLevel
  24920. */
  24921. getLODLevels(): MeshLODLevel[];
  24922. private _sortLODLevels;
  24923. /**
  24924. * Add a mesh as LOD level triggered at the given distance.
  24925. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24926. * @param distance The distance from the center of the object to show this level
  24927. * @param mesh The mesh to be added as LOD level (can be null)
  24928. * @return This mesh (for chaining)
  24929. */
  24930. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24931. /**
  24932. * Returns the LOD level mesh at the passed distance or null if not found.
  24933. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24934. * @param distance The distance from the center of the object to show this level
  24935. * @returns a Mesh or `null`
  24936. */
  24937. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24938. /**
  24939. * Remove a mesh from the LOD array
  24940. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24941. * @param mesh defines the mesh to be removed
  24942. * @return This mesh (for chaining)
  24943. */
  24944. removeLODLevel(mesh: Mesh): Mesh;
  24945. /**
  24946. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24947. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24948. * @param camera defines the camera to use to compute distance
  24949. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24950. * @return This mesh (for chaining)
  24951. */
  24952. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24953. /**
  24954. * Gets the mesh internal Geometry object
  24955. */
  24956. get geometry(): Nullable<Geometry>;
  24957. /**
  24958. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24959. * @returns the total number of vertices
  24960. */
  24961. getTotalVertices(): number;
  24962. /**
  24963. * Returns the content of an associated vertex buffer
  24964. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24965. * - VertexBuffer.PositionKind
  24966. * - VertexBuffer.UVKind
  24967. * - VertexBuffer.UV2Kind
  24968. * - VertexBuffer.UV3Kind
  24969. * - VertexBuffer.UV4Kind
  24970. * - VertexBuffer.UV5Kind
  24971. * - VertexBuffer.UV6Kind
  24972. * - VertexBuffer.ColorKind
  24973. * - VertexBuffer.MatricesIndicesKind
  24974. * - VertexBuffer.MatricesIndicesExtraKind
  24975. * - VertexBuffer.MatricesWeightsKind
  24976. * - VertexBuffer.MatricesWeightsExtraKind
  24977. * @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
  24978. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24979. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24980. */
  24981. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24982. /**
  24983. * Returns the mesh VertexBuffer object from the requested `kind`
  24984. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24985. * - VertexBuffer.PositionKind
  24986. * - VertexBuffer.NormalKind
  24987. * - VertexBuffer.UVKind
  24988. * - VertexBuffer.UV2Kind
  24989. * - VertexBuffer.UV3Kind
  24990. * - VertexBuffer.UV4Kind
  24991. * - VertexBuffer.UV5Kind
  24992. * - VertexBuffer.UV6Kind
  24993. * - VertexBuffer.ColorKind
  24994. * - VertexBuffer.MatricesIndicesKind
  24995. * - VertexBuffer.MatricesIndicesExtraKind
  24996. * - VertexBuffer.MatricesWeightsKind
  24997. * - VertexBuffer.MatricesWeightsExtraKind
  24998. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24999. */
  25000. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25001. /**
  25002. * Tests if a specific vertex buffer is associated with this mesh
  25003. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25004. * - VertexBuffer.PositionKind
  25005. * - VertexBuffer.NormalKind
  25006. * - VertexBuffer.UVKind
  25007. * - VertexBuffer.UV2Kind
  25008. * - VertexBuffer.UV3Kind
  25009. * - VertexBuffer.UV4Kind
  25010. * - VertexBuffer.UV5Kind
  25011. * - VertexBuffer.UV6Kind
  25012. * - VertexBuffer.ColorKind
  25013. * - VertexBuffer.MatricesIndicesKind
  25014. * - VertexBuffer.MatricesIndicesExtraKind
  25015. * - VertexBuffer.MatricesWeightsKind
  25016. * - VertexBuffer.MatricesWeightsExtraKind
  25017. * @returns a boolean
  25018. */
  25019. isVerticesDataPresent(kind: string): boolean;
  25020. /**
  25021. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25022. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25023. * - VertexBuffer.PositionKind
  25024. * - VertexBuffer.UVKind
  25025. * - VertexBuffer.UV2Kind
  25026. * - VertexBuffer.UV3Kind
  25027. * - VertexBuffer.UV4Kind
  25028. * - VertexBuffer.UV5Kind
  25029. * - VertexBuffer.UV6Kind
  25030. * - VertexBuffer.ColorKind
  25031. * - VertexBuffer.MatricesIndicesKind
  25032. * - VertexBuffer.MatricesIndicesExtraKind
  25033. * - VertexBuffer.MatricesWeightsKind
  25034. * - VertexBuffer.MatricesWeightsExtraKind
  25035. * @returns a boolean
  25036. */
  25037. isVertexBufferUpdatable(kind: string): boolean;
  25038. /**
  25039. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25040. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25041. * - VertexBuffer.PositionKind
  25042. * - VertexBuffer.NormalKind
  25043. * - VertexBuffer.UVKind
  25044. * - VertexBuffer.UV2Kind
  25045. * - VertexBuffer.UV3Kind
  25046. * - VertexBuffer.UV4Kind
  25047. * - VertexBuffer.UV5Kind
  25048. * - VertexBuffer.UV6Kind
  25049. * - VertexBuffer.ColorKind
  25050. * - VertexBuffer.MatricesIndicesKind
  25051. * - VertexBuffer.MatricesIndicesExtraKind
  25052. * - VertexBuffer.MatricesWeightsKind
  25053. * - VertexBuffer.MatricesWeightsExtraKind
  25054. * @returns an array of strings
  25055. */
  25056. getVerticesDataKinds(): string[];
  25057. /**
  25058. * Returns a positive integer : the total number of indices in this mesh geometry.
  25059. * @returns the numner of indices or zero if the mesh has no geometry.
  25060. */
  25061. getTotalIndices(): number;
  25062. /**
  25063. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25064. * @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.
  25065. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25066. * @returns the indices array or an empty array if the mesh has no geometry
  25067. */
  25068. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25069. get isBlocked(): boolean;
  25070. /**
  25071. * Determine if the current mesh is ready to be rendered
  25072. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25073. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25074. * @returns true if all associated assets are ready (material, textures, shaders)
  25075. */
  25076. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25077. /**
  25078. * 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.
  25079. */
  25080. get areNormalsFrozen(): boolean;
  25081. /**
  25082. * 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.
  25083. * @returns the current mesh
  25084. */
  25085. freezeNormals(): Mesh;
  25086. /**
  25087. * 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
  25088. * @returns the current mesh
  25089. */
  25090. unfreezeNormals(): Mesh;
  25091. /**
  25092. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25093. */
  25094. set overridenInstanceCount(count: number);
  25095. /** @hidden */
  25096. _preActivate(): Mesh;
  25097. /** @hidden */
  25098. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25099. /** @hidden */
  25100. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25101. /**
  25102. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25103. * This means the mesh underlying bounding box and sphere are recomputed.
  25104. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25105. * @returns the current mesh
  25106. */
  25107. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25108. /** @hidden */
  25109. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25110. /**
  25111. * This function will subdivide the mesh into multiple submeshes
  25112. * @param count defines the expected number of submeshes
  25113. */
  25114. subdivide(count: number): void;
  25115. /**
  25116. * Copy a FloatArray into a specific associated vertex buffer
  25117. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25118. * - VertexBuffer.PositionKind
  25119. * - VertexBuffer.UVKind
  25120. * - VertexBuffer.UV2Kind
  25121. * - VertexBuffer.UV3Kind
  25122. * - VertexBuffer.UV4Kind
  25123. * - VertexBuffer.UV5Kind
  25124. * - VertexBuffer.UV6Kind
  25125. * - VertexBuffer.ColorKind
  25126. * - VertexBuffer.MatricesIndicesKind
  25127. * - VertexBuffer.MatricesIndicesExtraKind
  25128. * - VertexBuffer.MatricesWeightsKind
  25129. * - VertexBuffer.MatricesWeightsExtraKind
  25130. * @param data defines the data source
  25131. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25132. * @param stride defines the data stride size (can be null)
  25133. * @returns the current mesh
  25134. */
  25135. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25136. /**
  25137. * Delete a vertex buffer associated with this mesh
  25138. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25139. * - VertexBuffer.PositionKind
  25140. * - VertexBuffer.UVKind
  25141. * - VertexBuffer.UV2Kind
  25142. * - VertexBuffer.UV3Kind
  25143. * - VertexBuffer.UV4Kind
  25144. * - VertexBuffer.UV5Kind
  25145. * - VertexBuffer.UV6Kind
  25146. * - VertexBuffer.ColorKind
  25147. * - VertexBuffer.MatricesIndicesKind
  25148. * - VertexBuffer.MatricesIndicesExtraKind
  25149. * - VertexBuffer.MatricesWeightsKind
  25150. * - VertexBuffer.MatricesWeightsExtraKind
  25151. */
  25152. removeVerticesData(kind: string): void;
  25153. /**
  25154. * Flags an associated vertex buffer as updatable
  25155. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25156. * - VertexBuffer.PositionKind
  25157. * - VertexBuffer.UVKind
  25158. * - VertexBuffer.UV2Kind
  25159. * - VertexBuffer.UV3Kind
  25160. * - VertexBuffer.UV4Kind
  25161. * - VertexBuffer.UV5Kind
  25162. * - VertexBuffer.UV6Kind
  25163. * - VertexBuffer.ColorKind
  25164. * - VertexBuffer.MatricesIndicesKind
  25165. * - VertexBuffer.MatricesIndicesExtraKind
  25166. * - VertexBuffer.MatricesWeightsKind
  25167. * - VertexBuffer.MatricesWeightsExtraKind
  25168. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25169. */
  25170. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25171. /**
  25172. * Sets the mesh global Vertex Buffer
  25173. * @param buffer defines the buffer to use
  25174. * @returns the current mesh
  25175. */
  25176. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25177. /**
  25178. * Update a specific associated vertex buffer
  25179. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25180. * - VertexBuffer.PositionKind
  25181. * - VertexBuffer.UVKind
  25182. * - VertexBuffer.UV2Kind
  25183. * - VertexBuffer.UV3Kind
  25184. * - VertexBuffer.UV4Kind
  25185. * - VertexBuffer.UV5Kind
  25186. * - VertexBuffer.UV6Kind
  25187. * - VertexBuffer.ColorKind
  25188. * - VertexBuffer.MatricesIndicesKind
  25189. * - VertexBuffer.MatricesIndicesExtraKind
  25190. * - VertexBuffer.MatricesWeightsKind
  25191. * - VertexBuffer.MatricesWeightsExtraKind
  25192. * @param data defines the data source
  25193. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25194. * @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)
  25195. * @returns the current mesh
  25196. */
  25197. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25198. /**
  25199. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25200. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25201. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25202. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25203. * @returns the current mesh
  25204. */
  25205. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25206. /**
  25207. * Creates a un-shared specific occurence of the geometry for the mesh.
  25208. * @returns the current mesh
  25209. */
  25210. makeGeometryUnique(): Mesh;
  25211. /**
  25212. * Set the index buffer of this mesh
  25213. * @param indices defines the source data
  25214. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25215. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25216. * @returns the current mesh
  25217. */
  25218. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25219. /**
  25220. * Update the current index buffer
  25221. * @param indices defines the source data
  25222. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25223. * @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)
  25224. * @returns the current mesh
  25225. */
  25226. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25227. /**
  25228. * Invert the geometry to move from a right handed system to a left handed one.
  25229. * @returns the current mesh
  25230. */
  25231. toLeftHanded(): Mesh;
  25232. /** @hidden */
  25233. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25234. /** @hidden */
  25235. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25236. /**
  25237. * Registers for this mesh a javascript function called just before the rendering process
  25238. * @param func defines the function to call before rendering this mesh
  25239. * @returns the current mesh
  25240. */
  25241. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25242. /**
  25243. * Disposes a previously registered javascript function called before the rendering
  25244. * @param func defines the function to remove
  25245. * @returns the current mesh
  25246. */
  25247. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25248. /**
  25249. * Registers for this mesh a javascript function called just after the rendering is complete
  25250. * @param func defines the function to call after rendering this mesh
  25251. * @returns the current mesh
  25252. */
  25253. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25254. /**
  25255. * Disposes a previously registered javascript function called after the rendering.
  25256. * @param func defines the function to remove
  25257. * @returns the current mesh
  25258. */
  25259. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25260. /** @hidden */
  25261. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25262. /** @hidden */
  25263. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25264. /** @hidden */
  25265. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25266. /** @hidden */
  25267. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25268. /** @hidden */
  25269. _rebuild(): void;
  25270. /** @hidden */
  25271. _freeze(): void;
  25272. /** @hidden */
  25273. _unFreeze(): void;
  25274. /**
  25275. * 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
  25276. * @param subMesh defines the subMesh to render
  25277. * @param enableAlphaMode defines if alpha mode can be changed
  25278. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25279. * @returns the current mesh
  25280. */
  25281. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25282. private _onBeforeDraw;
  25283. /**
  25284. * Renormalize the mesh and patch it up if there are no weights
  25285. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25286. * However in the case of zero weights then we set just a single influence to 1.
  25287. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25288. */
  25289. cleanMatrixWeights(): void;
  25290. private normalizeSkinFourWeights;
  25291. private normalizeSkinWeightsAndExtra;
  25292. /**
  25293. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25294. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25295. * the user know there was an issue with importing the mesh
  25296. * @returns a validation object with skinned, valid and report string
  25297. */
  25298. validateSkinning(): {
  25299. skinned: boolean;
  25300. valid: boolean;
  25301. report: string;
  25302. };
  25303. /** @hidden */
  25304. _checkDelayState(): Mesh;
  25305. private _queueLoad;
  25306. /**
  25307. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25308. * A mesh is in the frustum if its bounding box intersects the frustum
  25309. * @param frustumPlanes defines the frustum to test
  25310. * @returns true if the mesh is in the frustum planes
  25311. */
  25312. isInFrustum(frustumPlanes: Plane[]): boolean;
  25313. /**
  25314. * Sets the mesh material by the material or multiMaterial `id` property
  25315. * @param id is a string identifying the material or the multiMaterial
  25316. * @returns the current mesh
  25317. */
  25318. setMaterialByID(id: string): Mesh;
  25319. /**
  25320. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25321. * @returns an array of IAnimatable
  25322. */
  25323. getAnimatables(): IAnimatable[];
  25324. /**
  25325. * Modifies the mesh geometry according to the passed transformation matrix.
  25326. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25327. * The mesh normals are modified using the same transformation.
  25328. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25329. * @param transform defines the transform matrix to use
  25330. * @see http://doc.babylonjs.com/resources/baking_transformations
  25331. * @returns the current mesh
  25332. */
  25333. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25334. /**
  25335. * Modifies the mesh geometry according to its own current World Matrix.
  25336. * The mesh World Matrix is then reset.
  25337. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25338. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25339. * @see http://doc.babylonjs.com/resources/baking_transformations
  25340. * @returns the current mesh
  25341. */
  25342. bakeCurrentTransformIntoVertices(): Mesh;
  25343. /** @hidden */
  25344. get _positions(): Nullable<Vector3[]>;
  25345. /** @hidden */
  25346. _resetPointsArrayCache(): Mesh;
  25347. /** @hidden */
  25348. _generatePointsArray(): boolean;
  25349. /**
  25350. * Returns a new Mesh object generated from the current mesh properties.
  25351. * This method must not get confused with createInstance()
  25352. * @param name is a string, the name given to the new mesh
  25353. * @param newParent can be any Node object (default `null`)
  25354. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25355. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25356. * @returns a new mesh
  25357. */
  25358. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25359. /**
  25360. * Releases resources associated with this mesh.
  25361. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25362. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25363. */
  25364. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25365. /** @hidden */
  25366. _disposeInstanceSpecificData(): void;
  25367. /**
  25368. * Modifies the mesh geometry according to a displacement map.
  25369. * 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.
  25370. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25371. * @param url is a string, the URL from the image file is to be downloaded.
  25372. * @param minHeight is the lower limit of the displacement.
  25373. * @param maxHeight is the upper limit of the displacement.
  25374. * @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.
  25375. * @param uvOffset is an optional vector2 used to offset UV.
  25376. * @param uvScale is an optional vector2 used to scale UV.
  25377. * @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.
  25378. * @returns the Mesh.
  25379. */
  25380. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25381. /**
  25382. * Modifies the mesh geometry according to a displacementMap buffer.
  25383. * 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.
  25384. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25385. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25386. * @param heightMapWidth is the width of the buffer image.
  25387. * @param heightMapHeight is the height of the buffer image.
  25388. * @param minHeight is the lower limit of the displacement.
  25389. * @param maxHeight is the upper limit of the displacement.
  25390. * @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.
  25391. * @param uvOffset is an optional vector2 used to offset UV.
  25392. * @param uvScale is an optional vector2 used to scale UV.
  25393. * @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.
  25394. * @returns the Mesh.
  25395. */
  25396. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25397. /**
  25398. * Modify the mesh to get a flat shading rendering.
  25399. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25400. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25401. * @returns current mesh
  25402. */
  25403. convertToFlatShadedMesh(): Mesh;
  25404. /**
  25405. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25406. * In other words, more vertices, no more indices and a single bigger VBO.
  25407. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25408. * @returns current mesh
  25409. */
  25410. convertToUnIndexedMesh(): Mesh;
  25411. /**
  25412. * Inverses facet orientations.
  25413. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25414. * @param flipNormals will also inverts the normals
  25415. * @returns current mesh
  25416. */
  25417. flipFaces(flipNormals?: boolean): Mesh;
  25418. /**
  25419. * Increase the number of facets and hence vertices in a mesh
  25420. * Vertex normals are interpolated from existing vertex normals
  25421. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25422. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25423. */
  25424. increaseVertices(numberPerEdge: number): void;
  25425. /**
  25426. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25427. * This will undo any application of covertToFlatShadedMesh
  25428. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25429. */
  25430. forceSharedVertices(): void;
  25431. /** @hidden */
  25432. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25433. /** @hidden */
  25434. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25435. /**
  25436. * Creates a new InstancedMesh object from the mesh model.
  25437. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25438. * @param name defines the name of the new instance
  25439. * @returns a new InstancedMesh
  25440. */
  25441. createInstance(name: string): InstancedMesh;
  25442. /**
  25443. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25444. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25445. * @returns the current mesh
  25446. */
  25447. synchronizeInstances(): Mesh;
  25448. /**
  25449. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25450. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25451. * This should be used together with the simplification to avoid disappearing triangles.
  25452. * @param successCallback an optional success callback to be called after the optimization finished.
  25453. * @returns the current mesh
  25454. */
  25455. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25456. /**
  25457. * Serialize current mesh
  25458. * @param serializationObject defines the object which will receive the serialization data
  25459. */
  25460. serialize(serializationObject: any): void;
  25461. /** @hidden */
  25462. _syncGeometryWithMorphTargetManager(): void;
  25463. /** @hidden */
  25464. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25465. /**
  25466. * Returns a new Mesh object parsed from the source provided.
  25467. * @param parsedMesh is the source
  25468. * @param scene defines the hosting scene
  25469. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25470. * @returns a new Mesh
  25471. */
  25472. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25473. /**
  25474. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25475. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25476. * @param name defines the name of the mesh to create
  25477. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25478. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25479. * @param closePath creates a seam between the first and the last points of each path of the path array
  25480. * @param offset is taken in account only if the `pathArray` is containing a single path
  25481. * @param scene defines the hosting scene
  25482. * @param updatable defines if the mesh must be flagged as updatable
  25483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25484. * @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)
  25485. * @returns a new Mesh
  25486. */
  25487. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25488. /**
  25489. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25490. * @param name defines the name of the mesh to create
  25491. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25492. * @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
  25493. * @param scene defines the hosting scene
  25494. * @param updatable defines if the mesh must be flagged as updatable
  25495. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25496. * @returns a new Mesh
  25497. */
  25498. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25499. /**
  25500. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25501. * @param name defines the name of the mesh to create
  25502. * @param size sets the size (float) of each box side (default 1)
  25503. * @param scene defines the hosting scene
  25504. * @param updatable defines if the mesh must be flagged as updatable
  25505. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25506. * @returns a new Mesh
  25507. */
  25508. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25509. /**
  25510. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25511. * @param name defines the name of the mesh to create
  25512. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25513. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25514. * @param scene defines the hosting scene
  25515. * @param updatable defines if the mesh must be flagged as updatable
  25516. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25517. * @returns a new Mesh
  25518. */
  25519. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25520. /**
  25521. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25522. * @param name defines the name of the mesh to create
  25523. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25524. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25525. * @param scene defines the hosting scene
  25526. * @returns a new Mesh
  25527. */
  25528. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25529. /**
  25530. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25531. * @param name defines the name of the mesh to create
  25532. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25533. * @param diameterTop set the top cap diameter (floats, default 1)
  25534. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25535. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25536. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25537. * @param scene defines the hosting scene
  25538. * @param updatable defines if the mesh must be flagged as updatable
  25539. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25540. * @returns a new Mesh
  25541. */
  25542. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25543. /**
  25544. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25545. * @param name defines the name of the mesh to create
  25546. * @param diameter sets the diameter size (float) of the torus (default 1)
  25547. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25548. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25549. * @param scene defines the hosting scene
  25550. * @param updatable defines if the mesh must be flagged as updatable
  25551. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25552. * @returns a new Mesh
  25553. */
  25554. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25555. /**
  25556. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25557. * @param name defines the name of the mesh to create
  25558. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25559. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25560. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25561. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25562. * @param p the number of windings on X axis (positive integers, default 2)
  25563. * @param q the number of windings on Y axis (positive integers, default 3)
  25564. * @param scene defines the hosting scene
  25565. * @param updatable defines if the mesh must be flagged as updatable
  25566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25567. * @returns a new Mesh
  25568. */
  25569. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25570. /**
  25571. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25572. * @param name defines the name of the mesh to create
  25573. * @param points is an array successive Vector3
  25574. * @param scene defines the hosting scene
  25575. * @param updatable defines if the mesh must be flagged as updatable
  25576. * @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).
  25577. * @returns a new Mesh
  25578. */
  25579. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25580. /**
  25581. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25582. * @param name defines the name of the mesh to create
  25583. * @param points is an array successive Vector3
  25584. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25585. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25586. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25587. * @param scene defines the hosting scene
  25588. * @param updatable defines if the mesh must be flagged as updatable
  25589. * @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)
  25590. * @returns a new Mesh
  25591. */
  25592. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25593. /**
  25594. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25595. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25596. * 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.
  25597. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25598. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25599. * Remember you can only change the shape positions, not their number when updating a polygon.
  25600. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25601. * @param name defines the name of the mesh to create
  25602. * @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
  25603. * @param scene defines the hosting scene
  25604. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25605. * @param updatable defines if the mesh must be flagged as updatable
  25606. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25607. * @param earcutInjection can be used to inject your own earcut reference
  25608. * @returns a new Mesh
  25609. */
  25610. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25611. /**
  25612. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25613. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25614. * @param name defines the name of the mesh to create
  25615. * @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
  25616. * @param depth defines the height of extrusion
  25617. * @param scene defines the hosting scene
  25618. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25619. * @param updatable defines if the mesh must be flagged as updatable
  25620. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25621. * @param earcutInjection can be used to inject your own earcut reference
  25622. * @returns a new Mesh
  25623. */
  25624. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25625. /**
  25626. * Creates an extruded shape mesh.
  25627. * 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
  25628. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25629. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25630. * @param name defines the name of the mesh to create
  25631. * @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
  25632. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25633. * @param scale is the value to scale the shape
  25634. * @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
  25635. * @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
  25636. * @param scene defines the hosting scene
  25637. * @param updatable defines if the mesh must be flagged as updatable
  25638. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25639. * @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)
  25640. * @returns a new Mesh
  25641. */
  25642. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25643. /**
  25644. * Creates an custom extruded shape mesh.
  25645. * The custom extrusion is a parametric shape.
  25646. * It has no predefined shape. Its final shape will depend on the input parameters.
  25647. * Please consider using the same method from the MeshBuilder class instead
  25648. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25649. * @param name defines the name of the mesh to create
  25650. * @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
  25651. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25652. * @param scaleFunction is a custom Javascript function called on each path point
  25653. * @param rotationFunction is a custom Javascript function called on each path point
  25654. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25655. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25656. * @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
  25657. * @param scene defines the hosting scene
  25658. * @param updatable defines if the mesh must be flagged as updatable
  25659. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25660. * @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)
  25661. * @returns a new Mesh
  25662. */
  25663. 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;
  25664. /**
  25665. * Creates lathe mesh.
  25666. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25667. * Please consider using the same method from the MeshBuilder class instead
  25668. * @param name defines the name of the mesh to create
  25669. * @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
  25670. * @param radius is the radius value of the lathe
  25671. * @param tessellation is the side number of the lathe.
  25672. * @param scene defines the hosting scene
  25673. * @param updatable defines if the mesh must be flagged as updatable
  25674. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25675. * @returns a new Mesh
  25676. */
  25677. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25678. /**
  25679. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25680. * @param name defines the name of the mesh to create
  25681. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25682. * @param scene defines the hosting scene
  25683. * @param updatable defines if the mesh must be flagged as updatable
  25684. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25685. * @returns a new Mesh
  25686. */
  25687. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25688. /**
  25689. * Creates a ground mesh.
  25690. * Please consider using the same method from the MeshBuilder class instead
  25691. * @param name defines the name of the mesh to create
  25692. * @param width set the width of the ground
  25693. * @param height set the height of the ground
  25694. * @param subdivisions sets the number of subdivisions per side
  25695. * @param scene defines the hosting scene
  25696. * @param updatable defines if the mesh must be flagged as updatable
  25697. * @returns a new Mesh
  25698. */
  25699. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25700. /**
  25701. * Creates a tiled ground mesh.
  25702. * Please consider using the same method from the MeshBuilder class instead
  25703. * @param name defines the name of the mesh to create
  25704. * @param xmin set the ground minimum X coordinate
  25705. * @param zmin set the ground minimum Y coordinate
  25706. * @param xmax set the ground maximum X coordinate
  25707. * @param zmax set the ground maximum Z coordinate
  25708. * @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
  25709. * @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
  25710. * @param scene defines the hosting scene
  25711. * @param updatable defines if the mesh must be flagged as updatable
  25712. * @returns a new Mesh
  25713. */
  25714. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25715. w: number;
  25716. h: number;
  25717. }, precision: {
  25718. w: number;
  25719. h: number;
  25720. }, scene: Scene, updatable?: boolean): Mesh;
  25721. /**
  25722. * Creates a ground mesh from a height map.
  25723. * Please consider using the same method from the MeshBuilder class instead
  25724. * @see http://doc.babylonjs.com/babylon101/height_map
  25725. * @param name defines the name of the mesh to create
  25726. * @param url sets the URL of the height map image resource
  25727. * @param width set the ground width size
  25728. * @param height set the ground height size
  25729. * @param subdivisions sets the number of subdivision per side
  25730. * @param minHeight is the minimum altitude on the ground
  25731. * @param maxHeight is the maximum altitude on the ground
  25732. * @param scene defines the hosting scene
  25733. * @param updatable defines if the mesh must be flagged as updatable
  25734. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25735. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25736. * @returns a new Mesh
  25737. */
  25738. 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;
  25739. /**
  25740. * Creates a tube mesh.
  25741. * The tube is a parametric shape.
  25742. * It has no predefined shape. Its final shape will depend on the input parameters.
  25743. * Please consider using the same method from the MeshBuilder class instead
  25744. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25745. * @param name defines the name of the mesh to create
  25746. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25747. * @param radius sets the tube radius size
  25748. * @param tessellation is the number of sides on the tubular surface
  25749. * @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
  25750. * @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
  25751. * @param scene defines the hosting scene
  25752. * @param updatable defines if the mesh must be flagged as updatable
  25753. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25754. * @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)
  25755. * @returns a new Mesh
  25756. */
  25757. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25758. (i: number, distance: number): number;
  25759. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25760. /**
  25761. * Creates a polyhedron mesh.
  25762. * Please consider using the same method from the MeshBuilder class instead.
  25763. * * 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
  25764. * * The parameter `size` (positive float, default 1) sets the polygon size
  25765. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25766. * * 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`
  25767. * * 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
  25768. * * 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)`)
  25769. * * 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
  25770. * * 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
  25771. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25772. * * If you create a double-sided mesh, you can choose what parts of 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
  25773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25774. * @param name defines the name of the mesh to create
  25775. * @param options defines the options used to create the mesh
  25776. * @param scene defines the hosting scene
  25777. * @returns a new Mesh
  25778. */
  25779. static CreatePolyhedron(name: string, options: {
  25780. type?: number;
  25781. size?: number;
  25782. sizeX?: number;
  25783. sizeY?: number;
  25784. sizeZ?: number;
  25785. custom?: any;
  25786. faceUV?: Vector4[];
  25787. faceColors?: Color4[];
  25788. updatable?: boolean;
  25789. sideOrientation?: number;
  25790. }, scene: Scene): Mesh;
  25791. /**
  25792. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25793. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25794. * * 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`)
  25795. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25796. * * 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
  25797. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25798. * * If you create a double-sided mesh, you can choose what parts of 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
  25799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25800. * @param name defines the name of the mesh
  25801. * @param options defines the options used to create the mesh
  25802. * @param scene defines the hosting scene
  25803. * @returns a new Mesh
  25804. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25805. */
  25806. static CreateIcoSphere(name: string, options: {
  25807. radius?: number;
  25808. flat?: boolean;
  25809. subdivisions?: number;
  25810. sideOrientation?: number;
  25811. updatable?: boolean;
  25812. }, scene: Scene): Mesh;
  25813. /**
  25814. * Creates a decal mesh.
  25815. * Please consider using the same method from the MeshBuilder class instead.
  25816. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25817. * @param name defines the name of the mesh
  25818. * @param sourceMesh defines the mesh receiving the decal
  25819. * @param position sets the position of the decal in world coordinates
  25820. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25821. * @param size sets the decal scaling
  25822. * @param angle sets the angle to rotate the decal
  25823. * @returns a new Mesh
  25824. */
  25825. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25826. /**
  25827. * Prepare internal position array for software CPU skinning
  25828. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25829. */
  25830. setPositionsForCPUSkinning(): Float32Array;
  25831. /**
  25832. * Prepare internal normal array for software CPU skinning
  25833. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25834. */
  25835. setNormalsForCPUSkinning(): Float32Array;
  25836. /**
  25837. * Updates the vertex buffer by applying transformation from the bones
  25838. * @param skeleton defines the skeleton to apply to current mesh
  25839. * @returns the current mesh
  25840. */
  25841. applySkeleton(skeleton: Skeleton): Mesh;
  25842. /**
  25843. * 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
  25844. * @param meshes defines the list of meshes to scan
  25845. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25846. */
  25847. static MinMax(meshes: AbstractMesh[]): {
  25848. min: Vector3;
  25849. max: Vector3;
  25850. };
  25851. /**
  25852. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25853. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25854. * @returns a vector3
  25855. */
  25856. static Center(meshesOrMinMaxVector: {
  25857. min: Vector3;
  25858. max: Vector3;
  25859. } | AbstractMesh[]): Vector3;
  25860. /**
  25861. * Merge the array of meshes into a single mesh for performance reasons.
  25862. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25863. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25864. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25865. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25866. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25867. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25868. * @returns a new mesh
  25869. */
  25870. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25871. /** @hidden */
  25872. addInstance(instance: InstancedMesh): void;
  25873. /** @hidden */
  25874. removeInstance(instance: InstancedMesh): void;
  25875. }
  25876. }
  25877. declare module "babylonjs/Cameras/camera" {
  25878. import { SmartArray } from "babylonjs/Misc/smartArray";
  25879. import { Observable } from "babylonjs/Misc/observable";
  25880. import { Nullable } from "babylonjs/types";
  25881. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25882. import { Scene } from "babylonjs/scene";
  25883. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25884. import { Node } from "babylonjs/node";
  25885. import { Mesh } from "babylonjs/Meshes/mesh";
  25886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25887. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25888. import { Viewport } from "babylonjs/Maths/math.viewport";
  25889. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25890. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25891. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25892. import { Ray } from "babylonjs/Culling/ray";
  25893. /**
  25894. * This is the base class of all the camera used in the application.
  25895. * @see http://doc.babylonjs.com/features/cameras
  25896. */
  25897. export class Camera extends Node {
  25898. /** @hidden */
  25899. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25900. /**
  25901. * This is the default projection mode used by the cameras.
  25902. * It helps recreating a feeling of perspective and better appreciate depth.
  25903. * This is the best way to simulate real life cameras.
  25904. */
  25905. static readonly PERSPECTIVE_CAMERA: number;
  25906. /**
  25907. * This helps creating camera with an orthographic mode.
  25908. * 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.
  25909. */
  25910. static readonly ORTHOGRAPHIC_CAMERA: number;
  25911. /**
  25912. * This is the default FOV mode for perspective cameras.
  25913. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25914. */
  25915. static readonly FOVMODE_VERTICAL_FIXED: number;
  25916. /**
  25917. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25918. */
  25919. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25920. /**
  25921. * This specifies ther is no need for a camera rig.
  25922. * Basically only one eye is rendered corresponding to the camera.
  25923. */
  25924. static readonly RIG_MODE_NONE: number;
  25925. /**
  25926. * Simulates a camera Rig with one blue eye and one red eye.
  25927. * This can be use with 3d blue and red glasses.
  25928. */
  25929. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25930. /**
  25931. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25932. */
  25933. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25934. /**
  25935. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25936. */
  25937. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25938. /**
  25939. * Defines that both eyes of the camera will be rendered over under each other.
  25940. */
  25941. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25942. /**
  25943. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25944. */
  25945. static readonly RIG_MODE_VR: number;
  25946. /**
  25947. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25948. */
  25949. static readonly RIG_MODE_WEBVR: number;
  25950. /**
  25951. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25952. */
  25953. static readonly RIG_MODE_CUSTOM: number;
  25954. /**
  25955. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25956. */
  25957. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25958. /**
  25959. * Define the input manager associated with the camera.
  25960. */
  25961. inputs: CameraInputsManager<Camera>;
  25962. /** @hidden */
  25963. _position: Vector3;
  25964. /**
  25965. * Define the current local position of the camera in the scene
  25966. */
  25967. get position(): Vector3;
  25968. set position(newPosition: Vector3);
  25969. /**
  25970. * The vector the camera should consider as up.
  25971. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25972. */
  25973. upVector: Vector3;
  25974. /**
  25975. * Define the current limit on the left side for an orthographic camera
  25976. * In scene unit
  25977. */
  25978. orthoLeft: Nullable<number>;
  25979. /**
  25980. * Define the current limit on the right side for an orthographic camera
  25981. * In scene unit
  25982. */
  25983. orthoRight: Nullable<number>;
  25984. /**
  25985. * Define the current limit on the bottom side for an orthographic camera
  25986. * In scene unit
  25987. */
  25988. orthoBottom: Nullable<number>;
  25989. /**
  25990. * Define the current limit on the top side for an orthographic camera
  25991. * In scene unit
  25992. */
  25993. orthoTop: Nullable<number>;
  25994. /**
  25995. * Field Of View is set in Radians. (default is 0.8)
  25996. */
  25997. fov: number;
  25998. /**
  25999. * Define the minimum distance the camera can see from.
  26000. * This is important to note that the depth buffer are not infinite and the closer it starts
  26001. * the more your scene might encounter depth fighting issue.
  26002. */
  26003. minZ: number;
  26004. /**
  26005. * Define the maximum distance the camera can see to.
  26006. * This is important to note that the depth buffer are not infinite and the further it end
  26007. * the more your scene might encounter depth fighting issue.
  26008. */
  26009. maxZ: number;
  26010. /**
  26011. * Define the default inertia of the camera.
  26012. * This helps giving a smooth feeling to the camera movement.
  26013. */
  26014. inertia: number;
  26015. /**
  26016. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26017. */
  26018. mode: number;
  26019. /**
  26020. * Define wether the camera is intermediate.
  26021. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26022. */
  26023. isIntermediate: boolean;
  26024. /**
  26025. * Define the viewport of the camera.
  26026. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26027. */
  26028. viewport: Viewport;
  26029. /**
  26030. * Restricts the camera to viewing objects with the same layerMask.
  26031. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26032. */
  26033. layerMask: number;
  26034. /**
  26035. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26036. */
  26037. fovMode: number;
  26038. /**
  26039. * Rig mode of the camera.
  26040. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26041. * This is normally controlled byt the camera themselves as internal use.
  26042. */
  26043. cameraRigMode: number;
  26044. /**
  26045. * Defines the distance between both "eyes" in case of a RIG
  26046. */
  26047. interaxialDistance: number;
  26048. /**
  26049. * Defines if stereoscopic rendering is done side by side or over under.
  26050. */
  26051. isStereoscopicSideBySide: boolean;
  26052. /**
  26053. * 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
  26054. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26055. * else in the scene. (Eg. security camera)
  26056. *
  26057. * 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)
  26058. */
  26059. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26060. /**
  26061. * When set, the camera will render to this render target instead of the default canvas
  26062. *
  26063. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26064. */
  26065. outputRenderTarget: Nullable<RenderTargetTexture>;
  26066. /**
  26067. * Observable triggered when the camera view matrix has changed.
  26068. */
  26069. onViewMatrixChangedObservable: Observable<Camera>;
  26070. /**
  26071. * Observable triggered when the camera Projection matrix has changed.
  26072. */
  26073. onProjectionMatrixChangedObservable: Observable<Camera>;
  26074. /**
  26075. * Observable triggered when the inputs have been processed.
  26076. */
  26077. onAfterCheckInputsObservable: Observable<Camera>;
  26078. /**
  26079. * Observable triggered when reset has been called and applied to the camera.
  26080. */
  26081. onRestoreStateObservable: Observable<Camera>;
  26082. /** @hidden */
  26083. _cameraRigParams: any;
  26084. /** @hidden */
  26085. _rigCameras: Camera[];
  26086. /** @hidden */
  26087. _rigPostProcess: Nullable<PostProcess>;
  26088. protected _webvrViewMatrix: Matrix;
  26089. /** @hidden */
  26090. _skipRendering: boolean;
  26091. /** @hidden */
  26092. _projectionMatrix: Matrix;
  26093. /** @hidden */
  26094. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26095. /** @hidden */
  26096. _activeMeshes: SmartArray<AbstractMesh>;
  26097. protected _globalPosition: Vector3;
  26098. /** @hidden */
  26099. _computedViewMatrix: Matrix;
  26100. private _doNotComputeProjectionMatrix;
  26101. private _transformMatrix;
  26102. private _frustumPlanes;
  26103. private _refreshFrustumPlanes;
  26104. private _storedFov;
  26105. private _stateStored;
  26106. /**
  26107. * Instantiates a new camera object.
  26108. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26109. * @see http://doc.babylonjs.com/features/cameras
  26110. * @param name Defines the name of the camera in the scene
  26111. * @param position Defines the position of the camera
  26112. * @param scene Defines the scene the camera belongs too
  26113. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26114. */
  26115. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26116. /**
  26117. * Store current camera state (fov, position, etc..)
  26118. * @returns the camera
  26119. */
  26120. storeState(): Camera;
  26121. /**
  26122. * Restores the camera state values if it has been stored. You must call storeState() first
  26123. */
  26124. protected _restoreStateValues(): boolean;
  26125. /**
  26126. * Restored camera state. You must call storeState() first.
  26127. * @returns true if restored and false otherwise
  26128. */
  26129. restoreState(): boolean;
  26130. /**
  26131. * Gets the class name of the camera.
  26132. * @returns the class name
  26133. */
  26134. getClassName(): string;
  26135. /** @hidden */
  26136. readonly _isCamera: boolean;
  26137. /**
  26138. * Gets a string representation of the camera useful for debug purpose.
  26139. * @param fullDetails Defines that a more verboe level of logging is required
  26140. * @returns the string representation
  26141. */
  26142. toString(fullDetails?: boolean): string;
  26143. /**
  26144. * Gets the current world space position of the camera.
  26145. */
  26146. get globalPosition(): Vector3;
  26147. /**
  26148. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26149. * @returns the active meshe list
  26150. */
  26151. getActiveMeshes(): SmartArray<AbstractMesh>;
  26152. /**
  26153. * Check wether a mesh is part of the current active mesh list of the camera
  26154. * @param mesh Defines the mesh to check
  26155. * @returns true if active, false otherwise
  26156. */
  26157. isActiveMesh(mesh: Mesh): boolean;
  26158. /**
  26159. * Is this camera ready to be used/rendered
  26160. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26161. * @return true if the camera is ready
  26162. */
  26163. isReady(completeCheck?: boolean): boolean;
  26164. /** @hidden */
  26165. _initCache(): void;
  26166. /** @hidden */
  26167. _updateCache(ignoreParentClass?: boolean): void;
  26168. /** @hidden */
  26169. _isSynchronized(): boolean;
  26170. /** @hidden */
  26171. _isSynchronizedViewMatrix(): boolean;
  26172. /** @hidden */
  26173. _isSynchronizedProjectionMatrix(): boolean;
  26174. /**
  26175. * Attach the input controls to a specific dom element to get the input from.
  26176. * @param element Defines the element the controls should be listened from
  26177. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26178. */
  26179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26180. /**
  26181. * Detach the current controls from the specified dom element.
  26182. * @param element Defines the element to stop listening the inputs from
  26183. */
  26184. detachControl(element: HTMLElement): void;
  26185. /**
  26186. * Update the camera state according to the different inputs gathered during the frame.
  26187. */
  26188. update(): void;
  26189. /** @hidden */
  26190. _checkInputs(): void;
  26191. /** @hidden */
  26192. get rigCameras(): Camera[];
  26193. /**
  26194. * Gets the post process used by the rig cameras
  26195. */
  26196. get rigPostProcess(): Nullable<PostProcess>;
  26197. /**
  26198. * Internal, gets the first post proces.
  26199. * @returns the first post process to be run on this camera.
  26200. */
  26201. _getFirstPostProcess(): Nullable<PostProcess>;
  26202. private _cascadePostProcessesToRigCams;
  26203. /**
  26204. * Attach a post process to the camera.
  26205. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26206. * @param postProcess The post process to attach to the camera
  26207. * @param insertAt The position of the post process in case several of them are in use in the scene
  26208. * @returns the position the post process has been inserted at
  26209. */
  26210. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26211. /**
  26212. * Detach a post process to the camera.
  26213. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26214. * @param postProcess The post process to detach from the camera
  26215. */
  26216. detachPostProcess(postProcess: PostProcess): void;
  26217. /**
  26218. * Gets the current world matrix of the camera
  26219. */
  26220. getWorldMatrix(): Matrix;
  26221. /** @hidden */
  26222. _getViewMatrix(): Matrix;
  26223. /**
  26224. * Gets the current view matrix of the camera.
  26225. * @param force forces the camera to recompute the matrix without looking at the cached state
  26226. * @returns the view matrix
  26227. */
  26228. getViewMatrix(force?: boolean): Matrix;
  26229. /**
  26230. * Freeze the projection matrix.
  26231. * It will prevent the cache check of the camera projection compute and can speed up perf
  26232. * if no parameter of the camera are meant to change
  26233. * @param projection Defines manually a projection if necessary
  26234. */
  26235. freezeProjectionMatrix(projection?: Matrix): void;
  26236. /**
  26237. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26238. */
  26239. unfreezeProjectionMatrix(): void;
  26240. /**
  26241. * Gets the current projection matrix of the camera.
  26242. * @param force forces the camera to recompute the matrix without looking at the cached state
  26243. * @returns the projection matrix
  26244. */
  26245. getProjectionMatrix(force?: boolean): Matrix;
  26246. /**
  26247. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26248. * @returns a Matrix
  26249. */
  26250. getTransformationMatrix(): Matrix;
  26251. private _updateFrustumPlanes;
  26252. /**
  26253. * Checks if a cullable object (mesh...) is in the camera frustum
  26254. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26255. * @param target The object to check
  26256. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26257. * @returns true if the object is in frustum otherwise false
  26258. */
  26259. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26260. /**
  26261. * Checks if a cullable object (mesh...) is in the camera frustum
  26262. * Unlike isInFrustum this cheks the full bounding box
  26263. * @param target The object to check
  26264. * @returns true if the object is in frustum otherwise false
  26265. */
  26266. isCompletelyInFrustum(target: ICullable): boolean;
  26267. /**
  26268. * Gets a ray in the forward direction from the camera.
  26269. * @param length Defines the length of the ray to create
  26270. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26271. * @param origin Defines the start point of the ray which defaults to the camera position
  26272. * @returns the forward ray
  26273. */
  26274. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26275. /**
  26276. * Releases resources associated with this node.
  26277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26279. */
  26280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26281. /** @hidden */
  26282. _isLeftCamera: boolean;
  26283. /**
  26284. * Gets the left camera of a rig setup in case of Rigged Camera
  26285. */
  26286. get isLeftCamera(): boolean;
  26287. /** @hidden */
  26288. _isRightCamera: boolean;
  26289. /**
  26290. * Gets the right camera of a rig setup in case of Rigged Camera
  26291. */
  26292. get isRightCamera(): boolean;
  26293. /**
  26294. * Gets the left camera of a rig setup in case of Rigged Camera
  26295. */
  26296. get leftCamera(): Nullable<FreeCamera>;
  26297. /**
  26298. * Gets the right camera of a rig setup in case of Rigged Camera
  26299. */
  26300. get rightCamera(): Nullable<FreeCamera>;
  26301. /**
  26302. * Gets the left camera target of a rig setup in case of Rigged Camera
  26303. * @returns the target position
  26304. */
  26305. getLeftTarget(): Nullable<Vector3>;
  26306. /**
  26307. * Gets the right camera target of a rig setup in case of Rigged Camera
  26308. * @returns the target position
  26309. */
  26310. getRightTarget(): Nullable<Vector3>;
  26311. /**
  26312. * @hidden
  26313. */
  26314. setCameraRigMode(mode: number, rigParams: any): void;
  26315. /** @hidden */
  26316. static _setStereoscopicRigMode(camera: Camera): void;
  26317. /** @hidden */
  26318. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26319. /** @hidden */
  26320. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26321. /** @hidden */
  26322. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26323. /** @hidden */
  26324. _getVRProjectionMatrix(): Matrix;
  26325. protected _updateCameraRotationMatrix(): void;
  26326. protected _updateWebVRCameraRotationMatrix(): void;
  26327. /**
  26328. * This function MUST be overwritten by the different WebVR cameras available.
  26329. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26330. * @hidden
  26331. */
  26332. _getWebVRProjectionMatrix(): Matrix;
  26333. /**
  26334. * This function MUST be overwritten by the different WebVR cameras available.
  26335. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26336. * @hidden
  26337. */
  26338. _getWebVRViewMatrix(): Matrix;
  26339. /** @hidden */
  26340. setCameraRigParameter(name: string, value: any): void;
  26341. /**
  26342. * needs to be overridden by children so sub has required properties to be copied
  26343. * @hidden
  26344. */
  26345. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26346. /**
  26347. * May need to be overridden by children
  26348. * @hidden
  26349. */
  26350. _updateRigCameras(): void;
  26351. /** @hidden */
  26352. _setupInputs(): void;
  26353. /**
  26354. * Serialiaze the camera setup to a json represention
  26355. * @returns the JSON representation
  26356. */
  26357. serialize(): any;
  26358. /**
  26359. * Clones the current camera.
  26360. * @param name The cloned camera name
  26361. * @returns the cloned camera
  26362. */
  26363. clone(name: string): Camera;
  26364. /**
  26365. * Gets the direction of the camera relative to a given local axis.
  26366. * @param localAxis Defines the reference axis to provide a relative direction.
  26367. * @return the direction
  26368. */
  26369. getDirection(localAxis: Vector3): Vector3;
  26370. /**
  26371. * Returns the current camera absolute rotation
  26372. */
  26373. get absoluteRotation(): Quaternion;
  26374. /**
  26375. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26376. * @param localAxis Defines the reference axis to provide a relative direction.
  26377. * @param result Defines the vector to store the result in
  26378. */
  26379. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26380. /**
  26381. * Gets a camera constructor for a given camera type
  26382. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26383. * @param name The name of the camera the result will be able to instantiate
  26384. * @param scene The scene the result will construct the camera in
  26385. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26386. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26387. * @returns a factory method to construc the camera
  26388. */
  26389. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26390. /**
  26391. * Compute the world matrix of the camera.
  26392. * @returns the camera world matrix
  26393. */
  26394. computeWorldMatrix(): Matrix;
  26395. /**
  26396. * Parse a JSON and creates the camera from the parsed information
  26397. * @param parsedCamera The JSON to parse
  26398. * @param scene The scene to instantiate the camera in
  26399. * @returns the newly constructed camera
  26400. */
  26401. static Parse(parsedCamera: any, scene: Scene): Camera;
  26402. }
  26403. }
  26404. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26405. import { Nullable } from "babylonjs/types";
  26406. import { Scene } from "babylonjs/scene";
  26407. import { Vector4 } from "babylonjs/Maths/math.vector";
  26408. import { Mesh } from "babylonjs/Meshes/mesh";
  26409. /**
  26410. * Class containing static functions to help procedurally build meshes
  26411. */
  26412. export class DiscBuilder {
  26413. /**
  26414. * Creates a plane polygonal mesh. By default, this is a disc
  26415. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26416. * * 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
  26417. * * 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
  26418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26421. * @param name defines the name of the mesh
  26422. * @param options defines the options used to create the mesh
  26423. * @param scene defines the hosting scene
  26424. * @returns the plane polygonal mesh
  26425. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26426. */
  26427. static CreateDisc(name: string, options: {
  26428. radius?: number;
  26429. tessellation?: number;
  26430. arc?: number;
  26431. updatable?: boolean;
  26432. sideOrientation?: number;
  26433. frontUVs?: Vector4;
  26434. backUVs?: Vector4;
  26435. }, scene?: Nullable<Scene>): Mesh;
  26436. }
  26437. }
  26438. declare module "babylonjs/Materials/fresnelParameters" {
  26439. import { Color3 } from "babylonjs/Maths/math.color";
  26440. /**
  26441. * This represents all the required information to add a fresnel effect on a material:
  26442. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26443. */
  26444. export class FresnelParameters {
  26445. private _isEnabled;
  26446. /**
  26447. * Define if the fresnel effect is enable or not.
  26448. */
  26449. get isEnabled(): boolean;
  26450. set isEnabled(value: boolean);
  26451. /**
  26452. * Define the color used on edges (grazing angle)
  26453. */
  26454. leftColor: Color3;
  26455. /**
  26456. * Define the color used on center
  26457. */
  26458. rightColor: Color3;
  26459. /**
  26460. * Define bias applied to computed fresnel term
  26461. */
  26462. bias: number;
  26463. /**
  26464. * Defined the power exponent applied to fresnel term
  26465. */
  26466. power: number;
  26467. /**
  26468. * Clones the current fresnel and its valuues
  26469. * @returns a clone fresnel configuration
  26470. */
  26471. clone(): FresnelParameters;
  26472. /**
  26473. * Serializes the current fresnel parameters to a JSON representation.
  26474. * @return the JSON serialization
  26475. */
  26476. serialize(): any;
  26477. /**
  26478. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26479. * @param parsedFresnelParameters Define the JSON representation
  26480. * @returns the parsed parameters
  26481. */
  26482. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26483. }
  26484. }
  26485. declare module "babylonjs/Materials/pushMaterial" {
  26486. import { Nullable } from "babylonjs/types";
  26487. import { Scene } from "babylonjs/scene";
  26488. import { Matrix } from "babylonjs/Maths/math.vector";
  26489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26490. import { Mesh } from "babylonjs/Meshes/mesh";
  26491. import { Material } from "babylonjs/Materials/material";
  26492. import { Effect } from "babylonjs/Materials/effect";
  26493. /**
  26494. * Base class of materials working in push mode in babylon JS
  26495. * @hidden
  26496. */
  26497. export class PushMaterial extends Material {
  26498. protected _activeEffect: Effect;
  26499. protected _normalMatrix: Matrix;
  26500. /**
  26501. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26502. * This means that the material can keep using a previous shader while a new one is being compiled.
  26503. * This is mostly used when shader parallel compilation is supported (true by default)
  26504. */
  26505. allowShaderHotSwapping: boolean;
  26506. constructor(name: string, scene: Scene);
  26507. getEffect(): Effect;
  26508. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26509. /**
  26510. * Binds the given world matrix to the active effect
  26511. *
  26512. * @param world the matrix to bind
  26513. */
  26514. bindOnlyWorldMatrix(world: Matrix): void;
  26515. /**
  26516. * Binds the given normal matrix to the active effect
  26517. *
  26518. * @param normalMatrix the matrix to bind
  26519. */
  26520. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26521. bind(world: Matrix, mesh?: Mesh): void;
  26522. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26523. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26524. }
  26525. }
  26526. declare module "babylonjs/Materials/materialFlags" {
  26527. /**
  26528. * This groups all the flags used to control the materials channel.
  26529. */
  26530. export class MaterialFlags {
  26531. private static _DiffuseTextureEnabled;
  26532. /**
  26533. * Are diffuse textures enabled in the application.
  26534. */
  26535. static get DiffuseTextureEnabled(): boolean;
  26536. static set DiffuseTextureEnabled(value: boolean);
  26537. private static _AmbientTextureEnabled;
  26538. /**
  26539. * Are ambient textures enabled in the application.
  26540. */
  26541. static get AmbientTextureEnabled(): boolean;
  26542. static set AmbientTextureEnabled(value: boolean);
  26543. private static _OpacityTextureEnabled;
  26544. /**
  26545. * Are opacity textures enabled in the application.
  26546. */
  26547. static get OpacityTextureEnabled(): boolean;
  26548. static set OpacityTextureEnabled(value: boolean);
  26549. private static _ReflectionTextureEnabled;
  26550. /**
  26551. * Are reflection textures enabled in the application.
  26552. */
  26553. static get ReflectionTextureEnabled(): boolean;
  26554. static set ReflectionTextureEnabled(value: boolean);
  26555. private static _EmissiveTextureEnabled;
  26556. /**
  26557. * Are emissive textures enabled in the application.
  26558. */
  26559. static get EmissiveTextureEnabled(): boolean;
  26560. static set EmissiveTextureEnabled(value: boolean);
  26561. private static _SpecularTextureEnabled;
  26562. /**
  26563. * Are specular textures enabled in the application.
  26564. */
  26565. static get SpecularTextureEnabled(): boolean;
  26566. static set SpecularTextureEnabled(value: boolean);
  26567. private static _BumpTextureEnabled;
  26568. /**
  26569. * Are bump textures enabled in the application.
  26570. */
  26571. static get BumpTextureEnabled(): boolean;
  26572. static set BumpTextureEnabled(value: boolean);
  26573. private static _LightmapTextureEnabled;
  26574. /**
  26575. * Are lightmap textures enabled in the application.
  26576. */
  26577. static get LightmapTextureEnabled(): boolean;
  26578. static set LightmapTextureEnabled(value: boolean);
  26579. private static _RefractionTextureEnabled;
  26580. /**
  26581. * Are refraction textures enabled in the application.
  26582. */
  26583. static get RefractionTextureEnabled(): boolean;
  26584. static set RefractionTextureEnabled(value: boolean);
  26585. private static _ColorGradingTextureEnabled;
  26586. /**
  26587. * Are color grading textures enabled in the application.
  26588. */
  26589. static get ColorGradingTextureEnabled(): boolean;
  26590. static set ColorGradingTextureEnabled(value: boolean);
  26591. private static _FresnelEnabled;
  26592. /**
  26593. * Are fresnels enabled in the application.
  26594. */
  26595. static get FresnelEnabled(): boolean;
  26596. static set FresnelEnabled(value: boolean);
  26597. private static _ClearCoatTextureEnabled;
  26598. /**
  26599. * Are clear coat textures enabled in the application.
  26600. */
  26601. static get ClearCoatTextureEnabled(): boolean;
  26602. static set ClearCoatTextureEnabled(value: boolean);
  26603. private static _ClearCoatBumpTextureEnabled;
  26604. /**
  26605. * Are clear coat bump textures enabled in the application.
  26606. */
  26607. static get ClearCoatBumpTextureEnabled(): boolean;
  26608. static set ClearCoatBumpTextureEnabled(value: boolean);
  26609. private static _ClearCoatTintTextureEnabled;
  26610. /**
  26611. * Are clear coat tint textures enabled in the application.
  26612. */
  26613. static get ClearCoatTintTextureEnabled(): boolean;
  26614. static set ClearCoatTintTextureEnabled(value: boolean);
  26615. private static _SheenTextureEnabled;
  26616. /**
  26617. * Are sheen textures enabled in the application.
  26618. */
  26619. static get SheenTextureEnabled(): boolean;
  26620. static set SheenTextureEnabled(value: boolean);
  26621. private static _AnisotropicTextureEnabled;
  26622. /**
  26623. * Are anisotropic textures enabled in the application.
  26624. */
  26625. static get AnisotropicTextureEnabled(): boolean;
  26626. static set AnisotropicTextureEnabled(value: boolean);
  26627. private static _ThicknessTextureEnabled;
  26628. /**
  26629. * Are thickness textures enabled in the application.
  26630. */
  26631. static get ThicknessTextureEnabled(): boolean;
  26632. static set ThicknessTextureEnabled(value: boolean);
  26633. }
  26634. }
  26635. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26636. /** @hidden */
  26637. export var defaultFragmentDeclaration: {
  26638. name: string;
  26639. shader: string;
  26640. };
  26641. }
  26642. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26643. /** @hidden */
  26644. export var defaultUboDeclaration: {
  26645. name: string;
  26646. shader: string;
  26647. };
  26648. }
  26649. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26650. /** @hidden */
  26651. export var lightFragmentDeclaration: {
  26652. name: string;
  26653. shader: string;
  26654. };
  26655. }
  26656. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26657. /** @hidden */
  26658. export var lightUboDeclaration: {
  26659. name: string;
  26660. shader: string;
  26661. };
  26662. }
  26663. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26664. /** @hidden */
  26665. export var lightsFragmentFunctions: {
  26666. name: string;
  26667. shader: string;
  26668. };
  26669. }
  26670. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26671. /** @hidden */
  26672. export var shadowsFragmentFunctions: {
  26673. name: string;
  26674. shader: string;
  26675. };
  26676. }
  26677. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26678. /** @hidden */
  26679. export var fresnelFunction: {
  26680. name: string;
  26681. shader: string;
  26682. };
  26683. }
  26684. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26685. /** @hidden */
  26686. export var reflectionFunction: {
  26687. name: string;
  26688. shader: string;
  26689. };
  26690. }
  26691. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26692. /** @hidden */
  26693. export var bumpFragmentFunctions: {
  26694. name: string;
  26695. shader: string;
  26696. };
  26697. }
  26698. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26699. /** @hidden */
  26700. export var logDepthDeclaration: {
  26701. name: string;
  26702. shader: string;
  26703. };
  26704. }
  26705. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26706. /** @hidden */
  26707. export var bumpFragment: {
  26708. name: string;
  26709. shader: string;
  26710. };
  26711. }
  26712. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26713. /** @hidden */
  26714. export var depthPrePass: {
  26715. name: string;
  26716. shader: string;
  26717. };
  26718. }
  26719. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26720. /** @hidden */
  26721. export var lightFragment: {
  26722. name: string;
  26723. shader: string;
  26724. };
  26725. }
  26726. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26727. /** @hidden */
  26728. export var logDepthFragment: {
  26729. name: string;
  26730. shader: string;
  26731. };
  26732. }
  26733. declare module "babylonjs/Shaders/default.fragment" {
  26734. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26735. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26736. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26737. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26738. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26739. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26740. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26741. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26742. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26743. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26744. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26745. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26746. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26747. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26748. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26749. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26750. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26751. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26752. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26753. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26754. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26755. /** @hidden */
  26756. export var defaultPixelShader: {
  26757. name: string;
  26758. shader: string;
  26759. };
  26760. }
  26761. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26762. /** @hidden */
  26763. export var defaultVertexDeclaration: {
  26764. name: string;
  26765. shader: string;
  26766. };
  26767. }
  26768. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26769. /** @hidden */
  26770. export var bumpVertexDeclaration: {
  26771. name: string;
  26772. shader: string;
  26773. };
  26774. }
  26775. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26776. /** @hidden */
  26777. export var bumpVertex: {
  26778. name: string;
  26779. shader: string;
  26780. };
  26781. }
  26782. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26783. /** @hidden */
  26784. export var fogVertex: {
  26785. name: string;
  26786. shader: string;
  26787. };
  26788. }
  26789. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26790. /** @hidden */
  26791. export var shadowsVertex: {
  26792. name: string;
  26793. shader: string;
  26794. };
  26795. }
  26796. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26797. /** @hidden */
  26798. export var pointCloudVertex: {
  26799. name: string;
  26800. shader: string;
  26801. };
  26802. }
  26803. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26804. /** @hidden */
  26805. export var logDepthVertex: {
  26806. name: string;
  26807. shader: string;
  26808. };
  26809. }
  26810. declare module "babylonjs/Shaders/default.vertex" {
  26811. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26812. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26813. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26814. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26815. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26816. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26817. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26818. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26819. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26820. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26821. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26822. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26823. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26824. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26825. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26826. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26827. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26828. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26829. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26830. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26831. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26832. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26833. /** @hidden */
  26834. export var defaultVertexShader: {
  26835. name: string;
  26836. shader: string;
  26837. };
  26838. }
  26839. declare module "babylonjs/Materials/standardMaterial" {
  26840. import { SmartArray } from "babylonjs/Misc/smartArray";
  26841. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26842. import { Nullable } from "babylonjs/types";
  26843. import { Scene } from "babylonjs/scene";
  26844. import { Matrix } from "babylonjs/Maths/math.vector";
  26845. import { Color3 } from "babylonjs/Maths/math.color";
  26846. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26848. import { Mesh } from "babylonjs/Meshes/mesh";
  26849. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26850. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26851. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26852. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26853. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26854. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26856. import "babylonjs/Shaders/default.fragment";
  26857. import "babylonjs/Shaders/default.vertex";
  26858. /** @hidden */
  26859. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26860. MAINUV1: boolean;
  26861. MAINUV2: boolean;
  26862. DIFFUSE: boolean;
  26863. DIFFUSEDIRECTUV: number;
  26864. AMBIENT: boolean;
  26865. AMBIENTDIRECTUV: number;
  26866. OPACITY: boolean;
  26867. OPACITYDIRECTUV: number;
  26868. OPACITYRGB: boolean;
  26869. REFLECTION: boolean;
  26870. EMISSIVE: boolean;
  26871. EMISSIVEDIRECTUV: number;
  26872. SPECULAR: boolean;
  26873. SPECULARDIRECTUV: number;
  26874. BUMP: boolean;
  26875. BUMPDIRECTUV: number;
  26876. PARALLAX: boolean;
  26877. PARALLAXOCCLUSION: boolean;
  26878. SPECULAROVERALPHA: boolean;
  26879. CLIPPLANE: boolean;
  26880. CLIPPLANE2: boolean;
  26881. CLIPPLANE3: boolean;
  26882. CLIPPLANE4: boolean;
  26883. CLIPPLANE5: boolean;
  26884. CLIPPLANE6: boolean;
  26885. ALPHATEST: boolean;
  26886. DEPTHPREPASS: boolean;
  26887. ALPHAFROMDIFFUSE: boolean;
  26888. POINTSIZE: boolean;
  26889. FOG: boolean;
  26890. SPECULARTERM: boolean;
  26891. DIFFUSEFRESNEL: boolean;
  26892. OPACITYFRESNEL: boolean;
  26893. REFLECTIONFRESNEL: boolean;
  26894. REFRACTIONFRESNEL: boolean;
  26895. EMISSIVEFRESNEL: boolean;
  26896. FRESNEL: boolean;
  26897. NORMAL: boolean;
  26898. UV1: boolean;
  26899. UV2: boolean;
  26900. VERTEXCOLOR: boolean;
  26901. VERTEXALPHA: boolean;
  26902. NUM_BONE_INFLUENCERS: number;
  26903. BonesPerMesh: number;
  26904. BONETEXTURE: boolean;
  26905. INSTANCES: boolean;
  26906. GLOSSINESS: boolean;
  26907. ROUGHNESS: boolean;
  26908. EMISSIVEASILLUMINATION: boolean;
  26909. LINKEMISSIVEWITHDIFFUSE: boolean;
  26910. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26911. LIGHTMAP: boolean;
  26912. LIGHTMAPDIRECTUV: number;
  26913. OBJECTSPACE_NORMALMAP: boolean;
  26914. USELIGHTMAPASSHADOWMAP: boolean;
  26915. REFLECTIONMAP_3D: boolean;
  26916. REFLECTIONMAP_SPHERICAL: boolean;
  26917. REFLECTIONMAP_PLANAR: boolean;
  26918. REFLECTIONMAP_CUBIC: boolean;
  26919. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26920. REFLECTIONMAP_PROJECTION: boolean;
  26921. REFLECTIONMAP_SKYBOX: boolean;
  26922. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26923. REFLECTIONMAP_EXPLICIT: boolean;
  26924. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26925. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26926. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26927. INVERTCUBICMAP: boolean;
  26928. LOGARITHMICDEPTH: boolean;
  26929. REFRACTION: boolean;
  26930. REFRACTIONMAP_3D: boolean;
  26931. REFLECTIONOVERALPHA: boolean;
  26932. TWOSIDEDLIGHTING: boolean;
  26933. SHADOWFLOAT: boolean;
  26934. MORPHTARGETS: boolean;
  26935. MORPHTARGETS_NORMAL: boolean;
  26936. MORPHTARGETS_TANGENT: boolean;
  26937. MORPHTARGETS_UV: boolean;
  26938. NUM_MORPH_INFLUENCERS: number;
  26939. NONUNIFORMSCALING: boolean;
  26940. PREMULTIPLYALPHA: boolean;
  26941. IMAGEPROCESSING: boolean;
  26942. VIGNETTE: boolean;
  26943. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26944. VIGNETTEBLENDMODEOPAQUE: boolean;
  26945. TONEMAPPING: boolean;
  26946. TONEMAPPING_ACES: boolean;
  26947. CONTRAST: boolean;
  26948. COLORCURVES: boolean;
  26949. COLORGRADING: boolean;
  26950. COLORGRADING3D: boolean;
  26951. SAMPLER3DGREENDEPTH: boolean;
  26952. SAMPLER3DBGRMAP: boolean;
  26953. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26954. MULTIVIEW: boolean;
  26955. /**
  26956. * If the reflection texture on this material is in linear color space
  26957. * @hidden
  26958. */
  26959. IS_REFLECTION_LINEAR: boolean;
  26960. /**
  26961. * If the refraction texture on this material is in linear color space
  26962. * @hidden
  26963. */
  26964. IS_REFRACTION_LINEAR: boolean;
  26965. EXPOSURE: boolean;
  26966. constructor();
  26967. setReflectionMode(modeToEnable: string): void;
  26968. }
  26969. /**
  26970. * This is the default material used in Babylon. It is the best trade off between quality
  26971. * and performances.
  26972. * @see http://doc.babylonjs.com/babylon101/materials
  26973. */
  26974. export class StandardMaterial extends PushMaterial {
  26975. private _diffuseTexture;
  26976. /**
  26977. * The basic texture of the material as viewed under a light.
  26978. */
  26979. diffuseTexture: Nullable<BaseTexture>;
  26980. private _ambientTexture;
  26981. /**
  26982. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26983. */
  26984. ambientTexture: Nullable<BaseTexture>;
  26985. private _opacityTexture;
  26986. /**
  26987. * Define the transparency of the material from a texture.
  26988. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26989. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26990. */
  26991. opacityTexture: Nullable<BaseTexture>;
  26992. private _reflectionTexture;
  26993. /**
  26994. * Define the texture used to display the reflection.
  26995. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26996. */
  26997. reflectionTexture: Nullable<BaseTexture>;
  26998. private _emissiveTexture;
  26999. /**
  27000. * Define texture of the material as if self lit.
  27001. * This will be mixed in the final result even in the absence of light.
  27002. */
  27003. emissiveTexture: Nullable<BaseTexture>;
  27004. private _specularTexture;
  27005. /**
  27006. * Define how the color and intensity of the highlight given by the light in the material.
  27007. */
  27008. specularTexture: Nullable<BaseTexture>;
  27009. private _bumpTexture;
  27010. /**
  27011. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27012. * 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.
  27013. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27014. */
  27015. bumpTexture: Nullable<BaseTexture>;
  27016. private _lightmapTexture;
  27017. /**
  27018. * Complex lighting can be computationally expensive to compute at runtime.
  27019. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27020. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27021. */
  27022. lightmapTexture: Nullable<BaseTexture>;
  27023. private _refractionTexture;
  27024. /**
  27025. * Define the texture used to display the refraction.
  27026. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27027. */
  27028. refractionTexture: Nullable<BaseTexture>;
  27029. /**
  27030. * The color of the material lit by the environmental background lighting.
  27031. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27032. */
  27033. ambientColor: Color3;
  27034. /**
  27035. * The basic color of the material as viewed under a light.
  27036. */
  27037. diffuseColor: Color3;
  27038. /**
  27039. * Define how the color and intensity of the highlight given by the light in the material.
  27040. */
  27041. specularColor: Color3;
  27042. /**
  27043. * Define the color of the material as if self lit.
  27044. * This will be mixed in the final result even in the absence of light.
  27045. */
  27046. emissiveColor: Color3;
  27047. /**
  27048. * Defines how sharp are the highlights in the material.
  27049. * The bigger the value the sharper giving a more glossy feeling to the result.
  27050. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27051. */
  27052. specularPower: number;
  27053. private _useAlphaFromDiffuseTexture;
  27054. /**
  27055. * Does the transparency come from the diffuse texture alpha channel.
  27056. */
  27057. useAlphaFromDiffuseTexture: boolean;
  27058. private _useEmissiveAsIllumination;
  27059. /**
  27060. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27061. */
  27062. useEmissiveAsIllumination: boolean;
  27063. private _linkEmissiveWithDiffuse;
  27064. /**
  27065. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27066. * the emissive level when the final color is close to one.
  27067. */
  27068. linkEmissiveWithDiffuse: boolean;
  27069. private _useSpecularOverAlpha;
  27070. /**
  27071. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27072. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27073. */
  27074. useSpecularOverAlpha: boolean;
  27075. private _useReflectionOverAlpha;
  27076. /**
  27077. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27078. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27079. */
  27080. useReflectionOverAlpha: boolean;
  27081. private _disableLighting;
  27082. /**
  27083. * Does lights from the scene impacts this material.
  27084. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27085. */
  27086. disableLighting: boolean;
  27087. private _useObjectSpaceNormalMap;
  27088. /**
  27089. * Allows using an object space normal map (instead of tangent space).
  27090. */
  27091. useObjectSpaceNormalMap: boolean;
  27092. private _useParallax;
  27093. /**
  27094. * Is parallax enabled or not.
  27095. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27096. */
  27097. useParallax: boolean;
  27098. private _useParallaxOcclusion;
  27099. /**
  27100. * Is parallax occlusion enabled or not.
  27101. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27102. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27103. */
  27104. useParallaxOcclusion: boolean;
  27105. /**
  27106. * 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.
  27107. */
  27108. parallaxScaleBias: number;
  27109. private _roughness;
  27110. /**
  27111. * Helps to define how blurry the reflections should appears in the material.
  27112. */
  27113. roughness: number;
  27114. /**
  27115. * In case of refraction, define the value of the index of refraction.
  27116. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27117. */
  27118. indexOfRefraction: number;
  27119. /**
  27120. * Invert the refraction texture alongside the y axis.
  27121. * It can be useful with procedural textures or probe for instance.
  27122. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27123. */
  27124. invertRefractionY: boolean;
  27125. /**
  27126. * Defines the alpha limits in alpha test mode.
  27127. */
  27128. alphaCutOff: number;
  27129. private _useLightmapAsShadowmap;
  27130. /**
  27131. * In case of light mapping, define whether the map contains light or shadow informations.
  27132. */
  27133. useLightmapAsShadowmap: boolean;
  27134. private _diffuseFresnelParameters;
  27135. /**
  27136. * Define the diffuse fresnel parameters of the material.
  27137. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27138. */
  27139. diffuseFresnelParameters: FresnelParameters;
  27140. private _opacityFresnelParameters;
  27141. /**
  27142. * Define the opacity fresnel parameters of the material.
  27143. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27144. */
  27145. opacityFresnelParameters: FresnelParameters;
  27146. private _reflectionFresnelParameters;
  27147. /**
  27148. * Define the reflection fresnel parameters of the material.
  27149. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27150. */
  27151. reflectionFresnelParameters: FresnelParameters;
  27152. private _refractionFresnelParameters;
  27153. /**
  27154. * Define the refraction fresnel parameters of the material.
  27155. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27156. */
  27157. refractionFresnelParameters: FresnelParameters;
  27158. private _emissiveFresnelParameters;
  27159. /**
  27160. * Define the emissive fresnel parameters of the material.
  27161. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27162. */
  27163. emissiveFresnelParameters: FresnelParameters;
  27164. private _useReflectionFresnelFromSpecular;
  27165. /**
  27166. * If true automatically deducts the fresnels values from the material specularity.
  27167. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27168. */
  27169. useReflectionFresnelFromSpecular: boolean;
  27170. private _useGlossinessFromSpecularMapAlpha;
  27171. /**
  27172. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27173. */
  27174. useGlossinessFromSpecularMapAlpha: boolean;
  27175. private _maxSimultaneousLights;
  27176. /**
  27177. * Defines the maximum number of lights that can be used in the material
  27178. */
  27179. maxSimultaneousLights: number;
  27180. private _invertNormalMapX;
  27181. /**
  27182. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27183. */
  27184. invertNormalMapX: boolean;
  27185. private _invertNormalMapY;
  27186. /**
  27187. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27188. */
  27189. invertNormalMapY: boolean;
  27190. private _twoSidedLighting;
  27191. /**
  27192. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27193. */
  27194. twoSidedLighting: boolean;
  27195. /**
  27196. * Default configuration related to image processing available in the standard Material.
  27197. */
  27198. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27199. /**
  27200. * Gets the image processing configuration used either in this material.
  27201. */
  27202. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27203. /**
  27204. * Sets the Default image processing configuration used either in the this material.
  27205. *
  27206. * If sets to null, the scene one is in use.
  27207. */
  27208. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27209. /**
  27210. * Keep track of the image processing observer to allow dispose and replace.
  27211. */
  27212. private _imageProcessingObserver;
  27213. /**
  27214. * Attaches a new image processing configuration to the Standard Material.
  27215. * @param configuration
  27216. */
  27217. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27218. /**
  27219. * Gets wether the color curves effect is enabled.
  27220. */
  27221. get cameraColorCurvesEnabled(): boolean;
  27222. /**
  27223. * Sets wether the color curves effect is enabled.
  27224. */
  27225. set cameraColorCurvesEnabled(value: boolean);
  27226. /**
  27227. * Gets wether the color grading effect is enabled.
  27228. */
  27229. get cameraColorGradingEnabled(): boolean;
  27230. /**
  27231. * Gets wether the color grading effect is enabled.
  27232. */
  27233. set cameraColorGradingEnabled(value: boolean);
  27234. /**
  27235. * Gets wether tonemapping is enabled or not.
  27236. */
  27237. get cameraToneMappingEnabled(): boolean;
  27238. /**
  27239. * Sets wether tonemapping is enabled or not
  27240. */
  27241. set cameraToneMappingEnabled(value: boolean);
  27242. /**
  27243. * The camera exposure used on this material.
  27244. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27245. * This corresponds to a photographic exposure.
  27246. */
  27247. get cameraExposure(): number;
  27248. /**
  27249. * The camera exposure used on this material.
  27250. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27251. * This corresponds to a photographic exposure.
  27252. */
  27253. set cameraExposure(value: number);
  27254. /**
  27255. * Gets The camera contrast used on this material.
  27256. */
  27257. get cameraContrast(): number;
  27258. /**
  27259. * Sets The camera contrast used on this material.
  27260. */
  27261. set cameraContrast(value: number);
  27262. /**
  27263. * Gets the Color Grading 2D Lookup Texture.
  27264. */
  27265. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27266. /**
  27267. * Sets the Color Grading 2D Lookup Texture.
  27268. */
  27269. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27270. /**
  27271. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27272. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27273. * 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;
  27274. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27275. */
  27276. get cameraColorCurves(): Nullable<ColorCurves>;
  27277. /**
  27278. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27279. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27280. * 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;
  27281. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27282. */
  27283. set cameraColorCurves(value: Nullable<ColorCurves>);
  27284. /**
  27285. * Custom callback helping to override the default shader used in the material.
  27286. */
  27287. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27288. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27289. protected _worldViewProjectionMatrix: Matrix;
  27290. protected _globalAmbientColor: Color3;
  27291. protected _useLogarithmicDepth: boolean;
  27292. protected _rebuildInParallel: boolean;
  27293. /**
  27294. * Instantiates a new standard material.
  27295. * This is the default material used in Babylon. It is the best trade off between quality
  27296. * and performances.
  27297. * @see http://doc.babylonjs.com/babylon101/materials
  27298. * @param name Define the name of the material in the scene
  27299. * @param scene Define the scene the material belong to
  27300. */
  27301. constructor(name: string, scene: Scene);
  27302. /**
  27303. * Gets a boolean indicating that current material needs to register RTT
  27304. */
  27305. get hasRenderTargetTextures(): boolean;
  27306. /**
  27307. * Gets the current class name of the material e.g. "StandardMaterial"
  27308. * Mainly use in serialization.
  27309. * @returns the class name
  27310. */
  27311. getClassName(): string;
  27312. /**
  27313. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27314. * You can try switching to logarithmic depth.
  27315. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27316. */
  27317. get useLogarithmicDepth(): boolean;
  27318. set useLogarithmicDepth(value: boolean);
  27319. /**
  27320. * Specifies if the material will require alpha blending
  27321. * @returns a boolean specifying if alpha blending is needed
  27322. */
  27323. needAlphaBlending(): boolean;
  27324. /**
  27325. * Specifies if this material should be rendered in alpha test mode
  27326. * @returns a boolean specifying if an alpha test is needed.
  27327. */
  27328. needAlphaTesting(): boolean;
  27329. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27330. /**
  27331. * Get the texture used for alpha test purpose.
  27332. * @returns the diffuse texture in case of the standard material.
  27333. */
  27334. getAlphaTestTexture(): Nullable<BaseTexture>;
  27335. /**
  27336. * Get if the submesh is ready to be used and all its information available.
  27337. * Child classes can use it to update shaders
  27338. * @param mesh defines the mesh to check
  27339. * @param subMesh defines which submesh to check
  27340. * @param useInstances specifies that instances should be used
  27341. * @returns a boolean indicating that the submesh is ready or not
  27342. */
  27343. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27344. /**
  27345. * Builds the material UBO layouts.
  27346. * Used internally during the effect preparation.
  27347. */
  27348. buildUniformLayout(): void;
  27349. /**
  27350. * Unbinds the material from the mesh
  27351. */
  27352. unbind(): void;
  27353. /**
  27354. * Binds the submesh to this material by preparing the effect and shader to draw
  27355. * @param world defines the world transformation matrix
  27356. * @param mesh defines the mesh containing the submesh
  27357. * @param subMesh defines the submesh to bind the material to
  27358. */
  27359. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27360. /**
  27361. * Get the list of animatables in the material.
  27362. * @returns the list of animatables object used in the material
  27363. */
  27364. getAnimatables(): IAnimatable[];
  27365. /**
  27366. * Gets the active textures from the material
  27367. * @returns an array of textures
  27368. */
  27369. getActiveTextures(): BaseTexture[];
  27370. /**
  27371. * Specifies if the material uses a texture
  27372. * @param texture defines the texture to check against the material
  27373. * @returns a boolean specifying if the material uses the texture
  27374. */
  27375. hasTexture(texture: BaseTexture): boolean;
  27376. /**
  27377. * Disposes the material
  27378. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27379. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27380. */
  27381. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27382. /**
  27383. * Makes a duplicate of the material, and gives it a new name
  27384. * @param name defines the new name for the duplicated material
  27385. * @returns the cloned material
  27386. */
  27387. clone(name: string): StandardMaterial;
  27388. /**
  27389. * Serializes this material in a JSON representation
  27390. * @returns the serialized material object
  27391. */
  27392. serialize(): any;
  27393. /**
  27394. * Creates a standard material from parsed material data
  27395. * @param source defines the JSON representation of the material
  27396. * @param scene defines the hosting scene
  27397. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27398. * @returns a new standard material
  27399. */
  27400. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27401. /**
  27402. * Are diffuse textures enabled in the application.
  27403. */
  27404. static get DiffuseTextureEnabled(): boolean;
  27405. static set DiffuseTextureEnabled(value: boolean);
  27406. /**
  27407. * Are ambient textures enabled in the application.
  27408. */
  27409. static get AmbientTextureEnabled(): boolean;
  27410. static set AmbientTextureEnabled(value: boolean);
  27411. /**
  27412. * Are opacity textures enabled in the application.
  27413. */
  27414. static get OpacityTextureEnabled(): boolean;
  27415. static set OpacityTextureEnabled(value: boolean);
  27416. /**
  27417. * Are reflection textures enabled in the application.
  27418. */
  27419. static get ReflectionTextureEnabled(): boolean;
  27420. static set ReflectionTextureEnabled(value: boolean);
  27421. /**
  27422. * Are emissive textures enabled in the application.
  27423. */
  27424. static get EmissiveTextureEnabled(): boolean;
  27425. static set EmissiveTextureEnabled(value: boolean);
  27426. /**
  27427. * Are specular textures enabled in the application.
  27428. */
  27429. static get SpecularTextureEnabled(): boolean;
  27430. static set SpecularTextureEnabled(value: boolean);
  27431. /**
  27432. * Are bump textures enabled in the application.
  27433. */
  27434. static get BumpTextureEnabled(): boolean;
  27435. static set BumpTextureEnabled(value: boolean);
  27436. /**
  27437. * Are lightmap textures enabled in the application.
  27438. */
  27439. static get LightmapTextureEnabled(): boolean;
  27440. static set LightmapTextureEnabled(value: boolean);
  27441. /**
  27442. * Are refraction textures enabled in the application.
  27443. */
  27444. static get RefractionTextureEnabled(): boolean;
  27445. static set RefractionTextureEnabled(value: boolean);
  27446. /**
  27447. * Are color grading textures enabled in the application.
  27448. */
  27449. static get ColorGradingTextureEnabled(): boolean;
  27450. static set ColorGradingTextureEnabled(value: boolean);
  27451. /**
  27452. * Are fresnels enabled in the application.
  27453. */
  27454. static get FresnelEnabled(): boolean;
  27455. static set FresnelEnabled(value: boolean);
  27456. }
  27457. }
  27458. declare module "babylonjs/Particles/solidParticleSystem" {
  27459. import { Nullable } from "babylonjs/types";
  27460. import { Vector3 } from "babylonjs/Maths/math.vector";
  27461. import { Mesh } from "babylonjs/Meshes/mesh";
  27462. import { Scene, IDisposable } from "babylonjs/scene";
  27463. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27464. import { Material } from "babylonjs/Materials/material";
  27465. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27466. /**
  27467. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27468. *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.
  27469. * The SPS is also a particle system. It provides some methods to manage the particles.
  27470. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27471. *
  27472. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27473. */
  27474. export class SolidParticleSystem implements IDisposable {
  27475. /**
  27476. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27477. * Example : var p = SPS.particles[i];
  27478. */
  27479. particles: SolidParticle[];
  27480. /**
  27481. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27482. */
  27483. nbParticles: number;
  27484. /**
  27485. * If the particles must ever face the camera (default false). Useful for planar particles.
  27486. */
  27487. billboard: boolean;
  27488. /**
  27489. * Recompute normals when adding a shape
  27490. */
  27491. recomputeNormals: boolean;
  27492. /**
  27493. * This a counter ofr your own usage. It's not set by any SPS functions.
  27494. */
  27495. counter: number;
  27496. /**
  27497. * The SPS name. This name is also given to the underlying mesh.
  27498. */
  27499. name: string;
  27500. /**
  27501. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27502. */
  27503. mesh: Mesh;
  27504. /**
  27505. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27506. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27507. */
  27508. vars: any;
  27509. /**
  27510. * This array is populated when the SPS is set as 'pickable'.
  27511. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27512. * Each element of this array is an object `{idx: int, faceId: int}`.
  27513. * `idx` is the picked particle index in the `SPS.particles` array
  27514. * `faceId` is the picked face index counted within this particle.
  27515. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27516. */
  27517. pickedParticles: {
  27518. idx: number;
  27519. faceId: number;
  27520. }[];
  27521. /**
  27522. * This array is populated when `enableDepthSort` is set to true.
  27523. * Each element of this array is an instance of the class DepthSortedParticle.
  27524. */
  27525. depthSortedParticles: DepthSortedParticle[];
  27526. /**
  27527. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27528. * @hidden
  27529. */
  27530. _bSphereOnly: boolean;
  27531. /**
  27532. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27533. * @hidden
  27534. */
  27535. _bSphereRadiusFactor: number;
  27536. private _scene;
  27537. private _positions;
  27538. private _indices;
  27539. private _normals;
  27540. private _colors;
  27541. private _uvs;
  27542. private _indices32;
  27543. private _positions32;
  27544. private _normals32;
  27545. private _fixedNormal32;
  27546. private _colors32;
  27547. private _uvs32;
  27548. private _index;
  27549. private _updatable;
  27550. private _pickable;
  27551. private _isVisibilityBoxLocked;
  27552. private _alwaysVisible;
  27553. private _depthSort;
  27554. private _expandable;
  27555. private _shapeCounter;
  27556. private _copy;
  27557. private _color;
  27558. private _computeParticleColor;
  27559. private _computeParticleTexture;
  27560. private _computeParticleRotation;
  27561. private _computeParticleVertex;
  27562. private _computeBoundingBox;
  27563. private _depthSortParticles;
  27564. private _camera;
  27565. private _mustUnrotateFixedNormals;
  27566. private _particlesIntersect;
  27567. private _needs32Bits;
  27568. private _isNotBuilt;
  27569. private _lastParticleId;
  27570. private _idxOfId;
  27571. private _multimaterialEnabled;
  27572. private _useModelMaterial;
  27573. private _indicesByMaterial;
  27574. private _materialIndexes;
  27575. private _depthSortFunction;
  27576. private _materialSortFunction;
  27577. private _materials;
  27578. private _multimaterial;
  27579. private _materialIndexesById;
  27580. private _defaultMaterial;
  27581. private _autoUpdateSubMeshes;
  27582. /**
  27583. * Creates a SPS (Solid Particle System) object.
  27584. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27585. * @param scene (Scene) is the scene in which the SPS is added.
  27586. * @param options defines the options of the sps e.g.
  27587. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27588. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27589. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27590. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27591. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27592. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27593. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27594. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27595. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27596. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27597. */
  27598. constructor(name: string, scene: Scene, options?: {
  27599. updatable?: boolean;
  27600. isPickable?: boolean;
  27601. enableDepthSort?: boolean;
  27602. particleIntersection?: boolean;
  27603. boundingSphereOnly?: boolean;
  27604. bSphereRadiusFactor?: number;
  27605. expandable?: boolean;
  27606. useModelMaterial?: boolean;
  27607. enableMultiMaterial?: boolean;
  27608. });
  27609. /**
  27610. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27611. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27612. * @returns the created mesh
  27613. */
  27614. buildMesh(): Mesh;
  27615. /**
  27616. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27617. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27618. * Thus the particles generated from `digest()` have their property `position` set yet.
  27619. * @param mesh ( Mesh ) is the mesh to be digested
  27620. * @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
  27621. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27622. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27623. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27624. * @returns the current SPS
  27625. */
  27626. digest(mesh: Mesh, options?: {
  27627. facetNb?: number;
  27628. number?: number;
  27629. delta?: number;
  27630. storage?: [];
  27631. }): SolidParticleSystem;
  27632. /**
  27633. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27634. * @hidden
  27635. */
  27636. private _unrotateFixedNormals;
  27637. /**
  27638. * Resets the temporary working copy particle
  27639. * @hidden
  27640. */
  27641. private _resetCopy;
  27642. /**
  27643. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27644. * @param p the current index in the positions array to be updated
  27645. * @param ind the current index in the indices array
  27646. * @param shape a Vector3 array, the shape geometry
  27647. * @param positions the positions array to be updated
  27648. * @param meshInd the shape indices array
  27649. * @param indices the indices array to be updated
  27650. * @param meshUV the shape uv array
  27651. * @param uvs the uv array to be updated
  27652. * @param meshCol the shape color array
  27653. * @param colors the color array to be updated
  27654. * @param meshNor the shape normals array
  27655. * @param normals the normals array to be updated
  27656. * @param idx the particle index
  27657. * @param idxInShape the particle index in its shape
  27658. * @param options the addShape() method passed options
  27659. * @model the particle model
  27660. * @hidden
  27661. */
  27662. private _meshBuilder;
  27663. /**
  27664. * Returns a shape Vector3 array from positions float array
  27665. * @param positions float array
  27666. * @returns a vector3 array
  27667. * @hidden
  27668. */
  27669. private _posToShape;
  27670. /**
  27671. * Returns a shapeUV array from a float uvs (array deep copy)
  27672. * @param uvs as a float array
  27673. * @returns a shapeUV array
  27674. * @hidden
  27675. */
  27676. private _uvsToShapeUV;
  27677. /**
  27678. * Adds a new particle object in the particles array
  27679. * @param idx particle index in particles array
  27680. * @param id particle id
  27681. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27682. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27683. * @param model particle ModelShape object
  27684. * @param shapeId model shape identifier
  27685. * @param idxInShape index of the particle in the current model
  27686. * @param bInfo model bounding info object
  27687. * @param storage target storage array, if any
  27688. * @hidden
  27689. */
  27690. private _addParticle;
  27691. /**
  27692. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27693. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27694. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27695. * @param nb (positive integer) the number of particles to be created from this model
  27696. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27697. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27698. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27699. * @returns the number of shapes in the system
  27700. */
  27701. addShape(mesh: Mesh, nb: number, options?: {
  27702. positionFunction?: any;
  27703. vertexFunction?: any;
  27704. storage?: [];
  27705. }): number;
  27706. /**
  27707. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27708. * @hidden
  27709. */
  27710. private _rebuildParticle;
  27711. /**
  27712. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27713. * @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.
  27714. * @returns the SPS.
  27715. */
  27716. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27717. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27718. * Returns an array with the removed particles.
  27719. * 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.
  27720. * The SPS can't be empty so at least one particle needs to remain in place.
  27721. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27722. * @param start index of the first particle to remove
  27723. * @param end index of the last particle to remove (included)
  27724. * @returns an array populated with the removed particles
  27725. */
  27726. removeParticles(start: number, end: number): SolidParticle[];
  27727. /**
  27728. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27729. * @param solidParticleArray an array populated with Solid Particles objects
  27730. * @returns the SPS
  27731. */
  27732. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27733. /**
  27734. * Creates a new particle and modifies the SPS mesh geometry :
  27735. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27736. * - calls _addParticle() to populate the particle array
  27737. * factorized code from addShape() and insertParticlesFromArray()
  27738. * @param idx particle index in the particles array
  27739. * @param i particle index in its shape
  27740. * @param modelShape particle ModelShape object
  27741. * @param shape shape vertex array
  27742. * @param meshInd shape indices array
  27743. * @param meshUV shape uv array
  27744. * @param meshCol shape color array
  27745. * @param meshNor shape normals array
  27746. * @param bbInfo shape bounding info
  27747. * @param storage target particle storage
  27748. * @options addShape() passed options
  27749. * @hidden
  27750. */
  27751. private _insertNewParticle;
  27752. /**
  27753. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27754. * This method calls `updateParticle()` for each particle of the SPS.
  27755. * For an animated SPS, it is usually called within the render loop.
  27756. * 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.
  27757. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27758. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27759. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27760. * @returns the SPS.
  27761. */
  27762. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27763. /**
  27764. * Disposes the SPS.
  27765. */
  27766. dispose(): void;
  27767. /**
  27768. * Returns a SolidParticle object from its identifier : particle.id
  27769. * @param id (integer) the particle Id
  27770. * @returns the searched particle or null if not found in the SPS.
  27771. */
  27772. getParticleById(id: number): Nullable<SolidParticle>;
  27773. /**
  27774. * Returns a new array populated with the particles having the passed shapeId.
  27775. * @param shapeId (integer) the shape identifier
  27776. * @returns a new solid particle array
  27777. */
  27778. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27779. /**
  27780. * Populates the passed array "ref" with the particles having the passed shapeId.
  27781. * @param shapeId the shape identifier
  27782. * @returns the SPS
  27783. * @param ref
  27784. */
  27785. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27786. /**
  27787. * Computes the required SubMeshes according the materials assigned to the particles.
  27788. * @returns the solid particle system.
  27789. * Does nothing if called before the SPS mesh is built.
  27790. */
  27791. computeSubMeshes(): SolidParticleSystem;
  27792. /**
  27793. * Sorts the solid particles by material when MultiMaterial is enabled.
  27794. * Updates the indices32 array.
  27795. * Updates the indicesByMaterial array.
  27796. * Updates the mesh indices array.
  27797. * @returns the SPS
  27798. * @hidden
  27799. */
  27800. private _sortParticlesByMaterial;
  27801. /**
  27802. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27803. * @hidden
  27804. */
  27805. private _setMaterialIndexesById;
  27806. /**
  27807. * Returns an array with unique values of Materials from the passed array
  27808. * @param array the material array to be checked and filtered
  27809. * @hidden
  27810. */
  27811. private _filterUniqueMaterialId;
  27812. /**
  27813. * Sets a new Standard Material as _defaultMaterial if not already set.
  27814. * @hidden
  27815. */
  27816. private _setDefaultMaterial;
  27817. /**
  27818. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27819. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27820. * @returns the SPS.
  27821. */
  27822. refreshVisibleSize(): SolidParticleSystem;
  27823. /**
  27824. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27825. * @param size the size (float) of the visibility box
  27826. * note : this doesn't lock the SPS mesh bounding box.
  27827. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27828. */
  27829. setVisibilityBox(size: number): void;
  27830. /**
  27831. * Gets whether the SPS as always visible or not
  27832. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27833. */
  27834. get isAlwaysVisible(): boolean;
  27835. /**
  27836. * Sets the SPS as always visible or not
  27837. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27838. */
  27839. set isAlwaysVisible(val: boolean);
  27840. /**
  27841. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27842. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27843. */
  27844. set isVisibilityBoxLocked(val: boolean);
  27845. /**
  27846. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27847. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27848. */
  27849. get isVisibilityBoxLocked(): boolean;
  27850. /**
  27851. * Tells to `setParticles()` to compute the particle rotations or not.
  27852. * Default value : true. The SPS is faster when it's set to false.
  27853. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27854. */
  27855. set computeParticleRotation(val: boolean);
  27856. /**
  27857. * Tells to `setParticles()` to compute the particle colors or not.
  27858. * Default value : true. The SPS is faster when it's set to false.
  27859. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27860. */
  27861. set computeParticleColor(val: boolean);
  27862. set computeParticleTexture(val: boolean);
  27863. /**
  27864. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27865. * Default value : false. The SPS is faster when it's set to false.
  27866. * Note : the particle custom vertex positions aren't stored values.
  27867. */
  27868. set computeParticleVertex(val: boolean);
  27869. /**
  27870. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27871. */
  27872. set computeBoundingBox(val: boolean);
  27873. /**
  27874. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27875. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27876. * Default : `true`
  27877. */
  27878. set depthSortParticles(val: boolean);
  27879. /**
  27880. * Gets if `setParticles()` computes the particle rotations or not.
  27881. * Default value : true. The SPS is faster when it's set to false.
  27882. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27883. */
  27884. get computeParticleRotation(): boolean;
  27885. /**
  27886. * Gets if `setParticles()` computes the particle colors or not.
  27887. * Default value : true. The SPS is faster when it's set to false.
  27888. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27889. */
  27890. get computeParticleColor(): boolean;
  27891. /**
  27892. * Gets if `setParticles()` computes the particle textures or not.
  27893. * Default value : true. The SPS is faster when it's set to false.
  27894. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27895. */
  27896. get computeParticleTexture(): boolean;
  27897. /**
  27898. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27899. * Default value : false. The SPS is faster when it's set to false.
  27900. * Note : the particle custom vertex positions aren't stored values.
  27901. */
  27902. get computeParticleVertex(): boolean;
  27903. /**
  27904. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27905. */
  27906. get computeBoundingBox(): boolean;
  27907. /**
  27908. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27909. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27910. * Default : `true`
  27911. */
  27912. get depthSortParticles(): boolean;
  27913. /**
  27914. * Gets if the SPS is created as expandable at construction time.
  27915. * Default : `false`
  27916. */
  27917. get expandable(): boolean;
  27918. /**
  27919. * Gets if the SPS supports the Multi Materials
  27920. */
  27921. get multimaterialEnabled(): boolean;
  27922. /**
  27923. * Gets if the SPS uses the model materials for its own multimaterial.
  27924. */
  27925. get useModelMaterial(): boolean;
  27926. /**
  27927. * The SPS used material array.
  27928. */
  27929. get materials(): Material[];
  27930. /**
  27931. * Sets the SPS MultiMaterial from the passed materials.
  27932. * Note : the passed array is internally copied and not used then by reference.
  27933. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27934. */
  27935. setMultiMaterial(materials: Material[]): void;
  27936. /**
  27937. * The SPS computed multimaterial object
  27938. */
  27939. get multimaterial(): MultiMaterial;
  27940. set multimaterial(mm: MultiMaterial);
  27941. /**
  27942. * If the subMeshes must be updated on the next call to setParticles()
  27943. */
  27944. get autoUpdateSubMeshes(): boolean;
  27945. set autoUpdateSubMeshes(val: boolean);
  27946. /**
  27947. * This function does nothing. It may be overwritten to set all the particle first values.
  27948. * The SPS doesn't call this function, you may have to call it by your own.
  27949. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27950. */
  27951. initParticles(): void;
  27952. /**
  27953. * This function does nothing. It may be overwritten to recycle a particle.
  27954. * The SPS doesn't call this function, you may have to call it by your own.
  27955. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27956. * @param particle The particle to recycle
  27957. * @returns the recycled particle
  27958. */
  27959. recycleParticle(particle: SolidParticle): SolidParticle;
  27960. /**
  27961. * Updates a particle : this function should be overwritten by the user.
  27962. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27963. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27964. * @example : just set a particle position or velocity and recycle conditions
  27965. * @param particle The particle to update
  27966. * @returns the updated particle
  27967. */
  27968. updateParticle(particle: SolidParticle): SolidParticle;
  27969. /**
  27970. * Updates a vertex of a particle : it can be overwritten by the user.
  27971. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27972. * @param particle the current particle
  27973. * @param vertex the current index of the current particle
  27974. * @param pt the index of the current vertex in the particle shape
  27975. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27976. * @example : just set a vertex particle position
  27977. * @returns the updated vertex
  27978. */
  27979. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27980. /**
  27981. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27982. * This does nothing and may be overwritten by the user.
  27983. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27984. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27985. * @param update the boolean update value actually passed to setParticles()
  27986. */
  27987. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27988. /**
  27989. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27990. * This will be passed three parameters.
  27991. * This does nothing and may be overwritten by the user.
  27992. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27993. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27994. * @param update the boolean update value actually passed to setParticles()
  27995. */
  27996. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27997. }
  27998. }
  27999. declare module "babylonjs/Particles/solidParticle" {
  28000. import { Nullable } from "babylonjs/types";
  28001. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28002. import { Color4 } from "babylonjs/Maths/math.color";
  28003. import { Mesh } from "babylonjs/Meshes/mesh";
  28004. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28005. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28006. import { Plane } from "babylonjs/Maths/math.plane";
  28007. import { Material } from "babylonjs/Materials/material";
  28008. /**
  28009. * Represents one particle of a solid particle system.
  28010. */
  28011. export class SolidParticle {
  28012. /**
  28013. * particle global index
  28014. */
  28015. idx: number;
  28016. /**
  28017. * particle identifier
  28018. */
  28019. id: number;
  28020. /**
  28021. * The color of the particle
  28022. */
  28023. color: Nullable<Color4>;
  28024. /**
  28025. * The world space position of the particle.
  28026. */
  28027. position: Vector3;
  28028. /**
  28029. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28030. */
  28031. rotation: Vector3;
  28032. /**
  28033. * The world space rotation quaternion of the particle.
  28034. */
  28035. rotationQuaternion: Nullable<Quaternion>;
  28036. /**
  28037. * The scaling of the particle.
  28038. */
  28039. scaling: Vector3;
  28040. /**
  28041. * The uvs of the particle.
  28042. */
  28043. uvs: Vector4;
  28044. /**
  28045. * The current speed of the particle.
  28046. */
  28047. velocity: Vector3;
  28048. /**
  28049. * The pivot point in the particle local space.
  28050. */
  28051. pivot: Vector3;
  28052. /**
  28053. * Must the particle be translated from its pivot point in its local space ?
  28054. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28055. * Default : false
  28056. */
  28057. translateFromPivot: boolean;
  28058. /**
  28059. * Is the particle active or not ?
  28060. */
  28061. alive: boolean;
  28062. /**
  28063. * Is the particle visible or not ?
  28064. */
  28065. isVisible: boolean;
  28066. /**
  28067. * Index of this particle in the global "positions" array (Internal use)
  28068. * @hidden
  28069. */
  28070. _pos: number;
  28071. /**
  28072. * @hidden Index of this particle in the global "indices" array (Internal use)
  28073. */
  28074. _ind: number;
  28075. /**
  28076. * @hidden ModelShape of this particle (Internal use)
  28077. */
  28078. _model: ModelShape;
  28079. /**
  28080. * ModelShape id of this particle
  28081. */
  28082. shapeId: number;
  28083. /**
  28084. * Index of the particle in its shape id
  28085. */
  28086. idxInShape: number;
  28087. /**
  28088. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28089. */
  28090. _modelBoundingInfo: BoundingInfo;
  28091. /**
  28092. * @hidden Particle BoundingInfo object (Internal use)
  28093. */
  28094. _boundingInfo: BoundingInfo;
  28095. /**
  28096. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28097. */
  28098. _sps: SolidParticleSystem;
  28099. /**
  28100. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28101. */
  28102. _stillInvisible: boolean;
  28103. /**
  28104. * @hidden Last computed particle rotation matrix
  28105. */
  28106. _rotationMatrix: number[];
  28107. /**
  28108. * Parent particle Id, if any.
  28109. * Default null.
  28110. */
  28111. parentId: Nullable<number>;
  28112. /**
  28113. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28114. */
  28115. materialIndex: Nullable<number>;
  28116. /**
  28117. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28118. * The possible values are :
  28119. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28120. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28121. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28122. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28123. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28124. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28125. * */
  28126. cullingStrategy: number;
  28127. /**
  28128. * @hidden Internal global position in the SPS.
  28129. */
  28130. _globalPosition: Vector3;
  28131. /**
  28132. * Creates a Solid Particle object.
  28133. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28134. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28135. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28136. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28137. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28138. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28139. * @param shapeId (integer) is the model shape identifier in the SPS.
  28140. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28141. * @param sps defines the sps it is associated to
  28142. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28143. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28144. */
  28145. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28146. /**
  28147. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28148. * @param target the particle target
  28149. * @returns the current particle
  28150. */
  28151. copyToRef(target: SolidParticle): SolidParticle;
  28152. /**
  28153. * Legacy support, changed scale to scaling
  28154. */
  28155. get scale(): Vector3;
  28156. /**
  28157. * Legacy support, changed scale to scaling
  28158. */
  28159. set scale(scale: Vector3);
  28160. /**
  28161. * Legacy support, changed quaternion to rotationQuaternion
  28162. */
  28163. get quaternion(): Nullable<Quaternion>;
  28164. /**
  28165. * Legacy support, changed quaternion to rotationQuaternion
  28166. */
  28167. set quaternion(q: Nullable<Quaternion>);
  28168. /**
  28169. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28170. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28171. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28172. * @returns true if it intersects
  28173. */
  28174. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28175. /**
  28176. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28177. * A particle is in the frustum if its bounding box intersects the frustum
  28178. * @param frustumPlanes defines the frustum to test
  28179. * @returns true if the particle is in the frustum planes
  28180. */
  28181. isInFrustum(frustumPlanes: Plane[]): boolean;
  28182. /**
  28183. * get the rotation matrix of the particle
  28184. * @hidden
  28185. */
  28186. getRotationMatrix(m: Matrix): void;
  28187. }
  28188. /**
  28189. * Represents the shape of the model used by one particle of a solid particle system.
  28190. * SPS internal tool, don't use it manually.
  28191. */
  28192. export class ModelShape {
  28193. /**
  28194. * The shape id
  28195. * @hidden
  28196. */
  28197. shapeID: number;
  28198. /**
  28199. * flat array of model positions (internal use)
  28200. * @hidden
  28201. */
  28202. _shape: Vector3[];
  28203. /**
  28204. * flat array of model UVs (internal use)
  28205. * @hidden
  28206. */
  28207. _shapeUV: number[];
  28208. /**
  28209. * color array of the model
  28210. * @hidden
  28211. */
  28212. _shapeColors: number[];
  28213. /**
  28214. * indices array of the model
  28215. * @hidden
  28216. */
  28217. _indices: number[];
  28218. /**
  28219. * normals array of the model
  28220. * @hidden
  28221. */
  28222. _normals: number[];
  28223. /**
  28224. * length of the shape in the model indices array (internal use)
  28225. * @hidden
  28226. */
  28227. _indicesLength: number;
  28228. /**
  28229. * Custom position function (internal use)
  28230. * @hidden
  28231. */
  28232. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28233. /**
  28234. * Custom vertex function (internal use)
  28235. * @hidden
  28236. */
  28237. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28238. /**
  28239. * Model material (internal use)
  28240. * @hidden
  28241. */
  28242. _material: Nullable<Material>;
  28243. /**
  28244. * 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.
  28245. * SPS internal tool, don't use it manually.
  28246. * @hidden
  28247. */
  28248. 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>, material: Nullable<Material>);
  28249. }
  28250. /**
  28251. * Represents a Depth Sorted Particle in the solid particle system.
  28252. * @hidden
  28253. */
  28254. export class DepthSortedParticle {
  28255. /**
  28256. * Index of the particle in the "indices" array
  28257. */
  28258. ind: number;
  28259. /**
  28260. * Length of the particle shape in the "indices" array
  28261. */
  28262. indicesLength: number;
  28263. /**
  28264. * Squared distance from the particle to the camera
  28265. */
  28266. sqDistance: number;
  28267. /**
  28268. * Material index when used with MultiMaterials
  28269. */
  28270. materialIndex: number;
  28271. /**
  28272. * Creates a new sorted particle
  28273. * @param materialIndex
  28274. */
  28275. constructor(ind: number, indLength: number, materialIndex: number);
  28276. }
  28277. }
  28278. declare module "babylonjs/Collisions/meshCollisionData" {
  28279. import { Collider } from "babylonjs/Collisions/collider";
  28280. import { Vector3 } from "babylonjs/Maths/math.vector";
  28281. import { Nullable } from "babylonjs/types";
  28282. import { Observer } from "babylonjs/Misc/observable";
  28283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28284. /**
  28285. * @hidden
  28286. */
  28287. export class _MeshCollisionData {
  28288. _checkCollisions: boolean;
  28289. _collisionMask: number;
  28290. _collisionGroup: number;
  28291. _collider: Nullable<Collider>;
  28292. _oldPositionForCollisions: Vector3;
  28293. _diffPositionForCollisions: Vector3;
  28294. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28295. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28296. }
  28297. }
  28298. declare module "babylonjs/Meshes/abstractMesh" {
  28299. import { Observable } from "babylonjs/Misc/observable";
  28300. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28301. import { Camera } from "babylonjs/Cameras/camera";
  28302. import { Scene, IDisposable } from "babylonjs/scene";
  28303. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28304. import { Node } from "babylonjs/node";
  28305. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28306. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28307. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28308. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28309. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28310. import { Material } from "babylonjs/Materials/material";
  28311. import { Light } from "babylonjs/Lights/light";
  28312. import { Skeleton } from "babylonjs/Bones/skeleton";
  28313. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28314. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28315. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28316. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28317. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28318. import { Plane } from "babylonjs/Maths/math.plane";
  28319. import { Ray } from "babylonjs/Culling/ray";
  28320. import { Collider } from "babylonjs/Collisions/collider";
  28321. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28322. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28323. /** @hidden */
  28324. class _FacetDataStorage {
  28325. facetPositions: Vector3[];
  28326. facetNormals: Vector3[];
  28327. facetPartitioning: number[][];
  28328. facetNb: number;
  28329. partitioningSubdivisions: number;
  28330. partitioningBBoxRatio: number;
  28331. facetDataEnabled: boolean;
  28332. facetParameters: any;
  28333. bbSize: Vector3;
  28334. subDiv: {
  28335. max: number;
  28336. X: number;
  28337. Y: number;
  28338. Z: number;
  28339. };
  28340. facetDepthSort: boolean;
  28341. facetDepthSortEnabled: boolean;
  28342. depthSortedIndices: IndicesArray;
  28343. depthSortedFacets: {
  28344. ind: number;
  28345. sqDistance: number;
  28346. }[];
  28347. facetDepthSortFunction: (f1: {
  28348. ind: number;
  28349. sqDistance: number;
  28350. }, f2: {
  28351. ind: number;
  28352. sqDistance: number;
  28353. }) => number;
  28354. facetDepthSortFrom: Vector3;
  28355. facetDepthSortOrigin: Vector3;
  28356. invertedMatrix: Matrix;
  28357. }
  28358. /**
  28359. * @hidden
  28360. **/
  28361. class _InternalAbstractMeshDataInfo {
  28362. _hasVertexAlpha: boolean;
  28363. _useVertexColors: boolean;
  28364. _numBoneInfluencers: number;
  28365. _applyFog: boolean;
  28366. _receiveShadows: boolean;
  28367. _facetData: _FacetDataStorage;
  28368. _visibility: number;
  28369. _skeleton: Nullable<Skeleton>;
  28370. _layerMask: number;
  28371. _computeBonesUsingShaders: boolean;
  28372. _isActive: boolean;
  28373. _onlyForInstances: boolean;
  28374. _isActiveIntermediate: boolean;
  28375. _onlyForInstancesIntermediate: boolean;
  28376. _actAsRegularMesh: boolean;
  28377. }
  28378. /**
  28379. * Class used to store all common mesh properties
  28380. */
  28381. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28382. /** No occlusion */
  28383. static OCCLUSION_TYPE_NONE: number;
  28384. /** Occlusion set to optimisitic */
  28385. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28386. /** Occlusion set to strict */
  28387. static OCCLUSION_TYPE_STRICT: number;
  28388. /** Use an accurante occlusion algorithm */
  28389. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28390. /** Use a conservative occlusion algorithm */
  28391. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28392. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28393. * Test order :
  28394. * Is the bounding sphere outside the frustum ?
  28395. * If not, are the bounding box vertices outside the frustum ?
  28396. * It not, then the cullable object is in the frustum.
  28397. */
  28398. static readonly CULLINGSTRATEGY_STANDARD: number;
  28399. /** Culling strategy : Bounding Sphere Only.
  28400. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28401. * It's also less accurate than the standard because some not visible objects can still be selected.
  28402. * Test : is the bounding sphere outside the frustum ?
  28403. * If not, then the cullable object is in the frustum.
  28404. */
  28405. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28406. /** Culling strategy : Optimistic Inclusion.
  28407. * This in an inclusion test first, then the standard exclusion test.
  28408. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28409. * 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.
  28410. * Anyway, it's as accurate as the standard strategy.
  28411. * Test :
  28412. * Is the cullable object bounding sphere center in the frustum ?
  28413. * If not, apply the default culling strategy.
  28414. */
  28415. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28416. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28417. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28418. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28419. * 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.
  28420. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28421. * Test :
  28422. * Is the cullable object bounding sphere center in the frustum ?
  28423. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28424. */
  28425. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28426. /**
  28427. * No billboard
  28428. */
  28429. static get BILLBOARDMODE_NONE(): number;
  28430. /** Billboard on X axis */
  28431. static get BILLBOARDMODE_X(): number;
  28432. /** Billboard on Y axis */
  28433. static get BILLBOARDMODE_Y(): number;
  28434. /** Billboard on Z axis */
  28435. static get BILLBOARDMODE_Z(): number;
  28436. /** Billboard on all axes */
  28437. static get BILLBOARDMODE_ALL(): number;
  28438. /** Billboard on using position instead of orientation */
  28439. static get BILLBOARDMODE_USE_POSITION(): number;
  28440. /** @hidden */
  28441. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28442. /**
  28443. * The culling strategy to use to check whether the mesh must be rendered or not.
  28444. * This value can be changed at any time and will be used on the next render mesh selection.
  28445. * The possible values are :
  28446. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28447. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28448. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28449. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28450. * Please read each static variable documentation to get details about the culling process.
  28451. * */
  28452. cullingStrategy: number;
  28453. /**
  28454. * Gets the number of facets in the mesh
  28455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28456. */
  28457. get facetNb(): number;
  28458. /**
  28459. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28461. */
  28462. get partitioningSubdivisions(): number;
  28463. set partitioningSubdivisions(nb: number);
  28464. /**
  28465. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28466. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28467. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28468. */
  28469. get partitioningBBoxRatio(): number;
  28470. set partitioningBBoxRatio(ratio: number);
  28471. /**
  28472. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28473. * Works only for updatable meshes.
  28474. * Doesn't work with multi-materials
  28475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28476. */
  28477. get mustDepthSortFacets(): boolean;
  28478. set mustDepthSortFacets(sort: boolean);
  28479. /**
  28480. * The location (Vector3) where the facet depth sort must be computed from.
  28481. * By default, the active camera position.
  28482. * Used only when facet depth sort is enabled
  28483. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28484. */
  28485. get facetDepthSortFrom(): Vector3;
  28486. set facetDepthSortFrom(location: Vector3);
  28487. /**
  28488. * gets a boolean indicating if facetData is enabled
  28489. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28490. */
  28491. get isFacetDataEnabled(): boolean;
  28492. /** @hidden */
  28493. _updateNonUniformScalingState(value: boolean): boolean;
  28494. /**
  28495. * An event triggered when this mesh collides with another one
  28496. */
  28497. onCollideObservable: Observable<AbstractMesh>;
  28498. /** Set a function to call when this mesh collides with another one */
  28499. set onCollide(callback: () => void);
  28500. /**
  28501. * An event triggered when the collision's position changes
  28502. */
  28503. onCollisionPositionChangeObservable: Observable<Vector3>;
  28504. /** Set a function to call when the collision's position changes */
  28505. set onCollisionPositionChange(callback: () => void);
  28506. /**
  28507. * An event triggered when material is changed
  28508. */
  28509. onMaterialChangedObservable: Observable<AbstractMesh>;
  28510. /**
  28511. * Gets or sets the orientation for POV movement & rotation
  28512. */
  28513. definedFacingForward: boolean;
  28514. /** @hidden */
  28515. _occlusionQuery: Nullable<WebGLQuery>;
  28516. /** @hidden */
  28517. _renderingGroup: Nullable<RenderingGroup>;
  28518. /**
  28519. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28520. */
  28521. get visibility(): number;
  28522. /**
  28523. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28524. */
  28525. set visibility(value: number);
  28526. /** Gets or sets the alpha index used to sort transparent meshes
  28527. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28528. */
  28529. alphaIndex: number;
  28530. /**
  28531. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28532. */
  28533. isVisible: boolean;
  28534. /**
  28535. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28536. */
  28537. isPickable: boolean;
  28538. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28539. showSubMeshesBoundingBox: boolean;
  28540. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28541. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28542. */
  28543. isBlocker: boolean;
  28544. /**
  28545. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28546. */
  28547. enablePointerMoveEvents: boolean;
  28548. /**
  28549. * Specifies the rendering group id for this mesh (0 by default)
  28550. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28551. */
  28552. renderingGroupId: number;
  28553. private _material;
  28554. /** Gets or sets current material */
  28555. get material(): Nullable<Material>;
  28556. set material(value: Nullable<Material>);
  28557. /**
  28558. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28559. * @see http://doc.babylonjs.com/babylon101/shadows
  28560. */
  28561. get receiveShadows(): boolean;
  28562. set receiveShadows(value: boolean);
  28563. /** Defines color to use when rendering outline */
  28564. outlineColor: Color3;
  28565. /** Define width to use when rendering outline */
  28566. outlineWidth: number;
  28567. /** Defines color to use when rendering overlay */
  28568. overlayColor: Color3;
  28569. /** Defines alpha to use when rendering overlay */
  28570. overlayAlpha: number;
  28571. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28572. get hasVertexAlpha(): boolean;
  28573. set hasVertexAlpha(value: boolean);
  28574. /** 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) */
  28575. get useVertexColors(): boolean;
  28576. set useVertexColors(value: boolean);
  28577. /**
  28578. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28579. */
  28580. get computeBonesUsingShaders(): boolean;
  28581. set computeBonesUsingShaders(value: boolean);
  28582. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28583. get numBoneInfluencers(): number;
  28584. set numBoneInfluencers(value: number);
  28585. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28586. get applyFog(): boolean;
  28587. set applyFog(value: boolean);
  28588. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28589. useOctreeForRenderingSelection: boolean;
  28590. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28591. useOctreeForPicking: boolean;
  28592. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28593. useOctreeForCollisions: boolean;
  28594. /**
  28595. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28596. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28597. */
  28598. get layerMask(): number;
  28599. set layerMask(value: number);
  28600. /**
  28601. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28602. */
  28603. alwaysSelectAsActiveMesh: boolean;
  28604. /**
  28605. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28606. */
  28607. doNotSyncBoundingInfo: boolean;
  28608. /**
  28609. * Gets or sets the current action manager
  28610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28611. */
  28612. actionManager: Nullable<AbstractActionManager>;
  28613. private _meshCollisionData;
  28614. /**
  28615. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28616. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28617. */
  28618. ellipsoid: Vector3;
  28619. /**
  28620. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28621. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28622. */
  28623. ellipsoidOffset: Vector3;
  28624. /**
  28625. * Gets or sets a collision mask used to mask collisions (default is -1).
  28626. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28627. */
  28628. get collisionMask(): number;
  28629. set collisionMask(mask: number);
  28630. /**
  28631. * Gets or sets the current collision group mask (-1 by default).
  28632. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28633. */
  28634. get collisionGroup(): number;
  28635. set collisionGroup(mask: number);
  28636. /**
  28637. * Defines edge width used when edgesRenderer is enabled
  28638. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28639. */
  28640. edgesWidth: number;
  28641. /**
  28642. * Defines edge color used when edgesRenderer is enabled
  28643. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28644. */
  28645. edgesColor: Color4;
  28646. /** @hidden */
  28647. _edgesRenderer: Nullable<IEdgesRenderer>;
  28648. /** @hidden */
  28649. _masterMesh: Nullable<AbstractMesh>;
  28650. /** @hidden */
  28651. _boundingInfo: Nullable<BoundingInfo>;
  28652. /** @hidden */
  28653. _renderId: number;
  28654. /**
  28655. * Gets or sets the list of subMeshes
  28656. * @see http://doc.babylonjs.com/how_to/multi_materials
  28657. */
  28658. subMeshes: SubMesh[];
  28659. /** @hidden */
  28660. _intersectionsInProgress: AbstractMesh[];
  28661. /** @hidden */
  28662. _unIndexed: boolean;
  28663. /** @hidden */
  28664. _lightSources: Light[];
  28665. /** Gets the list of lights affecting that mesh */
  28666. get lightSources(): Light[];
  28667. /** @hidden */
  28668. get _positions(): Nullable<Vector3[]>;
  28669. /** @hidden */
  28670. _waitingData: {
  28671. lods: Nullable<any>;
  28672. actions: Nullable<any>;
  28673. freezeWorldMatrix: Nullable<boolean>;
  28674. };
  28675. /** @hidden */
  28676. _bonesTransformMatrices: Nullable<Float32Array>;
  28677. /** @hidden */
  28678. _transformMatrixTexture: Nullable<RawTexture>;
  28679. /**
  28680. * Gets or sets a skeleton to apply skining transformations
  28681. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28682. */
  28683. set skeleton(value: Nullable<Skeleton>);
  28684. get skeleton(): Nullable<Skeleton>;
  28685. /**
  28686. * An event triggered when the mesh is rebuilt.
  28687. */
  28688. onRebuildObservable: Observable<AbstractMesh>;
  28689. /**
  28690. * Creates a new AbstractMesh
  28691. * @param name defines the name of the mesh
  28692. * @param scene defines the hosting scene
  28693. */
  28694. constructor(name: string, scene?: Nullable<Scene>);
  28695. /**
  28696. * Returns the string "AbstractMesh"
  28697. * @returns "AbstractMesh"
  28698. */
  28699. getClassName(): string;
  28700. /**
  28701. * Gets a string representation of the current mesh
  28702. * @param fullDetails defines a boolean indicating if full details must be included
  28703. * @returns a string representation of the current mesh
  28704. */
  28705. toString(fullDetails?: boolean): string;
  28706. /**
  28707. * @hidden
  28708. */
  28709. protected _getEffectiveParent(): Nullable<Node>;
  28710. /** @hidden */
  28711. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28712. /** @hidden */
  28713. _rebuild(): void;
  28714. /** @hidden */
  28715. _resyncLightSources(): void;
  28716. /** @hidden */
  28717. _resyncLightSource(light: Light): void;
  28718. /** @hidden */
  28719. _unBindEffect(): void;
  28720. /** @hidden */
  28721. _removeLightSource(light: Light, dispose: boolean): void;
  28722. private _markSubMeshesAsDirty;
  28723. /** @hidden */
  28724. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28725. /** @hidden */
  28726. _markSubMeshesAsAttributesDirty(): void;
  28727. /** @hidden */
  28728. _markSubMeshesAsMiscDirty(): void;
  28729. /**
  28730. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28731. */
  28732. get scaling(): Vector3;
  28733. set scaling(newScaling: Vector3);
  28734. /**
  28735. * Returns true if the mesh is blocked. Implemented by child classes
  28736. */
  28737. get isBlocked(): boolean;
  28738. /**
  28739. * Returns the mesh itself by default. Implemented by child classes
  28740. * @param camera defines the camera to use to pick the right LOD level
  28741. * @returns the currentAbstractMesh
  28742. */
  28743. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28744. /**
  28745. * Returns 0 by default. Implemented by child classes
  28746. * @returns an integer
  28747. */
  28748. getTotalVertices(): number;
  28749. /**
  28750. * Returns a positive integer : the total number of indices in this mesh geometry.
  28751. * @returns the numner of indices or zero if the mesh has no geometry.
  28752. */
  28753. getTotalIndices(): number;
  28754. /**
  28755. * Returns null by default. Implemented by child classes
  28756. * @returns null
  28757. */
  28758. getIndices(): Nullable<IndicesArray>;
  28759. /**
  28760. * Returns the array of the requested vertex data kind. Implemented by child classes
  28761. * @param kind defines the vertex data kind to use
  28762. * @returns null
  28763. */
  28764. getVerticesData(kind: string): Nullable<FloatArray>;
  28765. /**
  28766. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28767. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28768. * Note that a new underlying VertexBuffer object is created each call.
  28769. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28770. * @param kind defines vertex data kind:
  28771. * * VertexBuffer.PositionKind
  28772. * * VertexBuffer.UVKind
  28773. * * VertexBuffer.UV2Kind
  28774. * * VertexBuffer.UV3Kind
  28775. * * VertexBuffer.UV4Kind
  28776. * * VertexBuffer.UV5Kind
  28777. * * VertexBuffer.UV6Kind
  28778. * * VertexBuffer.ColorKind
  28779. * * VertexBuffer.MatricesIndicesKind
  28780. * * VertexBuffer.MatricesIndicesExtraKind
  28781. * * VertexBuffer.MatricesWeightsKind
  28782. * * VertexBuffer.MatricesWeightsExtraKind
  28783. * @param data defines the data source
  28784. * @param updatable defines if the data must be flagged as updatable (or static)
  28785. * @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
  28786. * @returns the current mesh
  28787. */
  28788. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28789. /**
  28790. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28791. * If the mesh has no geometry, it is simply returned as it is.
  28792. * @param kind defines vertex data kind:
  28793. * * VertexBuffer.PositionKind
  28794. * * VertexBuffer.UVKind
  28795. * * VertexBuffer.UV2Kind
  28796. * * VertexBuffer.UV3Kind
  28797. * * VertexBuffer.UV4Kind
  28798. * * VertexBuffer.UV5Kind
  28799. * * VertexBuffer.UV6Kind
  28800. * * VertexBuffer.ColorKind
  28801. * * VertexBuffer.MatricesIndicesKind
  28802. * * VertexBuffer.MatricesIndicesExtraKind
  28803. * * VertexBuffer.MatricesWeightsKind
  28804. * * VertexBuffer.MatricesWeightsExtraKind
  28805. * @param data defines the data source
  28806. * @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
  28807. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28808. * @returns the current mesh
  28809. */
  28810. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28811. /**
  28812. * Sets the mesh indices,
  28813. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28814. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28815. * @param totalVertices Defines the total number of vertices
  28816. * @returns the current mesh
  28817. */
  28818. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28819. /**
  28820. * Gets a boolean indicating if specific vertex data is present
  28821. * @param kind defines the vertex data kind to use
  28822. * @returns true is data kind is present
  28823. */
  28824. isVerticesDataPresent(kind: string): boolean;
  28825. /**
  28826. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28827. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28828. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28829. * @returns a BoundingInfo
  28830. */
  28831. getBoundingInfo(): BoundingInfo;
  28832. /**
  28833. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28834. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28835. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28836. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28837. * @returns the current mesh
  28838. */
  28839. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28840. /**
  28841. * Overwrite the current bounding info
  28842. * @param boundingInfo defines the new bounding info
  28843. * @returns the current mesh
  28844. */
  28845. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28846. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28847. get useBones(): boolean;
  28848. /** @hidden */
  28849. _preActivate(): void;
  28850. /** @hidden */
  28851. _preActivateForIntermediateRendering(renderId: number): void;
  28852. /** @hidden */
  28853. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28854. /** @hidden */
  28855. _postActivate(): void;
  28856. /** @hidden */
  28857. _freeze(): void;
  28858. /** @hidden */
  28859. _unFreeze(): void;
  28860. /**
  28861. * Gets the current world matrix
  28862. * @returns a Matrix
  28863. */
  28864. getWorldMatrix(): Matrix;
  28865. /** @hidden */
  28866. _getWorldMatrixDeterminant(): number;
  28867. /**
  28868. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28869. */
  28870. get isAnInstance(): boolean;
  28871. /**
  28872. * Gets a boolean indicating if this mesh has instances
  28873. */
  28874. get hasInstances(): boolean;
  28875. /**
  28876. * Perform relative position change from the point of view of behind the front of the mesh.
  28877. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28878. * Supports definition of mesh facing forward or backward
  28879. * @param amountRight defines the distance on the right axis
  28880. * @param amountUp defines the distance on the up axis
  28881. * @param amountForward defines the distance on the forward axis
  28882. * @returns the current mesh
  28883. */
  28884. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28885. /**
  28886. * Calculate relative position change from the point of view of behind the front of the mesh.
  28887. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28888. * Supports definition of mesh facing forward or backward
  28889. * @param amountRight defines the distance on the right axis
  28890. * @param amountUp defines the distance on the up axis
  28891. * @param amountForward defines the distance on the forward axis
  28892. * @returns the new displacement vector
  28893. */
  28894. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28895. /**
  28896. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28897. * Supports definition of mesh facing forward or backward
  28898. * @param flipBack defines the flip
  28899. * @param twirlClockwise defines the twirl
  28900. * @param tiltRight defines the tilt
  28901. * @returns the current mesh
  28902. */
  28903. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28904. /**
  28905. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28906. * Supports definition of mesh facing forward or backward.
  28907. * @param flipBack defines the flip
  28908. * @param twirlClockwise defines the twirl
  28909. * @param tiltRight defines the tilt
  28910. * @returns the new rotation vector
  28911. */
  28912. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28913. /**
  28914. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28915. * This means the mesh underlying bounding box and sphere are recomputed.
  28916. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28917. * @returns the current mesh
  28918. */
  28919. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28920. /** @hidden */
  28921. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28922. /** @hidden */
  28923. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28924. /** @hidden */
  28925. _updateBoundingInfo(): AbstractMesh;
  28926. /** @hidden */
  28927. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28928. /** @hidden */
  28929. protected _afterComputeWorldMatrix(): void;
  28930. /** @hidden */
  28931. get _effectiveMesh(): AbstractMesh;
  28932. /**
  28933. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28934. * A mesh is in the frustum if its bounding box intersects the frustum
  28935. * @param frustumPlanes defines the frustum to test
  28936. * @returns true if the mesh is in the frustum planes
  28937. */
  28938. isInFrustum(frustumPlanes: Plane[]): boolean;
  28939. /**
  28940. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28941. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28942. * @param frustumPlanes defines the frustum to test
  28943. * @returns true if the mesh is completely in the frustum planes
  28944. */
  28945. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28946. /**
  28947. * True if the mesh intersects another mesh or a SolidParticle object
  28948. * @param mesh defines a target mesh or SolidParticle to test
  28949. * @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)
  28950. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28951. * @returns true if there is an intersection
  28952. */
  28953. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28954. /**
  28955. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28956. * @param point defines the point to test
  28957. * @returns true if there is an intersection
  28958. */
  28959. intersectsPoint(point: Vector3): boolean;
  28960. /**
  28961. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28962. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28963. */
  28964. get checkCollisions(): boolean;
  28965. set checkCollisions(collisionEnabled: boolean);
  28966. /**
  28967. * Gets Collider object used to compute collisions (not physics)
  28968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28969. */
  28970. get collider(): Nullable<Collider>;
  28971. /**
  28972. * Move the mesh using collision engine
  28973. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28974. * @param displacement defines the requested displacement vector
  28975. * @returns the current mesh
  28976. */
  28977. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28978. private _onCollisionPositionChange;
  28979. /** @hidden */
  28980. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28981. /** @hidden */
  28982. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28983. /** @hidden */
  28984. _checkCollision(collider: Collider): AbstractMesh;
  28985. /** @hidden */
  28986. _generatePointsArray(): boolean;
  28987. /**
  28988. * Checks if the passed Ray intersects with the mesh
  28989. * @param ray defines the ray to use
  28990. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28991. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28992. * @returns the picking info
  28993. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28994. */
  28995. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28996. /**
  28997. * Clones the current mesh
  28998. * @param name defines the mesh name
  28999. * @param newParent defines the new mesh parent
  29000. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29001. * @returns the new mesh
  29002. */
  29003. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29004. /**
  29005. * Disposes all the submeshes of the current meshnp
  29006. * @returns the current mesh
  29007. */
  29008. releaseSubMeshes(): AbstractMesh;
  29009. /**
  29010. * Releases resources associated with this abstract mesh.
  29011. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29012. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29013. */
  29014. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29015. /**
  29016. * Adds the passed mesh as a child to the current mesh
  29017. * @param mesh defines the child mesh
  29018. * @returns the current mesh
  29019. */
  29020. addChild(mesh: AbstractMesh): AbstractMesh;
  29021. /**
  29022. * Removes the passed mesh from the current mesh children list
  29023. * @param mesh defines the child mesh
  29024. * @returns the current mesh
  29025. */
  29026. removeChild(mesh: AbstractMesh): AbstractMesh;
  29027. /** @hidden */
  29028. private _initFacetData;
  29029. /**
  29030. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29031. * This method can be called within the render loop.
  29032. * 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
  29033. * @returns the current mesh
  29034. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29035. */
  29036. updateFacetData(): AbstractMesh;
  29037. /**
  29038. * Returns the facetLocalNormals array.
  29039. * The normals are expressed in the mesh local spac
  29040. * @returns an array of Vector3
  29041. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29042. */
  29043. getFacetLocalNormals(): Vector3[];
  29044. /**
  29045. * Returns the facetLocalPositions array.
  29046. * The facet positions are expressed in the mesh local space
  29047. * @returns an array of Vector3
  29048. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29049. */
  29050. getFacetLocalPositions(): Vector3[];
  29051. /**
  29052. * Returns the facetLocalPartioning array
  29053. * @returns an array of array of numbers
  29054. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29055. */
  29056. getFacetLocalPartitioning(): number[][];
  29057. /**
  29058. * Returns the i-th facet position in the world system.
  29059. * This method allocates a new Vector3 per call
  29060. * @param i defines the facet index
  29061. * @returns a new Vector3
  29062. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29063. */
  29064. getFacetPosition(i: number): Vector3;
  29065. /**
  29066. * Sets the reference Vector3 with the i-th facet position in the world system
  29067. * @param i defines the facet index
  29068. * @param ref defines the target vector
  29069. * @returns the current mesh
  29070. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29071. */
  29072. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29073. /**
  29074. * Returns the i-th facet normal in the world system.
  29075. * This method allocates a new Vector3 per call
  29076. * @param i defines the facet index
  29077. * @returns a new Vector3
  29078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29079. */
  29080. getFacetNormal(i: number): Vector3;
  29081. /**
  29082. * Sets the reference Vector3 with the i-th facet normal in the world system
  29083. * @param i defines the facet index
  29084. * @param ref defines the target vector
  29085. * @returns the current mesh
  29086. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29087. */
  29088. getFacetNormalToRef(i: number, ref: Vector3): this;
  29089. /**
  29090. * 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)
  29091. * @param x defines x coordinate
  29092. * @param y defines y coordinate
  29093. * @param z defines z coordinate
  29094. * @returns the array of facet indexes
  29095. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29096. */
  29097. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29098. /**
  29099. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29100. * @param projected sets as the (x,y,z) world projection on the facet
  29101. * @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
  29102. * @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
  29103. * @param x defines x coordinate
  29104. * @param y defines y coordinate
  29105. * @param z defines z coordinate
  29106. * @returns the face index if found (or null instead)
  29107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29108. */
  29109. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29110. /**
  29111. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29112. * @param projected sets as the (x,y,z) local projection on the facet
  29113. * @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
  29114. * @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
  29115. * @param x defines x coordinate
  29116. * @param y defines y coordinate
  29117. * @param z defines z coordinate
  29118. * @returns the face index if found (or null instead)
  29119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29120. */
  29121. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29122. /**
  29123. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29124. * @returns the parameters
  29125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29126. */
  29127. getFacetDataParameters(): any;
  29128. /**
  29129. * Disables the feature FacetData and frees the related memory
  29130. * @returns the current mesh
  29131. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29132. */
  29133. disableFacetData(): AbstractMesh;
  29134. /**
  29135. * Updates the AbstractMesh indices array
  29136. * @param indices defines the data source
  29137. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29138. * @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)
  29139. * @returns the current mesh
  29140. */
  29141. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29142. /**
  29143. * Creates new normals data for the mesh
  29144. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29145. * @returns the current mesh
  29146. */
  29147. createNormals(updatable: boolean): AbstractMesh;
  29148. /**
  29149. * Align the mesh with a normal
  29150. * @param normal defines the normal to use
  29151. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29152. * @returns the current mesh
  29153. */
  29154. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29155. /** @hidden */
  29156. _checkOcclusionQuery(): boolean;
  29157. /**
  29158. * Disables the mesh edge rendering mode
  29159. * @returns the currentAbstractMesh
  29160. */
  29161. disableEdgesRendering(): AbstractMesh;
  29162. /**
  29163. * Enables the edge rendering mode on the mesh.
  29164. * This mode makes the mesh edges visible
  29165. * @param epsilon defines the maximal distance between two angles to detect a face
  29166. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29167. * @returns the currentAbstractMesh
  29168. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29169. */
  29170. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29171. }
  29172. }
  29173. declare module "babylonjs/Actions/actionEvent" {
  29174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29175. import { Nullable } from "babylonjs/types";
  29176. import { Sprite } from "babylonjs/Sprites/sprite";
  29177. import { Scene } from "babylonjs/scene";
  29178. import { Vector2 } from "babylonjs/Maths/math.vector";
  29179. /**
  29180. * Interface used to define ActionEvent
  29181. */
  29182. export interface IActionEvent {
  29183. /** The mesh or sprite that triggered the action */
  29184. source: any;
  29185. /** The X mouse cursor position at the time of the event */
  29186. pointerX: number;
  29187. /** The Y mouse cursor position at the time of the event */
  29188. pointerY: number;
  29189. /** The mesh that is currently pointed at (can be null) */
  29190. meshUnderPointer: Nullable<AbstractMesh>;
  29191. /** the original (browser) event that triggered the ActionEvent */
  29192. sourceEvent?: any;
  29193. /** additional data for the event */
  29194. additionalData?: any;
  29195. }
  29196. /**
  29197. * ActionEvent is the event being sent when an action is triggered.
  29198. */
  29199. export class ActionEvent implements IActionEvent {
  29200. /** The mesh or sprite that triggered the action */
  29201. source: any;
  29202. /** The X mouse cursor position at the time of the event */
  29203. pointerX: number;
  29204. /** The Y mouse cursor position at the time of the event */
  29205. pointerY: number;
  29206. /** The mesh that is currently pointed at (can be null) */
  29207. meshUnderPointer: Nullable<AbstractMesh>;
  29208. /** the original (browser) event that triggered the ActionEvent */
  29209. sourceEvent?: any;
  29210. /** additional data for the event */
  29211. additionalData?: any;
  29212. /**
  29213. * Creates a new ActionEvent
  29214. * @param source The mesh or sprite that triggered the action
  29215. * @param pointerX The X mouse cursor position at the time of the event
  29216. * @param pointerY The Y mouse cursor position at the time of the event
  29217. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29218. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29219. * @param additionalData additional data for the event
  29220. */
  29221. constructor(
  29222. /** The mesh or sprite that triggered the action */
  29223. source: any,
  29224. /** The X mouse cursor position at the time of the event */
  29225. pointerX: number,
  29226. /** The Y mouse cursor position at the time of the event */
  29227. pointerY: number,
  29228. /** The mesh that is currently pointed at (can be null) */
  29229. meshUnderPointer: Nullable<AbstractMesh>,
  29230. /** the original (browser) event that triggered the ActionEvent */
  29231. sourceEvent?: any,
  29232. /** additional data for the event */
  29233. additionalData?: any);
  29234. /**
  29235. * Helper function to auto-create an ActionEvent from a source mesh.
  29236. * @param source The source mesh that triggered the event
  29237. * @param evt The original (browser) event
  29238. * @param additionalData additional data for the event
  29239. * @returns the new ActionEvent
  29240. */
  29241. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29242. /**
  29243. * Helper function to auto-create an ActionEvent from a source sprite
  29244. * @param source The source sprite that triggered the event
  29245. * @param scene Scene associated with the sprite
  29246. * @param evt The original (browser) event
  29247. * @param additionalData additional data for the event
  29248. * @returns the new ActionEvent
  29249. */
  29250. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29251. /**
  29252. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29253. * @param scene the scene where the event occurred
  29254. * @param evt The original (browser) event
  29255. * @returns the new ActionEvent
  29256. */
  29257. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29258. /**
  29259. * Helper function to auto-create an ActionEvent from a primitive
  29260. * @param prim defines the target primitive
  29261. * @param pointerPos defines the pointer position
  29262. * @param evt The original (browser) event
  29263. * @param additionalData additional data for the event
  29264. * @returns the new ActionEvent
  29265. */
  29266. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29267. }
  29268. }
  29269. declare module "babylonjs/Actions/abstractActionManager" {
  29270. import { IDisposable } from "babylonjs/scene";
  29271. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29272. import { IAction } from "babylonjs/Actions/action";
  29273. import { Nullable } from "babylonjs/types";
  29274. /**
  29275. * Abstract class used to decouple action Manager from scene and meshes.
  29276. * Do not instantiate.
  29277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29278. */
  29279. export abstract class AbstractActionManager implements IDisposable {
  29280. /** Gets the list of active triggers */
  29281. static Triggers: {
  29282. [key: string]: number;
  29283. };
  29284. /** Gets the cursor to use when hovering items */
  29285. hoverCursor: string;
  29286. /** Gets the list of actions */
  29287. actions: IAction[];
  29288. /**
  29289. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29290. */
  29291. isRecursive: boolean;
  29292. /**
  29293. * Releases all associated resources
  29294. */
  29295. abstract dispose(): void;
  29296. /**
  29297. * Does this action manager has pointer triggers
  29298. */
  29299. abstract get hasPointerTriggers(): boolean;
  29300. /**
  29301. * Does this action manager has pick triggers
  29302. */
  29303. abstract get hasPickTriggers(): boolean;
  29304. /**
  29305. * Process a specific trigger
  29306. * @param trigger defines the trigger to process
  29307. * @param evt defines the event details to be processed
  29308. */
  29309. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29310. /**
  29311. * Does this action manager handles actions of any of the given triggers
  29312. * @param triggers defines the triggers to be tested
  29313. * @return a boolean indicating whether one (or more) of the triggers is handled
  29314. */
  29315. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29316. /**
  29317. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29318. * speed.
  29319. * @param triggerA defines the trigger to be tested
  29320. * @param triggerB defines the trigger to be tested
  29321. * @return a boolean indicating whether one (or more) of the triggers is handled
  29322. */
  29323. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29324. /**
  29325. * Does this action manager handles actions of a given trigger
  29326. * @param trigger defines the trigger to be tested
  29327. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29328. * @return whether the trigger is handled
  29329. */
  29330. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29331. /**
  29332. * Serialize this manager to a JSON object
  29333. * @param name defines the property name to store this manager
  29334. * @returns a JSON representation of this manager
  29335. */
  29336. abstract serialize(name: string): any;
  29337. /**
  29338. * Registers an action to this action manager
  29339. * @param action defines the action to be registered
  29340. * @return the action amended (prepared) after registration
  29341. */
  29342. abstract registerAction(action: IAction): Nullable<IAction>;
  29343. /**
  29344. * Unregisters an action to this action manager
  29345. * @param action defines the action to be unregistered
  29346. * @return a boolean indicating whether the action has been unregistered
  29347. */
  29348. abstract unregisterAction(action: IAction): Boolean;
  29349. /**
  29350. * Does exist one action manager with at least one trigger
  29351. **/
  29352. static get HasTriggers(): boolean;
  29353. /**
  29354. * Does exist one action manager with at least one pick trigger
  29355. **/
  29356. static get HasPickTriggers(): boolean;
  29357. /**
  29358. * Does exist one action manager that handles actions of a given trigger
  29359. * @param trigger defines the trigger to be tested
  29360. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29361. **/
  29362. static HasSpecificTrigger(trigger: number): boolean;
  29363. }
  29364. }
  29365. declare module "babylonjs/node" {
  29366. import { Scene } from "babylonjs/scene";
  29367. import { Nullable } from "babylonjs/types";
  29368. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29369. import { Engine } from "babylonjs/Engines/engine";
  29370. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29371. import { Observable } from "babylonjs/Misc/observable";
  29372. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29373. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29374. import { Animatable } from "babylonjs/Animations/animatable";
  29375. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29376. import { Animation } from "babylonjs/Animations/animation";
  29377. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29379. /**
  29380. * Defines how a node can be built from a string name.
  29381. */
  29382. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29383. /**
  29384. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29385. */
  29386. export class Node implements IBehaviorAware<Node> {
  29387. /** @hidden */
  29388. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29389. private static _NodeConstructors;
  29390. /**
  29391. * Add a new node constructor
  29392. * @param type defines the type name of the node to construct
  29393. * @param constructorFunc defines the constructor function
  29394. */
  29395. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29396. /**
  29397. * Returns a node constructor based on type name
  29398. * @param type defines the type name
  29399. * @param name defines the new node name
  29400. * @param scene defines the hosting scene
  29401. * @param options defines optional options to transmit to constructors
  29402. * @returns the new constructor or null
  29403. */
  29404. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29405. /**
  29406. * Gets or sets the name of the node
  29407. */
  29408. name: string;
  29409. /**
  29410. * Gets or sets the id of the node
  29411. */
  29412. id: string;
  29413. /**
  29414. * Gets or sets the unique id of the node
  29415. */
  29416. uniqueId: number;
  29417. /**
  29418. * Gets or sets a string used to store user defined state for the node
  29419. */
  29420. state: string;
  29421. /**
  29422. * Gets or sets an object used to store user defined information for the node
  29423. */
  29424. metadata: any;
  29425. /**
  29426. * For internal use only. Please do not use.
  29427. */
  29428. reservedDataStore: any;
  29429. /**
  29430. * List of inspectable custom properties (used by the Inspector)
  29431. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29432. */
  29433. inspectableCustomProperties: IInspectable[];
  29434. private _doNotSerialize;
  29435. /**
  29436. * Gets or sets a boolean used to define if the node must be serialized
  29437. */
  29438. get doNotSerialize(): boolean;
  29439. set doNotSerialize(value: boolean);
  29440. /** @hidden */
  29441. _isDisposed: boolean;
  29442. /**
  29443. * Gets a list of Animations associated with the node
  29444. */
  29445. animations: import("babylonjs/Animations/animation").Animation[];
  29446. protected _ranges: {
  29447. [name: string]: Nullable<AnimationRange>;
  29448. };
  29449. /**
  29450. * Callback raised when the node is ready to be used
  29451. */
  29452. onReady: Nullable<(node: Node) => void>;
  29453. private _isEnabled;
  29454. private _isParentEnabled;
  29455. private _isReady;
  29456. /** @hidden */
  29457. _currentRenderId: number;
  29458. private _parentUpdateId;
  29459. /** @hidden */
  29460. _childUpdateId: number;
  29461. /** @hidden */
  29462. _waitingParentId: Nullable<string>;
  29463. /** @hidden */
  29464. _scene: Scene;
  29465. /** @hidden */
  29466. _cache: any;
  29467. private _parentNode;
  29468. private _children;
  29469. /** @hidden */
  29470. _worldMatrix: Matrix;
  29471. /** @hidden */
  29472. _worldMatrixDeterminant: number;
  29473. /** @hidden */
  29474. _worldMatrixDeterminantIsDirty: boolean;
  29475. /** @hidden */
  29476. private _sceneRootNodesIndex;
  29477. /**
  29478. * Gets a boolean indicating if the node has been disposed
  29479. * @returns true if the node was disposed
  29480. */
  29481. isDisposed(): boolean;
  29482. /**
  29483. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29484. * @see https://doc.babylonjs.com/how_to/parenting
  29485. */
  29486. set parent(parent: Nullable<Node>);
  29487. get parent(): Nullable<Node>;
  29488. /** @hidden */
  29489. _addToSceneRootNodes(): void;
  29490. /** @hidden */
  29491. _removeFromSceneRootNodes(): void;
  29492. private _animationPropertiesOverride;
  29493. /**
  29494. * Gets or sets the animation properties override
  29495. */
  29496. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29497. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29498. /**
  29499. * Gets a string idenfifying the name of the class
  29500. * @returns "Node" string
  29501. */
  29502. getClassName(): string;
  29503. /** @hidden */
  29504. readonly _isNode: boolean;
  29505. /**
  29506. * An event triggered when the mesh is disposed
  29507. */
  29508. onDisposeObservable: Observable<Node>;
  29509. private _onDisposeObserver;
  29510. /**
  29511. * Sets a callback that will be raised when the node will be disposed
  29512. */
  29513. set onDispose(callback: () => void);
  29514. /**
  29515. * Creates a new Node
  29516. * @param name the name and id to be given to this node
  29517. * @param scene the scene this node will be added to
  29518. */
  29519. constructor(name: string, scene?: Nullable<Scene>);
  29520. /**
  29521. * Gets the scene of the node
  29522. * @returns a scene
  29523. */
  29524. getScene(): Scene;
  29525. /**
  29526. * Gets the engine of the node
  29527. * @returns a Engine
  29528. */
  29529. getEngine(): Engine;
  29530. private _behaviors;
  29531. /**
  29532. * Attach a behavior to the node
  29533. * @see http://doc.babylonjs.com/features/behaviour
  29534. * @param behavior defines the behavior to attach
  29535. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29536. * @returns the current Node
  29537. */
  29538. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29539. /**
  29540. * Remove an attached behavior
  29541. * @see http://doc.babylonjs.com/features/behaviour
  29542. * @param behavior defines the behavior to attach
  29543. * @returns the current Node
  29544. */
  29545. removeBehavior(behavior: Behavior<Node>): Node;
  29546. /**
  29547. * Gets the list of attached behaviors
  29548. * @see http://doc.babylonjs.com/features/behaviour
  29549. */
  29550. get behaviors(): Behavior<Node>[];
  29551. /**
  29552. * Gets an attached behavior by name
  29553. * @param name defines the name of the behavior to look for
  29554. * @see http://doc.babylonjs.com/features/behaviour
  29555. * @returns null if behavior was not found else the requested behavior
  29556. */
  29557. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29558. /**
  29559. * Returns the latest update of the World matrix
  29560. * @returns a Matrix
  29561. */
  29562. getWorldMatrix(): Matrix;
  29563. /** @hidden */
  29564. _getWorldMatrixDeterminant(): number;
  29565. /**
  29566. * Returns directly the latest state of the mesh World matrix.
  29567. * A Matrix is returned.
  29568. */
  29569. get worldMatrixFromCache(): Matrix;
  29570. /** @hidden */
  29571. _initCache(): void;
  29572. /** @hidden */
  29573. updateCache(force?: boolean): void;
  29574. /** @hidden */
  29575. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29576. /** @hidden */
  29577. _updateCache(ignoreParentClass?: boolean): void;
  29578. /** @hidden */
  29579. _isSynchronized(): boolean;
  29580. /** @hidden */
  29581. _markSyncedWithParent(): void;
  29582. /** @hidden */
  29583. isSynchronizedWithParent(): boolean;
  29584. /** @hidden */
  29585. isSynchronized(): boolean;
  29586. /**
  29587. * Is this node ready to be used/rendered
  29588. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29589. * @return true if the node is ready
  29590. */
  29591. isReady(completeCheck?: boolean): boolean;
  29592. /**
  29593. * Is this node enabled?
  29594. * 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
  29595. * @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
  29596. * @return whether this node (and its parent) is enabled
  29597. */
  29598. isEnabled(checkAncestors?: boolean): boolean;
  29599. /** @hidden */
  29600. protected _syncParentEnabledState(): void;
  29601. /**
  29602. * Set the enabled state of this node
  29603. * @param value defines the new enabled state
  29604. */
  29605. setEnabled(value: boolean): void;
  29606. /**
  29607. * Is this node a descendant of the given node?
  29608. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29609. * @param ancestor defines the parent node to inspect
  29610. * @returns a boolean indicating if this node is a descendant of the given node
  29611. */
  29612. isDescendantOf(ancestor: Node): boolean;
  29613. /** @hidden */
  29614. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29615. /**
  29616. * Will return all nodes that have this node as ascendant
  29617. * @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
  29618. * @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
  29619. * @return all children nodes of all types
  29620. */
  29621. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29622. /**
  29623. * Get all child-meshes of this node
  29624. * @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)
  29625. * @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
  29626. * @returns an array of AbstractMesh
  29627. */
  29628. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29629. /**
  29630. * Get all direct children of this node
  29631. * @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
  29632. * @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)
  29633. * @returns an array of Node
  29634. */
  29635. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29636. /** @hidden */
  29637. _setReady(state: boolean): void;
  29638. /**
  29639. * Get an animation by name
  29640. * @param name defines the name of the animation to look for
  29641. * @returns null if not found else the requested animation
  29642. */
  29643. getAnimationByName(name: string): Nullable<Animation>;
  29644. /**
  29645. * Creates an animation range for this node
  29646. * @param name defines the name of the range
  29647. * @param from defines the starting key
  29648. * @param to defines the end key
  29649. */
  29650. createAnimationRange(name: string, from: number, to: number): void;
  29651. /**
  29652. * Delete a specific animation range
  29653. * @param name defines the name of the range to delete
  29654. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29655. */
  29656. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29657. /**
  29658. * Get an animation range by name
  29659. * @param name defines the name of the animation range to look for
  29660. * @returns null if not found else the requested animation range
  29661. */
  29662. getAnimationRange(name: string): Nullable<AnimationRange>;
  29663. /**
  29664. * Gets the list of all animation ranges defined on this node
  29665. * @returns an array
  29666. */
  29667. getAnimationRanges(): Nullable<AnimationRange>[];
  29668. /**
  29669. * Will start the animation sequence
  29670. * @param name defines the range frames for animation sequence
  29671. * @param loop defines if the animation should loop (false by default)
  29672. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29673. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29674. * @returns the object created for this animation. If range does not exist, it will return null
  29675. */
  29676. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29677. /**
  29678. * Serialize animation ranges into a JSON compatible object
  29679. * @returns serialization object
  29680. */
  29681. serializeAnimationRanges(): any;
  29682. /**
  29683. * Computes the world matrix of the node
  29684. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29685. * @returns the world matrix
  29686. */
  29687. computeWorldMatrix(force?: boolean): Matrix;
  29688. /**
  29689. * Releases resources associated with this node.
  29690. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29691. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29692. */
  29693. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29694. /**
  29695. * Parse animation range data from a serialization object and store them into a given node
  29696. * @param node defines where to store the animation ranges
  29697. * @param parsedNode defines the serialization object to read data from
  29698. * @param scene defines the hosting scene
  29699. */
  29700. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29701. /**
  29702. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29703. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29704. * @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
  29705. * @returns the new bounding vectors
  29706. */
  29707. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29708. min: Vector3;
  29709. max: Vector3;
  29710. };
  29711. }
  29712. }
  29713. declare module "babylonjs/Animations/animation" {
  29714. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29715. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29716. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29717. import { Nullable } from "babylonjs/types";
  29718. import { Scene } from "babylonjs/scene";
  29719. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29720. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29721. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29722. import { Node } from "babylonjs/node";
  29723. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29724. import { Size } from "babylonjs/Maths/math.size";
  29725. import { Animatable } from "babylonjs/Animations/animatable";
  29726. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29727. /**
  29728. * @hidden
  29729. */
  29730. export class _IAnimationState {
  29731. key: number;
  29732. repeatCount: number;
  29733. workValue?: any;
  29734. loopMode?: number;
  29735. offsetValue?: any;
  29736. highLimitValue?: any;
  29737. }
  29738. /**
  29739. * Class used to store any kind of animation
  29740. */
  29741. export class Animation {
  29742. /**Name of the animation */
  29743. name: string;
  29744. /**Property to animate */
  29745. targetProperty: string;
  29746. /**The frames per second of the animation */
  29747. framePerSecond: number;
  29748. /**The data type of the animation */
  29749. dataType: number;
  29750. /**The loop mode of the animation */
  29751. loopMode?: number | undefined;
  29752. /**Specifies if blending should be enabled */
  29753. enableBlending?: boolean | undefined;
  29754. /**
  29755. * Use matrix interpolation instead of using direct key value when animating matrices
  29756. */
  29757. static AllowMatricesInterpolation: boolean;
  29758. /**
  29759. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29760. */
  29761. static AllowMatrixDecomposeForInterpolation: boolean;
  29762. /**
  29763. * Stores the key frames of the animation
  29764. */
  29765. private _keys;
  29766. /**
  29767. * Stores the easing function of the animation
  29768. */
  29769. private _easingFunction;
  29770. /**
  29771. * @hidden Internal use only
  29772. */
  29773. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29774. /**
  29775. * The set of event that will be linked to this animation
  29776. */
  29777. private _events;
  29778. /**
  29779. * Stores an array of target property paths
  29780. */
  29781. targetPropertyPath: string[];
  29782. /**
  29783. * Stores the blending speed of the animation
  29784. */
  29785. blendingSpeed: number;
  29786. /**
  29787. * Stores the animation ranges for the animation
  29788. */
  29789. private _ranges;
  29790. /**
  29791. * @hidden Internal use
  29792. */
  29793. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29794. /**
  29795. * Sets up an animation
  29796. * @param property The property to animate
  29797. * @param animationType The animation type to apply
  29798. * @param framePerSecond The frames per second of the animation
  29799. * @param easingFunction The easing function used in the animation
  29800. * @returns The created animation
  29801. */
  29802. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29803. /**
  29804. * Create and start an animation on a node
  29805. * @param name defines the name of the global animation that will be run on all nodes
  29806. * @param node defines the root node where the animation will take place
  29807. * @param targetProperty defines property to animate
  29808. * @param framePerSecond defines the number of frame per second yo use
  29809. * @param totalFrame defines the number of frames in total
  29810. * @param from defines the initial value
  29811. * @param to defines the final value
  29812. * @param loopMode defines which loop mode you want to use (off by default)
  29813. * @param easingFunction defines the easing function to use (linear by default)
  29814. * @param onAnimationEnd defines the callback to call when animation end
  29815. * @returns the animatable created for this animation
  29816. */
  29817. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29818. /**
  29819. * Create and start an animation on a node and its descendants
  29820. * @param name defines the name of the global animation that will be run on all nodes
  29821. * @param node defines the root node where the animation will take place
  29822. * @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
  29823. * @param targetProperty defines property to animate
  29824. * @param framePerSecond defines the number of frame per second to use
  29825. * @param totalFrame defines the number of frames in total
  29826. * @param from defines the initial value
  29827. * @param to defines the final value
  29828. * @param loopMode defines which loop mode you want to use (off by default)
  29829. * @param easingFunction defines the easing function to use (linear by default)
  29830. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29831. * @returns the list of animatables created for all nodes
  29832. * @example https://www.babylonjs-playground.com/#MH0VLI
  29833. */
  29834. 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[]>;
  29835. /**
  29836. * Creates a new animation, merges it with the existing animations and starts it
  29837. * @param name Name of the animation
  29838. * @param node Node which contains the scene that begins the animations
  29839. * @param targetProperty Specifies which property to animate
  29840. * @param framePerSecond The frames per second of the animation
  29841. * @param totalFrame The total number of frames
  29842. * @param from The frame at the beginning of the animation
  29843. * @param to The frame at the end of the animation
  29844. * @param loopMode Specifies the loop mode of the animation
  29845. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29846. * @param onAnimationEnd Callback to run once the animation is complete
  29847. * @returns Nullable animation
  29848. */
  29849. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29850. /**
  29851. * Transition property of an host to the target Value
  29852. * @param property The property to transition
  29853. * @param targetValue The target Value of the property
  29854. * @param host The object where the property to animate belongs
  29855. * @param scene Scene used to run the animation
  29856. * @param frameRate Framerate (in frame/s) to use
  29857. * @param transition The transition type we want to use
  29858. * @param duration The duration of the animation, in milliseconds
  29859. * @param onAnimationEnd Callback trigger at the end of the animation
  29860. * @returns Nullable animation
  29861. */
  29862. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29863. /**
  29864. * Return the array of runtime animations currently using this animation
  29865. */
  29866. get runtimeAnimations(): RuntimeAnimation[];
  29867. /**
  29868. * Specifies if any of the runtime animations are currently running
  29869. */
  29870. get hasRunningRuntimeAnimations(): boolean;
  29871. /**
  29872. * Initializes the animation
  29873. * @param name Name of the animation
  29874. * @param targetProperty Property to animate
  29875. * @param framePerSecond The frames per second of the animation
  29876. * @param dataType The data type of the animation
  29877. * @param loopMode The loop mode of the animation
  29878. * @param enableBlending Specifies if blending should be enabled
  29879. */
  29880. constructor(
  29881. /**Name of the animation */
  29882. name: string,
  29883. /**Property to animate */
  29884. targetProperty: string,
  29885. /**The frames per second of the animation */
  29886. framePerSecond: number,
  29887. /**The data type of the animation */
  29888. dataType: number,
  29889. /**The loop mode of the animation */
  29890. loopMode?: number | undefined,
  29891. /**Specifies if blending should be enabled */
  29892. enableBlending?: boolean | undefined);
  29893. /**
  29894. * Converts the animation to a string
  29895. * @param fullDetails support for multiple levels of logging within scene loading
  29896. * @returns String form of the animation
  29897. */
  29898. toString(fullDetails?: boolean): string;
  29899. /**
  29900. * Add an event to this animation
  29901. * @param event Event to add
  29902. */
  29903. addEvent(event: AnimationEvent): void;
  29904. /**
  29905. * Remove all events found at the given frame
  29906. * @param frame The frame to remove events from
  29907. */
  29908. removeEvents(frame: number): void;
  29909. /**
  29910. * Retrieves all the events from the animation
  29911. * @returns Events from the animation
  29912. */
  29913. getEvents(): AnimationEvent[];
  29914. /**
  29915. * Creates an animation range
  29916. * @param name Name of the animation range
  29917. * @param from Starting frame of the animation range
  29918. * @param to Ending frame of the animation
  29919. */
  29920. createRange(name: string, from: number, to: number): void;
  29921. /**
  29922. * Deletes an animation range by name
  29923. * @param name Name of the animation range to delete
  29924. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29925. */
  29926. deleteRange(name: string, deleteFrames?: boolean): void;
  29927. /**
  29928. * Gets the animation range by name, or null if not defined
  29929. * @param name Name of the animation range
  29930. * @returns Nullable animation range
  29931. */
  29932. getRange(name: string): Nullable<AnimationRange>;
  29933. /**
  29934. * Gets the key frames from the animation
  29935. * @returns The key frames of the animation
  29936. */
  29937. getKeys(): Array<IAnimationKey>;
  29938. /**
  29939. * Gets the highest frame rate of the animation
  29940. * @returns Highest frame rate of the animation
  29941. */
  29942. getHighestFrame(): number;
  29943. /**
  29944. * Gets the easing function of the animation
  29945. * @returns Easing function of the animation
  29946. */
  29947. getEasingFunction(): IEasingFunction;
  29948. /**
  29949. * Sets the easing function of the animation
  29950. * @param easingFunction A custom mathematical formula for animation
  29951. */
  29952. setEasingFunction(easingFunction: EasingFunction): void;
  29953. /**
  29954. * Interpolates a scalar linearly
  29955. * @param startValue Start value of the animation curve
  29956. * @param endValue End value of the animation curve
  29957. * @param gradient Scalar amount to interpolate
  29958. * @returns Interpolated scalar value
  29959. */
  29960. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29961. /**
  29962. * Interpolates a scalar cubically
  29963. * @param startValue Start value of the animation curve
  29964. * @param outTangent End tangent of the animation
  29965. * @param endValue End value of the animation curve
  29966. * @param inTangent Start tangent of the animation curve
  29967. * @param gradient Scalar amount to interpolate
  29968. * @returns Interpolated scalar value
  29969. */
  29970. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29971. /**
  29972. * Interpolates a quaternion using a spherical linear interpolation
  29973. * @param startValue Start value of the animation curve
  29974. * @param endValue End value of the animation curve
  29975. * @param gradient Scalar amount to interpolate
  29976. * @returns Interpolated quaternion value
  29977. */
  29978. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29979. /**
  29980. * Interpolates a quaternion cubically
  29981. * @param startValue Start value of the animation curve
  29982. * @param outTangent End tangent of the animation curve
  29983. * @param endValue End value of the animation curve
  29984. * @param inTangent Start tangent of the animation curve
  29985. * @param gradient Scalar amount to interpolate
  29986. * @returns Interpolated quaternion value
  29987. */
  29988. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29989. /**
  29990. * Interpolates a Vector3 linearl
  29991. * @param startValue Start value of the animation curve
  29992. * @param endValue End value of the animation curve
  29993. * @param gradient Scalar amount to interpolate
  29994. * @returns Interpolated scalar value
  29995. */
  29996. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29997. /**
  29998. * Interpolates a Vector3 cubically
  29999. * @param startValue Start value of the animation curve
  30000. * @param outTangent End tangent of the animation
  30001. * @param endValue End value of the animation curve
  30002. * @param inTangent Start tangent of the animation curve
  30003. * @param gradient Scalar amount to interpolate
  30004. * @returns InterpolatedVector3 value
  30005. */
  30006. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30007. /**
  30008. * Interpolates a Vector2 linearly
  30009. * @param startValue Start value of the animation curve
  30010. * @param endValue End value of the animation curve
  30011. * @param gradient Scalar amount to interpolate
  30012. * @returns Interpolated Vector2 value
  30013. */
  30014. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30015. /**
  30016. * Interpolates a Vector2 cubically
  30017. * @param startValue Start value of the animation curve
  30018. * @param outTangent End tangent of the animation
  30019. * @param endValue End value of the animation curve
  30020. * @param inTangent Start tangent of the animation curve
  30021. * @param gradient Scalar amount to interpolate
  30022. * @returns Interpolated Vector2 value
  30023. */
  30024. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30025. /**
  30026. * Interpolates a size linearly
  30027. * @param startValue Start value of the animation curve
  30028. * @param endValue End value of the animation curve
  30029. * @param gradient Scalar amount to interpolate
  30030. * @returns Interpolated Size value
  30031. */
  30032. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30033. /**
  30034. * Interpolates a Color3 linearly
  30035. * @param startValue Start value of the animation curve
  30036. * @param endValue End value of the animation curve
  30037. * @param gradient Scalar amount to interpolate
  30038. * @returns Interpolated Color3 value
  30039. */
  30040. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30041. /**
  30042. * Interpolates a Color4 linearly
  30043. * @param startValue Start value of the animation curve
  30044. * @param endValue End value of the animation curve
  30045. * @param gradient Scalar amount to interpolate
  30046. * @returns Interpolated Color3 value
  30047. */
  30048. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30049. /**
  30050. * @hidden Internal use only
  30051. */
  30052. _getKeyValue(value: any): any;
  30053. /**
  30054. * @hidden Internal use only
  30055. */
  30056. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30057. /**
  30058. * Defines the function to use to interpolate matrices
  30059. * @param startValue defines the start matrix
  30060. * @param endValue defines the end matrix
  30061. * @param gradient defines the gradient between both matrices
  30062. * @param result defines an optional target matrix where to store the interpolation
  30063. * @returns the interpolated matrix
  30064. */
  30065. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30066. /**
  30067. * Makes a copy of the animation
  30068. * @returns Cloned animation
  30069. */
  30070. clone(): Animation;
  30071. /**
  30072. * Sets the key frames of the animation
  30073. * @param values The animation key frames to set
  30074. */
  30075. setKeys(values: Array<IAnimationKey>): void;
  30076. /**
  30077. * Serializes the animation to an object
  30078. * @returns Serialized object
  30079. */
  30080. serialize(): any;
  30081. /**
  30082. * Float animation type
  30083. */
  30084. static readonly ANIMATIONTYPE_FLOAT: number;
  30085. /**
  30086. * Vector3 animation type
  30087. */
  30088. static readonly ANIMATIONTYPE_VECTOR3: number;
  30089. /**
  30090. * Quaternion animation type
  30091. */
  30092. static readonly ANIMATIONTYPE_QUATERNION: number;
  30093. /**
  30094. * Matrix animation type
  30095. */
  30096. static readonly ANIMATIONTYPE_MATRIX: number;
  30097. /**
  30098. * Color3 animation type
  30099. */
  30100. static readonly ANIMATIONTYPE_COLOR3: number;
  30101. /**
  30102. * Color3 animation type
  30103. */
  30104. static readonly ANIMATIONTYPE_COLOR4: number;
  30105. /**
  30106. * Vector2 animation type
  30107. */
  30108. static readonly ANIMATIONTYPE_VECTOR2: number;
  30109. /**
  30110. * Size animation type
  30111. */
  30112. static readonly ANIMATIONTYPE_SIZE: number;
  30113. /**
  30114. * Relative Loop Mode
  30115. */
  30116. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30117. /**
  30118. * Cycle Loop Mode
  30119. */
  30120. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30121. /**
  30122. * Constant Loop Mode
  30123. */
  30124. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30125. /** @hidden */
  30126. static _UniversalLerp(left: any, right: any, amount: number): any;
  30127. /**
  30128. * Parses an animation object and creates an animation
  30129. * @param parsedAnimation Parsed animation object
  30130. * @returns Animation object
  30131. */
  30132. static Parse(parsedAnimation: any): Animation;
  30133. /**
  30134. * Appends the serialized animations from the source animations
  30135. * @param source Source containing the animations
  30136. * @param destination Target to store the animations
  30137. */
  30138. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30139. }
  30140. }
  30141. declare module "babylonjs/Animations/animatable.interface" {
  30142. import { Nullable } from "babylonjs/types";
  30143. import { Animation } from "babylonjs/Animations/animation";
  30144. /**
  30145. * Interface containing an array of animations
  30146. */
  30147. export interface IAnimatable {
  30148. /**
  30149. * Array of animations
  30150. */
  30151. animations: Nullable<Array<Animation>>;
  30152. }
  30153. }
  30154. declare module "babylonjs/Misc/decorators" {
  30155. import { Nullable } from "babylonjs/types";
  30156. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30157. import { Scene } from "babylonjs/scene";
  30158. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30159. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30160. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30161. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30162. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30163. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30164. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30165. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30166. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30167. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30168. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30169. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30170. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30171. /**
  30172. * Decorator used to define property that can be serialized as reference to a camera
  30173. * @param sourceName defines the name of the property to decorate
  30174. */
  30175. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30176. /**
  30177. * Class used to help serialization objects
  30178. */
  30179. export class SerializationHelper {
  30180. /** @hidden */
  30181. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30182. /** @hidden */
  30183. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30184. /** @hidden */
  30185. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30186. /** @hidden */
  30187. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30188. /**
  30189. * Appends the serialized animations from the source animations
  30190. * @param source Source containing the animations
  30191. * @param destination Target to store the animations
  30192. */
  30193. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30194. /**
  30195. * Static function used to serialized a specific entity
  30196. * @param entity defines the entity to serialize
  30197. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30198. * @returns a JSON compatible object representing the serialization of the entity
  30199. */
  30200. static Serialize<T>(entity: T, serializationObject?: any): any;
  30201. /**
  30202. * Creates a new entity from a serialization data object
  30203. * @param creationFunction defines a function used to instanciated the new entity
  30204. * @param source defines the source serialization data
  30205. * @param scene defines the hosting scene
  30206. * @param rootUrl defines the root url for resources
  30207. * @returns a new entity
  30208. */
  30209. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30210. /**
  30211. * Clones an object
  30212. * @param creationFunction defines the function used to instanciate the new object
  30213. * @param source defines the source object
  30214. * @returns the cloned object
  30215. */
  30216. static Clone<T>(creationFunction: () => T, source: T): T;
  30217. /**
  30218. * Instanciates a new object based on a source one (some data will be shared between both object)
  30219. * @param creationFunction defines the function used to instanciate the new object
  30220. * @param source defines the source object
  30221. * @returns the new object
  30222. */
  30223. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30224. }
  30225. }
  30226. declare module "babylonjs/Misc/guid" {
  30227. /**
  30228. * Class used to manipulate GUIDs
  30229. */
  30230. export class GUID {
  30231. /**
  30232. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30233. * Be aware Math.random() could cause collisions, but:
  30234. * "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"
  30235. * @returns a pseudo random id
  30236. */
  30237. static RandomId(): string;
  30238. }
  30239. }
  30240. declare module "babylonjs/Materials/Textures/baseTexture" {
  30241. import { Observable } from "babylonjs/Misc/observable";
  30242. import { Nullable } from "babylonjs/types";
  30243. import { Scene } from "babylonjs/scene";
  30244. import { Matrix } from "babylonjs/Maths/math.vector";
  30245. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30246. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30247. import { ISize } from "babylonjs/Maths/math.size";
  30248. /**
  30249. * Base class of all the textures in babylon.
  30250. * It groups all the common properties the materials, post process, lights... might need
  30251. * in order to make a correct use of the texture.
  30252. */
  30253. export class BaseTexture implements IAnimatable {
  30254. /**
  30255. * Default anisotropic filtering level for the application.
  30256. * It is set to 4 as a good tradeoff between perf and quality.
  30257. */
  30258. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30259. /**
  30260. * Gets or sets the unique id of the texture
  30261. */
  30262. uniqueId: number;
  30263. /**
  30264. * Define the name of the texture.
  30265. */
  30266. name: string;
  30267. /**
  30268. * Gets or sets an object used to store user defined information.
  30269. */
  30270. metadata: any;
  30271. /**
  30272. * For internal use only. Please do not use.
  30273. */
  30274. reservedDataStore: any;
  30275. private _hasAlpha;
  30276. /**
  30277. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30278. */
  30279. set hasAlpha(value: boolean);
  30280. get hasAlpha(): boolean;
  30281. /**
  30282. * Defines if the alpha value should be determined via the rgb values.
  30283. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30284. */
  30285. getAlphaFromRGB: boolean;
  30286. /**
  30287. * Intensity or strength of the texture.
  30288. * It is commonly used by materials to fine tune the intensity of the texture
  30289. */
  30290. level: number;
  30291. /**
  30292. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30293. * This is part of the texture as textures usually maps to one uv set.
  30294. */
  30295. coordinatesIndex: number;
  30296. private _coordinatesMode;
  30297. /**
  30298. * How a texture is mapped.
  30299. *
  30300. * | Value | Type | Description |
  30301. * | ----- | ----------------------------------- | ----------- |
  30302. * | 0 | EXPLICIT_MODE | |
  30303. * | 1 | SPHERICAL_MODE | |
  30304. * | 2 | PLANAR_MODE | |
  30305. * | 3 | CUBIC_MODE | |
  30306. * | 4 | PROJECTION_MODE | |
  30307. * | 5 | SKYBOX_MODE | |
  30308. * | 6 | INVCUBIC_MODE | |
  30309. * | 7 | EQUIRECTANGULAR_MODE | |
  30310. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30311. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30312. */
  30313. set coordinatesMode(value: number);
  30314. get coordinatesMode(): number;
  30315. /**
  30316. * | Value | Type | Description |
  30317. * | ----- | ------------------ | ----------- |
  30318. * | 0 | CLAMP_ADDRESSMODE | |
  30319. * | 1 | WRAP_ADDRESSMODE | |
  30320. * | 2 | MIRROR_ADDRESSMODE | |
  30321. */
  30322. wrapU: number;
  30323. /**
  30324. * | Value | Type | Description |
  30325. * | ----- | ------------------ | ----------- |
  30326. * | 0 | CLAMP_ADDRESSMODE | |
  30327. * | 1 | WRAP_ADDRESSMODE | |
  30328. * | 2 | MIRROR_ADDRESSMODE | |
  30329. */
  30330. wrapV: number;
  30331. /**
  30332. * | Value | Type | Description |
  30333. * | ----- | ------------------ | ----------- |
  30334. * | 0 | CLAMP_ADDRESSMODE | |
  30335. * | 1 | WRAP_ADDRESSMODE | |
  30336. * | 2 | MIRROR_ADDRESSMODE | |
  30337. */
  30338. wrapR: number;
  30339. /**
  30340. * With compliant hardware and browser (supporting anisotropic filtering)
  30341. * this defines the level of anisotropic filtering in the texture.
  30342. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30343. */
  30344. anisotropicFilteringLevel: number;
  30345. /**
  30346. * Define if the texture is a cube texture or if false a 2d texture.
  30347. */
  30348. get isCube(): boolean;
  30349. set isCube(value: boolean);
  30350. /**
  30351. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30352. */
  30353. get is3D(): boolean;
  30354. set is3D(value: boolean);
  30355. /**
  30356. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30357. */
  30358. get is2DArray(): boolean;
  30359. set is2DArray(value: boolean);
  30360. /**
  30361. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30362. * HDR texture are usually stored in linear space.
  30363. * This only impacts the PBR and Background materials
  30364. */
  30365. gammaSpace: boolean;
  30366. /**
  30367. * Gets or sets whether or not the texture contains RGBD data.
  30368. */
  30369. get isRGBD(): boolean;
  30370. set isRGBD(value: boolean);
  30371. /**
  30372. * Is Z inverted in the texture (useful in a cube texture).
  30373. */
  30374. invertZ: boolean;
  30375. /**
  30376. * Are mip maps generated for this texture or not.
  30377. */
  30378. get noMipmap(): boolean;
  30379. /**
  30380. * @hidden
  30381. */
  30382. lodLevelInAlpha: boolean;
  30383. /**
  30384. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30385. */
  30386. get lodGenerationOffset(): number;
  30387. set lodGenerationOffset(value: number);
  30388. /**
  30389. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30390. */
  30391. get lodGenerationScale(): number;
  30392. set lodGenerationScale(value: number);
  30393. /**
  30394. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30395. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30396. * average roughness values.
  30397. */
  30398. get linearSpecularLOD(): boolean;
  30399. set linearSpecularLOD(value: boolean);
  30400. /**
  30401. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30402. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30403. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30404. */
  30405. get irradianceTexture(): Nullable<BaseTexture>;
  30406. set irradianceTexture(value: Nullable<BaseTexture>);
  30407. /**
  30408. * Define if the texture is a render target.
  30409. */
  30410. isRenderTarget: boolean;
  30411. /**
  30412. * Define the unique id of the texture in the scene.
  30413. */
  30414. get uid(): string;
  30415. /**
  30416. * Return a string representation of the texture.
  30417. * @returns the texture as a string
  30418. */
  30419. toString(): string;
  30420. /**
  30421. * Get the class name of the texture.
  30422. * @returns "BaseTexture"
  30423. */
  30424. getClassName(): string;
  30425. /**
  30426. * Define the list of animation attached to the texture.
  30427. */
  30428. animations: import("babylonjs/Animations/animation").Animation[];
  30429. /**
  30430. * An event triggered when the texture is disposed.
  30431. */
  30432. onDisposeObservable: Observable<BaseTexture>;
  30433. private _onDisposeObserver;
  30434. /**
  30435. * Callback triggered when the texture has been disposed.
  30436. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30437. */
  30438. set onDispose(callback: () => void);
  30439. /**
  30440. * Define the current state of the loading sequence when in delayed load mode.
  30441. */
  30442. delayLoadState: number;
  30443. private _scene;
  30444. /** @hidden */
  30445. _texture: Nullable<InternalTexture>;
  30446. private _uid;
  30447. /**
  30448. * Define if the texture is preventinga material to render or not.
  30449. * If not and the texture is not ready, the engine will use a default black texture instead.
  30450. */
  30451. get isBlocking(): boolean;
  30452. /**
  30453. * Instantiates a new BaseTexture.
  30454. * Base class of all the textures in babylon.
  30455. * It groups all the common properties the materials, post process, lights... might need
  30456. * in order to make a correct use of the texture.
  30457. * @param scene Define the scene the texture blongs to
  30458. */
  30459. constructor(scene: Nullable<Scene>);
  30460. /**
  30461. * Get the scene the texture belongs to.
  30462. * @returns the scene or null if undefined
  30463. */
  30464. getScene(): Nullable<Scene>;
  30465. /**
  30466. * Get the texture transform matrix used to offset tile the texture for istance.
  30467. * @returns the transformation matrix
  30468. */
  30469. getTextureMatrix(): Matrix;
  30470. /**
  30471. * Get the texture reflection matrix used to rotate/transform the reflection.
  30472. * @returns the reflection matrix
  30473. */
  30474. getReflectionTextureMatrix(): Matrix;
  30475. /**
  30476. * Get the underlying lower level texture from Babylon.
  30477. * @returns the insternal texture
  30478. */
  30479. getInternalTexture(): Nullable<InternalTexture>;
  30480. /**
  30481. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30482. * @returns true if ready or not blocking
  30483. */
  30484. isReadyOrNotBlocking(): boolean;
  30485. /**
  30486. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30487. * @returns true if fully ready
  30488. */
  30489. isReady(): boolean;
  30490. private _cachedSize;
  30491. /**
  30492. * Get the size of the texture.
  30493. * @returns the texture size.
  30494. */
  30495. getSize(): ISize;
  30496. /**
  30497. * Get the base size of the texture.
  30498. * It can be different from the size if the texture has been resized for POT for instance
  30499. * @returns the base size
  30500. */
  30501. getBaseSize(): ISize;
  30502. /**
  30503. * Update the sampling mode of the texture.
  30504. * Default is Trilinear mode.
  30505. *
  30506. * | Value | Type | Description |
  30507. * | ----- | ------------------ | ----------- |
  30508. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30509. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30510. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30511. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30512. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30513. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30514. * | 7 | NEAREST_LINEAR | |
  30515. * | 8 | NEAREST_NEAREST | |
  30516. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30517. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30518. * | 11 | LINEAR_LINEAR | |
  30519. * | 12 | LINEAR_NEAREST | |
  30520. *
  30521. * > _mag_: magnification filter (close to the viewer)
  30522. * > _min_: minification filter (far from the viewer)
  30523. * > _mip_: filter used between mip map levels
  30524. *@param samplingMode Define the new sampling mode of the texture
  30525. */
  30526. updateSamplingMode(samplingMode: number): void;
  30527. /**
  30528. * Scales the texture if is `canRescale()`
  30529. * @param ratio the resize factor we want to use to rescale
  30530. */
  30531. scale(ratio: number): void;
  30532. /**
  30533. * Get if the texture can rescale.
  30534. */
  30535. get canRescale(): boolean;
  30536. /** @hidden */
  30537. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30538. /** @hidden */
  30539. _rebuild(): void;
  30540. /**
  30541. * Triggers the load sequence in delayed load mode.
  30542. */
  30543. delayLoad(): void;
  30544. /**
  30545. * Clones the texture.
  30546. * @returns the cloned texture
  30547. */
  30548. clone(): Nullable<BaseTexture>;
  30549. /**
  30550. * Get the texture underlying type (INT, FLOAT...)
  30551. */
  30552. get textureType(): number;
  30553. /**
  30554. * Get the texture underlying format (RGB, RGBA...)
  30555. */
  30556. get textureFormat(): number;
  30557. /**
  30558. * Indicates that textures need to be re-calculated for all materials
  30559. */
  30560. protected _markAllSubMeshesAsTexturesDirty(): void;
  30561. /**
  30562. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30563. * This will returns an RGBA array buffer containing either in values (0-255) or
  30564. * float values (0-1) depending of the underlying buffer type.
  30565. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30566. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30567. * @param buffer defines a user defined buffer to fill with data (can be null)
  30568. * @returns The Array buffer containing the pixels data.
  30569. */
  30570. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30571. /**
  30572. * Release and destroy the underlying lower level texture aka internalTexture.
  30573. */
  30574. releaseInternalTexture(): void;
  30575. /** @hidden */
  30576. get _lodTextureHigh(): Nullable<BaseTexture>;
  30577. /** @hidden */
  30578. get _lodTextureMid(): Nullable<BaseTexture>;
  30579. /** @hidden */
  30580. get _lodTextureLow(): Nullable<BaseTexture>;
  30581. /**
  30582. * Dispose the texture and release its associated resources.
  30583. */
  30584. dispose(): void;
  30585. /**
  30586. * Serialize the texture into a JSON representation that can be parsed later on.
  30587. * @returns the JSON representation of the texture
  30588. */
  30589. serialize(): any;
  30590. /**
  30591. * Helper function to be called back once a list of texture contains only ready textures.
  30592. * @param textures Define the list of textures to wait for
  30593. * @param callback Define the callback triggered once the entire list will be ready
  30594. */
  30595. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30596. }
  30597. }
  30598. declare module "babylonjs/Materials/effect" {
  30599. import { Observable } from "babylonjs/Misc/observable";
  30600. import { Nullable } from "babylonjs/types";
  30601. import { IDisposable } from "babylonjs/scene";
  30602. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30603. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30604. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30605. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30606. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30607. import { Engine } from "babylonjs/Engines/engine";
  30608. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30609. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30610. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30611. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30612. /**
  30613. * Options to be used when creating an effect.
  30614. */
  30615. export interface IEffectCreationOptions {
  30616. /**
  30617. * Atrributes that will be used in the shader.
  30618. */
  30619. attributes: string[];
  30620. /**
  30621. * Uniform varible names that will be set in the shader.
  30622. */
  30623. uniformsNames: string[];
  30624. /**
  30625. * Uniform buffer variable names that will be set in the shader.
  30626. */
  30627. uniformBuffersNames: string[];
  30628. /**
  30629. * Sampler texture variable names that will be set in the shader.
  30630. */
  30631. samplers: string[];
  30632. /**
  30633. * Define statements that will be set in the shader.
  30634. */
  30635. defines: any;
  30636. /**
  30637. * Possible fallbacks for this effect to improve performance when needed.
  30638. */
  30639. fallbacks: Nullable<IEffectFallbacks>;
  30640. /**
  30641. * Callback that will be called when the shader is compiled.
  30642. */
  30643. onCompiled: Nullable<(effect: Effect) => void>;
  30644. /**
  30645. * Callback that will be called if an error occurs during shader compilation.
  30646. */
  30647. onError: Nullable<(effect: Effect, errors: string) => void>;
  30648. /**
  30649. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30650. */
  30651. indexParameters?: any;
  30652. /**
  30653. * Max number of lights that can be used in the shader.
  30654. */
  30655. maxSimultaneousLights?: number;
  30656. /**
  30657. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30658. */
  30659. transformFeedbackVaryings?: Nullable<string[]>;
  30660. }
  30661. /**
  30662. * Effect containing vertex and fragment shader that can be executed on an object.
  30663. */
  30664. export class Effect implements IDisposable {
  30665. /**
  30666. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30667. */
  30668. static ShadersRepository: string;
  30669. /**
  30670. * Name of the effect.
  30671. */
  30672. name: any;
  30673. /**
  30674. * String container all the define statements that should be set on the shader.
  30675. */
  30676. defines: string;
  30677. /**
  30678. * Callback that will be called when the shader is compiled.
  30679. */
  30680. onCompiled: Nullable<(effect: Effect) => void>;
  30681. /**
  30682. * Callback that will be called if an error occurs during shader compilation.
  30683. */
  30684. onError: Nullable<(effect: Effect, errors: string) => void>;
  30685. /**
  30686. * Callback that will be called when effect is bound.
  30687. */
  30688. onBind: Nullable<(effect: Effect) => void>;
  30689. /**
  30690. * Unique ID of the effect.
  30691. */
  30692. uniqueId: number;
  30693. /**
  30694. * Observable that will be called when the shader is compiled.
  30695. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30696. */
  30697. onCompileObservable: Observable<Effect>;
  30698. /**
  30699. * Observable that will be called if an error occurs during shader compilation.
  30700. */
  30701. onErrorObservable: Observable<Effect>;
  30702. /** @hidden */
  30703. _onBindObservable: Nullable<Observable<Effect>>;
  30704. /**
  30705. * Observable that will be called when effect is bound.
  30706. */
  30707. get onBindObservable(): Observable<Effect>;
  30708. /** @hidden */
  30709. _bonesComputationForcedToCPU: boolean;
  30710. private static _uniqueIdSeed;
  30711. private _engine;
  30712. private _uniformBuffersNames;
  30713. private _uniformsNames;
  30714. private _samplerList;
  30715. private _samplers;
  30716. private _isReady;
  30717. private _compilationError;
  30718. private _allFallbacksProcessed;
  30719. private _attributesNames;
  30720. private _attributes;
  30721. private _attributeLocationByName;
  30722. private _uniforms;
  30723. /**
  30724. * Key for the effect.
  30725. * @hidden
  30726. */
  30727. _key: string;
  30728. private _indexParameters;
  30729. private _fallbacks;
  30730. private _vertexSourceCode;
  30731. private _fragmentSourceCode;
  30732. private _vertexSourceCodeOverride;
  30733. private _fragmentSourceCodeOverride;
  30734. private _transformFeedbackVaryings;
  30735. /**
  30736. * Compiled shader to webGL program.
  30737. * @hidden
  30738. */
  30739. _pipelineContext: Nullable<IPipelineContext>;
  30740. private _valueCache;
  30741. private static _baseCache;
  30742. /**
  30743. * Instantiates an effect.
  30744. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30745. * @param baseName Name of the effect.
  30746. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30747. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30748. * @param samplers List of sampler variables that will be passed to the shader.
  30749. * @param engine Engine to be used to render the effect
  30750. * @param defines Define statements to be added to the shader.
  30751. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30752. * @param onCompiled Callback that will be called when the shader is compiled.
  30753. * @param onError Callback that will be called if an error occurs during shader compilation.
  30754. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30755. */
  30756. 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);
  30757. private _useFinalCode;
  30758. /**
  30759. * Unique key for this effect
  30760. */
  30761. get key(): string;
  30762. /**
  30763. * If the effect has been compiled and prepared.
  30764. * @returns if the effect is compiled and prepared.
  30765. */
  30766. isReady(): boolean;
  30767. private _isReadyInternal;
  30768. /**
  30769. * The engine the effect was initialized with.
  30770. * @returns the engine.
  30771. */
  30772. getEngine(): Engine;
  30773. /**
  30774. * The pipeline context for this effect
  30775. * @returns the associated pipeline context
  30776. */
  30777. getPipelineContext(): Nullable<IPipelineContext>;
  30778. /**
  30779. * The set of names of attribute variables for the shader.
  30780. * @returns An array of attribute names.
  30781. */
  30782. getAttributesNames(): string[];
  30783. /**
  30784. * Returns the attribute at the given index.
  30785. * @param index The index of the attribute.
  30786. * @returns The location of the attribute.
  30787. */
  30788. getAttributeLocation(index: number): number;
  30789. /**
  30790. * Returns the attribute based on the name of the variable.
  30791. * @param name of the attribute to look up.
  30792. * @returns the attribute location.
  30793. */
  30794. getAttributeLocationByName(name: string): number;
  30795. /**
  30796. * The number of attributes.
  30797. * @returns the numnber of attributes.
  30798. */
  30799. getAttributesCount(): number;
  30800. /**
  30801. * Gets the index of a uniform variable.
  30802. * @param uniformName of the uniform to look up.
  30803. * @returns the index.
  30804. */
  30805. getUniformIndex(uniformName: string): number;
  30806. /**
  30807. * Returns the attribute based on the name of the variable.
  30808. * @param uniformName of the uniform to look up.
  30809. * @returns the location of the uniform.
  30810. */
  30811. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30812. /**
  30813. * Returns an array of sampler variable names
  30814. * @returns The array of sampler variable neames.
  30815. */
  30816. getSamplers(): string[];
  30817. /**
  30818. * The error from the last compilation.
  30819. * @returns the error string.
  30820. */
  30821. getCompilationError(): string;
  30822. /**
  30823. * Gets a boolean indicating that all fallbacks were used during compilation
  30824. * @returns true if all fallbacks were used
  30825. */
  30826. allFallbacksProcessed(): boolean;
  30827. /**
  30828. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30829. * @param func The callback to be used.
  30830. */
  30831. executeWhenCompiled(func: (effect: Effect) => void): void;
  30832. private _checkIsReady;
  30833. private _loadShader;
  30834. /**
  30835. * Recompiles the webGL program
  30836. * @param vertexSourceCode The source code for the vertex shader.
  30837. * @param fragmentSourceCode The source code for the fragment shader.
  30838. * @param onCompiled Callback called when completed.
  30839. * @param onError Callback called on error.
  30840. * @hidden
  30841. */
  30842. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30843. /**
  30844. * Prepares the effect
  30845. * @hidden
  30846. */
  30847. _prepareEffect(): void;
  30848. private _processCompilationErrors;
  30849. /**
  30850. * Checks if the effect is supported. (Must be called after compilation)
  30851. */
  30852. get isSupported(): boolean;
  30853. /**
  30854. * Binds a texture to the engine to be used as output of the shader.
  30855. * @param channel Name of the output variable.
  30856. * @param texture Texture to bind.
  30857. * @hidden
  30858. */
  30859. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30860. /**
  30861. * Sets a texture on the engine to be used in the shader.
  30862. * @param channel Name of the sampler variable.
  30863. * @param texture Texture to set.
  30864. */
  30865. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30866. /**
  30867. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30868. * @param channel Name of the sampler variable.
  30869. * @param texture Texture to set.
  30870. */
  30871. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30872. /**
  30873. * Sets an array of textures on the engine to be used in the shader.
  30874. * @param channel Name of the variable.
  30875. * @param textures Textures to set.
  30876. */
  30877. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30878. /**
  30879. * 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)
  30880. * @param channel Name of the sampler variable.
  30881. * @param postProcess Post process to get the input texture from.
  30882. */
  30883. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30884. /**
  30885. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30886. * 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)
  30887. * @param channel Name of the sampler variable.
  30888. * @param postProcess Post process to get the output texture from.
  30889. */
  30890. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30891. /** @hidden */
  30892. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30893. /** @hidden */
  30894. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30895. /** @hidden */
  30896. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30897. /** @hidden */
  30898. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30899. /**
  30900. * Binds a buffer to a uniform.
  30901. * @param buffer Buffer to bind.
  30902. * @param name Name of the uniform variable to bind to.
  30903. */
  30904. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30905. /**
  30906. * Binds block to a uniform.
  30907. * @param blockName Name of the block to bind.
  30908. * @param index Index to bind.
  30909. */
  30910. bindUniformBlock(blockName: string, index: number): void;
  30911. /**
  30912. * Sets an interger value on a uniform variable.
  30913. * @param uniformName Name of the variable.
  30914. * @param value Value to be set.
  30915. * @returns this effect.
  30916. */
  30917. setInt(uniformName: string, value: number): Effect;
  30918. /**
  30919. * Sets an int array on a uniform variable.
  30920. * @param uniformName Name of the variable.
  30921. * @param array array to be set.
  30922. * @returns this effect.
  30923. */
  30924. setIntArray(uniformName: string, array: Int32Array): Effect;
  30925. /**
  30926. * 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)
  30927. * @param uniformName Name of the variable.
  30928. * @param array array to be set.
  30929. * @returns this effect.
  30930. */
  30931. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30932. /**
  30933. * 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)
  30934. * @param uniformName Name of the variable.
  30935. * @param array array to be set.
  30936. * @returns this effect.
  30937. */
  30938. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30939. /**
  30940. * 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)
  30941. * @param uniformName Name of the variable.
  30942. * @param array array to be set.
  30943. * @returns this effect.
  30944. */
  30945. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30946. /**
  30947. * Sets an float array on a uniform variable.
  30948. * @param uniformName Name of the variable.
  30949. * @param array array to be set.
  30950. * @returns this effect.
  30951. */
  30952. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30953. /**
  30954. * 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)
  30955. * @param uniformName Name of the variable.
  30956. * @param array array to be set.
  30957. * @returns this effect.
  30958. */
  30959. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30960. /**
  30961. * 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)
  30962. * @param uniformName Name of the variable.
  30963. * @param array array to be set.
  30964. * @returns this effect.
  30965. */
  30966. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30967. /**
  30968. * 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)
  30969. * @param uniformName Name of the variable.
  30970. * @param array array to be set.
  30971. * @returns this effect.
  30972. */
  30973. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30974. /**
  30975. * Sets an array on a uniform variable.
  30976. * @param uniformName Name of the variable.
  30977. * @param array array to be set.
  30978. * @returns this effect.
  30979. */
  30980. setArray(uniformName: string, array: number[]): Effect;
  30981. /**
  30982. * 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)
  30983. * @param uniformName Name of the variable.
  30984. * @param array array to be set.
  30985. * @returns this effect.
  30986. */
  30987. setArray2(uniformName: string, array: number[]): Effect;
  30988. /**
  30989. * 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)
  30990. * @param uniformName Name of the variable.
  30991. * @param array array to be set.
  30992. * @returns this effect.
  30993. */
  30994. setArray3(uniformName: string, array: number[]): Effect;
  30995. /**
  30996. * 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)
  30997. * @param uniformName Name of the variable.
  30998. * @param array array to be set.
  30999. * @returns this effect.
  31000. */
  31001. setArray4(uniformName: string, array: number[]): Effect;
  31002. /**
  31003. * Sets matrices on a uniform variable.
  31004. * @param uniformName Name of the variable.
  31005. * @param matrices matrices to be set.
  31006. * @returns this effect.
  31007. */
  31008. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31009. /**
  31010. * Sets matrix on a uniform variable.
  31011. * @param uniformName Name of the variable.
  31012. * @param matrix matrix to be set.
  31013. * @returns this effect.
  31014. */
  31015. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31016. /**
  31017. * 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)
  31018. * @param uniformName Name of the variable.
  31019. * @param matrix matrix to be set.
  31020. * @returns this effect.
  31021. */
  31022. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31023. /**
  31024. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31025. * @param uniformName Name of the variable.
  31026. * @param matrix matrix to be set.
  31027. * @returns this effect.
  31028. */
  31029. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31030. /**
  31031. * Sets a float on a uniform variable.
  31032. * @param uniformName Name of the variable.
  31033. * @param value value to be set.
  31034. * @returns this effect.
  31035. */
  31036. setFloat(uniformName: string, value: number): Effect;
  31037. /**
  31038. * Sets a boolean on a uniform variable.
  31039. * @param uniformName Name of the variable.
  31040. * @param bool value to be set.
  31041. * @returns this effect.
  31042. */
  31043. setBool(uniformName: string, bool: boolean): Effect;
  31044. /**
  31045. * Sets a Vector2 on a uniform variable.
  31046. * @param uniformName Name of the variable.
  31047. * @param vector2 vector2 to be set.
  31048. * @returns this effect.
  31049. */
  31050. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31051. /**
  31052. * Sets a float2 on a uniform variable.
  31053. * @param uniformName Name of the variable.
  31054. * @param x First float in float2.
  31055. * @param y Second float in float2.
  31056. * @returns this effect.
  31057. */
  31058. setFloat2(uniformName: string, x: number, y: number): Effect;
  31059. /**
  31060. * Sets a Vector3 on a uniform variable.
  31061. * @param uniformName Name of the variable.
  31062. * @param vector3 Value to be set.
  31063. * @returns this effect.
  31064. */
  31065. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31066. /**
  31067. * Sets a float3 on a uniform variable.
  31068. * @param uniformName Name of the variable.
  31069. * @param x First float in float3.
  31070. * @param y Second float in float3.
  31071. * @param z Third float in float3.
  31072. * @returns this effect.
  31073. */
  31074. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31075. /**
  31076. * Sets a Vector4 on a uniform variable.
  31077. * @param uniformName Name of the variable.
  31078. * @param vector4 Value to be set.
  31079. * @returns this effect.
  31080. */
  31081. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31082. /**
  31083. * Sets a float4 on a uniform variable.
  31084. * @param uniformName Name of the variable.
  31085. * @param x First float in float4.
  31086. * @param y Second float in float4.
  31087. * @param z Third float in float4.
  31088. * @param w Fourth float in float4.
  31089. * @returns this effect.
  31090. */
  31091. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31092. /**
  31093. * Sets a Color3 on a uniform variable.
  31094. * @param uniformName Name of the variable.
  31095. * @param color3 Value to be set.
  31096. * @returns this effect.
  31097. */
  31098. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31099. /**
  31100. * Sets a Color4 on a uniform variable.
  31101. * @param uniformName Name of the variable.
  31102. * @param color3 Value to be set.
  31103. * @param alpha Alpha value to be set.
  31104. * @returns this effect.
  31105. */
  31106. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31107. /**
  31108. * Sets a Color4 on a uniform variable
  31109. * @param uniformName defines the name of the variable
  31110. * @param color4 defines the value to be set
  31111. * @returns this effect.
  31112. */
  31113. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31114. /** Release all associated resources */
  31115. dispose(): void;
  31116. /**
  31117. * This function will add a new shader to the shader store
  31118. * @param name the name of the shader
  31119. * @param pixelShader optional pixel shader content
  31120. * @param vertexShader optional vertex shader content
  31121. */
  31122. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31123. /**
  31124. * Store of each shader (The can be looked up using effect.key)
  31125. */
  31126. static ShadersStore: {
  31127. [key: string]: string;
  31128. };
  31129. /**
  31130. * Store of each included file for a shader (The can be looked up using effect.key)
  31131. */
  31132. static IncludesShadersStore: {
  31133. [key: string]: string;
  31134. };
  31135. /**
  31136. * Resets the cache of effects.
  31137. */
  31138. static ResetCache(): void;
  31139. }
  31140. }
  31141. declare module "babylonjs/Engines/engineCapabilities" {
  31142. /**
  31143. * Interface used to describe the capabilities of the engine relatively to the current browser
  31144. */
  31145. export interface EngineCapabilities {
  31146. /** Maximum textures units per fragment shader */
  31147. maxTexturesImageUnits: number;
  31148. /** Maximum texture units per vertex shader */
  31149. maxVertexTextureImageUnits: number;
  31150. /** Maximum textures units in the entire pipeline */
  31151. maxCombinedTexturesImageUnits: number;
  31152. /** Maximum texture size */
  31153. maxTextureSize: number;
  31154. /** Maximum texture samples */
  31155. maxSamples?: number;
  31156. /** Maximum cube texture size */
  31157. maxCubemapTextureSize: number;
  31158. /** Maximum render texture size */
  31159. maxRenderTextureSize: number;
  31160. /** Maximum number of vertex attributes */
  31161. maxVertexAttribs: number;
  31162. /** Maximum number of varyings */
  31163. maxVaryingVectors: number;
  31164. /** Maximum number of uniforms per vertex shader */
  31165. maxVertexUniformVectors: number;
  31166. /** Maximum number of uniforms per fragment shader */
  31167. maxFragmentUniformVectors: number;
  31168. /** Defines if standard derivates (dx/dy) are supported */
  31169. standardDerivatives: boolean;
  31170. /** Defines if s3tc texture compression is supported */
  31171. s3tc?: WEBGL_compressed_texture_s3tc;
  31172. /** Defines if pvrtc texture compression is supported */
  31173. pvrtc: any;
  31174. /** Defines if etc1 texture compression is supported */
  31175. etc1: any;
  31176. /** Defines if etc2 texture compression is supported */
  31177. etc2: any;
  31178. /** Defines if astc texture compression is supported */
  31179. astc: any;
  31180. /** Defines if float textures are supported */
  31181. textureFloat: boolean;
  31182. /** Defines if vertex array objects are supported */
  31183. vertexArrayObject: boolean;
  31184. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31185. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31186. /** Gets the maximum level of anisotropy supported */
  31187. maxAnisotropy: number;
  31188. /** Defines if instancing is supported */
  31189. instancedArrays: boolean;
  31190. /** Defines if 32 bits indices are supported */
  31191. uintIndices: boolean;
  31192. /** Defines if high precision shaders are supported */
  31193. highPrecisionShaderSupported: boolean;
  31194. /** Defines if depth reading in the fragment shader is supported */
  31195. fragmentDepthSupported: boolean;
  31196. /** Defines if float texture linear filtering is supported*/
  31197. textureFloatLinearFiltering: boolean;
  31198. /** Defines if rendering to float textures is supported */
  31199. textureFloatRender: boolean;
  31200. /** Defines if half float textures are supported*/
  31201. textureHalfFloat: boolean;
  31202. /** Defines if half float texture linear filtering is supported*/
  31203. textureHalfFloatLinearFiltering: boolean;
  31204. /** Defines if rendering to half float textures is supported */
  31205. textureHalfFloatRender: boolean;
  31206. /** Defines if textureLOD shader command is supported */
  31207. textureLOD: boolean;
  31208. /** Defines if draw buffers extension is supported */
  31209. drawBuffersExtension: boolean;
  31210. /** Defines if depth textures are supported */
  31211. depthTextureExtension: boolean;
  31212. /** Defines if float color buffer are supported */
  31213. colorBufferFloat: boolean;
  31214. /** Gets disjoint timer query extension (null if not supported) */
  31215. timerQuery?: EXT_disjoint_timer_query;
  31216. /** Defines if timestamp can be used with timer query */
  31217. canUseTimestampForTimerQuery: boolean;
  31218. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31219. multiview?: any;
  31220. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31221. oculusMultiview?: any;
  31222. /** Function used to let the system compiles shaders in background */
  31223. parallelShaderCompile?: {
  31224. COMPLETION_STATUS_KHR: number;
  31225. };
  31226. /** Max number of texture samples for MSAA */
  31227. maxMSAASamples: number;
  31228. /** Defines if the blend min max extension is supported */
  31229. blendMinMax: boolean;
  31230. }
  31231. }
  31232. declare module "babylonjs/States/depthCullingState" {
  31233. import { Nullable } from "babylonjs/types";
  31234. /**
  31235. * @hidden
  31236. **/
  31237. export class DepthCullingState {
  31238. private _isDepthTestDirty;
  31239. private _isDepthMaskDirty;
  31240. private _isDepthFuncDirty;
  31241. private _isCullFaceDirty;
  31242. private _isCullDirty;
  31243. private _isZOffsetDirty;
  31244. private _isFrontFaceDirty;
  31245. private _depthTest;
  31246. private _depthMask;
  31247. private _depthFunc;
  31248. private _cull;
  31249. private _cullFace;
  31250. private _zOffset;
  31251. private _frontFace;
  31252. /**
  31253. * Initializes the state.
  31254. */
  31255. constructor();
  31256. get isDirty(): boolean;
  31257. get zOffset(): number;
  31258. set zOffset(value: number);
  31259. get cullFace(): Nullable<number>;
  31260. set cullFace(value: Nullable<number>);
  31261. get cull(): Nullable<boolean>;
  31262. set cull(value: Nullable<boolean>);
  31263. get depthFunc(): Nullable<number>;
  31264. set depthFunc(value: Nullable<number>);
  31265. get depthMask(): boolean;
  31266. set depthMask(value: boolean);
  31267. get depthTest(): boolean;
  31268. set depthTest(value: boolean);
  31269. get frontFace(): Nullable<number>;
  31270. set frontFace(value: Nullable<number>);
  31271. reset(): void;
  31272. apply(gl: WebGLRenderingContext): void;
  31273. }
  31274. }
  31275. declare module "babylonjs/States/stencilState" {
  31276. /**
  31277. * @hidden
  31278. **/
  31279. export class StencilState {
  31280. /** 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 */
  31281. static readonly ALWAYS: number;
  31282. /** Passed to stencilOperation to specify that stencil value must be kept */
  31283. static readonly KEEP: number;
  31284. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31285. static readonly REPLACE: number;
  31286. private _isStencilTestDirty;
  31287. private _isStencilMaskDirty;
  31288. private _isStencilFuncDirty;
  31289. private _isStencilOpDirty;
  31290. private _stencilTest;
  31291. private _stencilMask;
  31292. private _stencilFunc;
  31293. private _stencilFuncRef;
  31294. private _stencilFuncMask;
  31295. private _stencilOpStencilFail;
  31296. private _stencilOpDepthFail;
  31297. private _stencilOpStencilDepthPass;
  31298. get isDirty(): boolean;
  31299. get stencilFunc(): number;
  31300. set stencilFunc(value: number);
  31301. get stencilFuncRef(): number;
  31302. set stencilFuncRef(value: number);
  31303. get stencilFuncMask(): number;
  31304. set stencilFuncMask(value: number);
  31305. get stencilOpStencilFail(): number;
  31306. set stencilOpStencilFail(value: number);
  31307. get stencilOpDepthFail(): number;
  31308. set stencilOpDepthFail(value: number);
  31309. get stencilOpStencilDepthPass(): number;
  31310. set stencilOpStencilDepthPass(value: number);
  31311. get stencilMask(): number;
  31312. set stencilMask(value: number);
  31313. get stencilTest(): boolean;
  31314. set stencilTest(value: boolean);
  31315. constructor();
  31316. reset(): void;
  31317. apply(gl: WebGLRenderingContext): void;
  31318. }
  31319. }
  31320. declare module "babylonjs/States/alphaCullingState" {
  31321. /**
  31322. * @hidden
  31323. **/
  31324. export class AlphaState {
  31325. private _isAlphaBlendDirty;
  31326. private _isBlendFunctionParametersDirty;
  31327. private _isBlendEquationParametersDirty;
  31328. private _isBlendConstantsDirty;
  31329. private _alphaBlend;
  31330. private _blendFunctionParameters;
  31331. private _blendEquationParameters;
  31332. private _blendConstants;
  31333. /**
  31334. * Initializes the state.
  31335. */
  31336. constructor();
  31337. get isDirty(): boolean;
  31338. get alphaBlend(): boolean;
  31339. set alphaBlend(value: boolean);
  31340. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31341. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31342. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31343. reset(): void;
  31344. apply(gl: WebGLRenderingContext): void;
  31345. }
  31346. }
  31347. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31348. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31349. /** @hidden */
  31350. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31351. attributeProcessor(attribute: string): string;
  31352. varyingProcessor(varying: string, isFragment: boolean): string;
  31353. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31354. }
  31355. }
  31356. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31357. /**
  31358. * Interface for attribute information associated with buffer instanciation
  31359. */
  31360. export interface InstancingAttributeInfo {
  31361. /**
  31362. * Name of the GLSL attribute
  31363. * if attribute index is not specified, this is used to retrieve the index from the effect
  31364. */
  31365. attributeName: string;
  31366. /**
  31367. * Index/offset of the attribute in the vertex shader
  31368. * if not specified, this will be computes from the name.
  31369. */
  31370. index?: number;
  31371. /**
  31372. * size of the attribute, 1, 2, 3 or 4
  31373. */
  31374. attributeSize: number;
  31375. /**
  31376. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31377. */
  31378. offset: number;
  31379. /**
  31380. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31381. * default to 1
  31382. */
  31383. divisor?: number;
  31384. /**
  31385. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31386. * default is FLOAT
  31387. */
  31388. attributeType?: number;
  31389. /**
  31390. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31391. */
  31392. normalized?: boolean;
  31393. }
  31394. }
  31395. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31396. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31397. import { Nullable } from "babylonjs/types";
  31398. module "babylonjs/Engines/thinEngine" {
  31399. interface ThinEngine {
  31400. /**
  31401. * Update a video texture
  31402. * @param texture defines the texture to update
  31403. * @param video defines the video element to use
  31404. * @param invertY defines if data must be stored with Y axis inverted
  31405. */
  31406. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31407. }
  31408. }
  31409. }
  31410. declare module "babylonjs/Materials/Textures/videoTexture" {
  31411. import { Observable } from "babylonjs/Misc/observable";
  31412. import { Nullable } from "babylonjs/types";
  31413. import { Scene } from "babylonjs/scene";
  31414. import { Texture } from "babylonjs/Materials/Textures/texture";
  31415. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31416. /**
  31417. * Settings for finer control over video usage
  31418. */
  31419. export interface VideoTextureSettings {
  31420. /**
  31421. * Applies `autoplay` to video, if specified
  31422. */
  31423. autoPlay?: boolean;
  31424. /**
  31425. * Applies `loop` to video, if specified
  31426. */
  31427. loop?: boolean;
  31428. /**
  31429. * Automatically updates internal texture from video at every frame in the render loop
  31430. */
  31431. autoUpdateTexture: boolean;
  31432. /**
  31433. * Image src displayed during the video loading or until the user interacts with the video.
  31434. */
  31435. poster?: string;
  31436. }
  31437. /**
  31438. * If you want to display a video in your scene, this is the special texture for that.
  31439. * This special texture works similar to other textures, with the exception of a few parameters.
  31440. * @see https://doc.babylonjs.com/how_to/video_texture
  31441. */
  31442. export class VideoTexture extends Texture {
  31443. /**
  31444. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31445. */
  31446. readonly autoUpdateTexture: boolean;
  31447. /**
  31448. * The video instance used by the texture internally
  31449. */
  31450. readonly video: HTMLVideoElement;
  31451. private _onUserActionRequestedObservable;
  31452. /**
  31453. * Event triggerd when a dom action is required by the user to play the video.
  31454. * This happens due to recent changes in browser policies preventing video to auto start.
  31455. */
  31456. get onUserActionRequestedObservable(): Observable<Texture>;
  31457. private _generateMipMaps;
  31458. private _engine;
  31459. private _stillImageCaptured;
  31460. private _displayingPosterTexture;
  31461. private _settings;
  31462. private _createInternalTextureOnEvent;
  31463. private _frameId;
  31464. /**
  31465. * Creates a video texture.
  31466. * If you want to display a video in your scene, this is the special texture for that.
  31467. * This special texture works similar to other textures, with the exception of a few parameters.
  31468. * @see https://doc.babylonjs.com/how_to/video_texture
  31469. * @param name optional name, will detect from video source, if not defined
  31470. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31471. * @param scene is obviously the current scene.
  31472. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31473. * @param invertY is false by default but can be used to invert video on Y axis
  31474. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31475. * @param settings allows finer control over video usage
  31476. */
  31477. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31478. private _getName;
  31479. private _getVideo;
  31480. private _createInternalTexture;
  31481. private reset;
  31482. /**
  31483. * @hidden Internal method to initiate `update`.
  31484. */
  31485. _rebuild(): void;
  31486. /**
  31487. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31488. */
  31489. update(): void;
  31490. /**
  31491. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31492. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31493. */
  31494. updateTexture(isVisible: boolean): void;
  31495. protected _updateInternalTexture: () => void;
  31496. /**
  31497. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31498. * @param url New url.
  31499. */
  31500. updateURL(url: string): void;
  31501. /**
  31502. * Dispose the texture and release its associated resources.
  31503. */
  31504. dispose(): void;
  31505. /**
  31506. * Creates a video texture straight from a stream.
  31507. * @param scene Define the scene the texture should be created in
  31508. * @param stream Define the stream the texture should be created from
  31509. * @returns The created video texture as a promise
  31510. */
  31511. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31512. /**
  31513. * Creates a video texture straight from your WebCam video feed.
  31514. * @param scene Define the scene the texture should be created in
  31515. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31516. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31517. * @returns The created video texture as a promise
  31518. */
  31519. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31520. minWidth: number;
  31521. maxWidth: number;
  31522. minHeight: number;
  31523. maxHeight: number;
  31524. deviceId: string;
  31525. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31526. /**
  31527. * Creates a video texture straight from your WebCam video feed.
  31528. * @param scene Define the scene the texture should be created in
  31529. * @param onReady Define a callback to triggered once the texture will be ready
  31530. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31531. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31532. */
  31533. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31534. minWidth: number;
  31535. maxWidth: number;
  31536. minHeight: number;
  31537. maxHeight: number;
  31538. deviceId: string;
  31539. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31540. }
  31541. }
  31542. declare module "babylonjs/Engines/thinEngine" {
  31543. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31544. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31545. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31546. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31547. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31548. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31549. import { Observable } from "babylonjs/Misc/observable";
  31550. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31551. import { StencilState } from "babylonjs/States/stencilState";
  31552. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31554. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31555. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31556. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31557. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31558. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31559. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31560. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31561. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31562. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31563. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31564. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31565. /**
  31566. * Defines the interface used by objects working like Scene
  31567. * @hidden
  31568. */
  31569. interface ISceneLike {
  31570. _addPendingData(data: any): void;
  31571. _removePendingData(data: any): void;
  31572. offlineProvider: IOfflineProvider;
  31573. }
  31574. /** Interface defining initialization parameters for Engine class */
  31575. export interface EngineOptions extends WebGLContextAttributes {
  31576. /**
  31577. * Defines if the engine should no exceed a specified device ratio
  31578. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31579. */
  31580. limitDeviceRatio?: number;
  31581. /**
  31582. * Defines if webvr should be enabled automatically
  31583. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31584. */
  31585. autoEnableWebVR?: boolean;
  31586. /**
  31587. * Defines if webgl2 should be turned off even if supported
  31588. * @see http://doc.babylonjs.com/features/webgl2
  31589. */
  31590. disableWebGL2Support?: boolean;
  31591. /**
  31592. * Defines if webaudio should be initialized as well
  31593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31594. */
  31595. audioEngine?: boolean;
  31596. /**
  31597. * Defines if animations should run using a deterministic lock step
  31598. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31599. */
  31600. deterministicLockstep?: boolean;
  31601. /** Defines the maximum steps to use with deterministic lock step mode */
  31602. lockstepMaxSteps?: number;
  31603. /** Defines the seconds between each deterministic lock step */
  31604. timeStep?: number;
  31605. /**
  31606. * Defines that engine should ignore context lost events
  31607. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31608. */
  31609. doNotHandleContextLost?: boolean;
  31610. /**
  31611. * Defines that engine should ignore modifying touch action attribute and style
  31612. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31613. */
  31614. doNotHandleTouchAction?: boolean;
  31615. /**
  31616. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31617. */
  31618. useHighPrecisionFloats?: boolean;
  31619. }
  31620. /**
  31621. * The base engine class (root of all engines)
  31622. */
  31623. export class ThinEngine {
  31624. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31625. static ExceptionList: ({
  31626. key: string;
  31627. capture: string;
  31628. captureConstraint: number;
  31629. targets: string[];
  31630. } | {
  31631. key: string;
  31632. capture: null;
  31633. captureConstraint: null;
  31634. targets: string[];
  31635. })[];
  31636. /** @hidden */
  31637. static _TextureLoaders: IInternalTextureLoader[];
  31638. /**
  31639. * Returns the current npm package of the sdk
  31640. */
  31641. static get NpmPackage(): string;
  31642. /**
  31643. * Returns the current version of the framework
  31644. */
  31645. static get Version(): string;
  31646. /**
  31647. * Returns a string describing the current engine
  31648. */
  31649. get description(): string;
  31650. /**
  31651. * Gets or sets the epsilon value used by collision engine
  31652. */
  31653. static CollisionsEpsilon: number;
  31654. /**
  31655. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31656. */
  31657. static get ShadersRepository(): string;
  31658. static set ShadersRepository(value: string);
  31659. /**
  31660. * Gets or sets the textures that the engine should not attempt to load as compressed
  31661. */
  31662. protected _excludedCompressedTextures: string[];
  31663. /**
  31664. * Filters the compressed texture formats to only include
  31665. * files that are not included in the skippable list
  31666. *
  31667. * @param url the current extension
  31668. * @param textureFormatInUse the current compressed texture format
  31669. * @returns "format" string
  31670. */
  31671. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31672. /** @hidden */
  31673. _shaderProcessor: IShaderProcessor;
  31674. /**
  31675. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31676. */
  31677. forcePOTTextures: boolean;
  31678. /**
  31679. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31680. */
  31681. isFullscreen: boolean;
  31682. /**
  31683. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31684. */
  31685. cullBackFaces: boolean;
  31686. /**
  31687. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31688. */
  31689. renderEvenInBackground: boolean;
  31690. /**
  31691. * Gets or sets a boolean indicating that cache can be kept between frames
  31692. */
  31693. preventCacheWipeBetweenFrames: boolean;
  31694. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31695. validateShaderPrograms: boolean;
  31696. /**
  31697. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31698. * This can provide greater z depth for distant objects.
  31699. */
  31700. useReverseDepthBuffer: boolean;
  31701. /**
  31702. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31703. */
  31704. disableUniformBuffers: boolean;
  31705. /** @hidden */
  31706. _uniformBuffers: UniformBuffer[];
  31707. /**
  31708. * Gets a boolean indicating that the engine supports uniform buffers
  31709. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31710. */
  31711. get supportsUniformBuffers(): boolean;
  31712. /** @hidden */
  31713. _gl: WebGLRenderingContext;
  31714. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31715. protected _windowIsBackground: boolean;
  31716. protected _webGLVersion: number;
  31717. protected _creationOptions: EngineOptions;
  31718. protected _highPrecisionShadersAllowed: boolean;
  31719. /** @hidden */
  31720. get _shouldUseHighPrecisionShader(): boolean;
  31721. /**
  31722. * Gets a boolean indicating that only power of 2 textures are supported
  31723. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31724. */
  31725. get needPOTTextures(): boolean;
  31726. /** @hidden */
  31727. _badOS: boolean;
  31728. /** @hidden */
  31729. _badDesktopOS: boolean;
  31730. private _hardwareScalingLevel;
  31731. /** @hidden */
  31732. _caps: EngineCapabilities;
  31733. private _isStencilEnable;
  31734. private _glVersion;
  31735. private _glRenderer;
  31736. private _glVendor;
  31737. /** @hidden */
  31738. _videoTextureSupported: boolean;
  31739. protected _renderingQueueLaunched: boolean;
  31740. protected _activeRenderLoops: (() => void)[];
  31741. /**
  31742. * Observable signaled when a context lost event is raised
  31743. */
  31744. onContextLostObservable: Observable<ThinEngine>;
  31745. /**
  31746. * Observable signaled when a context restored event is raised
  31747. */
  31748. onContextRestoredObservable: Observable<ThinEngine>;
  31749. private _onContextLost;
  31750. private _onContextRestored;
  31751. protected _contextWasLost: boolean;
  31752. /** @hidden */
  31753. _doNotHandleContextLost: boolean;
  31754. /**
  31755. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31756. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31757. */
  31758. get doNotHandleContextLost(): boolean;
  31759. set doNotHandleContextLost(value: boolean);
  31760. /**
  31761. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31762. */
  31763. disableVertexArrayObjects: boolean;
  31764. /** @hidden */
  31765. protected _colorWrite: boolean;
  31766. /** @hidden */
  31767. protected _colorWriteChanged: boolean;
  31768. /** @hidden */
  31769. protected _depthCullingState: DepthCullingState;
  31770. /** @hidden */
  31771. protected _stencilState: StencilState;
  31772. /** @hidden */
  31773. _alphaState: AlphaState;
  31774. /** @hidden */
  31775. _alphaMode: number;
  31776. /** @hidden */
  31777. _alphaEquation: number;
  31778. /** @hidden */
  31779. _internalTexturesCache: InternalTexture[];
  31780. /** @hidden */
  31781. protected _activeChannel: number;
  31782. private _currentTextureChannel;
  31783. /** @hidden */
  31784. protected _boundTexturesCache: {
  31785. [key: string]: Nullable<InternalTexture>;
  31786. };
  31787. /** @hidden */
  31788. protected _currentEffect: Nullable<Effect>;
  31789. /** @hidden */
  31790. protected _currentProgram: Nullable<WebGLProgram>;
  31791. private _compiledEffects;
  31792. private _vertexAttribArraysEnabled;
  31793. /** @hidden */
  31794. protected _cachedViewport: Nullable<IViewportLike>;
  31795. private _cachedVertexArrayObject;
  31796. /** @hidden */
  31797. protected _cachedVertexBuffers: any;
  31798. /** @hidden */
  31799. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31800. /** @hidden */
  31801. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31802. /** @hidden */
  31803. _currentRenderTarget: Nullable<InternalTexture>;
  31804. private _uintIndicesCurrentlySet;
  31805. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31806. /** @hidden */
  31807. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31808. private _currentBufferPointers;
  31809. private _currentInstanceLocations;
  31810. private _currentInstanceBuffers;
  31811. private _textureUnits;
  31812. /** @hidden */
  31813. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31814. /** @hidden */
  31815. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31816. /** @hidden */
  31817. _boundRenderFunction: any;
  31818. private _vaoRecordInProgress;
  31819. private _mustWipeVertexAttributes;
  31820. private _emptyTexture;
  31821. private _emptyCubeTexture;
  31822. private _emptyTexture3D;
  31823. private _emptyTexture2DArray;
  31824. /** @hidden */
  31825. _frameHandler: number;
  31826. private _nextFreeTextureSlots;
  31827. private _maxSimultaneousTextures;
  31828. private _activeRequests;
  31829. protected _texturesSupported: string[];
  31830. /** @hidden */
  31831. _textureFormatInUse: Nullable<string>;
  31832. protected get _supportsHardwareTextureRescaling(): boolean;
  31833. /**
  31834. * Gets the list of texture formats supported
  31835. */
  31836. get texturesSupported(): Array<string>;
  31837. /**
  31838. * Gets the list of texture formats in use
  31839. */
  31840. get textureFormatInUse(): Nullable<string>;
  31841. /**
  31842. * Gets the current viewport
  31843. */
  31844. get currentViewport(): Nullable<IViewportLike>;
  31845. /**
  31846. * Gets the default empty texture
  31847. */
  31848. get emptyTexture(): InternalTexture;
  31849. /**
  31850. * Gets the default empty 3D texture
  31851. */
  31852. get emptyTexture3D(): InternalTexture;
  31853. /**
  31854. * Gets the default empty 2D array texture
  31855. */
  31856. get emptyTexture2DArray(): InternalTexture;
  31857. /**
  31858. * Gets the default empty cube texture
  31859. */
  31860. get emptyCubeTexture(): InternalTexture;
  31861. /**
  31862. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31863. */
  31864. readonly premultipliedAlpha: boolean;
  31865. /**
  31866. * Observable event triggered before each texture is initialized
  31867. */
  31868. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31869. /**
  31870. * Creates a new engine
  31871. * @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
  31872. * @param antialias defines enable antialiasing (default: false)
  31873. * @param options defines further options to be sent to the getContext() function
  31874. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31875. */
  31876. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31877. private _rebuildInternalTextures;
  31878. private _rebuildEffects;
  31879. /**
  31880. * Gets a boolean indicating if all created effects are ready
  31881. * @returns true if all effects are ready
  31882. */
  31883. areAllEffectsReady(): boolean;
  31884. protected _rebuildBuffers(): void;
  31885. private _initGLContext;
  31886. /**
  31887. * Gets version of the current webGL context
  31888. */
  31889. get webGLVersion(): number;
  31890. /**
  31891. * Gets a string idenfifying the name of the class
  31892. * @returns "Engine" string
  31893. */
  31894. getClassName(): string;
  31895. /**
  31896. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31897. */
  31898. get isStencilEnable(): boolean;
  31899. /** @hidden */
  31900. _prepareWorkingCanvas(): void;
  31901. /**
  31902. * Reset the texture cache to empty state
  31903. */
  31904. resetTextureCache(): void;
  31905. /**
  31906. * Gets an object containing information about the current webGL context
  31907. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31908. */
  31909. getGlInfo(): {
  31910. vendor: string;
  31911. renderer: string;
  31912. version: string;
  31913. };
  31914. /**
  31915. * Defines the hardware scaling level.
  31916. * By default the hardware scaling level is computed from the window device ratio.
  31917. * 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.
  31918. * @param level defines the level to use
  31919. */
  31920. setHardwareScalingLevel(level: number): void;
  31921. /**
  31922. * Gets the current hardware scaling level.
  31923. * By default the hardware scaling level is computed from the window device ratio.
  31924. * 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.
  31925. * @returns a number indicating the current hardware scaling level
  31926. */
  31927. getHardwareScalingLevel(): number;
  31928. /**
  31929. * Gets the list of loaded textures
  31930. * @returns an array containing all loaded textures
  31931. */
  31932. getLoadedTexturesCache(): InternalTexture[];
  31933. /**
  31934. * Gets the object containing all engine capabilities
  31935. * @returns the EngineCapabilities object
  31936. */
  31937. getCaps(): EngineCapabilities;
  31938. /**
  31939. * stop executing a render loop function and remove it from the execution array
  31940. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31941. */
  31942. stopRenderLoop(renderFunction?: () => void): void;
  31943. /** @hidden */
  31944. _renderLoop(): void;
  31945. /**
  31946. * Gets the HTML canvas attached with the current webGL context
  31947. * @returns a HTML canvas
  31948. */
  31949. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31950. /**
  31951. * Gets host window
  31952. * @returns the host window object
  31953. */
  31954. getHostWindow(): Nullable<Window>;
  31955. /**
  31956. * Gets the current render width
  31957. * @param useScreen defines if screen size must be used (or the current render target if any)
  31958. * @returns a number defining the current render width
  31959. */
  31960. getRenderWidth(useScreen?: boolean): number;
  31961. /**
  31962. * Gets the current render height
  31963. * @param useScreen defines if screen size must be used (or the current render target if any)
  31964. * @returns a number defining the current render height
  31965. */
  31966. getRenderHeight(useScreen?: boolean): number;
  31967. /**
  31968. * Can be used to override the current requestAnimationFrame requester.
  31969. * @hidden
  31970. */
  31971. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31972. /**
  31973. * Register and execute a render loop. The engine can have more than one render function
  31974. * @param renderFunction defines the function to continuously execute
  31975. */
  31976. runRenderLoop(renderFunction: () => void): void;
  31977. /**
  31978. * Clear the current render buffer or the current render target (if any is set up)
  31979. * @param color defines the color to use
  31980. * @param backBuffer defines if the back buffer must be cleared
  31981. * @param depth defines if the depth buffer must be cleared
  31982. * @param stencil defines if the stencil buffer must be cleared
  31983. */
  31984. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31985. private _viewportCached;
  31986. /** @hidden */
  31987. _viewport(x: number, y: number, width: number, height: number): void;
  31988. /**
  31989. * Set the WebGL's viewport
  31990. * @param viewport defines the viewport element to be used
  31991. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31992. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31993. */
  31994. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31995. /**
  31996. * Begin a new frame
  31997. */
  31998. beginFrame(): void;
  31999. /**
  32000. * Enf the current frame
  32001. */
  32002. endFrame(): void;
  32003. /**
  32004. * Resize the view according to the canvas' size
  32005. */
  32006. resize(): void;
  32007. /**
  32008. * Force a specific size of the canvas
  32009. * @param width defines the new canvas' width
  32010. * @param height defines the new canvas' height
  32011. */
  32012. setSize(width: number, height: number): void;
  32013. /**
  32014. * Binds the frame buffer to the specified texture.
  32015. * @param texture The texture to render to or null for the default canvas
  32016. * @param faceIndex The face of the texture to render to in case of cube texture
  32017. * @param requiredWidth The width of the target to render to
  32018. * @param requiredHeight The height of the target to render to
  32019. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32020. * @param depthStencilTexture The depth stencil texture to use to render
  32021. * @param lodLevel defines le lod level to bind to the frame buffer
  32022. */
  32023. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  32024. /** @hidden */
  32025. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32026. /**
  32027. * Unbind the current render target texture from the webGL context
  32028. * @param texture defines the render target texture to unbind
  32029. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32030. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32031. */
  32032. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32033. /**
  32034. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32035. */
  32036. flushFramebuffer(): void;
  32037. /**
  32038. * Unbind the current render target and bind the default framebuffer
  32039. */
  32040. restoreDefaultFramebuffer(): void;
  32041. /** @hidden */
  32042. protected _resetVertexBufferBinding(): void;
  32043. /**
  32044. * Creates a vertex buffer
  32045. * @param data the data for the vertex buffer
  32046. * @returns the new WebGL static buffer
  32047. */
  32048. createVertexBuffer(data: DataArray): DataBuffer;
  32049. private _createVertexBuffer;
  32050. /**
  32051. * Creates a dynamic vertex buffer
  32052. * @param data the data for the dynamic vertex buffer
  32053. * @returns the new WebGL dynamic buffer
  32054. */
  32055. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32056. protected _resetIndexBufferBinding(): void;
  32057. /**
  32058. * Creates a new index buffer
  32059. * @param indices defines the content of the index buffer
  32060. * @param updatable defines if the index buffer must be updatable
  32061. * @returns a new webGL buffer
  32062. */
  32063. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32064. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32065. /**
  32066. * Bind a webGL buffer to the webGL context
  32067. * @param buffer defines the buffer to bind
  32068. */
  32069. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32070. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32071. private bindBuffer;
  32072. /**
  32073. * update the bound buffer with the given data
  32074. * @param data defines the data to update
  32075. */
  32076. updateArrayBuffer(data: Float32Array): void;
  32077. private _vertexAttribPointer;
  32078. private _bindIndexBufferWithCache;
  32079. private _bindVertexBuffersAttributes;
  32080. /**
  32081. * Records a vertex array object
  32082. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32083. * @param vertexBuffers defines the list of vertex buffers to store
  32084. * @param indexBuffer defines the index buffer to store
  32085. * @param effect defines the effect to store
  32086. * @returns the new vertex array object
  32087. */
  32088. recordVertexArrayObject(vertexBuffers: {
  32089. [key: string]: VertexBuffer;
  32090. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32091. /**
  32092. * Bind a specific vertex array object
  32093. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32094. * @param vertexArrayObject defines the vertex array object to bind
  32095. * @param indexBuffer defines the index buffer to bind
  32096. */
  32097. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32098. /**
  32099. * Bind webGl buffers directly to the webGL context
  32100. * @param vertexBuffer defines the vertex buffer to bind
  32101. * @param indexBuffer defines the index buffer to bind
  32102. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32103. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32104. * @param effect defines the effect associated with the vertex buffer
  32105. */
  32106. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32107. private _unbindVertexArrayObject;
  32108. /**
  32109. * Bind a list of vertex buffers to the webGL context
  32110. * @param vertexBuffers defines the list of vertex buffers to bind
  32111. * @param indexBuffer defines the index buffer to bind
  32112. * @param effect defines the effect associated with the vertex buffers
  32113. */
  32114. bindBuffers(vertexBuffers: {
  32115. [key: string]: Nullable<VertexBuffer>;
  32116. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32117. /**
  32118. * Unbind all instance attributes
  32119. */
  32120. unbindInstanceAttributes(): void;
  32121. /**
  32122. * Release and free the memory of a vertex array object
  32123. * @param vao defines the vertex array object to delete
  32124. */
  32125. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32126. /** @hidden */
  32127. _releaseBuffer(buffer: DataBuffer): boolean;
  32128. protected _deleteBuffer(buffer: DataBuffer): void;
  32129. /**
  32130. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32131. * @param instancesBuffer defines the webGL buffer to update and bind
  32132. * @param data defines the data to store in the buffer
  32133. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32134. */
  32135. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32136. /**
  32137. * Bind the content of a webGL buffer used with instanciation
  32138. * @param instancesBuffer defines the webGL buffer to bind
  32139. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32140. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32141. */
  32142. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32143. /**
  32144. * Disable the instance attribute corresponding to the name in parameter
  32145. * @param name defines the name of the attribute to disable
  32146. */
  32147. disableInstanceAttributeByName(name: string): void;
  32148. /**
  32149. * Disable the instance attribute corresponding to the location in parameter
  32150. * @param attributeLocation defines the attribute location of the attribute to disable
  32151. */
  32152. disableInstanceAttribute(attributeLocation: number): void;
  32153. /**
  32154. * Disable the attribute corresponding to the location in parameter
  32155. * @param attributeLocation defines the attribute location of the attribute to disable
  32156. */
  32157. disableAttributeByIndex(attributeLocation: number): void;
  32158. /**
  32159. * Send a draw order
  32160. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32161. * @param indexStart defines the starting index
  32162. * @param indexCount defines the number of index to draw
  32163. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32164. */
  32165. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32166. /**
  32167. * Draw a list of points
  32168. * @param verticesStart defines the index of first vertex to draw
  32169. * @param verticesCount defines the count of vertices to draw
  32170. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32171. */
  32172. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32173. /**
  32174. * Draw a list of unindexed primitives
  32175. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32176. * @param verticesStart defines the index of first vertex to draw
  32177. * @param verticesCount defines the count of vertices to draw
  32178. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32179. */
  32180. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32181. /**
  32182. * Draw a list of indexed primitives
  32183. * @param fillMode defines the primitive to use
  32184. * @param indexStart defines the starting index
  32185. * @param indexCount defines the number of index to draw
  32186. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32187. */
  32188. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32189. /**
  32190. * Draw a list of unindexed primitives
  32191. * @param fillMode defines the primitive to use
  32192. * @param verticesStart defines the index of first vertex to draw
  32193. * @param verticesCount defines the count of vertices to draw
  32194. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32195. */
  32196. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32197. private _drawMode;
  32198. /** @hidden */
  32199. protected _reportDrawCall(): void;
  32200. /** @hidden */
  32201. _releaseEffect(effect: Effect): void;
  32202. /** @hidden */
  32203. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32204. /**
  32205. * Create a new effect (used to store vertex/fragment shaders)
  32206. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32207. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32208. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32209. * @param samplers defines an array of string used to represent textures
  32210. * @param defines defines the string containing the defines to use to compile the shaders
  32211. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32212. * @param onCompiled defines a function to call when the effect creation is successful
  32213. * @param onError defines a function to call when the effect creation has failed
  32214. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32215. * @returns the new Effect
  32216. */
  32217. 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;
  32218. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32219. private _compileShader;
  32220. private _compileRawShader;
  32221. /**
  32222. * Directly creates a webGL program
  32223. * @param pipelineContext defines the pipeline context to attach to
  32224. * @param vertexCode defines the vertex shader code to use
  32225. * @param fragmentCode defines the fragment shader code to use
  32226. * @param context defines the webGL context to use (if not set, the current one will be used)
  32227. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32228. * @returns the new webGL program
  32229. */
  32230. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32231. /**
  32232. * Creates a webGL program
  32233. * @param pipelineContext defines the pipeline context to attach to
  32234. * @param vertexCode defines the vertex shader code to use
  32235. * @param fragmentCode defines the fragment shader code to use
  32236. * @param defines defines the string containing the defines to use to compile the shaders
  32237. * @param context defines the webGL context to use (if not set, the current one will be used)
  32238. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32239. * @returns the new webGL program
  32240. */
  32241. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32242. /**
  32243. * Creates a new pipeline context
  32244. * @returns the new pipeline
  32245. */
  32246. createPipelineContext(): IPipelineContext;
  32247. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32248. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32249. /** @hidden */
  32250. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32251. /** @hidden */
  32252. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32253. /** @hidden */
  32254. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32255. /**
  32256. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32257. * @param pipelineContext defines the pipeline context to use
  32258. * @param uniformsNames defines the list of uniform names
  32259. * @returns an array of webGL uniform locations
  32260. */
  32261. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32262. /**
  32263. * Gets the lsit of active attributes for a given webGL program
  32264. * @param pipelineContext defines the pipeline context to use
  32265. * @param attributesNames defines the list of attribute names to get
  32266. * @returns an array of indices indicating the offset of each attribute
  32267. */
  32268. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32269. /**
  32270. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32271. * @param effect defines the effect to activate
  32272. */
  32273. enableEffect(effect: Nullable<Effect>): void;
  32274. /**
  32275. * Set the value of an uniform to a number (int)
  32276. * @param uniform defines the webGL uniform location where to store the value
  32277. * @param value defines the int number to store
  32278. */
  32279. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32280. /**
  32281. * Set the value of an uniform to an array of int32
  32282. * @param uniform defines the webGL uniform location where to store the value
  32283. * @param array defines the array of int32 to store
  32284. */
  32285. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32286. /**
  32287. * Set the value of an uniform to an array of int32 (stored as vec2)
  32288. * @param uniform defines the webGL uniform location where to store the value
  32289. * @param array defines the array of int32 to store
  32290. */
  32291. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32292. /**
  32293. * Set the value of an uniform to an array of int32 (stored as vec3)
  32294. * @param uniform defines the webGL uniform location where to store the value
  32295. * @param array defines the array of int32 to store
  32296. */
  32297. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32298. /**
  32299. * Set the value of an uniform to an array of int32 (stored as vec4)
  32300. * @param uniform defines the webGL uniform location where to store the value
  32301. * @param array defines the array of int32 to store
  32302. */
  32303. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32304. /**
  32305. * Set the value of an uniform to an array of number
  32306. * @param uniform defines the webGL uniform location where to store the value
  32307. * @param array defines the array of number to store
  32308. */
  32309. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32310. /**
  32311. * Set the value of an uniform to an array of number (stored as vec2)
  32312. * @param uniform defines the webGL uniform location where to store the value
  32313. * @param array defines the array of number to store
  32314. */
  32315. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32316. /**
  32317. * Set the value of an uniform to an array of number (stored as vec3)
  32318. * @param uniform defines the webGL uniform location where to store the value
  32319. * @param array defines the array of number to store
  32320. */
  32321. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32322. /**
  32323. * Set the value of an uniform to an array of number (stored as vec4)
  32324. * @param uniform defines the webGL uniform location where to store the value
  32325. * @param array defines the array of number to store
  32326. */
  32327. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32328. /**
  32329. * Set the value of an uniform to an array of float32 (stored as matrices)
  32330. * @param uniform defines the webGL uniform location where to store the value
  32331. * @param matrices defines the array of float32 to store
  32332. */
  32333. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32334. /**
  32335. * Set the value of an uniform to a matrix (3x3)
  32336. * @param uniform defines the webGL uniform location where to store the value
  32337. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32338. */
  32339. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32340. /**
  32341. * Set the value of an uniform to a matrix (2x2)
  32342. * @param uniform defines the webGL uniform location where to store the value
  32343. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32344. */
  32345. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32346. /**
  32347. * Set the value of an uniform to a number (float)
  32348. * @param uniform defines the webGL uniform location where to store the value
  32349. * @param value defines the float number to store
  32350. */
  32351. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32352. /**
  32353. * Set the value of an uniform to a vec2
  32354. * @param uniform defines the webGL uniform location where to store the value
  32355. * @param x defines the 1st component of the value
  32356. * @param y defines the 2nd component of the value
  32357. */
  32358. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32359. /**
  32360. * Set the value of an uniform to a vec3
  32361. * @param uniform defines the webGL uniform location where to store the value
  32362. * @param x defines the 1st component of the value
  32363. * @param y defines the 2nd component of the value
  32364. * @param z defines the 3rd component of the value
  32365. */
  32366. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32367. /**
  32368. * Set the value of an uniform to a vec4
  32369. * @param uniform defines the webGL uniform location where to store the value
  32370. * @param x defines the 1st component of the value
  32371. * @param y defines the 2nd component of the value
  32372. * @param z defines the 3rd component of the value
  32373. * @param w defines the 4th component of the value
  32374. */
  32375. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32376. /**
  32377. * Apply all cached states (depth, culling, stencil and alpha)
  32378. */
  32379. applyStates(): void;
  32380. /**
  32381. * Enable or disable color writing
  32382. * @param enable defines the state to set
  32383. */
  32384. setColorWrite(enable: boolean): void;
  32385. /**
  32386. * Gets a boolean indicating if color writing is enabled
  32387. * @returns the current color writing state
  32388. */
  32389. getColorWrite(): boolean;
  32390. /**
  32391. * Gets the depth culling state manager
  32392. */
  32393. get depthCullingState(): DepthCullingState;
  32394. /**
  32395. * Gets the alpha state manager
  32396. */
  32397. get alphaState(): AlphaState;
  32398. /**
  32399. * Gets the stencil state manager
  32400. */
  32401. get stencilState(): StencilState;
  32402. /**
  32403. * Clears the list of texture accessible through engine.
  32404. * This can help preventing texture load conflict due to name collision.
  32405. */
  32406. clearInternalTexturesCache(): void;
  32407. /**
  32408. * Force the entire cache to be cleared
  32409. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32410. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32411. */
  32412. wipeCaches(bruteForce?: boolean): void;
  32413. /** @hidden */
  32414. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32415. min: number;
  32416. mag: number;
  32417. };
  32418. /** @hidden */
  32419. _createTexture(): WebGLTexture;
  32420. /**
  32421. * Usually called from Texture.ts.
  32422. * Passed information to create a WebGLTexture
  32423. * @param urlArg defines a value which contains one of the following:
  32424. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32425. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32426. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32427. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32428. * @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)
  32429. * @param scene needed for loading to the correct scene
  32430. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32431. * @param onLoad optional callback to be called upon successful completion
  32432. * @param onError optional callback to be called upon failure
  32433. * @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
  32434. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32435. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32436. * @param forcedExtension defines the extension to use to pick the right loader
  32437. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32438. * @param mimeType defines an optional mime type
  32439. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32440. */
  32441. 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;
  32442. /**
  32443. * @hidden
  32444. */
  32445. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32446. /**
  32447. * Creates a raw texture
  32448. * @param data defines the data to store in the texture
  32449. * @param width defines the width of the texture
  32450. * @param height defines the height of the texture
  32451. * @param format defines the format of the data
  32452. * @param generateMipMaps defines if the engine should generate the mip levels
  32453. * @param invertY defines if data must be stored with Y axis inverted
  32454. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32455. * @param compression defines the compression used (null by default)
  32456. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32457. * @returns the raw texture inside an InternalTexture
  32458. */
  32459. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32460. /**
  32461. * Creates a new raw cube texture
  32462. * @param data defines the array of data to use to create each face
  32463. * @param size defines the size of the textures
  32464. * @param format defines the format of the data
  32465. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32466. * @param generateMipMaps defines if the engine should generate the mip levels
  32467. * @param invertY defines if data must be stored with Y axis inverted
  32468. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32469. * @param compression defines the compression used (null by default)
  32470. * @returns the cube texture as an InternalTexture
  32471. */
  32472. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32473. /**
  32474. * Creates a new raw 3D texture
  32475. * @param data defines the data used to create the texture
  32476. * @param width defines the width of the texture
  32477. * @param height defines the height of the texture
  32478. * @param depth defines the depth of the texture
  32479. * @param format defines the format of the texture
  32480. * @param generateMipMaps defines if the engine must generate mip levels
  32481. * @param invertY defines if data must be stored with Y axis inverted
  32482. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32483. * @param compression defines the compressed used (can be null)
  32484. * @param textureType defines the compressed used (can be null)
  32485. * @returns a new raw 3D texture (stored in an InternalTexture)
  32486. */
  32487. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32488. /**
  32489. * Creates a new raw 2D array texture
  32490. * @param data defines the data used to create the texture
  32491. * @param width defines the width of the texture
  32492. * @param height defines the height of the texture
  32493. * @param depth defines the number of layers of the texture
  32494. * @param format defines the format of the texture
  32495. * @param generateMipMaps defines if the engine must generate mip levels
  32496. * @param invertY defines if data must be stored with Y axis inverted
  32497. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32498. * @param compression defines the compressed used (can be null)
  32499. * @param textureType defines the compressed used (can be null)
  32500. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32501. */
  32502. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32503. private _unpackFlipYCached;
  32504. /**
  32505. * In case you are sharing the context with other applications, it might
  32506. * be interested to not cache the unpack flip y state to ensure a consistent
  32507. * value would be set.
  32508. */
  32509. enableUnpackFlipYCached: boolean;
  32510. /** @hidden */
  32511. _unpackFlipY(value: boolean): void;
  32512. /** @hidden */
  32513. _getUnpackAlignement(): number;
  32514. private _getTextureTarget;
  32515. /**
  32516. * Update the sampling mode of a given texture
  32517. * @param samplingMode defines the required sampling mode
  32518. * @param texture defines the texture to update
  32519. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32520. */
  32521. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32522. /**
  32523. * Update the sampling mode of a given texture
  32524. * @param texture defines the texture to update
  32525. * @param wrapU defines the texture wrap mode of the u coordinates
  32526. * @param wrapV defines the texture wrap mode of the v coordinates
  32527. * @param wrapR defines the texture wrap mode of the r coordinates
  32528. */
  32529. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32530. /** @hidden */
  32531. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32532. width: number;
  32533. height: number;
  32534. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32535. /** @hidden */
  32536. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32537. /** @hidden */
  32538. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32539. /** @hidden */
  32540. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32541. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32542. private _prepareWebGLTexture;
  32543. /** @hidden */
  32544. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32545. private _getDepthStencilBuffer;
  32546. /** @hidden */
  32547. _releaseFramebufferObjects(texture: InternalTexture): void;
  32548. /** @hidden */
  32549. _releaseTexture(texture: InternalTexture): void;
  32550. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32551. protected _setProgram(program: WebGLProgram): void;
  32552. protected _boundUniforms: {
  32553. [key: number]: WebGLUniformLocation;
  32554. };
  32555. /**
  32556. * Binds an effect to the webGL context
  32557. * @param effect defines the effect to bind
  32558. */
  32559. bindSamplers(effect: Effect): void;
  32560. private _activateCurrentTexture;
  32561. /** @hidden */
  32562. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32563. /** @hidden */
  32564. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32565. /**
  32566. * Unbind all textures from the webGL context
  32567. */
  32568. unbindAllTextures(): void;
  32569. /**
  32570. * Sets a texture to the according uniform.
  32571. * @param channel The texture channel
  32572. * @param uniform The uniform to set
  32573. * @param texture The texture to apply
  32574. */
  32575. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32576. private _bindSamplerUniformToChannel;
  32577. private _getTextureWrapMode;
  32578. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32579. /**
  32580. * Sets an array of texture to the webGL context
  32581. * @param channel defines the channel where the texture array must be set
  32582. * @param uniform defines the associated uniform location
  32583. * @param textures defines the array of textures to bind
  32584. */
  32585. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32586. /** @hidden */
  32587. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32588. private _setTextureParameterFloat;
  32589. private _setTextureParameterInteger;
  32590. /**
  32591. * Unbind all vertex attributes from the webGL context
  32592. */
  32593. unbindAllAttributes(): void;
  32594. /**
  32595. * 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
  32596. */
  32597. releaseEffects(): void;
  32598. /**
  32599. * Dispose and release all associated resources
  32600. */
  32601. dispose(): void;
  32602. /**
  32603. * Attach a new callback raised when context lost event is fired
  32604. * @param callback defines the callback to call
  32605. */
  32606. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32607. /**
  32608. * Attach a new callback raised when context restored event is fired
  32609. * @param callback defines the callback to call
  32610. */
  32611. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32612. /**
  32613. * Get the current error code of the webGL context
  32614. * @returns the error code
  32615. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32616. */
  32617. getError(): number;
  32618. private _canRenderToFloatFramebuffer;
  32619. private _canRenderToHalfFloatFramebuffer;
  32620. private _canRenderToFramebuffer;
  32621. /** @hidden */
  32622. _getWebGLTextureType(type: number): number;
  32623. /** @hidden */
  32624. _getInternalFormat(format: number): number;
  32625. /** @hidden */
  32626. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32627. /** @hidden */
  32628. _getRGBAMultiSampleBufferFormat(type: number): number;
  32629. /** @hidden */
  32630. _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;
  32631. /**
  32632. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32633. * @param x defines the x coordinate of the rectangle where pixels must be read
  32634. * @param y defines the y coordinate of the rectangle where pixels must be read
  32635. * @param width defines the width of the rectangle where pixels must be read
  32636. * @param height defines the height of the rectangle where pixels must be read
  32637. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32638. * @returns a Uint8Array containing RGBA colors
  32639. */
  32640. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32641. private static _isSupported;
  32642. /**
  32643. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32644. * @returns true if the engine can be created
  32645. * @ignorenaming
  32646. */
  32647. static isSupported(): boolean;
  32648. /**
  32649. * Find the next highest power of two.
  32650. * @param x Number to start search from.
  32651. * @return Next highest power of two.
  32652. */
  32653. static CeilingPOT(x: number): number;
  32654. /**
  32655. * Find the next lowest power of two.
  32656. * @param x Number to start search from.
  32657. * @return Next lowest power of two.
  32658. */
  32659. static FloorPOT(x: number): number;
  32660. /**
  32661. * Find the nearest power of two.
  32662. * @param x Number to start search from.
  32663. * @return Next nearest power of two.
  32664. */
  32665. static NearestPOT(x: number): number;
  32666. /**
  32667. * Get the closest exponent of two
  32668. * @param value defines the value to approximate
  32669. * @param max defines the maximum value to return
  32670. * @param mode defines how to define the closest value
  32671. * @returns closest exponent of two of the given value
  32672. */
  32673. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32674. /**
  32675. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32676. * @param func - the function to be called
  32677. * @param requester - the object that will request the next frame. Falls back to window.
  32678. * @returns frame number
  32679. */
  32680. static QueueNewFrame(func: () => void, requester?: any): number;
  32681. /**
  32682. * Gets host document
  32683. * @returns the host document object
  32684. */
  32685. getHostDocument(): Nullable<Document>;
  32686. }
  32687. }
  32688. declare module "babylonjs/Maths/sphericalPolynomial" {
  32689. import { Vector3 } from "babylonjs/Maths/math.vector";
  32690. import { Color3 } from "babylonjs/Maths/math.color";
  32691. /**
  32692. * Class representing spherical harmonics coefficients to the 3rd degree
  32693. */
  32694. export class SphericalHarmonics {
  32695. /**
  32696. * Defines whether or not the harmonics have been prescaled for rendering.
  32697. */
  32698. preScaled: boolean;
  32699. /**
  32700. * The l0,0 coefficients of the spherical harmonics
  32701. */
  32702. l00: Vector3;
  32703. /**
  32704. * The l1,-1 coefficients of the spherical harmonics
  32705. */
  32706. l1_1: Vector3;
  32707. /**
  32708. * The l1,0 coefficients of the spherical harmonics
  32709. */
  32710. l10: Vector3;
  32711. /**
  32712. * The l1,1 coefficients of the spherical harmonics
  32713. */
  32714. l11: Vector3;
  32715. /**
  32716. * The l2,-2 coefficients of the spherical harmonics
  32717. */
  32718. l2_2: Vector3;
  32719. /**
  32720. * The l2,-1 coefficients of the spherical harmonics
  32721. */
  32722. l2_1: Vector3;
  32723. /**
  32724. * The l2,0 coefficients of the spherical harmonics
  32725. */
  32726. l20: Vector3;
  32727. /**
  32728. * The l2,1 coefficients of the spherical harmonics
  32729. */
  32730. l21: Vector3;
  32731. /**
  32732. * The l2,2 coefficients of the spherical harmonics
  32733. */
  32734. l22: Vector3;
  32735. /**
  32736. * Adds a light to the spherical harmonics
  32737. * @param direction the direction of the light
  32738. * @param color the color of the light
  32739. * @param deltaSolidAngle the delta solid angle of the light
  32740. */
  32741. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32742. /**
  32743. * Scales the spherical harmonics by the given amount
  32744. * @param scale the amount to scale
  32745. */
  32746. scaleInPlace(scale: number): void;
  32747. /**
  32748. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32749. *
  32750. * ```
  32751. * E_lm = A_l * L_lm
  32752. * ```
  32753. *
  32754. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32755. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32756. * the scaling factors are given in equation 9.
  32757. */
  32758. convertIncidentRadianceToIrradiance(): void;
  32759. /**
  32760. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32761. *
  32762. * ```
  32763. * L = (1/pi) * E * rho
  32764. * ```
  32765. *
  32766. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32767. */
  32768. convertIrradianceToLambertianRadiance(): void;
  32769. /**
  32770. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32771. * required operations at run time.
  32772. *
  32773. * This is simply done by scaling back the SH with Ylm constants parameter.
  32774. * The trigonometric part being applied by the shader at run time.
  32775. */
  32776. preScaleForRendering(): void;
  32777. /**
  32778. * Constructs a spherical harmonics from an array.
  32779. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32780. * @returns the spherical harmonics
  32781. */
  32782. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32783. /**
  32784. * Gets the spherical harmonics from polynomial
  32785. * @param polynomial the spherical polynomial
  32786. * @returns the spherical harmonics
  32787. */
  32788. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32789. }
  32790. /**
  32791. * Class representing spherical polynomial coefficients to the 3rd degree
  32792. */
  32793. export class SphericalPolynomial {
  32794. private _harmonics;
  32795. /**
  32796. * The spherical harmonics used to create the polynomials.
  32797. */
  32798. get preScaledHarmonics(): SphericalHarmonics;
  32799. /**
  32800. * The x coefficients of the spherical polynomial
  32801. */
  32802. x: Vector3;
  32803. /**
  32804. * The y coefficients of the spherical polynomial
  32805. */
  32806. y: Vector3;
  32807. /**
  32808. * The z coefficients of the spherical polynomial
  32809. */
  32810. z: Vector3;
  32811. /**
  32812. * The xx coefficients of the spherical polynomial
  32813. */
  32814. xx: Vector3;
  32815. /**
  32816. * The yy coefficients of the spherical polynomial
  32817. */
  32818. yy: Vector3;
  32819. /**
  32820. * The zz coefficients of the spherical polynomial
  32821. */
  32822. zz: Vector3;
  32823. /**
  32824. * The xy coefficients of the spherical polynomial
  32825. */
  32826. xy: Vector3;
  32827. /**
  32828. * The yz coefficients of the spherical polynomial
  32829. */
  32830. yz: Vector3;
  32831. /**
  32832. * The zx coefficients of the spherical polynomial
  32833. */
  32834. zx: Vector3;
  32835. /**
  32836. * Adds an ambient color to the spherical polynomial
  32837. * @param color the color to add
  32838. */
  32839. addAmbient(color: Color3): void;
  32840. /**
  32841. * Scales the spherical polynomial by the given amount
  32842. * @param scale the amount to scale
  32843. */
  32844. scaleInPlace(scale: number): void;
  32845. /**
  32846. * Gets the spherical polynomial from harmonics
  32847. * @param harmonics the spherical harmonics
  32848. * @returns the spherical polynomial
  32849. */
  32850. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32851. /**
  32852. * Constructs a spherical polynomial from an array.
  32853. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32854. * @returns the spherical polynomial
  32855. */
  32856. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32857. }
  32858. }
  32859. declare module "babylonjs/Materials/Textures/internalTexture" {
  32860. import { Observable } from "babylonjs/Misc/observable";
  32861. import { Nullable, int } from "babylonjs/types";
  32862. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32864. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32865. /**
  32866. * Defines the source of the internal texture
  32867. */
  32868. export enum InternalTextureSource {
  32869. /**
  32870. * The source of the texture data is unknown
  32871. */
  32872. Unknown = 0,
  32873. /**
  32874. * Texture data comes from an URL
  32875. */
  32876. Url = 1,
  32877. /**
  32878. * Texture data is only used for temporary storage
  32879. */
  32880. Temp = 2,
  32881. /**
  32882. * Texture data comes from raw data (ArrayBuffer)
  32883. */
  32884. Raw = 3,
  32885. /**
  32886. * Texture content is dynamic (video or dynamic texture)
  32887. */
  32888. Dynamic = 4,
  32889. /**
  32890. * Texture content is generated by rendering to it
  32891. */
  32892. RenderTarget = 5,
  32893. /**
  32894. * Texture content is part of a multi render target process
  32895. */
  32896. MultiRenderTarget = 6,
  32897. /**
  32898. * Texture data comes from a cube data file
  32899. */
  32900. Cube = 7,
  32901. /**
  32902. * Texture data comes from a raw cube data
  32903. */
  32904. CubeRaw = 8,
  32905. /**
  32906. * Texture data come from a prefiltered cube data file
  32907. */
  32908. CubePrefiltered = 9,
  32909. /**
  32910. * Texture content is raw 3D data
  32911. */
  32912. Raw3D = 10,
  32913. /**
  32914. * Texture content is raw 2D array data
  32915. */
  32916. Raw2DArray = 11,
  32917. /**
  32918. * Texture content is a depth texture
  32919. */
  32920. Depth = 12,
  32921. /**
  32922. * Texture data comes from a raw cube data encoded with RGBD
  32923. */
  32924. CubeRawRGBD = 13
  32925. }
  32926. /**
  32927. * Class used to store data associated with WebGL texture data for the engine
  32928. * This class should not be used directly
  32929. */
  32930. export class InternalTexture {
  32931. /** @hidden */
  32932. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32933. /**
  32934. * Defines if the texture is ready
  32935. */
  32936. isReady: boolean;
  32937. /**
  32938. * Defines if the texture is a cube texture
  32939. */
  32940. isCube: boolean;
  32941. /**
  32942. * Defines if the texture contains 3D data
  32943. */
  32944. is3D: boolean;
  32945. /**
  32946. * Defines if the texture contains 2D array data
  32947. */
  32948. is2DArray: boolean;
  32949. /**
  32950. * Defines if the texture contains multiview data
  32951. */
  32952. isMultiview: boolean;
  32953. /**
  32954. * Gets the URL used to load this texture
  32955. */
  32956. url: string;
  32957. /**
  32958. * Gets the sampling mode of the texture
  32959. */
  32960. samplingMode: number;
  32961. /**
  32962. * Gets a boolean indicating if the texture needs mipmaps generation
  32963. */
  32964. generateMipMaps: boolean;
  32965. /**
  32966. * Gets the number of samples used by the texture (WebGL2+ only)
  32967. */
  32968. samples: number;
  32969. /**
  32970. * Gets the type of the texture (int, float...)
  32971. */
  32972. type: number;
  32973. /**
  32974. * Gets the format of the texture (RGB, RGBA...)
  32975. */
  32976. format: number;
  32977. /**
  32978. * Observable called when the texture is loaded
  32979. */
  32980. onLoadedObservable: Observable<InternalTexture>;
  32981. /**
  32982. * Gets the width of the texture
  32983. */
  32984. width: number;
  32985. /**
  32986. * Gets the height of the texture
  32987. */
  32988. height: number;
  32989. /**
  32990. * Gets the depth of the texture
  32991. */
  32992. depth: number;
  32993. /**
  32994. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32995. */
  32996. baseWidth: number;
  32997. /**
  32998. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32999. */
  33000. baseHeight: number;
  33001. /**
  33002. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33003. */
  33004. baseDepth: number;
  33005. /**
  33006. * Gets a boolean indicating if the texture is inverted on Y axis
  33007. */
  33008. invertY: boolean;
  33009. /** @hidden */
  33010. _invertVScale: boolean;
  33011. /** @hidden */
  33012. _associatedChannel: number;
  33013. /** @hidden */
  33014. _source: InternalTextureSource;
  33015. /** @hidden */
  33016. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33017. /** @hidden */
  33018. _bufferView: Nullable<ArrayBufferView>;
  33019. /** @hidden */
  33020. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33021. /** @hidden */
  33022. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33023. /** @hidden */
  33024. _size: number;
  33025. /** @hidden */
  33026. _extension: string;
  33027. /** @hidden */
  33028. _files: Nullable<string[]>;
  33029. /** @hidden */
  33030. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33031. /** @hidden */
  33032. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33033. /** @hidden */
  33034. _framebuffer: Nullable<WebGLFramebuffer>;
  33035. /** @hidden */
  33036. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33037. /** @hidden */
  33038. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33039. /** @hidden */
  33040. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33041. /** @hidden */
  33042. _attachments: Nullable<number[]>;
  33043. /** @hidden */
  33044. _cachedCoordinatesMode: Nullable<number>;
  33045. /** @hidden */
  33046. _cachedWrapU: Nullable<number>;
  33047. /** @hidden */
  33048. _cachedWrapV: Nullable<number>;
  33049. /** @hidden */
  33050. _cachedWrapR: Nullable<number>;
  33051. /** @hidden */
  33052. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33053. /** @hidden */
  33054. _isDisabled: boolean;
  33055. /** @hidden */
  33056. _compression: Nullable<string>;
  33057. /** @hidden */
  33058. _generateStencilBuffer: boolean;
  33059. /** @hidden */
  33060. _generateDepthBuffer: boolean;
  33061. /** @hidden */
  33062. _comparisonFunction: number;
  33063. /** @hidden */
  33064. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33065. /** @hidden */
  33066. _lodGenerationScale: number;
  33067. /** @hidden */
  33068. _lodGenerationOffset: number;
  33069. /** @hidden */
  33070. _colorTextureArray: Nullable<WebGLTexture>;
  33071. /** @hidden */
  33072. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33073. /** @hidden */
  33074. _lodTextureHigh: Nullable<BaseTexture>;
  33075. /** @hidden */
  33076. _lodTextureMid: Nullable<BaseTexture>;
  33077. /** @hidden */
  33078. _lodTextureLow: Nullable<BaseTexture>;
  33079. /** @hidden */
  33080. _isRGBD: boolean;
  33081. /** @hidden */
  33082. _linearSpecularLOD: boolean;
  33083. /** @hidden */
  33084. _irradianceTexture: Nullable<BaseTexture>;
  33085. /** @hidden */
  33086. _webGLTexture: Nullable<WebGLTexture>;
  33087. /** @hidden */
  33088. _references: number;
  33089. private _engine;
  33090. /**
  33091. * Gets the Engine the texture belongs to.
  33092. * @returns The babylon engine
  33093. */
  33094. getEngine(): ThinEngine;
  33095. /**
  33096. * Gets the data source type of the texture
  33097. */
  33098. get source(): InternalTextureSource;
  33099. /**
  33100. * Creates a new InternalTexture
  33101. * @param engine defines the engine to use
  33102. * @param source defines the type of data that will be used
  33103. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33104. */
  33105. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33106. /**
  33107. * Increments the number of references (ie. the number of Texture that point to it)
  33108. */
  33109. incrementReferences(): void;
  33110. /**
  33111. * Change the size of the texture (not the size of the content)
  33112. * @param width defines the new width
  33113. * @param height defines the new height
  33114. * @param depth defines the new depth (1 by default)
  33115. */
  33116. updateSize(width: int, height: int, depth?: int): void;
  33117. /** @hidden */
  33118. _rebuild(): void;
  33119. /** @hidden */
  33120. _swapAndDie(target: InternalTexture): void;
  33121. /**
  33122. * Dispose the current allocated resources
  33123. */
  33124. dispose(): void;
  33125. }
  33126. }
  33127. declare module "babylonjs/Audio/analyser" {
  33128. import { Scene } from "babylonjs/scene";
  33129. /**
  33130. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33131. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33132. */
  33133. export class Analyser {
  33134. /**
  33135. * Gets or sets the smoothing
  33136. * @ignorenaming
  33137. */
  33138. SMOOTHING: number;
  33139. /**
  33140. * Gets or sets the FFT table size
  33141. * @ignorenaming
  33142. */
  33143. FFT_SIZE: number;
  33144. /**
  33145. * Gets or sets the bar graph amplitude
  33146. * @ignorenaming
  33147. */
  33148. BARGRAPHAMPLITUDE: number;
  33149. /**
  33150. * Gets or sets the position of the debug canvas
  33151. * @ignorenaming
  33152. */
  33153. DEBUGCANVASPOS: {
  33154. x: number;
  33155. y: number;
  33156. };
  33157. /**
  33158. * Gets or sets the debug canvas size
  33159. * @ignorenaming
  33160. */
  33161. DEBUGCANVASSIZE: {
  33162. width: number;
  33163. height: number;
  33164. };
  33165. private _byteFreqs;
  33166. private _byteTime;
  33167. private _floatFreqs;
  33168. private _webAudioAnalyser;
  33169. private _debugCanvas;
  33170. private _debugCanvasContext;
  33171. private _scene;
  33172. private _registerFunc;
  33173. private _audioEngine;
  33174. /**
  33175. * Creates a new analyser
  33176. * @param scene defines hosting scene
  33177. */
  33178. constructor(scene: Scene);
  33179. /**
  33180. * Get the number of data values you will have to play with for the visualization
  33181. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33182. * @returns a number
  33183. */
  33184. getFrequencyBinCount(): number;
  33185. /**
  33186. * Gets the current frequency data as a byte array
  33187. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33188. * @returns a Uint8Array
  33189. */
  33190. getByteFrequencyData(): Uint8Array;
  33191. /**
  33192. * Gets the current waveform as a byte array
  33193. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33194. * @returns a Uint8Array
  33195. */
  33196. getByteTimeDomainData(): Uint8Array;
  33197. /**
  33198. * Gets the current frequency data as a float array
  33199. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33200. * @returns a Float32Array
  33201. */
  33202. getFloatFrequencyData(): Float32Array;
  33203. /**
  33204. * Renders the debug canvas
  33205. */
  33206. drawDebugCanvas(): void;
  33207. /**
  33208. * Stops rendering the debug canvas and removes it
  33209. */
  33210. stopDebugCanvas(): void;
  33211. /**
  33212. * Connects two audio nodes
  33213. * @param inputAudioNode defines first node to connect
  33214. * @param outputAudioNode defines second node to connect
  33215. */
  33216. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33217. /**
  33218. * Releases all associated resources
  33219. */
  33220. dispose(): void;
  33221. }
  33222. }
  33223. declare module "babylonjs/Audio/audioEngine" {
  33224. import { IDisposable } from "babylonjs/scene";
  33225. import { Analyser } from "babylonjs/Audio/analyser";
  33226. import { Nullable } from "babylonjs/types";
  33227. import { Observable } from "babylonjs/Misc/observable";
  33228. /**
  33229. * This represents an audio engine and it is responsible
  33230. * to play, synchronize and analyse sounds throughout the application.
  33231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33232. */
  33233. export interface IAudioEngine extends IDisposable {
  33234. /**
  33235. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33236. */
  33237. readonly canUseWebAudio: boolean;
  33238. /**
  33239. * Gets the current AudioContext if available.
  33240. */
  33241. readonly audioContext: Nullable<AudioContext>;
  33242. /**
  33243. * The master gain node defines the global audio volume of your audio engine.
  33244. */
  33245. readonly masterGain: GainNode;
  33246. /**
  33247. * Gets whether or not mp3 are supported by your browser.
  33248. */
  33249. readonly isMP3supported: boolean;
  33250. /**
  33251. * Gets whether or not ogg are supported by your browser.
  33252. */
  33253. readonly isOGGsupported: boolean;
  33254. /**
  33255. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33256. * @ignoreNaming
  33257. */
  33258. WarnedWebAudioUnsupported: boolean;
  33259. /**
  33260. * Defines if the audio engine relies on a custom unlocked button.
  33261. * In this case, the embedded button will not be displayed.
  33262. */
  33263. useCustomUnlockedButton: boolean;
  33264. /**
  33265. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33266. */
  33267. readonly unlocked: boolean;
  33268. /**
  33269. * Event raised when audio has been unlocked on the browser.
  33270. */
  33271. onAudioUnlockedObservable: Observable<AudioEngine>;
  33272. /**
  33273. * Event raised when audio has been locked on the browser.
  33274. */
  33275. onAudioLockedObservable: Observable<AudioEngine>;
  33276. /**
  33277. * Flags the audio engine in Locked state.
  33278. * This happens due to new browser policies preventing audio to autoplay.
  33279. */
  33280. lock(): void;
  33281. /**
  33282. * Unlocks the audio engine once a user action has been done on the dom.
  33283. * This is helpful to resume play once browser policies have been satisfied.
  33284. */
  33285. unlock(): void;
  33286. }
  33287. /**
  33288. * This represents the default audio engine used in babylon.
  33289. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33291. */
  33292. export class AudioEngine implements IAudioEngine {
  33293. private _audioContext;
  33294. private _audioContextInitialized;
  33295. private _muteButton;
  33296. private _hostElement;
  33297. /**
  33298. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33299. */
  33300. canUseWebAudio: boolean;
  33301. /**
  33302. * The master gain node defines the global audio volume of your audio engine.
  33303. */
  33304. masterGain: GainNode;
  33305. /**
  33306. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33307. * @ignoreNaming
  33308. */
  33309. WarnedWebAudioUnsupported: boolean;
  33310. /**
  33311. * Gets whether or not mp3 are supported by your browser.
  33312. */
  33313. isMP3supported: boolean;
  33314. /**
  33315. * Gets whether or not ogg are supported by your browser.
  33316. */
  33317. isOGGsupported: boolean;
  33318. /**
  33319. * Gets whether audio has been unlocked on the device.
  33320. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33321. * a user interaction has happened.
  33322. */
  33323. unlocked: boolean;
  33324. /**
  33325. * Defines if the audio engine relies on a custom unlocked button.
  33326. * In this case, the embedded button will not be displayed.
  33327. */
  33328. useCustomUnlockedButton: boolean;
  33329. /**
  33330. * Event raised when audio has been unlocked on the browser.
  33331. */
  33332. onAudioUnlockedObservable: Observable<AudioEngine>;
  33333. /**
  33334. * Event raised when audio has been locked on the browser.
  33335. */
  33336. onAudioLockedObservable: Observable<AudioEngine>;
  33337. /**
  33338. * Gets the current AudioContext if available.
  33339. */
  33340. get audioContext(): Nullable<AudioContext>;
  33341. private _connectedAnalyser;
  33342. /**
  33343. * Instantiates a new audio engine.
  33344. *
  33345. * There should be only one per page as some browsers restrict the number
  33346. * of audio contexts you can create.
  33347. * @param hostElement defines the host element where to display the mute icon if necessary
  33348. */
  33349. constructor(hostElement?: Nullable<HTMLElement>);
  33350. /**
  33351. * Flags the audio engine in Locked state.
  33352. * This happens due to new browser policies preventing audio to autoplay.
  33353. */
  33354. lock(): void;
  33355. /**
  33356. * Unlocks the audio engine once a user action has been done on the dom.
  33357. * This is helpful to resume play once browser policies have been satisfied.
  33358. */
  33359. unlock(): void;
  33360. private _resumeAudioContext;
  33361. private _initializeAudioContext;
  33362. private _tryToRun;
  33363. private _triggerRunningState;
  33364. private _triggerSuspendedState;
  33365. private _displayMuteButton;
  33366. private _moveButtonToTopLeft;
  33367. private _onResize;
  33368. private _hideMuteButton;
  33369. /**
  33370. * Destroy and release the resources associated with the audio ccontext.
  33371. */
  33372. dispose(): void;
  33373. /**
  33374. * Gets the global volume sets on the master gain.
  33375. * @returns the global volume if set or -1 otherwise
  33376. */
  33377. getGlobalVolume(): number;
  33378. /**
  33379. * Sets the global volume of your experience (sets on the master gain).
  33380. * @param newVolume Defines the new global volume of the application
  33381. */
  33382. setGlobalVolume(newVolume: number): void;
  33383. /**
  33384. * Connect the audio engine to an audio analyser allowing some amazing
  33385. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33387. * @param analyser The analyser to connect to the engine
  33388. */
  33389. connectToAnalyser(analyser: Analyser): void;
  33390. }
  33391. }
  33392. declare module "babylonjs/Loading/loadingScreen" {
  33393. /**
  33394. * Interface used to present a loading screen while loading a scene
  33395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33396. */
  33397. export interface ILoadingScreen {
  33398. /**
  33399. * Function called to display the loading screen
  33400. */
  33401. displayLoadingUI: () => void;
  33402. /**
  33403. * Function called to hide the loading screen
  33404. */
  33405. hideLoadingUI: () => void;
  33406. /**
  33407. * Gets or sets the color to use for the background
  33408. */
  33409. loadingUIBackgroundColor: string;
  33410. /**
  33411. * Gets or sets the text to display while loading
  33412. */
  33413. loadingUIText: string;
  33414. }
  33415. /**
  33416. * Class used for the default loading screen
  33417. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33418. */
  33419. export class DefaultLoadingScreen implements ILoadingScreen {
  33420. private _renderingCanvas;
  33421. private _loadingText;
  33422. private _loadingDivBackgroundColor;
  33423. private _loadingDiv;
  33424. private _loadingTextDiv;
  33425. /** Gets or sets the logo url to use for the default loading screen */
  33426. static DefaultLogoUrl: string;
  33427. /** Gets or sets the spinner url to use for the default loading screen */
  33428. static DefaultSpinnerUrl: string;
  33429. /**
  33430. * Creates a new default loading screen
  33431. * @param _renderingCanvas defines the canvas used to render the scene
  33432. * @param _loadingText defines the default text to display
  33433. * @param _loadingDivBackgroundColor defines the default background color
  33434. */
  33435. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33436. /**
  33437. * Function called to display the loading screen
  33438. */
  33439. displayLoadingUI(): void;
  33440. /**
  33441. * Function called to hide the loading screen
  33442. */
  33443. hideLoadingUI(): void;
  33444. /**
  33445. * Gets or sets the text to display while loading
  33446. */
  33447. set loadingUIText(text: string);
  33448. get loadingUIText(): string;
  33449. /**
  33450. * Gets or sets the color to use for the background
  33451. */
  33452. get loadingUIBackgroundColor(): string;
  33453. set loadingUIBackgroundColor(color: string);
  33454. private _resizeLoadingUI;
  33455. }
  33456. }
  33457. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33458. /**
  33459. * Interface for any object that can request an animation frame
  33460. */
  33461. export interface ICustomAnimationFrameRequester {
  33462. /**
  33463. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33464. */
  33465. renderFunction?: Function;
  33466. /**
  33467. * Called to request the next frame to render to
  33468. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33469. */
  33470. requestAnimationFrame: Function;
  33471. /**
  33472. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33473. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33474. */
  33475. requestID?: number;
  33476. }
  33477. }
  33478. declare module "babylonjs/Misc/performanceMonitor" {
  33479. /**
  33480. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33481. */
  33482. export class PerformanceMonitor {
  33483. private _enabled;
  33484. private _rollingFrameTime;
  33485. private _lastFrameTimeMs;
  33486. /**
  33487. * constructor
  33488. * @param frameSampleSize The number of samples required to saturate the sliding window
  33489. */
  33490. constructor(frameSampleSize?: number);
  33491. /**
  33492. * Samples current frame
  33493. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33494. */
  33495. sampleFrame(timeMs?: number): void;
  33496. /**
  33497. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33498. */
  33499. get averageFrameTime(): number;
  33500. /**
  33501. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33502. */
  33503. get averageFrameTimeVariance(): number;
  33504. /**
  33505. * Returns the frame time of the most recent frame
  33506. */
  33507. get instantaneousFrameTime(): number;
  33508. /**
  33509. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33510. */
  33511. get averageFPS(): number;
  33512. /**
  33513. * Returns the average framerate in frames per second using the most recent frame time
  33514. */
  33515. get instantaneousFPS(): number;
  33516. /**
  33517. * Returns true if enough samples have been taken to completely fill the sliding window
  33518. */
  33519. get isSaturated(): boolean;
  33520. /**
  33521. * Enables contributions to the sliding window sample set
  33522. */
  33523. enable(): void;
  33524. /**
  33525. * Disables contributions to the sliding window sample set
  33526. * Samples will not be interpolated over the disabled period
  33527. */
  33528. disable(): void;
  33529. /**
  33530. * Returns true if sampling is enabled
  33531. */
  33532. get isEnabled(): boolean;
  33533. /**
  33534. * Resets performance monitor
  33535. */
  33536. reset(): void;
  33537. }
  33538. /**
  33539. * RollingAverage
  33540. *
  33541. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33542. */
  33543. export class RollingAverage {
  33544. /**
  33545. * Current average
  33546. */
  33547. average: number;
  33548. /**
  33549. * Current variance
  33550. */
  33551. variance: number;
  33552. protected _samples: Array<number>;
  33553. protected _sampleCount: number;
  33554. protected _pos: number;
  33555. protected _m2: number;
  33556. /**
  33557. * constructor
  33558. * @param length The number of samples required to saturate the sliding window
  33559. */
  33560. constructor(length: number);
  33561. /**
  33562. * Adds a sample to the sample set
  33563. * @param v The sample value
  33564. */
  33565. add(v: number): void;
  33566. /**
  33567. * Returns previously added values or null if outside of history or outside the sliding window domain
  33568. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33569. * @return Value previously recorded with add() or null if outside of range
  33570. */
  33571. history(i: number): number;
  33572. /**
  33573. * Returns true if enough samples have been taken to completely fill the sliding window
  33574. * @return true if sample-set saturated
  33575. */
  33576. isSaturated(): boolean;
  33577. /**
  33578. * Resets the rolling average (equivalent to 0 samples taken so far)
  33579. */
  33580. reset(): void;
  33581. /**
  33582. * Wraps a value around the sample range boundaries
  33583. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33584. * @return Wrapped position in sample range
  33585. */
  33586. protected _wrapPosition(i: number): number;
  33587. }
  33588. }
  33589. declare module "babylonjs/Misc/perfCounter" {
  33590. /**
  33591. * This class is used to track a performance counter which is number based.
  33592. * The user has access to many properties which give statistics of different nature.
  33593. *
  33594. * The implementer can track two kinds of Performance Counter: time and count.
  33595. * 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.
  33596. * 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.
  33597. */
  33598. export class PerfCounter {
  33599. /**
  33600. * Gets or sets a global boolean to turn on and off all the counters
  33601. */
  33602. static Enabled: boolean;
  33603. /**
  33604. * Returns the smallest value ever
  33605. */
  33606. get min(): number;
  33607. /**
  33608. * Returns the biggest value ever
  33609. */
  33610. get max(): number;
  33611. /**
  33612. * Returns the average value since the performance counter is running
  33613. */
  33614. get average(): number;
  33615. /**
  33616. * Returns the average value of the last second the counter was monitored
  33617. */
  33618. get lastSecAverage(): number;
  33619. /**
  33620. * Returns the current value
  33621. */
  33622. get current(): number;
  33623. /**
  33624. * Gets the accumulated total
  33625. */
  33626. get total(): number;
  33627. /**
  33628. * Gets the total value count
  33629. */
  33630. get count(): number;
  33631. /**
  33632. * Creates a new counter
  33633. */
  33634. constructor();
  33635. /**
  33636. * Call this method to start monitoring a new frame.
  33637. * 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.
  33638. */
  33639. fetchNewFrame(): void;
  33640. /**
  33641. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33642. * @param newCount the count value to add to the monitored count
  33643. * @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.
  33644. */
  33645. addCount(newCount: number, fetchResult: boolean): void;
  33646. /**
  33647. * Start monitoring this performance counter
  33648. */
  33649. beginMonitoring(): void;
  33650. /**
  33651. * Compute the time lapsed since the previous beginMonitoring() call.
  33652. * @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
  33653. */
  33654. endMonitoring(newFrame?: boolean): void;
  33655. private _fetchResult;
  33656. private _startMonitoringTime;
  33657. private _min;
  33658. private _max;
  33659. private _average;
  33660. private _current;
  33661. private _totalValueCount;
  33662. private _totalAccumulated;
  33663. private _lastSecAverage;
  33664. private _lastSecAccumulated;
  33665. private _lastSecTime;
  33666. private _lastSecValueCount;
  33667. }
  33668. }
  33669. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33670. module "babylonjs/Engines/thinEngine" {
  33671. interface ThinEngine {
  33672. /**
  33673. * Sets alpha constants used by some alpha blending modes
  33674. * @param r defines the red component
  33675. * @param g defines the green component
  33676. * @param b defines the blue component
  33677. * @param a defines the alpha component
  33678. */
  33679. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33680. /**
  33681. * Sets the current alpha mode
  33682. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33683. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33684. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33685. */
  33686. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33687. /**
  33688. * Gets the current alpha mode
  33689. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33690. * @returns the current alpha mode
  33691. */
  33692. getAlphaMode(): number;
  33693. /**
  33694. * Sets the current alpha equation
  33695. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33696. */
  33697. setAlphaEquation(equation: number): void;
  33698. /**
  33699. * Gets the current alpha equation.
  33700. * @returns the current alpha equation
  33701. */
  33702. getAlphaEquation(): number;
  33703. }
  33704. }
  33705. }
  33706. declare module "babylonjs/Engines/engine" {
  33707. import { Observable } from "babylonjs/Misc/observable";
  33708. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33709. import { Scene } from "babylonjs/scene";
  33710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33711. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33712. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33713. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33714. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33715. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33716. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33717. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33718. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33719. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33720. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33721. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33722. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33723. import "babylonjs/Engines/Extensions/engine.alpha";
  33724. import { Material } from "babylonjs/Materials/material";
  33725. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33726. /**
  33727. * Defines the interface used by display changed events
  33728. */
  33729. export interface IDisplayChangedEventArgs {
  33730. /** Gets the vrDisplay object (if any) */
  33731. vrDisplay: Nullable<any>;
  33732. /** Gets a boolean indicating if webVR is supported */
  33733. vrSupported: boolean;
  33734. }
  33735. /**
  33736. * Defines the interface used by objects containing a viewport (like a camera)
  33737. */
  33738. interface IViewportOwnerLike {
  33739. /**
  33740. * Gets or sets the viewport
  33741. */
  33742. viewport: IViewportLike;
  33743. }
  33744. /**
  33745. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33746. */
  33747. export class Engine extends ThinEngine {
  33748. /** Defines that alpha blending is disabled */
  33749. static readonly ALPHA_DISABLE: number;
  33750. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33751. static readonly ALPHA_ADD: number;
  33752. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33753. static readonly ALPHA_COMBINE: number;
  33754. /** Defines that alpha blending to DEST - SRC * DEST */
  33755. static readonly ALPHA_SUBTRACT: number;
  33756. /** Defines that alpha blending to SRC * DEST */
  33757. static readonly ALPHA_MULTIPLY: number;
  33758. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33759. static readonly ALPHA_MAXIMIZED: number;
  33760. /** Defines that alpha blending to SRC + DEST */
  33761. static readonly ALPHA_ONEONE: number;
  33762. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33763. static readonly ALPHA_PREMULTIPLIED: number;
  33764. /**
  33765. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33766. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33767. */
  33768. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33769. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33770. static readonly ALPHA_INTERPOLATE: number;
  33771. /**
  33772. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33773. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33774. */
  33775. static readonly ALPHA_SCREENMODE: number;
  33776. /** Defines that the ressource is not delayed*/
  33777. static readonly DELAYLOADSTATE_NONE: number;
  33778. /** Defines that the ressource was successfully delay loaded */
  33779. static readonly DELAYLOADSTATE_LOADED: number;
  33780. /** Defines that the ressource is currently delay loading */
  33781. static readonly DELAYLOADSTATE_LOADING: number;
  33782. /** Defines that the ressource is delayed and has not started loading */
  33783. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33784. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33785. static readonly NEVER: number;
  33786. /** 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 */
  33787. static readonly ALWAYS: number;
  33788. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33789. static readonly LESS: number;
  33790. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33791. static readonly EQUAL: number;
  33792. /** 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 */
  33793. static readonly LEQUAL: number;
  33794. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33795. static readonly GREATER: number;
  33796. /** 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 */
  33797. static readonly GEQUAL: number;
  33798. /** 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 */
  33799. static readonly NOTEQUAL: number;
  33800. /** Passed to stencilOperation to specify that stencil value must be kept */
  33801. static readonly KEEP: number;
  33802. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33803. static readonly REPLACE: number;
  33804. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33805. static readonly INCR: number;
  33806. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33807. static readonly DECR: number;
  33808. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33809. static readonly INVERT: number;
  33810. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33811. static readonly INCR_WRAP: number;
  33812. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33813. static readonly DECR_WRAP: number;
  33814. /** Texture is not repeating outside of 0..1 UVs */
  33815. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33816. /** Texture is repeating outside of 0..1 UVs */
  33817. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33818. /** Texture is repeating and mirrored */
  33819. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33820. /** ALPHA */
  33821. static readonly TEXTUREFORMAT_ALPHA: number;
  33822. /** LUMINANCE */
  33823. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33824. /** LUMINANCE_ALPHA */
  33825. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33826. /** RGB */
  33827. static readonly TEXTUREFORMAT_RGB: number;
  33828. /** RGBA */
  33829. static readonly TEXTUREFORMAT_RGBA: number;
  33830. /** RED */
  33831. static readonly TEXTUREFORMAT_RED: number;
  33832. /** RED (2nd reference) */
  33833. static readonly TEXTUREFORMAT_R: number;
  33834. /** RG */
  33835. static readonly TEXTUREFORMAT_RG: number;
  33836. /** RED_INTEGER */
  33837. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33838. /** RED_INTEGER (2nd reference) */
  33839. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33840. /** RG_INTEGER */
  33841. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33842. /** RGB_INTEGER */
  33843. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33844. /** RGBA_INTEGER */
  33845. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33846. /** UNSIGNED_BYTE */
  33847. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33848. /** UNSIGNED_BYTE (2nd reference) */
  33849. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33850. /** FLOAT */
  33851. static readonly TEXTURETYPE_FLOAT: number;
  33852. /** HALF_FLOAT */
  33853. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33854. /** BYTE */
  33855. static readonly TEXTURETYPE_BYTE: number;
  33856. /** SHORT */
  33857. static readonly TEXTURETYPE_SHORT: number;
  33858. /** UNSIGNED_SHORT */
  33859. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33860. /** INT */
  33861. static readonly TEXTURETYPE_INT: number;
  33862. /** UNSIGNED_INT */
  33863. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33864. /** UNSIGNED_SHORT_4_4_4_4 */
  33865. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33866. /** UNSIGNED_SHORT_5_5_5_1 */
  33867. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33868. /** UNSIGNED_SHORT_5_6_5 */
  33869. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33870. /** UNSIGNED_INT_2_10_10_10_REV */
  33871. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33872. /** UNSIGNED_INT_24_8 */
  33873. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33874. /** UNSIGNED_INT_10F_11F_11F_REV */
  33875. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33876. /** UNSIGNED_INT_5_9_9_9_REV */
  33877. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33878. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33879. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33880. /** nearest is mag = nearest and min = nearest and mip = linear */
  33881. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33882. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33883. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33884. /** Trilinear is mag = linear and min = linear and mip = linear */
  33885. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33886. /** nearest is mag = nearest and min = nearest and mip = linear */
  33887. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33888. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33889. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33890. /** Trilinear is mag = linear and min = linear and mip = linear */
  33891. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33892. /** mag = nearest and min = nearest and mip = nearest */
  33893. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33894. /** mag = nearest and min = linear and mip = nearest */
  33895. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33896. /** mag = nearest and min = linear and mip = linear */
  33897. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33898. /** mag = nearest and min = linear and mip = none */
  33899. static readonly TEXTURE_NEAREST_LINEAR: number;
  33900. /** mag = nearest and min = nearest and mip = none */
  33901. static readonly TEXTURE_NEAREST_NEAREST: number;
  33902. /** mag = linear and min = nearest and mip = nearest */
  33903. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33904. /** mag = linear and min = nearest and mip = linear */
  33905. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33906. /** mag = linear and min = linear and mip = none */
  33907. static readonly TEXTURE_LINEAR_LINEAR: number;
  33908. /** mag = linear and min = nearest and mip = none */
  33909. static readonly TEXTURE_LINEAR_NEAREST: number;
  33910. /** Explicit coordinates mode */
  33911. static readonly TEXTURE_EXPLICIT_MODE: number;
  33912. /** Spherical coordinates mode */
  33913. static readonly TEXTURE_SPHERICAL_MODE: number;
  33914. /** Planar coordinates mode */
  33915. static readonly TEXTURE_PLANAR_MODE: number;
  33916. /** Cubic coordinates mode */
  33917. static readonly TEXTURE_CUBIC_MODE: number;
  33918. /** Projection coordinates mode */
  33919. static readonly TEXTURE_PROJECTION_MODE: number;
  33920. /** Skybox coordinates mode */
  33921. static readonly TEXTURE_SKYBOX_MODE: number;
  33922. /** Inverse Cubic coordinates mode */
  33923. static readonly TEXTURE_INVCUBIC_MODE: number;
  33924. /** Equirectangular coordinates mode */
  33925. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33926. /** Equirectangular Fixed coordinates mode */
  33927. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33928. /** Equirectangular Fixed Mirrored coordinates mode */
  33929. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33930. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33931. static readonly SCALEMODE_FLOOR: number;
  33932. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33933. static readonly SCALEMODE_NEAREST: number;
  33934. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33935. static readonly SCALEMODE_CEILING: number;
  33936. /**
  33937. * Returns the current npm package of the sdk
  33938. */
  33939. static get NpmPackage(): string;
  33940. /**
  33941. * Returns the current version of the framework
  33942. */
  33943. static get Version(): string;
  33944. /** Gets the list of created engines */
  33945. static get Instances(): Engine[];
  33946. /**
  33947. * Gets the latest created engine
  33948. */
  33949. static get LastCreatedEngine(): Nullable<Engine>;
  33950. /**
  33951. * Gets the latest created scene
  33952. */
  33953. static get LastCreatedScene(): Nullable<Scene>;
  33954. /**
  33955. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33956. * @param flag defines which part of the materials must be marked as dirty
  33957. * @param predicate defines a predicate used to filter which materials should be affected
  33958. */
  33959. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33960. /**
  33961. * Method called to create the default loading screen.
  33962. * This can be overriden in your own app.
  33963. * @param canvas The rendering canvas element
  33964. * @returns The loading screen
  33965. */
  33966. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33967. /**
  33968. * Method called to create the default rescale post process on each engine.
  33969. */
  33970. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33971. /**
  33972. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33973. **/
  33974. enableOfflineSupport: boolean;
  33975. /**
  33976. * 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)
  33977. **/
  33978. disableManifestCheck: boolean;
  33979. /**
  33980. * Gets the list of created scenes
  33981. */
  33982. scenes: Scene[];
  33983. /**
  33984. * Event raised when a new scene is created
  33985. */
  33986. onNewSceneAddedObservable: Observable<Scene>;
  33987. /**
  33988. * Gets the list of created postprocesses
  33989. */
  33990. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33991. /**
  33992. * Gets a boolean indicating if the pointer is currently locked
  33993. */
  33994. isPointerLock: boolean;
  33995. /**
  33996. * Observable event triggered each time the rendering canvas is resized
  33997. */
  33998. onResizeObservable: Observable<Engine>;
  33999. /**
  34000. * Observable event triggered each time the canvas loses focus
  34001. */
  34002. onCanvasBlurObservable: Observable<Engine>;
  34003. /**
  34004. * Observable event triggered each time the canvas gains focus
  34005. */
  34006. onCanvasFocusObservable: Observable<Engine>;
  34007. /**
  34008. * Observable event triggered each time the canvas receives pointerout event
  34009. */
  34010. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34011. /**
  34012. * Observable raised when the engine begins a new frame
  34013. */
  34014. onBeginFrameObservable: Observable<Engine>;
  34015. /**
  34016. * If set, will be used to request the next animation frame for the render loop
  34017. */
  34018. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34019. /**
  34020. * Observable raised when the engine ends the current frame
  34021. */
  34022. onEndFrameObservable: Observable<Engine>;
  34023. /**
  34024. * Observable raised when the engine is about to compile a shader
  34025. */
  34026. onBeforeShaderCompilationObservable: Observable<Engine>;
  34027. /**
  34028. * Observable raised when the engine has jsut compiled a shader
  34029. */
  34030. onAfterShaderCompilationObservable: Observable<Engine>;
  34031. /**
  34032. * Gets the audio engine
  34033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34034. * @ignorenaming
  34035. */
  34036. static audioEngine: IAudioEngine;
  34037. /**
  34038. * Default AudioEngine factory responsible of creating the Audio Engine.
  34039. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34040. */
  34041. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34042. /**
  34043. * Default offline support factory responsible of creating a tool used to store data locally.
  34044. * By default, this will create a Database object if the workload has been embedded.
  34045. */
  34046. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34047. private _loadingScreen;
  34048. private _pointerLockRequested;
  34049. private _dummyFramebuffer;
  34050. private _rescalePostProcess;
  34051. private _deterministicLockstep;
  34052. private _lockstepMaxSteps;
  34053. private _timeStep;
  34054. protected get _supportsHardwareTextureRescaling(): boolean;
  34055. private _fps;
  34056. private _deltaTime;
  34057. /** @hidden */
  34058. _drawCalls: PerfCounter;
  34059. /**
  34060. * Turn this value on if you want to pause FPS computation when in background
  34061. */
  34062. disablePerformanceMonitorInBackground: boolean;
  34063. private _performanceMonitor;
  34064. /**
  34065. * Gets the performance monitor attached to this engine
  34066. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34067. */
  34068. get performanceMonitor(): PerformanceMonitor;
  34069. private _onFocus;
  34070. private _onBlur;
  34071. private _onCanvasPointerOut;
  34072. private _onCanvasBlur;
  34073. private _onCanvasFocus;
  34074. private _onFullscreenChange;
  34075. private _onPointerLockChange;
  34076. /**
  34077. * Gets the HTML element used to attach event listeners
  34078. * @returns a HTML element
  34079. */
  34080. getInputElement(): Nullable<HTMLElement>;
  34081. /**
  34082. * Creates a new engine
  34083. * @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
  34084. * @param antialias defines enable antialiasing (default: false)
  34085. * @param options defines further options to be sent to the getContext() function
  34086. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34087. */
  34088. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34089. /**
  34090. * Gets current aspect ratio
  34091. * @param viewportOwner defines the camera to use to get the aspect ratio
  34092. * @param useScreen defines if screen size must be used (or the current render target if any)
  34093. * @returns a number defining the aspect ratio
  34094. */
  34095. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34096. /**
  34097. * Gets current screen aspect ratio
  34098. * @returns a number defining the aspect ratio
  34099. */
  34100. getScreenAspectRatio(): number;
  34101. /**
  34102. * Gets the client rect of the HTML canvas attached with the current webGL context
  34103. * @returns a client rectanglee
  34104. */
  34105. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34106. /**
  34107. * Gets the client rect of the HTML element used for events
  34108. * @returns a client rectanglee
  34109. */
  34110. getInputElementClientRect(): Nullable<ClientRect>;
  34111. /**
  34112. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34113. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34114. * @returns true if engine is in deterministic lock step mode
  34115. */
  34116. isDeterministicLockStep(): boolean;
  34117. /**
  34118. * Gets the max steps when engine is running in deterministic lock step
  34119. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34120. * @returns the max steps
  34121. */
  34122. getLockstepMaxSteps(): number;
  34123. /**
  34124. * Returns the time in ms between steps when using deterministic lock step.
  34125. * @returns time step in (ms)
  34126. */
  34127. getTimeStep(): number;
  34128. /**
  34129. * Force the mipmap generation for the given render target texture
  34130. * @param texture defines the render target texture to use
  34131. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34132. */
  34133. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34134. /** States */
  34135. /**
  34136. * Set various states to the webGL context
  34137. * @param culling defines backface culling state
  34138. * @param zOffset defines the value to apply to zOffset (0 by default)
  34139. * @param force defines if states must be applied even if cache is up to date
  34140. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34141. */
  34142. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34143. /**
  34144. * Set the z offset to apply to current rendering
  34145. * @param value defines the offset to apply
  34146. */
  34147. setZOffset(value: number): void;
  34148. /**
  34149. * Gets the current value of the zOffset
  34150. * @returns the current zOffset state
  34151. */
  34152. getZOffset(): number;
  34153. /**
  34154. * Enable or disable depth buffering
  34155. * @param enable defines the state to set
  34156. */
  34157. setDepthBuffer(enable: boolean): void;
  34158. /**
  34159. * Gets a boolean indicating if depth writing is enabled
  34160. * @returns the current depth writing state
  34161. */
  34162. getDepthWrite(): boolean;
  34163. /**
  34164. * Enable or disable depth writing
  34165. * @param enable defines the state to set
  34166. */
  34167. setDepthWrite(enable: boolean): void;
  34168. /**
  34169. * Gets a boolean indicating if stencil buffer is enabled
  34170. * @returns the current stencil buffer state
  34171. */
  34172. getStencilBuffer(): boolean;
  34173. /**
  34174. * Enable or disable the stencil buffer
  34175. * @param enable defines if the stencil buffer must be enabled or disabled
  34176. */
  34177. setStencilBuffer(enable: boolean): void;
  34178. /**
  34179. * Gets the current stencil mask
  34180. * @returns a number defining the new stencil mask to use
  34181. */
  34182. getStencilMask(): number;
  34183. /**
  34184. * Sets the current stencil mask
  34185. * @param mask defines the new stencil mask to use
  34186. */
  34187. setStencilMask(mask: number): void;
  34188. /**
  34189. * Gets the current stencil function
  34190. * @returns a number defining the stencil function to use
  34191. */
  34192. getStencilFunction(): number;
  34193. /**
  34194. * Gets the current stencil reference value
  34195. * @returns a number defining the stencil reference value to use
  34196. */
  34197. getStencilFunctionReference(): number;
  34198. /**
  34199. * Gets the current stencil mask
  34200. * @returns a number defining the stencil mask to use
  34201. */
  34202. getStencilFunctionMask(): number;
  34203. /**
  34204. * Sets the current stencil function
  34205. * @param stencilFunc defines the new stencil function to use
  34206. */
  34207. setStencilFunction(stencilFunc: number): void;
  34208. /**
  34209. * Sets the current stencil reference
  34210. * @param reference defines the new stencil reference to use
  34211. */
  34212. setStencilFunctionReference(reference: number): void;
  34213. /**
  34214. * Sets the current stencil mask
  34215. * @param mask defines the new stencil mask to use
  34216. */
  34217. setStencilFunctionMask(mask: number): void;
  34218. /**
  34219. * Gets the current stencil operation when stencil fails
  34220. * @returns a number defining stencil operation to use when stencil fails
  34221. */
  34222. getStencilOperationFail(): number;
  34223. /**
  34224. * Gets the current stencil operation when depth fails
  34225. * @returns a number defining stencil operation to use when depth fails
  34226. */
  34227. getStencilOperationDepthFail(): number;
  34228. /**
  34229. * Gets the current stencil operation when stencil passes
  34230. * @returns a number defining stencil operation to use when stencil passes
  34231. */
  34232. getStencilOperationPass(): number;
  34233. /**
  34234. * Sets the stencil operation to use when stencil fails
  34235. * @param operation defines the stencil operation to use when stencil fails
  34236. */
  34237. setStencilOperationFail(operation: number): void;
  34238. /**
  34239. * Sets the stencil operation to use when depth fails
  34240. * @param operation defines the stencil operation to use when depth fails
  34241. */
  34242. setStencilOperationDepthFail(operation: number): void;
  34243. /**
  34244. * Sets the stencil operation to use when stencil passes
  34245. * @param operation defines the stencil operation to use when stencil passes
  34246. */
  34247. setStencilOperationPass(operation: number): void;
  34248. /**
  34249. * Sets a boolean indicating if the dithering state is enabled or disabled
  34250. * @param value defines the dithering state
  34251. */
  34252. setDitheringState(value: boolean): void;
  34253. /**
  34254. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34255. * @param value defines the rasterizer state
  34256. */
  34257. setRasterizerState(value: boolean): void;
  34258. /**
  34259. * Gets the current depth function
  34260. * @returns a number defining the depth function
  34261. */
  34262. getDepthFunction(): Nullable<number>;
  34263. /**
  34264. * Sets the current depth function
  34265. * @param depthFunc defines the function to use
  34266. */
  34267. setDepthFunction(depthFunc: number): void;
  34268. /**
  34269. * Sets the current depth function to GREATER
  34270. */
  34271. setDepthFunctionToGreater(): void;
  34272. /**
  34273. * Sets the current depth function to GEQUAL
  34274. */
  34275. setDepthFunctionToGreaterOrEqual(): void;
  34276. /**
  34277. * Sets the current depth function to LESS
  34278. */
  34279. setDepthFunctionToLess(): void;
  34280. /**
  34281. * Sets the current depth function to LEQUAL
  34282. */
  34283. setDepthFunctionToLessOrEqual(): void;
  34284. private _cachedStencilBuffer;
  34285. private _cachedStencilFunction;
  34286. private _cachedStencilMask;
  34287. private _cachedStencilOperationPass;
  34288. private _cachedStencilOperationFail;
  34289. private _cachedStencilOperationDepthFail;
  34290. private _cachedStencilReference;
  34291. /**
  34292. * Caches the the state of the stencil buffer
  34293. */
  34294. cacheStencilState(): void;
  34295. /**
  34296. * Restores the state of the stencil buffer
  34297. */
  34298. restoreStencilState(): void;
  34299. /**
  34300. * Directly set the WebGL Viewport
  34301. * @param x defines the x coordinate of the viewport (in screen space)
  34302. * @param y defines the y coordinate of the viewport (in screen space)
  34303. * @param width defines the width of the viewport (in screen space)
  34304. * @param height defines the height of the viewport (in screen space)
  34305. * @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
  34306. */
  34307. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34308. /**
  34309. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34310. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34311. * @param y defines the y-coordinate of the corner of the clear rectangle
  34312. * @param width defines the width of the clear rectangle
  34313. * @param height defines the height of the clear rectangle
  34314. * @param clearColor defines the clear color
  34315. */
  34316. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34317. /**
  34318. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34319. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34320. * @param y defines the y-coordinate of the corner of the clear rectangle
  34321. * @param width defines the width of the clear rectangle
  34322. * @param height defines the height of the clear rectangle
  34323. */
  34324. enableScissor(x: number, y: number, width: number, height: number): void;
  34325. /**
  34326. * Disable previously set scissor test rectangle
  34327. */
  34328. disableScissor(): void;
  34329. protected _reportDrawCall(): void;
  34330. /**
  34331. * Initializes a webVR display and starts listening to display change events
  34332. * The onVRDisplayChangedObservable will be notified upon these changes
  34333. * @returns The onVRDisplayChangedObservable
  34334. */
  34335. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34336. /** @hidden */
  34337. _prepareVRComponent(): void;
  34338. /** @hidden */
  34339. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34340. /** @hidden */
  34341. _submitVRFrame(): void;
  34342. /**
  34343. * Call this function to leave webVR mode
  34344. * Will do nothing if webVR is not supported or if there is no webVR device
  34345. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34346. */
  34347. disableVR(): void;
  34348. /**
  34349. * Gets a boolean indicating that the system is in VR mode and is presenting
  34350. * @returns true if VR mode is engaged
  34351. */
  34352. isVRPresenting(): boolean;
  34353. /** @hidden */
  34354. _requestVRFrame(): void;
  34355. /** @hidden */
  34356. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34357. /**
  34358. * Gets the source code of the vertex shader associated with a specific webGL program
  34359. * @param program defines the program to use
  34360. * @returns a string containing the source code of the vertex shader associated with the program
  34361. */
  34362. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34363. /**
  34364. * Gets the source code of the fragment shader associated with a specific webGL program
  34365. * @param program defines the program to use
  34366. * @returns a string containing the source code of the fragment shader associated with the program
  34367. */
  34368. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34369. /**
  34370. * Sets a depth stencil texture from a render target to the according uniform.
  34371. * @param channel The texture channel
  34372. * @param uniform The uniform to set
  34373. * @param texture The render target texture containing the depth stencil texture to apply
  34374. */
  34375. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34376. /**
  34377. * Sets a texture to the webGL context from a postprocess
  34378. * @param channel defines the channel to use
  34379. * @param postProcess defines the source postprocess
  34380. */
  34381. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34382. /**
  34383. * Binds the output of the passed in post process to the texture channel specified
  34384. * @param channel The channel the texture should be bound to
  34385. * @param postProcess The post process which's output should be bound
  34386. */
  34387. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34388. /** @hidden */
  34389. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34390. protected _rebuildBuffers(): void;
  34391. /** @hidden */
  34392. _renderFrame(): void;
  34393. _renderLoop(): void;
  34394. /** @hidden */
  34395. _renderViews(): boolean;
  34396. /**
  34397. * Toggle full screen mode
  34398. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34399. */
  34400. switchFullscreen(requestPointerLock: boolean): void;
  34401. /**
  34402. * Enters full screen mode
  34403. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34404. */
  34405. enterFullscreen(requestPointerLock: boolean): void;
  34406. /**
  34407. * Exits full screen mode
  34408. */
  34409. exitFullscreen(): void;
  34410. /**
  34411. * Enters Pointerlock mode
  34412. */
  34413. enterPointerlock(): void;
  34414. /**
  34415. * Exits Pointerlock mode
  34416. */
  34417. exitPointerlock(): void;
  34418. /**
  34419. * Begin a new frame
  34420. */
  34421. beginFrame(): void;
  34422. /**
  34423. * Enf the current frame
  34424. */
  34425. endFrame(): void;
  34426. resize(): void;
  34427. /**
  34428. * Set the compressed texture format to use, based on the formats you have, and the formats
  34429. * supported by the hardware / browser.
  34430. *
  34431. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34432. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34433. * to API arguments needed to compressed textures. This puts the burden on the container
  34434. * generator to house the arcane code for determining these for current & future formats.
  34435. *
  34436. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34437. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34438. *
  34439. * Note: The result of this call is not taken into account when a texture is base64.
  34440. *
  34441. * @param formatsAvailable defines the list of those format families you have created
  34442. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34443. *
  34444. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34445. * @returns The extension selected.
  34446. */
  34447. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34448. /**
  34449. * Set the compressed texture extensions or file names to skip.
  34450. *
  34451. * @param skippedFiles defines the list of those texture files you want to skip
  34452. * Example: [".dds", ".env", "myfile.png"]
  34453. */
  34454. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34455. /**
  34456. * Force a specific size of the canvas
  34457. * @param width defines the new canvas' width
  34458. * @param height defines the new canvas' height
  34459. */
  34460. setSize(width: number, height: number): void;
  34461. /**
  34462. * Updates a dynamic vertex buffer.
  34463. * @param vertexBuffer the vertex buffer to update
  34464. * @param data the data used to update the vertex buffer
  34465. * @param byteOffset the byte offset of the data
  34466. * @param byteLength the byte length of the data
  34467. */
  34468. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34469. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34470. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34471. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34472. _releaseTexture(texture: InternalTexture): void;
  34473. /**
  34474. * @hidden
  34475. * Rescales a texture
  34476. * @param source input texutre
  34477. * @param destination destination texture
  34478. * @param scene scene to use to render the resize
  34479. * @param internalFormat format to use when resizing
  34480. * @param onComplete callback to be called when resize has completed
  34481. */
  34482. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34483. /**
  34484. * Gets the current framerate
  34485. * @returns a number representing the framerate
  34486. */
  34487. getFps(): number;
  34488. /**
  34489. * Gets the time spent between current and previous frame
  34490. * @returns a number representing the delta time in ms
  34491. */
  34492. getDeltaTime(): number;
  34493. private _measureFps;
  34494. /** @hidden */
  34495. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34496. /**
  34497. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34498. * @param renderTarget The render target to set the frame buffer for
  34499. */
  34500. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34501. /**
  34502. * Update a dynamic index buffer
  34503. * @param indexBuffer defines the target index buffer
  34504. * @param indices defines the data to update
  34505. * @param offset defines the offset in the target index buffer where update should start
  34506. */
  34507. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34508. /**
  34509. * Updates the sample count of a render target texture
  34510. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34511. * @param texture defines the texture to update
  34512. * @param samples defines the sample count to set
  34513. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34514. */
  34515. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34516. /**
  34517. * Updates a depth texture Comparison Mode and Function.
  34518. * If the comparison Function is equal to 0, the mode will be set to none.
  34519. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34520. * @param texture The texture to set the comparison function for
  34521. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34522. */
  34523. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34524. /**
  34525. * Creates a webGL buffer to use with instanciation
  34526. * @param capacity defines the size of the buffer
  34527. * @returns the webGL buffer
  34528. */
  34529. createInstancesBuffer(capacity: number): DataBuffer;
  34530. /**
  34531. * Delete a webGL buffer used with instanciation
  34532. * @param buffer defines the webGL buffer to delete
  34533. */
  34534. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34535. /** @hidden */
  34536. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34537. dispose(): void;
  34538. private _disableTouchAction;
  34539. /**
  34540. * Display the loading screen
  34541. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34542. */
  34543. displayLoadingUI(): void;
  34544. /**
  34545. * Hide the loading screen
  34546. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34547. */
  34548. hideLoadingUI(): void;
  34549. /**
  34550. * Gets the current loading screen object
  34551. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34552. */
  34553. get loadingScreen(): ILoadingScreen;
  34554. /**
  34555. * Sets the current loading screen object
  34556. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34557. */
  34558. set loadingScreen(loadingScreen: ILoadingScreen);
  34559. /**
  34560. * Sets the current loading screen text
  34561. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34562. */
  34563. set loadingUIText(text: string);
  34564. /**
  34565. * Sets the current loading screen background color
  34566. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34567. */
  34568. set loadingUIBackgroundColor(color: string);
  34569. /** Pointerlock and fullscreen */
  34570. /**
  34571. * Ask the browser to promote the current element to pointerlock mode
  34572. * @param element defines the DOM element to promote
  34573. */
  34574. static _RequestPointerlock(element: HTMLElement): void;
  34575. /**
  34576. * Asks the browser to exit pointerlock mode
  34577. */
  34578. static _ExitPointerlock(): void;
  34579. /**
  34580. * Ask the browser to promote the current element to fullscreen rendering mode
  34581. * @param element defines the DOM element to promote
  34582. */
  34583. static _RequestFullscreen(element: HTMLElement): void;
  34584. /**
  34585. * Asks the browser to exit fullscreen mode
  34586. */
  34587. static _ExitFullscreen(): void;
  34588. }
  34589. }
  34590. declare module "babylonjs/Engines/engineStore" {
  34591. import { Nullable } from "babylonjs/types";
  34592. import { Engine } from "babylonjs/Engines/engine";
  34593. import { Scene } from "babylonjs/scene";
  34594. /**
  34595. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34596. * during the life time of the application.
  34597. */
  34598. export class EngineStore {
  34599. /** Gets the list of created engines */
  34600. static Instances: import("babylonjs/Engines/engine").Engine[];
  34601. /** @hidden */
  34602. static _LastCreatedScene: Nullable<Scene>;
  34603. /**
  34604. * Gets the latest created engine
  34605. */
  34606. static get LastCreatedEngine(): Nullable<Engine>;
  34607. /**
  34608. * Gets the latest created scene
  34609. */
  34610. static get LastCreatedScene(): Nullable<Scene>;
  34611. /**
  34612. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34613. * @ignorenaming
  34614. */
  34615. static UseFallbackTexture: boolean;
  34616. /**
  34617. * Texture content used if a texture cannot loaded
  34618. * @ignorenaming
  34619. */
  34620. static FallbackTexture: string;
  34621. }
  34622. }
  34623. declare module "babylonjs/Misc/promise" {
  34624. /**
  34625. * Helper class that provides a small promise polyfill
  34626. */
  34627. export class PromisePolyfill {
  34628. /**
  34629. * Static function used to check if the polyfill is required
  34630. * If this is the case then the function will inject the polyfill to window.Promise
  34631. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34632. */
  34633. static Apply(force?: boolean): void;
  34634. }
  34635. }
  34636. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34637. /**
  34638. * Interface for screenshot methods with describe argument called `size` as object with options
  34639. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34640. */
  34641. export interface IScreenshotSize {
  34642. /**
  34643. * number in pixels for canvas height
  34644. */
  34645. height?: number;
  34646. /**
  34647. * multiplier allowing render at a higher or lower resolution
  34648. * If value is defined then height and width will be ignored and taken from camera
  34649. */
  34650. precision?: number;
  34651. /**
  34652. * number in pixels for canvas width
  34653. */
  34654. width?: number;
  34655. }
  34656. }
  34657. declare module "babylonjs/Misc/tools" {
  34658. import { Nullable, float } from "babylonjs/types";
  34659. import { DomManagement } from "babylonjs/Misc/domManagement";
  34660. import { WebRequest } from "babylonjs/Misc/webRequest";
  34661. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34662. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34663. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34664. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34665. import { Camera } from "babylonjs/Cameras/camera";
  34666. import { Engine } from "babylonjs/Engines/engine";
  34667. interface IColor4Like {
  34668. r: float;
  34669. g: float;
  34670. b: float;
  34671. a: float;
  34672. }
  34673. /**
  34674. * Class containing a set of static utilities functions
  34675. */
  34676. export class Tools {
  34677. /**
  34678. * Gets or sets the base URL to use to load assets
  34679. */
  34680. static get BaseUrl(): string;
  34681. static set BaseUrl(value: string);
  34682. /**
  34683. * Enable/Disable Custom HTTP Request Headers globally.
  34684. * default = false
  34685. * @see CustomRequestHeaders
  34686. */
  34687. static UseCustomRequestHeaders: boolean;
  34688. /**
  34689. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34690. * i.e. when loading files, where the server/service expects an Authorization header
  34691. */
  34692. static CustomRequestHeaders: {
  34693. [key: string]: string;
  34694. };
  34695. /**
  34696. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34697. */
  34698. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34699. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34700. /**
  34701. * Default behaviour for cors in the application.
  34702. * It can be a string if the expected behavior is identical in the entire app.
  34703. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34704. */
  34705. static CorsBehavior: string | ((url: string | string[]) => string);
  34706. /**
  34707. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34708. * @ignorenaming
  34709. */
  34710. static get UseFallbackTexture(): boolean;
  34711. static set UseFallbackTexture(value: boolean);
  34712. /**
  34713. * Use this object to register external classes like custom textures or material
  34714. * to allow the laoders to instantiate them
  34715. */
  34716. static get RegisteredExternalClasses(): {
  34717. [key: string]: Object;
  34718. };
  34719. static set RegisteredExternalClasses(classes: {
  34720. [key: string]: Object;
  34721. });
  34722. /**
  34723. * Texture content used if a texture cannot loaded
  34724. * @ignorenaming
  34725. */
  34726. static get fallbackTexture(): string;
  34727. static set fallbackTexture(value: string);
  34728. /**
  34729. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34730. * @param u defines the coordinate on X axis
  34731. * @param v defines the coordinate on Y axis
  34732. * @param width defines the width of the source data
  34733. * @param height defines the height of the source data
  34734. * @param pixels defines the source byte array
  34735. * @param color defines the output color
  34736. */
  34737. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34738. /**
  34739. * Interpolates between a and b via alpha
  34740. * @param a The lower value (returned when alpha = 0)
  34741. * @param b The upper value (returned when alpha = 1)
  34742. * @param alpha The interpolation-factor
  34743. * @return The mixed value
  34744. */
  34745. static Mix(a: number, b: number, alpha: number): number;
  34746. /**
  34747. * Tries to instantiate a new object from a given class name
  34748. * @param className defines the class name to instantiate
  34749. * @returns the new object or null if the system was not able to do the instantiation
  34750. */
  34751. static Instantiate(className: string): any;
  34752. /**
  34753. * Provides a slice function that will work even on IE
  34754. * @param data defines the array to slice
  34755. * @param start defines the start of the data (optional)
  34756. * @param end defines the end of the data (optional)
  34757. * @returns the new sliced array
  34758. */
  34759. static Slice<T>(data: T, start?: number, end?: number): T;
  34760. /**
  34761. * Polyfill for setImmediate
  34762. * @param action defines the action to execute after the current execution block
  34763. */
  34764. static SetImmediate(action: () => void): void;
  34765. /**
  34766. * Function indicating if a number is an exponent of 2
  34767. * @param value defines the value to test
  34768. * @returns true if the value is an exponent of 2
  34769. */
  34770. static IsExponentOfTwo(value: number): boolean;
  34771. private static _tmpFloatArray;
  34772. /**
  34773. * Returns the nearest 32-bit single precision float representation of a Number
  34774. * @param value A Number. If the parameter is of a different type, it will get converted
  34775. * to a number or to NaN if it cannot be converted
  34776. * @returns number
  34777. */
  34778. static FloatRound(value: number): number;
  34779. /**
  34780. * Extracts the filename from a path
  34781. * @param path defines the path to use
  34782. * @returns the filename
  34783. */
  34784. static GetFilename(path: string): string;
  34785. /**
  34786. * Extracts the "folder" part of a path (everything before the filename).
  34787. * @param uri The URI to extract the info from
  34788. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34789. * @returns The "folder" part of the path
  34790. */
  34791. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34792. /**
  34793. * Extracts text content from a DOM element hierarchy
  34794. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34795. */
  34796. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34797. /**
  34798. * Convert an angle in radians to degrees
  34799. * @param angle defines the angle to convert
  34800. * @returns the angle in degrees
  34801. */
  34802. static ToDegrees(angle: number): number;
  34803. /**
  34804. * Convert an angle in degrees to radians
  34805. * @param angle defines the angle to convert
  34806. * @returns the angle in radians
  34807. */
  34808. static ToRadians(angle: number): number;
  34809. /**
  34810. * Returns an array if obj is not an array
  34811. * @param obj defines the object to evaluate as an array
  34812. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34813. * @returns either obj directly if obj is an array or a new array containing obj
  34814. */
  34815. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34816. /**
  34817. * Gets the pointer prefix to use
  34818. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34819. */
  34820. static GetPointerPrefix(): string;
  34821. /**
  34822. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34823. * @param url define the url we are trying
  34824. * @param element define the dom element where to configure the cors policy
  34825. */
  34826. static SetCorsBehavior(url: string | string[], element: {
  34827. crossOrigin: string | null;
  34828. }): void;
  34829. /**
  34830. * Removes unwanted characters from an url
  34831. * @param url defines the url to clean
  34832. * @returns the cleaned url
  34833. */
  34834. static CleanUrl(url: string): string;
  34835. /**
  34836. * Gets or sets a function used to pre-process url before using them to load assets
  34837. */
  34838. static get PreprocessUrl(): (url: string) => string;
  34839. static set PreprocessUrl(processor: (url: string) => string);
  34840. /**
  34841. * Loads an image as an HTMLImageElement.
  34842. * @param input url string, ArrayBuffer, or Blob to load
  34843. * @param onLoad callback called when the image successfully loads
  34844. * @param onError callback called when the image fails to load
  34845. * @param offlineProvider offline provider for caching
  34846. * @param mimeType optional mime type
  34847. * @returns the HTMLImageElement of the loaded image
  34848. */
  34849. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34850. /**
  34851. * Loads a file from a url
  34852. * @param url url string, ArrayBuffer, or Blob to load
  34853. * @param onSuccess callback called when the file successfully loads
  34854. * @param onProgress callback called while file is loading (if the server supports this mode)
  34855. * @param offlineProvider defines the offline provider for caching
  34856. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34857. * @param onError callback called when the file fails to load
  34858. * @returns a file request object
  34859. */
  34860. 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;
  34861. /**
  34862. * Loads a file from a url
  34863. * @param url the file url to load
  34864. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34865. */
  34866. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34867. /**
  34868. * Load a script (identified by an url). When the url returns, the
  34869. * content of this file is added into a new script element, attached to the DOM (body element)
  34870. * @param scriptUrl defines the url of the script to laod
  34871. * @param onSuccess defines the callback called when the script is loaded
  34872. * @param onError defines the callback to call if an error occurs
  34873. * @param scriptId defines the id of the script element
  34874. */
  34875. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34876. /**
  34877. * Load an asynchronous script (identified by an url). When the url returns, the
  34878. * content of this file is added into a new script element, attached to the DOM (body element)
  34879. * @param scriptUrl defines the url of the script to laod
  34880. * @param scriptId defines the id of the script element
  34881. * @returns a promise request object
  34882. */
  34883. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34884. /**
  34885. * Loads a file from a blob
  34886. * @param fileToLoad defines the blob to use
  34887. * @param callback defines the callback to call when data is loaded
  34888. * @param progressCallback defines the callback to call during loading process
  34889. * @returns a file request object
  34890. */
  34891. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34892. /**
  34893. * Reads a file from a File object
  34894. * @param file defines the file to load
  34895. * @param onSuccess defines the callback to call when data is loaded
  34896. * @param onProgress defines the callback to call during loading process
  34897. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34898. * @param onError defines the callback to call when an error occurs
  34899. * @returns a file request object
  34900. */
  34901. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34902. /**
  34903. * Creates a data url from a given string content
  34904. * @param content defines the content to convert
  34905. * @returns the new data url link
  34906. */
  34907. static FileAsURL(content: string): string;
  34908. /**
  34909. * Format the given number to a specific decimal format
  34910. * @param value defines the number to format
  34911. * @param decimals defines the number of decimals to use
  34912. * @returns the formatted string
  34913. */
  34914. static Format(value: number, decimals?: number): string;
  34915. /**
  34916. * Tries to copy an object by duplicating every property
  34917. * @param source defines the source object
  34918. * @param destination defines the target object
  34919. * @param doNotCopyList defines a list of properties to avoid
  34920. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34921. */
  34922. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34923. /**
  34924. * Gets a boolean indicating if the given object has no own property
  34925. * @param obj defines the object to test
  34926. * @returns true if object has no own property
  34927. */
  34928. static IsEmpty(obj: any): boolean;
  34929. /**
  34930. * Function used to register events at window level
  34931. * @param windowElement defines the Window object to use
  34932. * @param events defines the events to register
  34933. */
  34934. static RegisterTopRootEvents(windowElement: Window, events: {
  34935. name: string;
  34936. handler: Nullable<(e: FocusEvent) => any>;
  34937. }[]): void;
  34938. /**
  34939. * Function used to unregister events from window level
  34940. * @param windowElement defines the Window object to use
  34941. * @param events defines the events to unregister
  34942. */
  34943. static UnregisterTopRootEvents(windowElement: Window, events: {
  34944. name: string;
  34945. handler: Nullable<(e: FocusEvent) => any>;
  34946. }[]): void;
  34947. /**
  34948. * @ignore
  34949. */
  34950. static _ScreenshotCanvas: HTMLCanvasElement;
  34951. /**
  34952. * Dumps the current bound framebuffer
  34953. * @param width defines the rendering width
  34954. * @param height defines the rendering height
  34955. * @param engine defines the hosting engine
  34956. * @param successCallback defines the callback triggered once the data are available
  34957. * @param mimeType defines the mime type of the result
  34958. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34959. */
  34960. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34961. /**
  34962. * Converts the canvas data to blob.
  34963. * This acts as a polyfill for browsers not supporting the to blob function.
  34964. * @param canvas Defines the canvas to extract the data from
  34965. * @param successCallback Defines the callback triggered once the data are available
  34966. * @param mimeType Defines the mime type of the result
  34967. */
  34968. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34969. /**
  34970. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34971. * @param successCallback defines the callback triggered once the data are available
  34972. * @param mimeType defines the mime type of the result
  34973. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34974. */
  34975. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34976. /**
  34977. * Downloads a blob in the browser
  34978. * @param blob defines the blob to download
  34979. * @param fileName defines the name of the downloaded file
  34980. */
  34981. static Download(blob: Blob, fileName: string): void;
  34982. /**
  34983. * Captures a screenshot of the current rendering
  34984. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34985. * @param engine defines the rendering engine
  34986. * @param camera defines the source camera
  34987. * @param size This parameter can be set to a single number or to an object with the
  34988. * following (optional) properties: precision, width, height. If a single number is passed,
  34989. * it will be used for both width and height. If an object is passed, the screenshot size
  34990. * will be derived from the parameters. The precision property is a multiplier allowing
  34991. * rendering at a higher or lower resolution
  34992. * @param successCallback defines the callback receives a single parameter which contains the
  34993. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34994. * src parameter of an <img> to display it
  34995. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34996. * Check your browser for supported MIME types
  34997. */
  34998. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34999. /**
  35000. * Captures a screenshot of the current rendering
  35001. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35002. * @param engine defines the rendering engine
  35003. * @param camera defines the source camera
  35004. * @param size This parameter can be set to a single number or to an object with the
  35005. * following (optional) properties: precision, width, height. If a single number is passed,
  35006. * it will be used for both width and height. If an object is passed, the screenshot size
  35007. * will be derived from the parameters. The precision property is a multiplier allowing
  35008. * rendering at a higher or lower resolution
  35009. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35010. * Check your browser for supported MIME types
  35011. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35012. * to the src parameter of an <img> to display it
  35013. */
  35014. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35015. /**
  35016. * Generates an image screenshot from the specified camera.
  35017. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35018. * @param engine The engine to use for rendering
  35019. * @param camera The camera to use for rendering
  35020. * @param size This parameter can be set to a single number or to an object with the
  35021. * following (optional) properties: precision, width, height. If a single number is passed,
  35022. * it will be used for both width and height. If an object is passed, the screenshot size
  35023. * will be derived from the parameters. The precision property is a multiplier allowing
  35024. * rendering at a higher or lower resolution
  35025. * @param successCallback The callback receives a single parameter which contains the
  35026. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35027. * src parameter of an <img> to display it
  35028. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35029. * Check your browser for supported MIME types
  35030. * @param samples Texture samples (default: 1)
  35031. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35032. * @param fileName A name for for the downloaded file.
  35033. */
  35034. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35035. /**
  35036. * Generates an image screenshot from the specified camera.
  35037. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35038. * @param engine The engine to use for rendering
  35039. * @param camera The camera to use for rendering
  35040. * @param size This parameter can be set to a single number or to an object with the
  35041. * following (optional) properties: precision, width, height. If a single number is passed,
  35042. * it will be used for both width and height. If an object is passed, the screenshot size
  35043. * will be derived from the parameters. The precision property is a multiplier allowing
  35044. * rendering at a higher or lower resolution
  35045. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35046. * Check your browser for supported MIME types
  35047. * @param samples Texture samples (default: 1)
  35048. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35049. * @param fileName A name for for the downloaded file.
  35050. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35051. * to the src parameter of an <img> to display it
  35052. */
  35053. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35054. /**
  35055. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35056. * Be aware Math.random() could cause collisions, but:
  35057. * "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"
  35058. * @returns a pseudo random id
  35059. */
  35060. static RandomId(): string;
  35061. /**
  35062. * Test if the given uri is a base64 string
  35063. * @param uri The uri to test
  35064. * @return True if the uri is a base64 string or false otherwise
  35065. */
  35066. static IsBase64(uri: string): boolean;
  35067. /**
  35068. * Decode the given base64 uri.
  35069. * @param uri The uri to decode
  35070. * @return The decoded base64 data.
  35071. */
  35072. static DecodeBase64(uri: string): ArrayBuffer;
  35073. /**
  35074. * Gets the absolute url.
  35075. * @param url the input url
  35076. * @return the absolute url
  35077. */
  35078. static GetAbsoluteUrl(url: string): string;
  35079. /**
  35080. * No log
  35081. */
  35082. static readonly NoneLogLevel: number;
  35083. /**
  35084. * Only message logs
  35085. */
  35086. static readonly MessageLogLevel: number;
  35087. /**
  35088. * Only warning logs
  35089. */
  35090. static readonly WarningLogLevel: number;
  35091. /**
  35092. * Only error logs
  35093. */
  35094. static readonly ErrorLogLevel: number;
  35095. /**
  35096. * All logs
  35097. */
  35098. static readonly AllLogLevel: number;
  35099. /**
  35100. * Gets a value indicating the number of loading errors
  35101. * @ignorenaming
  35102. */
  35103. static get errorsCount(): number;
  35104. /**
  35105. * Callback called when a new log is added
  35106. */
  35107. static OnNewCacheEntry: (entry: string) => void;
  35108. /**
  35109. * Log a message to the console
  35110. * @param message defines the message to log
  35111. */
  35112. static Log(message: string): void;
  35113. /**
  35114. * Write a warning message to the console
  35115. * @param message defines the message to log
  35116. */
  35117. static Warn(message: string): void;
  35118. /**
  35119. * Write an error message to the console
  35120. * @param message defines the message to log
  35121. */
  35122. static Error(message: string): void;
  35123. /**
  35124. * Gets current log cache (list of logs)
  35125. */
  35126. static get LogCache(): string;
  35127. /**
  35128. * Clears the log cache
  35129. */
  35130. static ClearLogCache(): void;
  35131. /**
  35132. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35133. */
  35134. static set LogLevels(level: number);
  35135. /**
  35136. * Checks if the window object exists
  35137. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35138. */
  35139. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35140. /**
  35141. * No performance log
  35142. */
  35143. static readonly PerformanceNoneLogLevel: number;
  35144. /**
  35145. * Use user marks to log performance
  35146. */
  35147. static readonly PerformanceUserMarkLogLevel: number;
  35148. /**
  35149. * Log performance to the console
  35150. */
  35151. static readonly PerformanceConsoleLogLevel: number;
  35152. private static _performance;
  35153. /**
  35154. * Sets the current performance log level
  35155. */
  35156. static set PerformanceLogLevel(level: number);
  35157. private static _StartPerformanceCounterDisabled;
  35158. private static _EndPerformanceCounterDisabled;
  35159. private static _StartUserMark;
  35160. private static _EndUserMark;
  35161. private static _StartPerformanceConsole;
  35162. private static _EndPerformanceConsole;
  35163. /**
  35164. * Starts a performance counter
  35165. */
  35166. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35167. /**
  35168. * Ends a specific performance coutner
  35169. */
  35170. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35171. /**
  35172. * Gets either window.performance.now() if supported or Date.now() else
  35173. */
  35174. static get Now(): number;
  35175. /**
  35176. * This method will return the name of the class used to create the instance of the given object.
  35177. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35178. * @param object the object to get the class name from
  35179. * @param isType defines if the object is actually a type
  35180. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35181. */
  35182. static GetClassName(object: any, isType?: boolean): string;
  35183. /**
  35184. * Gets the first element of an array satisfying a given predicate
  35185. * @param array defines the array to browse
  35186. * @param predicate defines the predicate to use
  35187. * @returns null if not found or the element
  35188. */
  35189. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35190. /**
  35191. * This method will return the name of the full name of the class, including its owning module (if any).
  35192. * 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).
  35193. * @param object the object to get the class name from
  35194. * @param isType defines if the object is actually a type
  35195. * @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.
  35196. * @ignorenaming
  35197. */
  35198. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35199. /**
  35200. * Returns a promise that resolves after the given amount of time.
  35201. * @param delay Number of milliseconds to delay
  35202. * @returns Promise that resolves after the given amount of time
  35203. */
  35204. static DelayAsync(delay: number): Promise<void>;
  35205. }
  35206. /**
  35207. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35208. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35209. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35210. * @param name The name of the class, case should be preserved
  35211. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35212. */
  35213. export function className(name: string, module?: string): (target: Object) => void;
  35214. /**
  35215. * An implementation of a loop for asynchronous functions.
  35216. */
  35217. export class AsyncLoop {
  35218. /**
  35219. * Defines the number of iterations for the loop
  35220. */
  35221. iterations: number;
  35222. /**
  35223. * Defines the current index of the loop.
  35224. */
  35225. index: number;
  35226. private _done;
  35227. private _fn;
  35228. private _successCallback;
  35229. /**
  35230. * Constructor.
  35231. * @param iterations the number of iterations.
  35232. * @param func the function to run each iteration
  35233. * @param successCallback the callback that will be called upon succesful execution
  35234. * @param offset starting offset.
  35235. */
  35236. constructor(
  35237. /**
  35238. * Defines the number of iterations for the loop
  35239. */
  35240. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35241. /**
  35242. * Execute the next iteration. Must be called after the last iteration was finished.
  35243. */
  35244. executeNext(): void;
  35245. /**
  35246. * Break the loop and run the success callback.
  35247. */
  35248. breakLoop(): void;
  35249. /**
  35250. * Create and run an async loop.
  35251. * @param iterations the number of iterations.
  35252. * @param fn the function to run each iteration
  35253. * @param successCallback the callback that will be called upon succesful execution
  35254. * @param offset starting offset.
  35255. * @returns the created async loop object
  35256. */
  35257. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35258. /**
  35259. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35260. * @param iterations total number of iterations
  35261. * @param syncedIterations number of synchronous iterations in each async iteration.
  35262. * @param fn the function to call each iteration.
  35263. * @param callback a success call back that will be called when iterating stops.
  35264. * @param breakFunction a break condition (optional)
  35265. * @param timeout timeout settings for the setTimeout function. default - 0.
  35266. * @returns the created async loop object
  35267. */
  35268. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35269. }
  35270. }
  35271. declare module "babylonjs/Misc/stringDictionary" {
  35272. import { Nullable } from "babylonjs/types";
  35273. /**
  35274. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35275. * The underlying implementation relies on an associative array to ensure the best performances.
  35276. * The value can be anything including 'null' but except 'undefined'
  35277. */
  35278. export class StringDictionary<T> {
  35279. /**
  35280. * This will clear this dictionary and copy the content from the 'source' one.
  35281. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35282. * @param source the dictionary to take the content from and copy to this dictionary
  35283. */
  35284. copyFrom(source: StringDictionary<T>): void;
  35285. /**
  35286. * Get a value based from its key
  35287. * @param key the given key to get the matching value from
  35288. * @return the value if found, otherwise undefined is returned
  35289. */
  35290. get(key: string): T | undefined;
  35291. /**
  35292. * Get a value from its key or add it if it doesn't exist.
  35293. * This method will ensure you that a given key/data will be present in the dictionary.
  35294. * @param key the given key to get the matching value from
  35295. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35296. * The factory will only be invoked if there's no data for the given key.
  35297. * @return the value corresponding to the key.
  35298. */
  35299. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35300. /**
  35301. * Get a value from its key if present in the dictionary otherwise add it
  35302. * @param key the key to get the value from
  35303. * @param val if there's no such key/value pair in the dictionary add it with this value
  35304. * @return the value corresponding to the key
  35305. */
  35306. getOrAdd(key: string, val: T): T;
  35307. /**
  35308. * Check if there's a given key in the dictionary
  35309. * @param key the key to check for
  35310. * @return true if the key is present, false otherwise
  35311. */
  35312. contains(key: string): boolean;
  35313. /**
  35314. * Add a new key and its corresponding value
  35315. * @param key the key to add
  35316. * @param value the value corresponding to the key
  35317. * @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
  35318. */
  35319. add(key: string, value: T): boolean;
  35320. /**
  35321. * Update a specific value associated to a key
  35322. * @param key defines the key to use
  35323. * @param value defines the value to store
  35324. * @returns true if the value was updated (or false if the key was not found)
  35325. */
  35326. set(key: string, value: T): boolean;
  35327. /**
  35328. * Get the element of the given key and remove it from the dictionary
  35329. * @param key defines the key to search
  35330. * @returns the value associated with the key or null if not found
  35331. */
  35332. getAndRemove(key: string): Nullable<T>;
  35333. /**
  35334. * Remove a key/value from the dictionary.
  35335. * @param key the key to remove
  35336. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35337. */
  35338. remove(key: string): boolean;
  35339. /**
  35340. * Clear the whole content of the dictionary
  35341. */
  35342. clear(): void;
  35343. /**
  35344. * Gets the current count
  35345. */
  35346. get count(): number;
  35347. /**
  35348. * Execute a callback on each key/val of the dictionary.
  35349. * Note that you can remove any element in this dictionary in the callback implementation
  35350. * @param callback the callback to execute on a given key/value pair
  35351. */
  35352. forEach(callback: (key: string, val: T) => void): void;
  35353. /**
  35354. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35355. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35356. * Note that you can remove any element in this dictionary in the callback implementation
  35357. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35358. * @returns the first item
  35359. */
  35360. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35361. private _count;
  35362. private _data;
  35363. }
  35364. }
  35365. declare module "babylonjs/Collisions/collisionCoordinator" {
  35366. import { Nullable } from "babylonjs/types";
  35367. import { Scene } from "babylonjs/scene";
  35368. import { Vector3 } from "babylonjs/Maths/math.vector";
  35369. import { Collider } from "babylonjs/Collisions/collider";
  35370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35371. /** @hidden */
  35372. export interface ICollisionCoordinator {
  35373. createCollider(): Collider;
  35374. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35375. init(scene: Scene): void;
  35376. }
  35377. /** @hidden */
  35378. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35379. private _scene;
  35380. private _scaledPosition;
  35381. private _scaledVelocity;
  35382. private _finalPosition;
  35383. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35384. createCollider(): Collider;
  35385. init(scene: Scene): void;
  35386. private _collideWithWorld;
  35387. }
  35388. }
  35389. declare module "babylonjs/Inputs/scene.inputManager" {
  35390. import { Nullable } from "babylonjs/types";
  35391. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35392. import { Vector2 } from "babylonjs/Maths/math.vector";
  35393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35394. import { Scene } from "babylonjs/scene";
  35395. /**
  35396. * Class used to manage all inputs for the scene.
  35397. */
  35398. export class InputManager {
  35399. /** The distance in pixel that you have to move to prevent some events */
  35400. static DragMovementThreshold: number;
  35401. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35402. static LongPressDelay: number;
  35403. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35404. static DoubleClickDelay: number;
  35405. /** If you need to check double click without raising a single click at first click, enable this flag */
  35406. static ExclusiveDoubleClickMode: boolean;
  35407. private _wheelEventName;
  35408. private _onPointerMove;
  35409. private _onPointerDown;
  35410. private _onPointerUp;
  35411. private _initClickEvent;
  35412. private _initActionManager;
  35413. private _delayedSimpleClick;
  35414. private _delayedSimpleClickTimeout;
  35415. private _previousDelayedSimpleClickTimeout;
  35416. private _meshPickProceed;
  35417. private _previousButtonPressed;
  35418. private _currentPickResult;
  35419. private _previousPickResult;
  35420. private _totalPointersPressed;
  35421. private _doubleClickOccured;
  35422. private _pointerOverMesh;
  35423. private _pickedDownMesh;
  35424. private _pickedUpMesh;
  35425. private _pointerX;
  35426. private _pointerY;
  35427. private _unTranslatedPointerX;
  35428. private _unTranslatedPointerY;
  35429. private _startingPointerPosition;
  35430. private _previousStartingPointerPosition;
  35431. private _startingPointerTime;
  35432. private _previousStartingPointerTime;
  35433. private _pointerCaptures;
  35434. private _onKeyDown;
  35435. private _onKeyUp;
  35436. private _onCanvasFocusObserver;
  35437. private _onCanvasBlurObserver;
  35438. private _scene;
  35439. /**
  35440. * Creates a new InputManager
  35441. * @param scene defines the hosting scene
  35442. */
  35443. constructor(scene: Scene);
  35444. /**
  35445. * Gets the mesh that is currently under the pointer
  35446. */
  35447. get meshUnderPointer(): Nullable<AbstractMesh>;
  35448. /**
  35449. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35450. */
  35451. get unTranslatedPointer(): Vector2;
  35452. /**
  35453. * Gets or sets the current on-screen X position of the pointer
  35454. */
  35455. get pointerX(): number;
  35456. set pointerX(value: number);
  35457. /**
  35458. * Gets or sets the current on-screen Y position of the pointer
  35459. */
  35460. get pointerY(): number;
  35461. set pointerY(value: number);
  35462. private _updatePointerPosition;
  35463. private _processPointerMove;
  35464. private _setRayOnPointerInfo;
  35465. private _checkPrePointerObservable;
  35466. /**
  35467. * Use this method to simulate a pointer move on a mesh
  35468. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35469. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35470. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35471. */
  35472. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35473. /**
  35474. * Use this method to simulate a pointer down on a mesh
  35475. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35476. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35477. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35478. */
  35479. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35480. private _processPointerDown;
  35481. /** @hidden */
  35482. _isPointerSwiping(): boolean;
  35483. /**
  35484. * Use this method to simulate a pointer up on a mesh
  35485. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35486. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35487. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35488. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35489. */
  35490. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35491. private _processPointerUp;
  35492. /**
  35493. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35494. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35495. * @returns true if the pointer was captured
  35496. */
  35497. isPointerCaptured(pointerId?: number): boolean;
  35498. /**
  35499. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35500. * @param attachUp defines if you want to attach events to pointerup
  35501. * @param attachDown defines if you want to attach events to pointerdown
  35502. * @param attachMove defines if you want to attach events to pointermove
  35503. */
  35504. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35505. /**
  35506. * Detaches all event handlers
  35507. */
  35508. detachControl(): void;
  35509. /**
  35510. * Force the value of meshUnderPointer
  35511. * @param mesh defines the mesh to use
  35512. */
  35513. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35514. /**
  35515. * Gets the mesh under the pointer
  35516. * @returns a Mesh or null if no mesh is under the pointer
  35517. */
  35518. getPointerOverMesh(): Nullable<AbstractMesh>;
  35519. }
  35520. }
  35521. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35522. /**
  35523. * Helper class used to generate session unique ID
  35524. */
  35525. export class UniqueIdGenerator {
  35526. private static _UniqueIdCounter;
  35527. /**
  35528. * Gets an unique (relatively to the current scene) Id
  35529. */
  35530. static get UniqueId(): number;
  35531. }
  35532. }
  35533. declare module "babylonjs/Animations/animationGroup" {
  35534. import { Animatable } from "babylonjs/Animations/animatable";
  35535. import { Animation } from "babylonjs/Animations/animation";
  35536. import { Scene, IDisposable } from "babylonjs/scene";
  35537. import { Observable } from "babylonjs/Misc/observable";
  35538. import { Nullable } from "babylonjs/types";
  35539. import "babylonjs/Animations/animatable";
  35540. /**
  35541. * This class defines the direct association between an animation and a target
  35542. */
  35543. export class TargetedAnimation {
  35544. /**
  35545. * Animation to perform
  35546. */
  35547. animation: Animation;
  35548. /**
  35549. * Target to animate
  35550. */
  35551. target: any;
  35552. /**
  35553. * Serialize the object
  35554. * @returns the JSON object representing the current entity
  35555. */
  35556. serialize(): any;
  35557. }
  35558. /**
  35559. * Use this class to create coordinated animations on multiple targets
  35560. */
  35561. export class AnimationGroup implements IDisposable {
  35562. /** The name of the animation group */
  35563. name: string;
  35564. private _scene;
  35565. private _targetedAnimations;
  35566. private _animatables;
  35567. private _from;
  35568. private _to;
  35569. private _isStarted;
  35570. private _isPaused;
  35571. private _speedRatio;
  35572. private _loopAnimation;
  35573. /**
  35574. * Gets or sets the unique id of the node
  35575. */
  35576. uniqueId: number;
  35577. /**
  35578. * This observable will notify when one animation have ended
  35579. */
  35580. onAnimationEndObservable: Observable<TargetedAnimation>;
  35581. /**
  35582. * Observer raised when one animation loops
  35583. */
  35584. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35585. /**
  35586. * Observer raised when all animations have looped
  35587. */
  35588. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35589. /**
  35590. * This observable will notify when all animations have ended.
  35591. */
  35592. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35593. /**
  35594. * This observable will notify when all animations have paused.
  35595. */
  35596. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35597. /**
  35598. * This observable will notify when all animations are playing.
  35599. */
  35600. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35601. /**
  35602. * Gets the first frame
  35603. */
  35604. get from(): number;
  35605. /**
  35606. * Gets the last frame
  35607. */
  35608. get to(): number;
  35609. /**
  35610. * Define if the animations are started
  35611. */
  35612. get isStarted(): boolean;
  35613. /**
  35614. * Gets a value indicating that the current group is playing
  35615. */
  35616. get isPlaying(): boolean;
  35617. /**
  35618. * Gets or sets the speed ratio to use for all animations
  35619. */
  35620. get speedRatio(): number;
  35621. /**
  35622. * Gets or sets the speed ratio to use for all animations
  35623. */
  35624. set speedRatio(value: number);
  35625. /**
  35626. * Gets or sets if all animations should loop or not
  35627. */
  35628. get loopAnimation(): boolean;
  35629. set loopAnimation(value: boolean);
  35630. /**
  35631. * Gets the targeted animations for this animation group
  35632. */
  35633. get targetedAnimations(): Array<TargetedAnimation>;
  35634. /**
  35635. * returning the list of animatables controlled by this animation group.
  35636. */
  35637. get animatables(): Array<Animatable>;
  35638. /**
  35639. * Instantiates a new Animation Group.
  35640. * This helps managing several animations at once.
  35641. * @see http://doc.babylonjs.com/how_to/group
  35642. * @param name Defines the name of the group
  35643. * @param scene Defines the scene the group belongs to
  35644. */
  35645. constructor(
  35646. /** The name of the animation group */
  35647. name: string, scene?: Nullable<Scene>);
  35648. /**
  35649. * Add an animation (with its target) in the group
  35650. * @param animation defines the animation we want to add
  35651. * @param target defines the target of the animation
  35652. * @returns the TargetedAnimation object
  35653. */
  35654. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35655. /**
  35656. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35657. * It can add constant keys at begin or end
  35658. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35659. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35660. * @returns the animation group
  35661. */
  35662. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35663. private _animationLoopCount;
  35664. private _animationLoopFlags;
  35665. private _processLoop;
  35666. /**
  35667. * Start all animations on given targets
  35668. * @param loop defines if animations must loop
  35669. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35670. * @param from defines the from key (optional)
  35671. * @param to defines the to key (optional)
  35672. * @returns the current animation group
  35673. */
  35674. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35675. /**
  35676. * Pause all animations
  35677. * @returns the animation group
  35678. */
  35679. pause(): AnimationGroup;
  35680. /**
  35681. * Play all animations to initial state
  35682. * This function will start() the animations if they were not started or will restart() them if they were paused
  35683. * @param loop defines if animations must loop
  35684. * @returns the animation group
  35685. */
  35686. play(loop?: boolean): AnimationGroup;
  35687. /**
  35688. * Reset all animations to initial state
  35689. * @returns the animation group
  35690. */
  35691. reset(): AnimationGroup;
  35692. /**
  35693. * Restart animations from key 0
  35694. * @returns the animation group
  35695. */
  35696. restart(): AnimationGroup;
  35697. /**
  35698. * Stop all animations
  35699. * @returns the animation group
  35700. */
  35701. stop(): AnimationGroup;
  35702. /**
  35703. * Set animation weight for all animatables
  35704. * @param weight defines the weight to use
  35705. * @return the animationGroup
  35706. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35707. */
  35708. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35709. /**
  35710. * Synchronize and normalize all animatables with a source animatable
  35711. * @param root defines the root animatable to synchronize with
  35712. * @return the animationGroup
  35713. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35714. */
  35715. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35716. /**
  35717. * Goes to a specific frame in this animation group
  35718. * @param frame the frame number to go to
  35719. * @return the animationGroup
  35720. */
  35721. goToFrame(frame: number): AnimationGroup;
  35722. /**
  35723. * Dispose all associated resources
  35724. */
  35725. dispose(): void;
  35726. private _checkAnimationGroupEnded;
  35727. /**
  35728. * Clone the current animation group and returns a copy
  35729. * @param newName defines the name of the new group
  35730. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35731. * @returns the new aniamtion group
  35732. */
  35733. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35734. /**
  35735. * Serializes the animationGroup to an object
  35736. * @returns Serialized object
  35737. */
  35738. serialize(): any;
  35739. /**
  35740. * Returns a new AnimationGroup object parsed from the source provided.
  35741. * @param parsedAnimationGroup defines the source
  35742. * @param scene defines the scene that will receive the animationGroup
  35743. * @returns a new AnimationGroup
  35744. */
  35745. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35746. /**
  35747. * Returns the string "AnimationGroup"
  35748. * @returns "AnimationGroup"
  35749. */
  35750. getClassName(): string;
  35751. /**
  35752. * Creates a detailled string about the object
  35753. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35754. * @returns a string representing the object
  35755. */
  35756. toString(fullDetails?: boolean): string;
  35757. }
  35758. }
  35759. declare module "babylonjs/scene" {
  35760. import { Nullable } from "babylonjs/types";
  35761. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35762. import { Observable } from "babylonjs/Misc/observable";
  35763. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35764. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35765. import { Geometry } from "babylonjs/Meshes/geometry";
  35766. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35767. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35769. import { Mesh } from "babylonjs/Meshes/mesh";
  35770. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35771. import { Bone } from "babylonjs/Bones/bone";
  35772. import { Skeleton } from "babylonjs/Bones/skeleton";
  35773. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35774. import { Camera } from "babylonjs/Cameras/camera";
  35775. import { AbstractScene } from "babylonjs/abstractScene";
  35776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35778. import { Material } from "babylonjs/Materials/material";
  35779. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35780. import { Effect } from "babylonjs/Materials/effect";
  35781. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35782. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35783. import { Light } from "babylonjs/Lights/light";
  35784. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35785. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35786. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35787. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35788. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35789. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35790. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35791. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35792. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35793. import { Engine } from "babylonjs/Engines/engine";
  35794. import { Node } from "babylonjs/node";
  35795. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35796. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35797. import { WebRequest } from "babylonjs/Misc/webRequest";
  35798. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35799. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35800. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35801. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35802. import { Plane } from "babylonjs/Maths/math.plane";
  35803. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35804. import { Ray } from "babylonjs/Culling/ray";
  35805. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35806. import { Animation } from "babylonjs/Animations/animation";
  35807. import { Animatable } from "babylonjs/Animations/animatable";
  35808. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35809. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35810. import { Collider } from "babylonjs/Collisions/collider";
  35811. /**
  35812. * Define an interface for all classes that will hold resources
  35813. */
  35814. export interface IDisposable {
  35815. /**
  35816. * Releases all held resources
  35817. */
  35818. dispose(): void;
  35819. }
  35820. /** Interface defining initialization parameters for Scene class */
  35821. export interface SceneOptions {
  35822. /**
  35823. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35824. * It will improve performance when the number of geometries becomes important.
  35825. */
  35826. useGeometryUniqueIdsMap?: boolean;
  35827. /**
  35828. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35829. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35830. */
  35831. useMaterialMeshMap?: boolean;
  35832. /**
  35833. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35834. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35835. */
  35836. useClonedMeshhMap?: boolean;
  35837. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35838. virtual?: boolean;
  35839. }
  35840. /**
  35841. * Represents a scene to be rendered by the engine.
  35842. * @see http://doc.babylonjs.com/features/scene
  35843. */
  35844. export class Scene extends AbstractScene implements IAnimatable {
  35845. /** The fog is deactivated */
  35846. static readonly FOGMODE_NONE: number;
  35847. /** The fog density is following an exponential function */
  35848. static readonly FOGMODE_EXP: number;
  35849. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35850. static readonly FOGMODE_EXP2: number;
  35851. /** The fog density is following a linear function. */
  35852. static readonly FOGMODE_LINEAR: number;
  35853. /**
  35854. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35856. */
  35857. static MinDeltaTime: number;
  35858. /**
  35859. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35860. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35861. */
  35862. static MaxDeltaTime: number;
  35863. /**
  35864. * Factory used to create the default material.
  35865. * @param name The name of the material to create
  35866. * @param scene The scene to create the material for
  35867. * @returns The default material
  35868. */
  35869. static DefaultMaterialFactory(scene: Scene): Material;
  35870. /**
  35871. * Factory used to create the a collision coordinator.
  35872. * @returns The collision coordinator
  35873. */
  35874. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35875. /** @hidden */
  35876. _inputManager: InputManager;
  35877. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35878. cameraToUseForPointers: Nullable<Camera>;
  35879. /** @hidden */
  35880. readonly _isScene: boolean;
  35881. /**
  35882. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35883. */
  35884. autoClear: boolean;
  35885. /**
  35886. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35887. */
  35888. autoClearDepthAndStencil: boolean;
  35889. /**
  35890. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35891. */
  35892. clearColor: Color4;
  35893. /**
  35894. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35895. */
  35896. ambientColor: Color3;
  35897. /**
  35898. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35899. * It should only be one of the following (if not the default embedded one):
  35900. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35901. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35902. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35903. * The material properties need to be setup according to the type of texture in use.
  35904. */
  35905. environmentBRDFTexture: BaseTexture;
  35906. /** @hidden */
  35907. protected _environmentTexture: Nullable<BaseTexture>;
  35908. /**
  35909. * Texture used in all pbr material as the reflection texture.
  35910. * As in the majority of the scene they are the same (exception for multi room and so on),
  35911. * this is easier to reference from here than from all the materials.
  35912. */
  35913. get environmentTexture(): Nullable<BaseTexture>;
  35914. /**
  35915. * Texture used in all pbr material as the reflection texture.
  35916. * As in the majority of the scene they are the same (exception for multi room and so on),
  35917. * this is easier to set here than in all the materials.
  35918. */
  35919. set environmentTexture(value: Nullable<BaseTexture>);
  35920. /** @hidden */
  35921. protected _environmentIntensity: number;
  35922. /**
  35923. * Intensity of the environment in all pbr material.
  35924. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35925. * As in the majority of the scene they are the same (exception for multi room and so on),
  35926. * this is easier to reference from here than from all the materials.
  35927. */
  35928. get environmentIntensity(): number;
  35929. /**
  35930. * Intensity of the environment in all pbr material.
  35931. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35932. * As in the majority of the scene they are the same (exception for multi room and so on),
  35933. * this is easier to set here than in all the materials.
  35934. */
  35935. set environmentIntensity(value: number);
  35936. /** @hidden */
  35937. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35938. /**
  35939. * Default image processing configuration used either in the rendering
  35940. * Forward main pass or through the imageProcessingPostProcess if present.
  35941. * As in the majority of the scene they are the same (exception for multi camera),
  35942. * this is easier to reference from here than from all the materials and post process.
  35943. *
  35944. * No setter as we it is a shared configuration, you can set the values instead.
  35945. */
  35946. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35947. private _forceWireframe;
  35948. /**
  35949. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35950. */
  35951. set forceWireframe(value: boolean);
  35952. get forceWireframe(): boolean;
  35953. private _forcePointsCloud;
  35954. /**
  35955. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35956. */
  35957. set forcePointsCloud(value: boolean);
  35958. get forcePointsCloud(): boolean;
  35959. /**
  35960. * Gets or sets the active clipplane 1
  35961. */
  35962. clipPlane: Nullable<Plane>;
  35963. /**
  35964. * Gets or sets the active clipplane 2
  35965. */
  35966. clipPlane2: Nullable<Plane>;
  35967. /**
  35968. * Gets or sets the active clipplane 3
  35969. */
  35970. clipPlane3: Nullable<Plane>;
  35971. /**
  35972. * Gets or sets the active clipplane 4
  35973. */
  35974. clipPlane4: Nullable<Plane>;
  35975. /**
  35976. * Gets or sets the active clipplane 5
  35977. */
  35978. clipPlane5: Nullable<Plane>;
  35979. /**
  35980. * Gets or sets the active clipplane 6
  35981. */
  35982. clipPlane6: Nullable<Plane>;
  35983. /**
  35984. * Gets or sets a boolean indicating if animations are enabled
  35985. */
  35986. animationsEnabled: boolean;
  35987. private _animationPropertiesOverride;
  35988. /**
  35989. * Gets or sets the animation properties override
  35990. */
  35991. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35992. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35993. /**
  35994. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35995. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35996. */
  35997. useConstantAnimationDeltaTime: boolean;
  35998. /**
  35999. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36000. * Please note that it requires to run a ray cast through the scene on every frame
  36001. */
  36002. constantlyUpdateMeshUnderPointer: boolean;
  36003. /**
  36004. * Defines the HTML cursor to use when hovering over interactive elements
  36005. */
  36006. hoverCursor: string;
  36007. /**
  36008. * Defines the HTML default cursor to use (empty by default)
  36009. */
  36010. defaultCursor: string;
  36011. /**
  36012. * Defines wether cursors are handled by the scene.
  36013. */
  36014. doNotHandleCursors: boolean;
  36015. /**
  36016. * This is used to call preventDefault() on pointer down
  36017. * in order to block unwanted artifacts like system double clicks
  36018. */
  36019. preventDefaultOnPointerDown: boolean;
  36020. /**
  36021. * This is used to call preventDefault() on pointer up
  36022. * in order to block unwanted artifacts like system double clicks
  36023. */
  36024. preventDefaultOnPointerUp: boolean;
  36025. /**
  36026. * Gets or sets user defined metadata
  36027. */
  36028. metadata: any;
  36029. /**
  36030. * For internal use only. Please do not use.
  36031. */
  36032. reservedDataStore: any;
  36033. /**
  36034. * Gets the name of the plugin used to load this scene (null by default)
  36035. */
  36036. loadingPluginName: string;
  36037. /**
  36038. * Use this array to add regular expressions used to disable offline support for specific urls
  36039. */
  36040. disableOfflineSupportExceptionRules: RegExp[];
  36041. /**
  36042. * An event triggered when the scene is disposed.
  36043. */
  36044. onDisposeObservable: Observable<Scene>;
  36045. private _onDisposeObserver;
  36046. /** Sets a function to be executed when this scene is disposed. */
  36047. set onDispose(callback: () => void);
  36048. /**
  36049. * An event triggered before rendering the scene (right after animations and physics)
  36050. */
  36051. onBeforeRenderObservable: Observable<Scene>;
  36052. private _onBeforeRenderObserver;
  36053. /** Sets a function to be executed before rendering this scene */
  36054. set beforeRender(callback: Nullable<() => void>);
  36055. /**
  36056. * An event triggered after rendering the scene
  36057. */
  36058. onAfterRenderObservable: Observable<Scene>;
  36059. /**
  36060. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36061. */
  36062. onAfterRenderCameraObservable: Observable<Camera>;
  36063. private _onAfterRenderObserver;
  36064. /** Sets a function to be executed after rendering this scene */
  36065. set afterRender(callback: Nullable<() => void>);
  36066. /**
  36067. * An event triggered before animating the scene
  36068. */
  36069. onBeforeAnimationsObservable: Observable<Scene>;
  36070. /**
  36071. * An event triggered after animations processing
  36072. */
  36073. onAfterAnimationsObservable: Observable<Scene>;
  36074. /**
  36075. * An event triggered before draw calls are ready to be sent
  36076. */
  36077. onBeforeDrawPhaseObservable: Observable<Scene>;
  36078. /**
  36079. * An event triggered after draw calls have been sent
  36080. */
  36081. onAfterDrawPhaseObservable: Observable<Scene>;
  36082. /**
  36083. * An event triggered when the scene is ready
  36084. */
  36085. onReadyObservable: Observable<Scene>;
  36086. /**
  36087. * An event triggered before rendering a camera
  36088. */
  36089. onBeforeCameraRenderObservable: Observable<Camera>;
  36090. private _onBeforeCameraRenderObserver;
  36091. /** Sets a function to be executed before rendering a camera*/
  36092. set beforeCameraRender(callback: () => void);
  36093. /**
  36094. * An event triggered after rendering a camera
  36095. */
  36096. onAfterCameraRenderObservable: Observable<Camera>;
  36097. private _onAfterCameraRenderObserver;
  36098. /** Sets a function to be executed after rendering a camera*/
  36099. set afterCameraRender(callback: () => void);
  36100. /**
  36101. * An event triggered when active meshes evaluation is about to start
  36102. */
  36103. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36104. /**
  36105. * An event triggered when active meshes evaluation is done
  36106. */
  36107. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36108. /**
  36109. * An event triggered when particles rendering is about to start
  36110. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36111. */
  36112. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36113. /**
  36114. * An event triggered when particles rendering is done
  36115. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36116. */
  36117. onAfterParticlesRenderingObservable: Observable<Scene>;
  36118. /**
  36119. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36120. */
  36121. onDataLoadedObservable: Observable<Scene>;
  36122. /**
  36123. * An event triggered when a camera is created
  36124. */
  36125. onNewCameraAddedObservable: Observable<Camera>;
  36126. /**
  36127. * An event triggered when a camera is removed
  36128. */
  36129. onCameraRemovedObservable: Observable<Camera>;
  36130. /**
  36131. * An event triggered when a light is created
  36132. */
  36133. onNewLightAddedObservable: Observable<Light>;
  36134. /**
  36135. * An event triggered when a light is removed
  36136. */
  36137. onLightRemovedObservable: Observable<Light>;
  36138. /**
  36139. * An event triggered when a geometry is created
  36140. */
  36141. onNewGeometryAddedObservable: Observable<Geometry>;
  36142. /**
  36143. * An event triggered when a geometry is removed
  36144. */
  36145. onGeometryRemovedObservable: Observable<Geometry>;
  36146. /**
  36147. * An event triggered when a transform node is created
  36148. */
  36149. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36150. /**
  36151. * An event triggered when a transform node is removed
  36152. */
  36153. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36154. /**
  36155. * An event triggered when a mesh is created
  36156. */
  36157. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36158. /**
  36159. * An event triggered when a mesh is removed
  36160. */
  36161. onMeshRemovedObservable: Observable<AbstractMesh>;
  36162. /**
  36163. * An event triggered when a skeleton is created
  36164. */
  36165. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36166. /**
  36167. * An event triggered when a skeleton is removed
  36168. */
  36169. onSkeletonRemovedObservable: Observable<Skeleton>;
  36170. /**
  36171. * An event triggered when a material is created
  36172. */
  36173. onNewMaterialAddedObservable: Observable<Material>;
  36174. /**
  36175. * An event triggered when a material is removed
  36176. */
  36177. onMaterialRemovedObservable: Observable<Material>;
  36178. /**
  36179. * An event triggered when a texture is created
  36180. */
  36181. onNewTextureAddedObservable: Observable<BaseTexture>;
  36182. /**
  36183. * An event triggered when a texture is removed
  36184. */
  36185. onTextureRemovedObservable: Observable<BaseTexture>;
  36186. /**
  36187. * An event triggered when render targets are about to be rendered
  36188. * Can happen multiple times per frame.
  36189. */
  36190. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36191. /**
  36192. * An event triggered when render targets were rendered.
  36193. * Can happen multiple times per frame.
  36194. */
  36195. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36196. /**
  36197. * An event triggered before calculating deterministic simulation step
  36198. */
  36199. onBeforeStepObservable: Observable<Scene>;
  36200. /**
  36201. * An event triggered after calculating deterministic simulation step
  36202. */
  36203. onAfterStepObservable: Observable<Scene>;
  36204. /**
  36205. * An event triggered when the activeCamera property is updated
  36206. */
  36207. onActiveCameraChanged: Observable<Scene>;
  36208. /**
  36209. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36210. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36211. * 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)
  36212. */
  36213. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36214. /**
  36215. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36216. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36217. * 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)
  36218. */
  36219. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36220. /**
  36221. * This Observable will when a mesh has been imported into the scene.
  36222. */
  36223. onMeshImportedObservable: Observable<AbstractMesh>;
  36224. /**
  36225. * This Observable will when an animation file has been imported into the scene.
  36226. */
  36227. onAnimationFileImportedObservable: Observable<Scene>;
  36228. /**
  36229. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36230. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36231. */
  36232. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36233. /** @hidden */
  36234. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36235. /**
  36236. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36237. */
  36238. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36239. /**
  36240. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36241. */
  36242. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36243. /**
  36244. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36245. */
  36246. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36247. /** Callback called when a pointer move is detected */
  36248. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36249. /** Callback called when a pointer down is detected */
  36250. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36251. /** Callback called when a pointer up is detected */
  36252. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36253. /** Callback called when a pointer pick is detected */
  36254. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36255. /**
  36256. * 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).
  36257. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36258. */
  36259. onPrePointerObservable: Observable<PointerInfoPre>;
  36260. /**
  36261. * Observable event triggered each time an input event is received from the rendering canvas
  36262. */
  36263. onPointerObservable: Observable<PointerInfo>;
  36264. /**
  36265. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36266. */
  36267. get unTranslatedPointer(): Vector2;
  36268. /**
  36269. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36270. */
  36271. static get DragMovementThreshold(): number;
  36272. static set DragMovementThreshold(value: number);
  36273. /**
  36274. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36275. */
  36276. static get LongPressDelay(): number;
  36277. static set LongPressDelay(value: number);
  36278. /**
  36279. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36280. */
  36281. static get DoubleClickDelay(): number;
  36282. static set DoubleClickDelay(value: number);
  36283. /** If you need to check double click without raising a single click at first click, enable this flag */
  36284. static get ExclusiveDoubleClickMode(): boolean;
  36285. static set ExclusiveDoubleClickMode(value: boolean);
  36286. /** @hidden */
  36287. _mirroredCameraPosition: Nullable<Vector3>;
  36288. /**
  36289. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36290. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36291. */
  36292. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36293. /**
  36294. * Observable event triggered each time an keyboard event is received from the hosting window
  36295. */
  36296. onKeyboardObservable: Observable<KeyboardInfo>;
  36297. private _useRightHandedSystem;
  36298. /**
  36299. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36300. */
  36301. set useRightHandedSystem(value: boolean);
  36302. get useRightHandedSystem(): boolean;
  36303. private _timeAccumulator;
  36304. private _currentStepId;
  36305. private _currentInternalStep;
  36306. /**
  36307. * Sets the step Id used by deterministic lock step
  36308. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36309. * @param newStepId defines the step Id
  36310. */
  36311. setStepId(newStepId: number): void;
  36312. /**
  36313. * Gets the step Id used by deterministic lock step
  36314. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36315. * @returns the step Id
  36316. */
  36317. getStepId(): number;
  36318. /**
  36319. * Gets the internal step used by deterministic lock step
  36320. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36321. * @returns the internal step
  36322. */
  36323. getInternalStep(): number;
  36324. private _fogEnabled;
  36325. /**
  36326. * Gets or sets a boolean indicating if fog is enabled on this scene
  36327. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36328. * (Default is true)
  36329. */
  36330. set fogEnabled(value: boolean);
  36331. get fogEnabled(): boolean;
  36332. private _fogMode;
  36333. /**
  36334. * Gets or sets the fog mode to use
  36335. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36336. * | mode | value |
  36337. * | --- | --- |
  36338. * | FOGMODE_NONE | 0 |
  36339. * | FOGMODE_EXP | 1 |
  36340. * | FOGMODE_EXP2 | 2 |
  36341. * | FOGMODE_LINEAR | 3 |
  36342. */
  36343. set fogMode(value: number);
  36344. get fogMode(): number;
  36345. /**
  36346. * Gets or sets the fog color to use
  36347. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36348. * (Default is Color3(0.2, 0.2, 0.3))
  36349. */
  36350. fogColor: Color3;
  36351. /**
  36352. * Gets or sets the fog density to use
  36353. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36354. * (Default is 0.1)
  36355. */
  36356. fogDensity: number;
  36357. /**
  36358. * Gets or sets the fog start distance to use
  36359. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36360. * (Default is 0)
  36361. */
  36362. fogStart: number;
  36363. /**
  36364. * Gets or sets the fog end distance to use
  36365. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36366. * (Default is 1000)
  36367. */
  36368. fogEnd: number;
  36369. private _shadowsEnabled;
  36370. /**
  36371. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36372. */
  36373. set shadowsEnabled(value: boolean);
  36374. get shadowsEnabled(): boolean;
  36375. private _lightsEnabled;
  36376. /**
  36377. * Gets or sets a boolean indicating if lights are enabled on this scene
  36378. */
  36379. set lightsEnabled(value: boolean);
  36380. get lightsEnabled(): boolean;
  36381. /** All of the active cameras added to this scene. */
  36382. activeCameras: Camera[];
  36383. /** @hidden */
  36384. _activeCamera: Nullable<Camera>;
  36385. /** Gets or sets the current active camera */
  36386. get activeCamera(): Nullable<Camera>;
  36387. set activeCamera(value: Nullable<Camera>);
  36388. private _defaultMaterial;
  36389. /** The default material used on meshes when no material is affected */
  36390. get defaultMaterial(): Material;
  36391. /** The default material used on meshes when no material is affected */
  36392. set defaultMaterial(value: Material);
  36393. private _texturesEnabled;
  36394. /**
  36395. * Gets or sets a boolean indicating if textures are enabled on this scene
  36396. */
  36397. set texturesEnabled(value: boolean);
  36398. get texturesEnabled(): boolean;
  36399. /**
  36400. * Gets or sets a boolean indicating if particles are enabled on this scene
  36401. */
  36402. particlesEnabled: boolean;
  36403. /**
  36404. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36405. */
  36406. spritesEnabled: boolean;
  36407. private _skeletonsEnabled;
  36408. /**
  36409. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36410. */
  36411. set skeletonsEnabled(value: boolean);
  36412. get skeletonsEnabled(): boolean;
  36413. /**
  36414. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36415. */
  36416. lensFlaresEnabled: boolean;
  36417. /**
  36418. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36419. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36420. */
  36421. collisionsEnabled: boolean;
  36422. private _collisionCoordinator;
  36423. /** @hidden */
  36424. get collisionCoordinator(): ICollisionCoordinator;
  36425. /**
  36426. * Defines the gravity applied to this scene (used only for collisions)
  36427. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36428. */
  36429. gravity: Vector3;
  36430. /**
  36431. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36432. */
  36433. postProcessesEnabled: boolean;
  36434. /**
  36435. * The list of postprocesses added to the scene
  36436. */
  36437. postProcesses: PostProcess[];
  36438. /**
  36439. * Gets the current postprocess manager
  36440. */
  36441. postProcessManager: PostProcessManager;
  36442. /**
  36443. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36444. */
  36445. renderTargetsEnabled: boolean;
  36446. /**
  36447. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36448. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36449. */
  36450. dumpNextRenderTargets: boolean;
  36451. /**
  36452. * The list of user defined render targets added to the scene
  36453. */
  36454. customRenderTargets: RenderTargetTexture[];
  36455. /**
  36456. * Defines if texture loading must be delayed
  36457. * If true, textures will only be loaded when they need to be rendered
  36458. */
  36459. useDelayedTextureLoading: boolean;
  36460. /**
  36461. * Gets the list of meshes imported to the scene through SceneLoader
  36462. */
  36463. importedMeshesFiles: String[];
  36464. /**
  36465. * Gets or sets a boolean indicating if probes are enabled on this scene
  36466. */
  36467. probesEnabled: boolean;
  36468. /**
  36469. * Gets or sets the current offline provider to use to store scene data
  36470. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36471. */
  36472. offlineProvider: IOfflineProvider;
  36473. /**
  36474. * Gets or sets the action manager associated with the scene
  36475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36476. */
  36477. actionManager: AbstractActionManager;
  36478. private _meshesForIntersections;
  36479. /**
  36480. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36481. */
  36482. proceduralTexturesEnabled: boolean;
  36483. private _engine;
  36484. private _totalVertices;
  36485. /** @hidden */
  36486. _activeIndices: PerfCounter;
  36487. /** @hidden */
  36488. _activeParticles: PerfCounter;
  36489. /** @hidden */
  36490. _activeBones: PerfCounter;
  36491. private _animationRatio;
  36492. /** @hidden */
  36493. _animationTimeLast: number;
  36494. /** @hidden */
  36495. _animationTime: number;
  36496. /**
  36497. * Gets or sets a general scale for animation speed
  36498. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36499. */
  36500. animationTimeScale: number;
  36501. /** @hidden */
  36502. _cachedMaterial: Nullable<Material>;
  36503. /** @hidden */
  36504. _cachedEffect: Nullable<Effect>;
  36505. /** @hidden */
  36506. _cachedVisibility: Nullable<number>;
  36507. private _renderId;
  36508. private _frameId;
  36509. private _executeWhenReadyTimeoutId;
  36510. private _intermediateRendering;
  36511. private _viewUpdateFlag;
  36512. private _projectionUpdateFlag;
  36513. /** @hidden */
  36514. _toBeDisposed: Nullable<IDisposable>[];
  36515. private _activeRequests;
  36516. /** @hidden */
  36517. _pendingData: any[];
  36518. private _isDisposed;
  36519. /**
  36520. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36521. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36522. */
  36523. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36524. private _activeMeshes;
  36525. private _processedMaterials;
  36526. private _renderTargets;
  36527. /** @hidden */
  36528. _activeParticleSystems: SmartArray<IParticleSystem>;
  36529. private _activeSkeletons;
  36530. private _softwareSkinnedMeshes;
  36531. private _renderingManager;
  36532. /** @hidden */
  36533. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36534. private _transformMatrix;
  36535. private _sceneUbo;
  36536. /** @hidden */
  36537. _viewMatrix: Matrix;
  36538. private _projectionMatrix;
  36539. /** @hidden */
  36540. _forcedViewPosition: Nullable<Vector3>;
  36541. /** @hidden */
  36542. _frustumPlanes: Plane[];
  36543. /**
  36544. * Gets the list of frustum planes (built from the active camera)
  36545. */
  36546. get frustumPlanes(): Plane[];
  36547. /**
  36548. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36549. * This is useful if there are more lights that the maximum simulteanous authorized
  36550. */
  36551. requireLightSorting: boolean;
  36552. /** @hidden */
  36553. readonly useMaterialMeshMap: boolean;
  36554. /** @hidden */
  36555. readonly useClonedMeshhMap: boolean;
  36556. private _externalData;
  36557. private _uid;
  36558. /**
  36559. * @hidden
  36560. * Backing store of defined scene components.
  36561. */
  36562. _components: ISceneComponent[];
  36563. /**
  36564. * @hidden
  36565. * Backing store of defined scene components.
  36566. */
  36567. _serializableComponents: ISceneSerializableComponent[];
  36568. /**
  36569. * List of components to register on the next registration step.
  36570. */
  36571. private _transientComponents;
  36572. /**
  36573. * Registers the transient components if needed.
  36574. */
  36575. private _registerTransientComponents;
  36576. /**
  36577. * @hidden
  36578. * Add a component to the scene.
  36579. * Note that the ccomponent could be registered on th next frame if this is called after
  36580. * the register component stage.
  36581. * @param component Defines the component to add to the scene
  36582. */
  36583. _addComponent(component: ISceneComponent): void;
  36584. /**
  36585. * @hidden
  36586. * Gets a component from the scene.
  36587. * @param name defines the name of the component to retrieve
  36588. * @returns the component or null if not present
  36589. */
  36590. _getComponent(name: string): Nullable<ISceneComponent>;
  36591. /**
  36592. * @hidden
  36593. * Defines the actions happening before camera updates.
  36594. */
  36595. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36596. /**
  36597. * @hidden
  36598. * Defines the actions happening before clear the canvas.
  36599. */
  36600. _beforeClearStage: Stage<SimpleStageAction>;
  36601. /**
  36602. * @hidden
  36603. * Defines the actions when collecting render targets for the frame.
  36604. */
  36605. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36606. /**
  36607. * @hidden
  36608. * Defines the actions happening for one camera in the frame.
  36609. */
  36610. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36611. /**
  36612. * @hidden
  36613. * Defines the actions happening during the per mesh ready checks.
  36614. */
  36615. _isReadyForMeshStage: Stage<MeshStageAction>;
  36616. /**
  36617. * @hidden
  36618. * Defines the actions happening before evaluate active mesh checks.
  36619. */
  36620. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36621. /**
  36622. * @hidden
  36623. * Defines the actions happening during the evaluate sub mesh checks.
  36624. */
  36625. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36626. /**
  36627. * @hidden
  36628. * Defines the actions happening during the active mesh stage.
  36629. */
  36630. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36631. /**
  36632. * @hidden
  36633. * Defines the actions happening during the per camera render target step.
  36634. */
  36635. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36636. /**
  36637. * @hidden
  36638. * Defines the actions happening just before the active camera is drawing.
  36639. */
  36640. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36641. /**
  36642. * @hidden
  36643. * Defines the actions happening just before a render target is drawing.
  36644. */
  36645. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36646. /**
  36647. * @hidden
  36648. * Defines the actions happening just before a rendering group is drawing.
  36649. */
  36650. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36651. /**
  36652. * @hidden
  36653. * Defines the actions happening just before a mesh is drawing.
  36654. */
  36655. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36656. /**
  36657. * @hidden
  36658. * Defines the actions happening just after a mesh has been drawn.
  36659. */
  36660. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36661. /**
  36662. * @hidden
  36663. * Defines the actions happening just after a rendering group has been drawn.
  36664. */
  36665. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36666. /**
  36667. * @hidden
  36668. * Defines the actions happening just after the active camera has been drawn.
  36669. */
  36670. _afterCameraDrawStage: Stage<CameraStageAction>;
  36671. /**
  36672. * @hidden
  36673. * Defines the actions happening just after a render target has been drawn.
  36674. */
  36675. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36676. /**
  36677. * @hidden
  36678. * Defines the actions happening just after rendering all cameras and computing intersections.
  36679. */
  36680. _afterRenderStage: Stage<SimpleStageAction>;
  36681. /**
  36682. * @hidden
  36683. * Defines the actions happening when a pointer move event happens.
  36684. */
  36685. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36686. /**
  36687. * @hidden
  36688. * Defines the actions happening when a pointer down event happens.
  36689. */
  36690. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36691. /**
  36692. * @hidden
  36693. * Defines the actions happening when a pointer up event happens.
  36694. */
  36695. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36696. /**
  36697. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36698. */
  36699. private geometriesByUniqueId;
  36700. /**
  36701. * Creates a new Scene
  36702. * @param engine defines the engine to use to render this scene
  36703. * @param options defines the scene options
  36704. */
  36705. constructor(engine: Engine, options?: SceneOptions);
  36706. /**
  36707. * Gets a string idenfifying the name of the class
  36708. * @returns "Scene" string
  36709. */
  36710. getClassName(): string;
  36711. private _defaultMeshCandidates;
  36712. /**
  36713. * @hidden
  36714. */
  36715. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36716. private _defaultSubMeshCandidates;
  36717. /**
  36718. * @hidden
  36719. */
  36720. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36721. /**
  36722. * Sets the default candidate providers for the scene.
  36723. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36724. * and getCollidingSubMeshCandidates to their default function
  36725. */
  36726. setDefaultCandidateProviders(): void;
  36727. /**
  36728. * Gets the mesh that is currently under the pointer
  36729. */
  36730. get meshUnderPointer(): Nullable<AbstractMesh>;
  36731. /**
  36732. * Gets or sets the current on-screen X position of the pointer
  36733. */
  36734. get pointerX(): number;
  36735. set pointerX(value: number);
  36736. /**
  36737. * Gets or sets the current on-screen Y position of the pointer
  36738. */
  36739. get pointerY(): number;
  36740. set pointerY(value: number);
  36741. /**
  36742. * Gets the cached material (ie. the latest rendered one)
  36743. * @returns the cached material
  36744. */
  36745. getCachedMaterial(): Nullable<Material>;
  36746. /**
  36747. * Gets the cached effect (ie. the latest rendered one)
  36748. * @returns the cached effect
  36749. */
  36750. getCachedEffect(): Nullable<Effect>;
  36751. /**
  36752. * Gets the cached visibility state (ie. the latest rendered one)
  36753. * @returns the cached visibility state
  36754. */
  36755. getCachedVisibility(): Nullable<number>;
  36756. /**
  36757. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36758. * @param material defines the current material
  36759. * @param effect defines the current effect
  36760. * @param visibility defines the current visibility state
  36761. * @returns true if one parameter is not cached
  36762. */
  36763. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36764. /**
  36765. * Gets the engine associated with the scene
  36766. * @returns an Engine
  36767. */
  36768. getEngine(): Engine;
  36769. /**
  36770. * Gets the total number of vertices rendered per frame
  36771. * @returns the total number of vertices rendered per frame
  36772. */
  36773. getTotalVertices(): number;
  36774. /**
  36775. * Gets the performance counter for total vertices
  36776. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36777. */
  36778. get totalVerticesPerfCounter(): PerfCounter;
  36779. /**
  36780. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36781. * @returns the total number of active indices rendered per frame
  36782. */
  36783. getActiveIndices(): number;
  36784. /**
  36785. * Gets the performance counter for active indices
  36786. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36787. */
  36788. get totalActiveIndicesPerfCounter(): PerfCounter;
  36789. /**
  36790. * Gets the total number of active particles rendered per frame
  36791. * @returns the total number of active particles rendered per frame
  36792. */
  36793. getActiveParticles(): number;
  36794. /**
  36795. * Gets the performance counter for active particles
  36796. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36797. */
  36798. get activeParticlesPerfCounter(): PerfCounter;
  36799. /**
  36800. * Gets the total number of active bones rendered per frame
  36801. * @returns the total number of active bones rendered per frame
  36802. */
  36803. getActiveBones(): number;
  36804. /**
  36805. * Gets the performance counter for active bones
  36806. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36807. */
  36808. get activeBonesPerfCounter(): PerfCounter;
  36809. /**
  36810. * Gets the array of active meshes
  36811. * @returns an array of AbstractMesh
  36812. */
  36813. getActiveMeshes(): SmartArray<AbstractMesh>;
  36814. /**
  36815. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36816. * @returns a number
  36817. */
  36818. getAnimationRatio(): number;
  36819. /**
  36820. * Gets an unique Id for the current render phase
  36821. * @returns a number
  36822. */
  36823. getRenderId(): number;
  36824. /**
  36825. * Gets an unique Id for the current frame
  36826. * @returns a number
  36827. */
  36828. getFrameId(): number;
  36829. /** Call this function if you want to manually increment the render Id*/
  36830. incrementRenderId(): void;
  36831. private _createUbo;
  36832. /**
  36833. * Use this method to simulate a pointer move on a mesh
  36834. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36835. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36836. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36837. * @returns the current scene
  36838. */
  36839. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36840. /**
  36841. * Use this method to simulate a pointer down on a mesh
  36842. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36843. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36844. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36845. * @returns the current scene
  36846. */
  36847. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36848. /**
  36849. * Use this method to simulate a pointer up on a mesh
  36850. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36851. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36852. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36853. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36854. * @returns the current scene
  36855. */
  36856. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36857. /**
  36858. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36859. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36860. * @returns true if the pointer was captured
  36861. */
  36862. isPointerCaptured(pointerId?: number): boolean;
  36863. /**
  36864. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36865. * @param attachUp defines if you want to attach events to pointerup
  36866. * @param attachDown defines if you want to attach events to pointerdown
  36867. * @param attachMove defines if you want to attach events to pointermove
  36868. */
  36869. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36870. /** Detaches all event handlers*/
  36871. detachControl(): void;
  36872. /**
  36873. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36874. * Delay loaded resources are not taking in account
  36875. * @return true if all required resources are ready
  36876. */
  36877. isReady(): boolean;
  36878. /** Resets all cached information relative to material (including effect and visibility) */
  36879. resetCachedMaterial(): void;
  36880. /**
  36881. * Registers a function to be called before every frame render
  36882. * @param func defines the function to register
  36883. */
  36884. registerBeforeRender(func: () => void): void;
  36885. /**
  36886. * Unregisters a function called before every frame render
  36887. * @param func defines the function to unregister
  36888. */
  36889. unregisterBeforeRender(func: () => void): void;
  36890. /**
  36891. * Registers a function to be called after every frame render
  36892. * @param func defines the function to register
  36893. */
  36894. registerAfterRender(func: () => void): void;
  36895. /**
  36896. * Unregisters a function called after every frame render
  36897. * @param func defines the function to unregister
  36898. */
  36899. unregisterAfterRender(func: () => void): void;
  36900. private _executeOnceBeforeRender;
  36901. /**
  36902. * The provided function will run before render once and will be disposed afterwards.
  36903. * A timeout delay can be provided so that the function will be executed in N ms.
  36904. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36905. * @param func The function to be executed.
  36906. * @param timeout optional delay in ms
  36907. */
  36908. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36909. /** @hidden */
  36910. _addPendingData(data: any): void;
  36911. /** @hidden */
  36912. _removePendingData(data: any): void;
  36913. /**
  36914. * Returns the number of items waiting to be loaded
  36915. * @returns the number of items waiting to be loaded
  36916. */
  36917. getWaitingItemsCount(): number;
  36918. /**
  36919. * Returns a boolean indicating if the scene is still loading data
  36920. */
  36921. get isLoading(): boolean;
  36922. /**
  36923. * Registers a function to be executed when the scene is ready
  36924. * @param {Function} func - the function to be executed
  36925. */
  36926. executeWhenReady(func: () => void): void;
  36927. /**
  36928. * Returns a promise that resolves when the scene is ready
  36929. * @returns A promise that resolves when the scene is ready
  36930. */
  36931. whenReadyAsync(): Promise<void>;
  36932. /** @hidden */
  36933. _checkIsReady(): void;
  36934. /**
  36935. * Gets all animatable attached to the scene
  36936. */
  36937. get animatables(): Animatable[];
  36938. /**
  36939. * Resets the last animation time frame.
  36940. * Useful to override when animations start running when loading a scene for the first time.
  36941. */
  36942. resetLastAnimationTimeFrame(): void;
  36943. /**
  36944. * Gets the current view matrix
  36945. * @returns a Matrix
  36946. */
  36947. getViewMatrix(): Matrix;
  36948. /**
  36949. * Gets the current projection matrix
  36950. * @returns a Matrix
  36951. */
  36952. getProjectionMatrix(): Matrix;
  36953. /**
  36954. * Gets the current transform matrix
  36955. * @returns a Matrix made of View * Projection
  36956. */
  36957. getTransformMatrix(): Matrix;
  36958. /**
  36959. * Sets the current transform matrix
  36960. * @param viewL defines the View matrix to use
  36961. * @param projectionL defines the Projection matrix to use
  36962. * @param viewR defines the right View matrix to use (if provided)
  36963. * @param projectionR defines the right Projection matrix to use (if provided)
  36964. */
  36965. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36966. /**
  36967. * Gets the uniform buffer used to store scene data
  36968. * @returns a UniformBuffer
  36969. */
  36970. getSceneUniformBuffer(): UniformBuffer;
  36971. /**
  36972. * Gets an unique (relatively to the current scene) Id
  36973. * @returns an unique number for the scene
  36974. */
  36975. getUniqueId(): number;
  36976. /**
  36977. * Add a mesh to the list of scene's meshes
  36978. * @param newMesh defines the mesh to add
  36979. * @param recursive if all child meshes should also be added to the scene
  36980. */
  36981. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36982. /**
  36983. * Remove a mesh for the list of scene's meshes
  36984. * @param toRemove defines the mesh to remove
  36985. * @param recursive if all child meshes should also be removed from the scene
  36986. * @returns the index where the mesh was in the mesh list
  36987. */
  36988. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36989. /**
  36990. * Add a transform node to the list of scene's transform nodes
  36991. * @param newTransformNode defines the transform node to add
  36992. */
  36993. addTransformNode(newTransformNode: TransformNode): void;
  36994. /**
  36995. * Remove a transform node for the list of scene's transform nodes
  36996. * @param toRemove defines the transform node to remove
  36997. * @returns the index where the transform node was in the transform node list
  36998. */
  36999. removeTransformNode(toRemove: TransformNode): number;
  37000. /**
  37001. * Remove a skeleton for the list of scene's skeletons
  37002. * @param toRemove defines the skeleton to remove
  37003. * @returns the index where the skeleton was in the skeleton list
  37004. */
  37005. removeSkeleton(toRemove: Skeleton): number;
  37006. /**
  37007. * Remove a morph target for the list of scene's morph targets
  37008. * @param toRemove defines the morph target to remove
  37009. * @returns the index where the morph target was in the morph target list
  37010. */
  37011. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37012. /**
  37013. * Remove a light for the list of scene's lights
  37014. * @param toRemove defines the light to remove
  37015. * @returns the index where the light was in the light list
  37016. */
  37017. removeLight(toRemove: Light): number;
  37018. /**
  37019. * Remove a camera for the list of scene's cameras
  37020. * @param toRemove defines the camera to remove
  37021. * @returns the index where the camera was in the camera list
  37022. */
  37023. removeCamera(toRemove: Camera): number;
  37024. /**
  37025. * Remove a particle system for the list of scene's particle systems
  37026. * @param toRemove defines the particle system to remove
  37027. * @returns the index where the particle system was in the particle system list
  37028. */
  37029. removeParticleSystem(toRemove: IParticleSystem): number;
  37030. /**
  37031. * Remove a animation for the list of scene's animations
  37032. * @param toRemove defines the animation to remove
  37033. * @returns the index where the animation was in the animation list
  37034. */
  37035. removeAnimation(toRemove: Animation): number;
  37036. /**
  37037. * Will stop the animation of the given target
  37038. * @param target - the target
  37039. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37040. * @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)
  37041. */
  37042. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37043. /**
  37044. * Removes the given animation group from this scene.
  37045. * @param toRemove The animation group to remove
  37046. * @returns The index of the removed animation group
  37047. */
  37048. removeAnimationGroup(toRemove: AnimationGroup): number;
  37049. /**
  37050. * Removes the given multi-material from this scene.
  37051. * @param toRemove The multi-material to remove
  37052. * @returns The index of the removed multi-material
  37053. */
  37054. removeMultiMaterial(toRemove: MultiMaterial): number;
  37055. /**
  37056. * Removes the given material from this scene.
  37057. * @param toRemove The material to remove
  37058. * @returns The index of the removed material
  37059. */
  37060. removeMaterial(toRemove: Material): number;
  37061. /**
  37062. * Removes the given action manager from this scene.
  37063. * @param toRemove The action manager to remove
  37064. * @returns The index of the removed action manager
  37065. */
  37066. removeActionManager(toRemove: AbstractActionManager): number;
  37067. /**
  37068. * Removes the given texture from this scene.
  37069. * @param toRemove The texture to remove
  37070. * @returns The index of the removed texture
  37071. */
  37072. removeTexture(toRemove: BaseTexture): number;
  37073. /**
  37074. * Adds the given light to this scene
  37075. * @param newLight The light to add
  37076. */
  37077. addLight(newLight: Light): void;
  37078. /**
  37079. * Sorts the list list based on light priorities
  37080. */
  37081. sortLightsByPriority(): void;
  37082. /**
  37083. * Adds the given camera to this scene
  37084. * @param newCamera The camera to add
  37085. */
  37086. addCamera(newCamera: Camera): void;
  37087. /**
  37088. * Adds the given skeleton to this scene
  37089. * @param newSkeleton The skeleton to add
  37090. */
  37091. addSkeleton(newSkeleton: Skeleton): void;
  37092. /**
  37093. * Adds the given particle system to this scene
  37094. * @param newParticleSystem The particle system to add
  37095. */
  37096. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37097. /**
  37098. * Adds the given animation to this scene
  37099. * @param newAnimation The animation to add
  37100. */
  37101. addAnimation(newAnimation: Animation): void;
  37102. /**
  37103. * Adds the given animation group to this scene.
  37104. * @param newAnimationGroup The animation group to add
  37105. */
  37106. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37107. /**
  37108. * Adds the given multi-material to this scene
  37109. * @param newMultiMaterial The multi-material to add
  37110. */
  37111. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37112. /**
  37113. * Adds the given material to this scene
  37114. * @param newMaterial The material to add
  37115. */
  37116. addMaterial(newMaterial: Material): void;
  37117. /**
  37118. * Adds the given morph target to this scene
  37119. * @param newMorphTargetManager The morph target to add
  37120. */
  37121. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37122. /**
  37123. * Adds the given geometry to this scene
  37124. * @param newGeometry The geometry to add
  37125. */
  37126. addGeometry(newGeometry: Geometry): void;
  37127. /**
  37128. * Adds the given action manager to this scene
  37129. * @param newActionManager The action manager to add
  37130. */
  37131. addActionManager(newActionManager: AbstractActionManager): void;
  37132. /**
  37133. * Adds the given texture to this scene.
  37134. * @param newTexture The texture to add
  37135. */
  37136. addTexture(newTexture: BaseTexture): void;
  37137. /**
  37138. * Switch active camera
  37139. * @param newCamera defines the new active camera
  37140. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37141. */
  37142. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37143. /**
  37144. * sets the active camera of the scene using its ID
  37145. * @param id defines the camera's ID
  37146. * @return the new active camera or null if none found.
  37147. */
  37148. setActiveCameraByID(id: string): Nullable<Camera>;
  37149. /**
  37150. * sets the active camera of the scene using its name
  37151. * @param name defines the camera's name
  37152. * @returns the new active camera or null if none found.
  37153. */
  37154. setActiveCameraByName(name: string): Nullable<Camera>;
  37155. /**
  37156. * get an animation group using its name
  37157. * @param name defines the material's name
  37158. * @return the animation group or null if none found.
  37159. */
  37160. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37161. /**
  37162. * Get a material using its unique id
  37163. * @param uniqueId defines the material's unique id
  37164. * @return the material or null if none found.
  37165. */
  37166. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37167. /**
  37168. * get a material using its id
  37169. * @param id defines the material's ID
  37170. * @return the material or null if none found.
  37171. */
  37172. getMaterialByID(id: string): Nullable<Material>;
  37173. /**
  37174. * Gets a the last added material using a given id
  37175. * @param id defines the material's ID
  37176. * @return the last material with the given id or null if none found.
  37177. */
  37178. getLastMaterialByID(id: string): Nullable<Material>;
  37179. /**
  37180. * Gets a material using its name
  37181. * @param name defines the material's name
  37182. * @return the material or null if none found.
  37183. */
  37184. getMaterialByName(name: string): Nullable<Material>;
  37185. /**
  37186. * Get a texture using its unique id
  37187. * @param uniqueId defines the texture's unique id
  37188. * @return the texture or null if none found.
  37189. */
  37190. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37191. /**
  37192. * Gets a camera using its id
  37193. * @param id defines the id to look for
  37194. * @returns the camera or null if not found
  37195. */
  37196. getCameraByID(id: string): Nullable<Camera>;
  37197. /**
  37198. * Gets a camera using its unique id
  37199. * @param uniqueId defines the unique id to look for
  37200. * @returns the camera or null if not found
  37201. */
  37202. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37203. /**
  37204. * Gets a camera using its name
  37205. * @param name defines the camera's name
  37206. * @return the camera or null if none found.
  37207. */
  37208. getCameraByName(name: string): Nullable<Camera>;
  37209. /**
  37210. * Gets a bone using its id
  37211. * @param id defines the bone's id
  37212. * @return the bone or null if not found
  37213. */
  37214. getBoneByID(id: string): Nullable<Bone>;
  37215. /**
  37216. * Gets a bone using its id
  37217. * @param name defines the bone's name
  37218. * @return the bone or null if not found
  37219. */
  37220. getBoneByName(name: string): Nullable<Bone>;
  37221. /**
  37222. * Gets a light node using its name
  37223. * @param name defines the the light's name
  37224. * @return the light or null if none found.
  37225. */
  37226. getLightByName(name: string): Nullable<Light>;
  37227. /**
  37228. * Gets a light node using its id
  37229. * @param id defines the light's id
  37230. * @return the light or null if none found.
  37231. */
  37232. getLightByID(id: string): Nullable<Light>;
  37233. /**
  37234. * Gets a light node using its scene-generated unique ID
  37235. * @param uniqueId defines the light's unique id
  37236. * @return the light or null if none found.
  37237. */
  37238. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37239. /**
  37240. * Gets a particle system by id
  37241. * @param id defines the particle system id
  37242. * @return the corresponding system or null if none found
  37243. */
  37244. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37245. /**
  37246. * Gets a geometry using its ID
  37247. * @param id defines the geometry's id
  37248. * @return the geometry or null if none found.
  37249. */
  37250. getGeometryByID(id: string): Nullable<Geometry>;
  37251. private _getGeometryByUniqueID;
  37252. /**
  37253. * Add a new geometry to this scene
  37254. * @param geometry defines the geometry to be added to the scene.
  37255. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37256. * @return a boolean defining if the geometry was added or not
  37257. */
  37258. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37259. /**
  37260. * Removes an existing geometry
  37261. * @param geometry defines the geometry to be removed from the scene
  37262. * @return a boolean defining if the geometry was removed or not
  37263. */
  37264. removeGeometry(geometry: Geometry): boolean;
  37265. /**
  37266. * Gets the list of geometries attached to the scene
  37267. * @returns an array of Geometry
  37268. */
  37269. getGeometries(): Geometry[];
  37270. /**
  37271. * Gets the first added mesh found of a given ID
  37272. * @param id defines the id to search for
  37273. * @return the mesh found or null if not found at all
  37274. */
  37275. getMeshByID(id: string): Nullable<AbstractMesh>;
  37276. /**
  37277. * Gets a list of meshes using their id
  37278. * @param id defines the id to search for
  37279. * @returns a list of meshes
  37280. */
  37281. getMeshesByID(id: string): Array<AbstractMesh>;
  37282. /**
  37283. * Gets the first added transform node found of a given ID
  37284. * @param id defines the id to search for
  37285. * @return the found transform node or null if not found at all.
  37286. */
  37287. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37288. /**
  37289. * Gets a transform node with its auto-generated unique id
  37290. * @param uniqueId efines the unique id to search for
  37291. * @return the found transform node or null if not found at all.
  37292. */
  37293. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37294. /**
  37295. * Gets a list of transform nodes using their id
  37296. * @param id defines the id to search for
  37297. * @returns a list of transform nodes
  37298. */
  37299. getTransformNodesByID(id: string): Array<TransformNode>;
  37300. /**
  37301. * Gets a mesh with its auto-generated unique id
  37302. * @param uniqueId defines the unique id to search for
  37303. * @return the found mesh or null if not found at all.
  37304. */
  37305. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37306. /**
  37307. * Gets a the last added mesh using a given id
  37308. * @param id defines the id to search for
  37309. * @return the found mesh or null if not found at all.
  37310. */
  37311. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37312. /**
  37313. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37314. * @param id defines the id to search for
  37315. * @return the found node or null if not found at all
  37316. */
  37317. getLastEntryByID(id: string): Nullable<Node>;
  37318. /**
  37319. * Gets a node (Mesh, Camera, Light) using a given id
  37320. * @param id defines the id to search for
  37321. * @return the found node or null if not found at all
  37322. */
  37323. getNodeByID(id: string): Nullable<Node>;
  37324. /**
  37325. * Gets a node (Mesh, Camera, Light) using a given name
  37326. * @param name defines the name to search for
  37327. * @return the found node or null if not found at all.
  37328. */
  37329. getNodeByName(name: string): Nullable<Node>;
  37330. /**
  37331. * Gets a mesh using a given name
  37332. * @param name defines the name to search for
  37333. * @return the found mesh or null if not found at all.
  37334. */
  37335. getMeshByName(name: string): Nullable<AbstractMesh>;
  37336. /**
  37337. * Gets a transform node using a given name
  37338. * @param name defines the name to search for
  37339. * @return the found transform node or null if not found at all.
  37340. */
  37341. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37342. /**
  37343. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37344. * @param id defines the id to search for
  37345. * @return the found skeleton or null if not found at all.
  37346. */
  37347. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37348. /**
  37349. * Gets a skeleton using a given auto generated unique id
  37350. * @param uniqueId defines the unique id to search for
  37351. * @return the found skeleton or null if not found at all.
  37352. */
  37353. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37354. /**
  37355. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37356. * @param id defines the id to search for
  37357. * @return the found skeleton or null if not found at all.
  37358. */
  37359. getSkeletonById(id: string): Nullable<Skeleton>;
  37360. /**
  37361. * Gets a skeleton using a given name
  37362. * @param name defines the name to search for
  37363. * @return the found skeleton or null if not found at all.
  37364. */
  37365. getSkeletonByName(name: string): Nullable<Skeleton>;
  37366. /**
  37367. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37368. * @param id defines the id to search for
  37369. * @return the found morph target manager or null if not found at all.
  37370. */
  37371. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37372. /**
  37373. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37374. * @param id defines the id to search for
  37375. * @return the found morph target or null if not found at all.
  37376. */
  37377. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37378. /**
  37379. * Gets a boolean indicating if the given mesh is active
  37380. * @param mesh defines the mesh to look for
  37381. * @returns true if the mesh is in the active list
  37382. */
  37383. isActiveMesh(mesh: AbstractMesh): boolean;
  37384. /**
  37385. * Return a unique id as a string which can serve as an identifier for the scene
  37386. */
  37387. get uid(): string;
  37388. /**
  37389. * Add an externaly attached data from its key.
  37390. * This method call will fail and return false, if such key already exists.
  37391. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37392. * @param key the unique key that identifies the data
  37393. * @param data the data object to associate to the key for this Engine instance
  37394. * @return true if no such key were already present and the data was added successfully, false otherwise
  37395. */
  37396. addExternalData<T>(key: string, data: T): boolean;
  37397. /**
  37398. * Get an externaly attached data from its key
  37399. * @param key the unique key that identifies the data
  37400. * @return the associated data, if present (can be null), or undefined if not present
  37401. */
  37402. getExternalData<T>(key: string): Nullable<T>;
  37403. /**
  37404. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37405. * @param key the unique key that identifies the data
  37406. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37407. * @return the associated data, can be null if the factory returned null.
  37408. */
  37409. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37410. /**
  37411. * Remove an externaly attached data from the Engine instance
  37412. * @param key the unique key that identifies the data
  37413. * @return true if the data was successfully removed, false if it doesn't exist
  37414. */
  37415. removeExternalData(key: string): boolean;
  37416. private _evaluateSubMesh;
  37417. /**
  37418. * Clear the processed materials smart array preventing retention point in material dispose.
  37419. */
  37420. freeProcessedMaterials(): void;
  37421. private _preventFreeActiveMeshesAndRenderingGroups;
  37422. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37423. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37424. * when disposing several meshes in a row or a hierarchy of meshes.
  37425. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37426. */
  37427. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37428. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37429. /**
  37430. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37431. */
  37432. freeActiveMeshes(): void;
  37433. /**
  37434. * Clear the info related to rendering groups preventing retention points during dispose.
  37435. */
  37436. freeRenderingGroups(): void;
  37437. /** @hidden */
  37438. _isInIntermediateRendering(): boolean;
  37439. /**
  37440. * Lambda returning the list of potentially active meshes.
  37441. */
  37442. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37443. /**
  37444. * Lambda returning the list of potentially active sub meshes.
  37445. */
  37446. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37447. /**
  37448. * Lambda returning the list of potentially intersecting sub meshes.
  37449. */
  37450. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37451. /**
  37452. * Lambda returning the list of potentially colliding sub meshes.
  37453. */
  37454. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37455. private _activeMeshesFrozen;
  37456. private _skipEvaluateActiveMeshesCompletely;
  37457. /**
  37458. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37459. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37460. * @returns the current scene
  37461. */
  37462. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37463. /**
  37464. * Use this function to restart evaluating active meshes on every frame
  37465. * @returns the current scene
  37466. */
  37467. unfreezeActiveMeshes(): Scene;
  37468. private _evaluateActiveMeshes;
  37469. private _activeMesh;
  37470. /**
  37471. * Update the transform matrix to update from the current active camera
  37472. * @param force defines a boolean used to force the update even if cache is up to date
  37473. */
  37474. updateTransformMatrix(force?: boolean): void;
  37475. private _bindFrameBuffer;
  37476. /** @hidden */
  37477. _allowPostProcessClearColor: boolean;
  37478. /** @hidden */
  37479. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37480. private _processSubCameras;
  37481. private _checkIntersections;
  37482. /** @hidden */
  37483. _advancePhysicsEngineStep(step: number): void;
  37484. /**
  37485. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37486. */
  37487. getDeterministicFrameTime: () => number;
  37488. /** @hidden */
  37489. _animate(): void;
  37490. /** Execute all animations (for a frame) */
  37491. animate(): void;
  37492. /**
  37493. * Render the scene
  37494. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37495. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37496. */
  37497. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37498. /**
  37499. * Freeze all materials
  37500. * A frozen material will not be updatable but should be faster to render
  37501. */
  37502. freezeMaterials(): void;
  37503. /**
  37504. * Unfreeze all materials
  37505. * A frozen material will not be updatable but should be faster to render
  37506. */
  37507. unfreezeMaterials(): void;
  37508. /**
  37509. * Releases all held ressources
  37510. */
  37511. dispose(): void;
  37512. /**
  37513. * Gets if the scene is already disposed
  37514. */
  37515. get isDisposed(): boolean;
  37516. /**
  37517. * Call this function to reduce memory footprint of the scene.
  37518. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37519. */
  37520. clearCachedVertexData(): void;
  37521. /**
  37522. * This function will remove the local cached buffer data from texture.
  37523. * It will save memory but will prevent the texture from being rebuilt
  37524. */
  37525. cleanCachedTextureBuffer(): void;
  37526. /**
  37527. * Get the world extend vectors with an optional filter
  37528. *
  37529. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37530. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37531. */
  37532. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37533. min: Vector3;
  37534. max: Vector3;
  37535. };
  37536. /**
  37537. * Creates a ray that can be used to pick in the scene
  37538. * @param x defines the x coordinate of the origin (on-screen)
  37539. * @param y defines the y coordinate of the origin (on-screen)
  37540. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37541. * @param camera defines the camera to use for the picking
  37542. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37543. * @returns a Ray
  37544. */
  37545. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37546. /**
  37547. * Creates a ray that can be used to pick in the scene
  37548. * @param x defines the x coordinate of the origin (on-screen)
  37549. * @param y defines the y coordinate of the origin (on-screen)
  37550. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37551. * @param result defines the ray where to store the picking ray
  37552. * @param camera defines the camera to use for the picking
  37553. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37554. * @returns the current scene
  37555. */
  37556. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37557. /**
  37558. * Creates a ray that can be used to pick in the scene
  37559. * @param x defines the x coordinate of the origin (on-screen)
  37560. * @param y defines the y coordinate of the origin (on-screen)
  37561. * @param camera defines the camera to use for the picking
  37562. * @returns a Ray
  37563. */
  37564. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37565. /**
  37566. * Creates a ray that can be used to pick in the scene
  37567. * @param x defines the x coordinate of the origin (on-screen)
  37568. * @param y defines the y coordinate of the origin (on-screen)
  37569. * @param result defines the ray where to store the picking ray
  37570. * @param camera defines the camera to use for the picking
  37571. * @returns the current scene
  37572. */
  37573. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37574. /** Launch a ray to try to pick a mesh in the scene
  37575. * @param x position on screen
  37576. * @param y position on screen
  37577. * @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
  37578. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37579. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37580. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37581. * @returns a PickingInfo
  37582. */
  37583. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37584. /** Use the given ray to pick a mesh in the scene
  37585. * @param ray The ray to use to pick meshes
  37586. * @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
  37587. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37588. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37589. * @returns a PickingInfo
  37590. */
  37591. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37592. /**
  37593. * Launch a ray to try to pick a mesh in the scene
  37594. * @param x X position on screen
  37595. * @param y Y position on screen
  37596. * @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
  37597. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37598. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37599. * @returns an array of PickingInfo
  37600. */
  37601. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37602. /**
  37603. * Launch a ray to try to pick a mesh in the scene
  37604. * @param ray Ray to use
  37605. * @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
  37606. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37607. * @returns an array of PickingInfo
  37608. */
  37609. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37610. /**
  37611. * Force the value of meshUnderPointer
  37612. * @param mesh defines the mesh to use
  37613. */
  37614. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37615. /**
  37616. * Gets the mesh under the pointer
  37617. * @returns a Mesh or null if no mesh is under the pointer
  37618. */
  37619. getPointerOverMesh(): Nullable<AbstractMesh>;
  37620. /** @hidden */
  37621. _rebuildGeometries(): void;
  37622. /** @hidden */
  37623. _rebuildTextures(): void;
  37624. private _getByTags;
  37625. /**
  37626. * Get a list of meshes by tags
  37627. * @param tagsQuery defines the tags query to use
  37628. * @param forEach defines a predicate used to filter results
  37629. * @returns an array of Mesh
  37630. */
  37631. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37632. /**
  37633. * Get a list of cameras by tags
  37634. * @param tagsQuery defines the tags query to use
  37635. * @param forEach defines a predicate used to filter results
  37636. * @returns an array of Camera
  37637. */
  37638. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37639. /**
  37640. * Get a list of lights by tags
  37641. * @param tagsQuery defines the tags query to use
  37642. * @param forEach defines a predicate used to filter results
  37643. * @returns an array of Light
  37644. */
  37645. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37646. /**
  37647. * Get a list of materials by tags
  37648. * @param tagsQuery defines the tags query to use
  37649. * @param forEach defines a predicate used to filter results
  37650. * @returns an array of Material
  37651. */
  37652. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37653. /**
  37654. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37655. * This allowed control for front to back rendering or reversly depending of the special needs.
  37656. *
  37657. * @param renderingGroupId The rendering group id corresponding to its index
  37658. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37659. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37660. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37661. */
  37662. 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;
  37663. /**
  37664. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37665. *
  37666. * @param renderingGroupId The rendering group id corresponding to its index
  37667. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37668. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37669. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37670. */
  37671. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37672. /**
  37673. * Gets the current auto clear configuration for one rendering group of the rendering
  37674. * manager.
  37675. * @param index the rendering group index to get the information for
  37676. * @returns The auto clear setup for the requested rendering group
  37677. */
  37678. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37679. private _blockMaterialDirtyMechanism;
  37680. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37681. get blockMaterialDirtyMechanism(): boolean;
  37682. set blockMaterialDirtyMechanism(value: boolean);
  37683. /**
  37684. * Will flag all materials as dirty to trigger new shader compilation
  37685. * @param flag defines the flag used to specify which material part must be marked as dirty
  37686. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37687. */
  37688. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37689. /** @hidden */
  37690. _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;
  37691. /** @hidden */
  37692. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37693. /** @hidden */
  37694. _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;
  37695. /** @hidden */
  37696. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37697. /** @hidden */
  37698. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37699. /** @hidden */
  37700. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37701. }
  37702. }
  37703. declare module "babylonjs/assetContainer" {
  37704. import { AbstractScene } from "babylonjs/abstractScene";
  37705. import { Scene } from "babylonjs/scene";
  37706. import { Mesh } from "babylonjs/Meshes/mesh";
  37707. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37708. import { Skeleton } from "babylonjs/Bones/skeleton";
  37709. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37710. import { Animatable } from "babylonjs/Animations/animatable";
  37711. import { Nullable } from "babylonjs/types";
  37712. import { Node } from "babylonjs/node";
  37713. /**
  37714. * Set of assets to keep when moving a scene into an asset container.
  37715. */
  37716. export class KeepAssets extends AbstractScene {
  37717. }
  37718. /**
  37719. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37720. */
  37721. export class InstantiatedEntries {
  37722. /**
  37723. * List of new root nodes (eg. nodes with no parent)
  37724. */
  37725. rootNodes: TransformNode[];
  37726. /**
  37727. * List of new skeletons
  37728. */
  37729. skeletons: Skeleton[];
  37730. /**
  37731. * List of new animation groups
  37732. */
  37733. animationGroups: AnimationGroup[];
  37734. }
  37735. /**
  37736. * Container with a set of assets that can be added or removed from a scene.
  37737. */
  37738. export class AssetContainer extends AbstractScene {
  37739. /**
  37740. * The scene the AssetContainer belongs to.
  37741. */
  37742. scene: Scene;
  37743. /**
  37744. * Instantiates an AssetContainer.
  37745. * @param scene The scene the AssetContainer belongs to.
  37746. */
  37747. constructor(scene: Scene);
  37748. /**
  37749. * Instantiate or clone all meshes and add the new ones to the scene.
  37750. * Skeletons and animation groups will all be cloned
  37751. * @param nameFunction defines an optional function used to get new names for clones
  37752. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37753. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37754. */
  37755. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37756. /**
  37757. * Adds all the assets from the container to the scene.
  37758. */
  37759. addAllToScene(): void;
  37760. /**
  37761. * Removes all the assets in the container from the scene
  37762. */
  37763. removeAllFromScene(): void;
  37764. /**
  37765. * Disposes all the assets in the container
  37766. */
  37767. dispose(): void;
  37768. private _moveAssets;
  37769. /**
  37770. * Removes all the assets contained in the scene and adds them to the container.
  37771. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37772. */
  37773. moveAllFromScene(keepAssets?: KeepAssets): void;
  37774. /**
  37775. * 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.
  37776. * @returns the root mesh
  37777. */
  37778. createRootMesh(): Mesh;
  37779. /**
  37780. * Merge animations from this asset container into a scene
  37781. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37782. * @param animatables set of animatables to retarget to a node from the scene
  37783. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37784. */
  37785. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37786. }
  37787. }
  37788. declare module "babylonjs/abstractScene" {
  37789. import { Scene } from "babylonjs/scene";
  37790. import { Nullable } from "babylonjs/types";
  37791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37792. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37793. import { Geometry } from "babylonjs/Meshes/geometry";
  37794. import { Skeleton } from "babylonjs/Bones/skeleton";
  37795. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37796. import { AssetContainer } from "babylonjs/assetContainer";
  37797. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37798. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37800. import { Material } from "babylonjs/Materials/material";
  37801. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37802. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37803. import { Camera } from "babylonjs/Cameras/camera";
  37804. import { Light } from "babylonjs/Lights/light";
  37805. import { Node } from "babylonjs/node";
  37806. import { Animation } from "babylonjs/Animations/animation";
  37807. /**
  37808. * Defines how the parser contract is defined.
  37809. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37810. */
  37811. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37812. /**
  37813. * Defines how the individual parser contract is defined.
  37814. * These parser can parse an individual asset
  37815. */
  37816. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37817. /**
  37818. * Base class of the scene acting as a container for the different elements composing a scene.
  37819. * This class is dynamically extended by the different components of the scene increasing
  37820. * flexibility and reducing coupling
  37821. */
  37822. export abstract class AbstractScene {
  37823. /**
  37824. * Stores the list of available parsers in the application.
  37825. */
  37826. private static _BabylonFileParsers;
  37827. /**
  37828. * Stores the list of available individual parsers in the application.
  37829. */
  37830. private static _IndividualBabylonFileParsers;
  37831. /**
  37832. * Adds a parser in the list of available ones
  37833. * @param name Defines the name of the parser
  37834. * @param parser Defines the parser to add
  37835. */
  37836. static AddParser(name: string, parser: BabylonFileParser): void;
  37837. /**
  37838. * Gets a general parser from the list of avaialble ones
  37839. * @param name Defines the name of the parser
  37840. * @returns the requested parser or null
  37841. */
  37842. static GetParser(name: string): Nullable<BabylonFileParser>;
  37843. /**
  37844. * Adds n individual parser in the list of available ones
  37845. * @param name Defines the name of the parser
  37846. * @param parser Defines the parser to add
  37847. */
  37848. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37849. /**
  37850. * Gets an individual parser from the list of avaialble ones
  37851. * @param name Defines the name of the parser
  37852. * @returns the requested parser or null
  37853. */
  37854. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37855. /**
  37856. * Parser json data and populate both a scene and its associated container object
  37857. * @param jsonData Defines the data to parse
  37858. * @param scene Defines the scene to parse the data for
  37859. * @param container Defines the container attached to the parsing sequence
  37860. * @param rootUrl Defines the root url of the data
  37861. */
  37862. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37863. /**
  37864. * Gets the list of root nodes (ie. nodes with no parent)
  37865. */
  37866. rootNodes: Node[];
  37867. /** All of the cameras added to this scene
  37868. * @see http://doc.babylonjs.com/babylon101/cameras
  37869. */
  37870. cameras: Camera[];
  37871. /**
  37872. * All of the lights added to this scene
  37873. * @see http://doc.babylonjs.com/babylon101/lights
  37874. */
  37875. lights: Light[];
  37876. /**
  37877. * All of the (abstract) meshes added to this scene
  37878. */
  37879. meshes: AbstractMesh[];
  37880. /**
  37881. * The list of skeletons added to the scene
  37882. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37883. */
  37884. skeletons: Skeleton[];
  37885. /**
  37886. * All of the particle systems added to this scene
  37887. * @see http://doc.babylonjs.com/babylon101/particles
  37888. */
  37889. particleSystems: IParticleSystem[];
  37890. /**
  37891. * Gets a list of Animations associated with the scene
  37892. */
  37893. animations: Animation[];
  37894. /**
  37895. * All of the animation groups added to this scene
  37896. * @see http://doc.babylonjs.com/how_to/group
  37897. */
  37898. animationGroups: AnimationGroup[];
  37899. /**
  37900. * All of the multi-materials added to this scene
  37901. * @see http://doc.babylonjs.com/how_to/multi_materials
  37902. */
  37903. multiMaterials: MultiMaterial[];
  37904. /**
  37905. * All of the materials added to this scene
  37906. * In the context of a Scene, it is not supposed to be modified manually.
  37907. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37908. * Note also that the order of the Material within the array is not significant and might change.
  37909. * @see http://doc.babylonjs.com/babylon101/materials
  37910. */
  37911. materials: Material[];
  37912. /**
  37913. * The list of morph target managers added to the scene
  37914. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37915. */
  37916. morphTargetManagers: MorphTargetManager[];
  37917. /**
  37918. * The list of geometries used in the scene.
  37919. */
  37920. geometries: Geometry[];
  37921. /**
  37922. * All of the tranform nodes added to this scene
  37923. * In the context of a Scene, it is not supposed to be modified manually.
  37924. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37925. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37926. * @see http://doc.babylonjs.com/how_to/transformnode
  37927. */
  37928. transformNodes: TransformNode[];
  37929. /**
  37930. * ActionManagers available on the scene.
  37931. */
  37932. actionManagers: AbstractActionManager[];
  37933. /**
  37934. * Textures to keep.
  37935. */
  37936. textures: BaseTexture[];
  37937. /**
  37938. * Environment texture for the scene
  37939. */
  37940. environmentTexture: Nullable<BaseTexture>;
  37941. /**
  37942. * @returns all meshes, lights, cameras, transformNodes and bones
  37943. */
  37944. getNodes(): Array<Node>;
  37945. }
  37946. }
  37947. declare module "babylonjs/Audio/sound" {
  37948. import { Observable } from "babylonjs/Misc/observable";
  37949. import { Vector3 } from "babylonjs/Maths/math.vector";
  37950. import { Nullable } from "babylonjs/types";
  37951. import { Scene } from "babylonjs/scene";
  37952. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37953. /**
  37954. * Interface used to define options for Sound class
  37955. */
  37956. export interface ISoundOptions {
  37957. /**
  37958. * Does the sound autoplay once loaded.
  37959. */
  37960. autoplay?: boolean;
  37961. /**
  37962. * Does the sound loop after it finishes playing once.
  37963. */
  37964. loop?: boolean;
  37965. /**
  37966. * Sound's volume
  37967. */
  37968. volume?: number;
  37969. /**
  37970. * Is it a spatial sound?
  37971. */
  37972. spatialSound?: boolean;
  37973. /**
  37974. * Maximum distance to hear that sound
  37975. */
  37976. maxDistance?: number;
  37977. /**
  37978. * Uses user defined attenuation function
  37979. */
  37980. useCustomAttenuation?: boolean;
  37981. /**
  37982. * Define the roll off factor of spatial sounds.
  37983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37984. */
  37985. rolloffFactor?: number;
  37986. /**
  37987. * Define the reference distance the sound should be heard perfectly.
  37988. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37989. */
  37990. refDistance?: number;
  37991. /**
  37992. * Define the distance attenuation model the sound will follow.
  37993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37994. */
  37995. distanceModel?: string;
  37996. /**
  37997. * Defines the playback speed (1 by default)
  37998. */
  37999. playbackRate?: number;
  38000. /**
  38001. * Defines if the sound is from a streaming source
  38002. */
  38003. streaming?: boolean;
  38004. /**
  38005. * Defines an optional length (in seconds) inside the sound file
  38006. */
  38007. length?: number;
  38008. /**
  38009. * Defines an optional offset (in seconds) inside the sound file
  38010. */
  38011. offset?: number;
  38012. /**
  38013. * If true, URLs will not be required to state the audio file codec to use.
  38014. */
  38015. skipCodecCheck?: boolean;
  38016. }
  38017. /**
  38018. * Defines a sound that can be played in the application.
  38019. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38021. */
  38022. export class Sound {
  38023. /**
  38024. * The name of the sound in the scene.
  38025. */
  38026. name: string;
  38027. /**
  38028. * Does the sound autoplay once loaded.
  38029. */
  38030. autoplay: boolean;
  38031. /**
  38032. * Does the sound loop after it finishes playing once.
  38033. */
  38034. loop: boolean;
  38035. /**
  38036. * Does the sound use a custom attenuation curve to simulate the falloff
  38037. * happening when the source gets further away from the camera.
  38038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38039. */
  38040. useCustomAttenuation: boolean;
  38041. /**
  38042. * The sound track id this sound belongs to.
  38043. */
  38044. soundTrackId: number;
  38045. /**
  38046. * Is this sound currently played.
  38047. */
  38048. isPlaying: boolean;
  38049. /**
  38050. * Is this sound currently paused.
  38051. */
  38052. isPaused: boolean;
  38053. /**
  38054. * Does this sound enables spatial sound.
  38055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38056. */
  38057. spatialSound: boolean;
  38058. /**
  38059. * Define the reference distance the sound should be heard perfectly.
  38060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38061. */
  38062. refDistance: number;
  38063. /**
  38064. * Define the roll off factor of spatial sounds.
  38065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38066. */
  38067. rolloffFactor: number;
  38068. /**
  38069. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38071. */
  38072. maxDistance: number;
  38073. /**
  38074. * Define the distance attenuation model the sound will follow.
  38075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38076. */
  38077. distanceModel: string;
  38078. /**
  38079. * @hidden
  38080. * Back Compat
  38081. **/
  38082. onended: () => any;
  38083. /**
  38084. * Observable event when the current playing sound finishes.
  38085. */
  38086. onEndedObservable: Observable<Sound>;
  38087. private _panningModel;
  38088. private _playbackRate;
  38089. private _streaming;
  38090. private _startTime;
  38091. private _startOffset;
  38092. private _position;
  38093. /** @hidden */
  38094. _positionInEmitterSpace: boolean;
  38095. private _localDirection;
  38096. private _volume;
  38097. private _isReadyToPlay;
  38098. private _isDirectional;
  38099. private _readyToPlayCallback;
  38100. private _audioBuffer;
  38101. private _soundSource;
  38102. private _streamingSource;
  38103. private _soundPanner;
  38104. private _soundGain;
  38105. private _inputAudioNode;
  38106. private _outputAudioNode;
  38107. private _coneInnerAngle;
  38108. private _coneOuterAngle;
  38109. private _coneOuterGain;
  38110. private _scene;
  38111. private _connectedTransformNode;
  38112. private _customAttenuationFunction;
  38113. private _registerFunc;
  38114. private _isOutputConnected;
  38115. private _htmlAudioElement;
  38116. private _urlType;
  38117. private _length?;
  38118. private _offset?;
  38119. /** @hidden */
  38120. static _SceneComponentInitialization: (scene: Scene) => void;
  38121. /**
  38122. * Create a sound and attach it to a scene
  38123. * @param name Name of your sound
  38124. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38125. * @param scene defines the scene the sound belongs to
  38126. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38127. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38128. */
  38129. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38130. /**
  38131. * Release the sound and its associated resources
  38132. */
  38133. dispose(): void;
  38134. /**
  38135. * Gets if the sounds is ready to be played or not.
  38136. * @returns true if ready, otherwise false
  38137. */
  38138. isReady(): boolean;
  38139. private _soundLoaded;
  38140. /**
  38141. * Sets the data of the sound from an audiobuffer
  38142. * @param audioBuffer The audioBuffer containing the data
  38143. */
  38144. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38145. /**
  38146. * Updates the current sounds options such as maxdistance, loop...
  38147. * @param options A JSON object containing values named as the object properties
  38148. */
  38149. updateOptions(options: ISoundOptions): void;
  38150. private _createSpatialParameters;
  38151. private _updateSpatialParameters;
  38152. /**
  38153. * Switch the panning model to HRTF:
  38154. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38156. */
  38157. switchPanningModelToHRTF(): void;
  38158. /**
  38159. * Switch the panning model to Equal Power:
  38160. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38162. */
  38163. switchPanningModelToEqualPower(): void;
  38164. private _switchPanningModel;
  38165. /**
  38166. * Connect this sound to a sound track audio node like gain...
  38167. * @param soundTrackAudioNode the sound track audio node to connect to
  38168. */
  38169. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38170. /**
  38171. * Transform this sound into a directional source
  38172. * @param coneInnerAngle Size of the inner cone in degree
  38173. * @param coneOuterAngle Size of the outer cone in degree
  38174. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38175. */
  38176. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38177. /**
  38178. * Gets or sets the inner angle for the directional cone.
  38179. */
  38180. get directionalConeInnerAngle(): number;
  38181. /**
  38182. * Gets or sets the inner angle for the directional cone.
  38183. */
  38184. set directionalConeInnerAngle(value: number);
  38185. /**
  38186. * Gets or sets the outer angle for the directional cone.
  38187. */
  38188. get directionalConeOuterAngle(): number;
  38189. /**
  38190. * Gets or sets the outer angle for the directional cone.
  38191. */
  38192. set directionalConeOuterAngle(value: number);
  38193. /**
  38194. * Sets the position of the emitter if spatial sound is enabled
  38195. * @param newPosition Defines the new posisiton
  38196. */
  38197. setPosition(newPosition: Vector3): void;
  38198. /**
  38199. * Sets the local direction of the emitter if spatial sound is enabled
  38200. * @param newLocalDirection Defines the new local direction
  38201. */
  38202. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38203. private _updateDirection;
  38204. /** @hidden */
  38205. updateDistanceFromListener(): void;
  38206. /**
  38207. * Sets a new custom attenuation function for the sound.
  38208. * @param callback Defines the function used for the attenuation
  38209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38210. */
  38211. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38212. /**
  38213. * Play the sound
  38214. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38215. * @param offset (optional) Start the sound at a specific time in seconds
  38216. * @param length (optional) Sound duration (in seconds)
  38217. */
  38218. play(time?: number, offset?: number, length?: number): void;
  38219. private _onended;
  38220. /**
  38221. * Stop the sound
  38222. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38223. */
  38224. stop(time?: number): void;
  38225. /**
  38226. * Put the sound in pause
  38227. */
  38228. pause(): void;
  38229. /**
  38230. * Sets a dedicated volume for this sounds
  38231. * @param newVolume Define the new volume of the sound
  38232. * @param time Define time for gradual change to new volume
  38233. */
  38234. setVolume(newVolume: number, time?: number): void;
  38235. /**
  38236. * Set the sound play back rate
  38237. * @param newPlaybackRate Define the playback rate the sound should be played at
  38238. */
  38239. setPlaybackRate(newPlaybackRate: number): void;
  38240. /**
  38241. * Gets the volume of the sound.
  38242. * @returns the volume of the sound
  38243. */
  38244. getVolume(): number;
  38245. /**
  38246. * Attach the sound to a dedicated mesh
  38247. * @param transformNode The transform node to connect the sound with
  38248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38249. */
  38250. attachToMesh(transformNode: TransformNode): void;
  38251. /**
  38252. * Detach the sound from the previously attached mesh
  38253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38254. */
  38255. detachFromMesh(): void;
  38256. private _onRegisterAfterWorldMatrixUpdate;
  38257. /**
  38258. * Clone the current sound in the scene.
  38259. * @returns the new sound clone
  38260. */
  38261. clone(): Nullable<Sound>;
  38262. /**
  38263. * Gets the current underlying audio buffer containing the data
  38264. * @returns the audio buffer
  38265. */
  38266. getAudioBuffer(): Nullable<AudioBuffer>;
  38267. /**
  38268. * Serializes the Sound in a JSON representation
  38269. * @returns the JSON representation of the sound
  38270. */
  38271. serialize(): any;
  38272. /**
  38273. * Parse a JSON representation of a sound to innstantiate in a given scene
  38274. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38275. * @param scene Define the scene the new parsed sound should be created in
  38276. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38277. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38278. * @returns the newly parsed sound
  38279. */
  38280. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38281. }
  38282. }
  38283. declare module "babylonjs/Actions/directAudioActions" {
  38284. import { Action } from "babylonjs/Actions/action";
  38285. import { Condition } from "babylonjs/Actions/condition";
  38286. import { Sound } from "babylonjs/Audio/sound";
  38287. /**
  38288. * This defines an action helpful to play a defined sound on a triggered action.
  38289. */
  38290. export class PlaySoundAction extends Action {
  38291. private _sound;
  38292. /**
  38293. * Instantiate the action
  38294. * @param triggerOptions defines the trigger options
  38295. * @param sound defines the sound to play
  38296. * @param condition defines the trigger related conditions
  38297. */
  38298. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38299. /** @hidden */
  38300. _prepare(): void;
  38301. /**
  38302. * Execute the action and play the sound.
  38303. */
  38304. execute(): void;
  38305. /**
  38306. * Serializes the actions and its related information.
  38307. * @param parent defines the object to serialize in
  38308. * @returns the serialized object
  38309. */
  38310. serialize(parent: any): any;
  38311. }
  38312. /**
  38313. * This defines an action helpful to stop a defined sound on a triggered action.
  38314. */
  38315. export class StopSoundAction extends Action {
  38316. private _sound;
  38317. /**
  38318. * Instantiate the action
  38319. * @param triggerOptions defines the trigger options
  38320. * @param sound defines the sound to stop
  38321. * @param condition defines the trigger related conditions
  38322. */
  38323. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38324. /** @hidden */
  38325. _prepare(): void;
  38326. /**
  38327. * Execute the action and stop the sound.
  38328. */
  38329. execute(): void;
  38330. /**
  38331. * Serializes the actions and its related information.
  38332. * @param parent defines the object to serialize in
  38333. * @returns the serialized object
  38334. */
  38335. serialize(parent: any): any;
  38336. }
  38337. }
  38338. declare module "babylonjs/Actions/interpolateValueAction" {
  38339. import { Action } from "babylonjs/Actions/action";
  38340. import { Condition } from "babylonjs/Actions/condition";
  38341. import { Observable } from "babylonjs/Misc/observable";
  38342. /**
  38343. * This defines an action responsible to change the value of a property
  38344. * by interpolating between its current value and the newly set one once triggered.
  38345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38346. */
  38347. export class InterpolateValueAction extends Action {
  38348. /**
  38349. * Defines the path of the property where the value should be interpolated
  38350. */
  38351. propertyPath: string;
  38352. /**
  38353. * Defines the target value at the end of the interpolation.
  38354. */
  38355. value: any;
  38356. /**
  38357. * Defines the time it will take for the property to interpolate to the value.
  38358. */
  38359. duration: number;
  38360. /**
  38361. * Defines if the other scene animations should be stopped when the action has been triggered
  38362. */
  38363. stopOtherAnimations?: boolean;
  38364. /**
  38365. * Defines a callback raised once the interpolation animation has been done.
  38366. */
  38367. onInterpolationDone?: () => void;
  38368. /**
  38369. * Observable triggered once the interpolation animation has been done.
  38370. */
  38371. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38372. private _target;
  38373. private _effectiveTarget;
  38374. private _property;
  38375. /**
  38376. * Instantiate the action
  38377. * @param triggerOptions defines the trigger options
  38378. * @param target defines the object containing the value to interpolate
  38379. * @param propertyPath defines the path to the property in the target object
  38380. * @param value defines the target value at the end of the interpolation
  38381. * @param duration deines the time it will take for the property to interpolate to the value.
  38382. * @param condition defines the trigger related conditions
  38383. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38384. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38385. */
  38386. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38387. /** @hidden */
  38388. _prepare(): void;
  38389. /**
  38390. * Execute the action starts the value interpolation.
  38391. */
  38392. execute(): void;
  38393. /**
  38394. * Serializes the actions and its related information.
  38395. * @param parent defines the object to serialize in
  38396. * @returns the serialized object
  38397. */
  38398. serialize(parent: any): any;
  38399. }
  38400. }
  38401. declare module "babylonjs/Actions/index" {
  38402. export * from "babylonjs/Actions/abstractActionManager";
  38403. export * from "babylonjs/Actions/action";
  38404. export * from "babylonjs/Actions/actionEvent";
  38405. export * from "babylonjs/Actions/actionManager";
  38406. export * from "babylonjs/Actions/condition";
  38407. export * from "babylonjs/Actions/directActions";
  38408. export * from "babylonjs/Actions/directAudioActions";
  38409. export * from "babylonjs/Actions/interpolateValueAction";
  38410. }
  38411. declare module "babylonjs/Animations/index" {
  38412. export * from "babylonjs/Animations/animatable";
  38413. export * from "babylonjs/Animations/animation";
  38414. export * from "babylonjs/Animations/animationGroup";
  38415. export * from "babylonjs/Animations/animationPropertiesOverride";
  38416. export * from "babylonjs/Animations/easing";
  38417. export * from "babylonjs/Animations/runtimeAnimation";
  38418. export * from "babylonjs/Animations/animationEvent";
  38419. export * from "babylonjs/Animations/animationGroup";
  38420. export * from "babylonjs/Animations/animationKey";
  38421. export * from "babylonjs/Animations/animationRange";
  38422. export * from "babylonjs/Animations/animatable.interface";
  38423. }
  38424. declare module "babylonjs/Audio/soundTrack" {
  38425. import { Sound } from "babylonjs/Audio/sound";
  38426. import { Analyser } from "babylonjs/Audio/analyser";
  38427. import { Scene } from "babylonjs/scene";
  38428. /**
  38429. * Options allowed during the creation of a sound track.
  38430. */
  38431. export interface ISoundTrackOptions {
  38432. /**
  38433. * The volume the sound track should take during creation
  38434. */
  38435. volume?: number;
  38436. /**
  38437. * Define if the sound track is the main sound track of the scene
  38438. */
  38439. mainTrack?: boolean;
  38440. }
  38441. /**
  38442. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38443. * It will be also used in a future release to apply effects on a specific track.
  38444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38445. */
  38446. export class SoundTrack {
  38447. /**
  38448. * The unique identifier of the sound track in the scene.
  38449. */
  38450. id: number;
  38451. /**
  38452. * The list of sounds included in the sound track.
  38453. */
  38454. soundCollection: Array<Sound>;
  38455. private _outputAudioNode;
  38456. private _scene;
  38457. private _connectedAnalyser;
  38458. private _options;
  38459. private _isInitialized;
  38460. /**
  38461. * Creates a new sound track.
  38462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38463. * @param scene Define the scene the sound track belongs to
  38464. * @param options
  38465. */
  38466. constructor(scene: Scene, options?: ISoundTrackOptions);
  38467. private _initializeSoundTrackAudioGraph;
  38468. /**
  38469. * Release the sound track and its associated resources
  38470. */
  38471. dispose(): void;
  38472. /**
  38473. * Adds a sound to this sound track
  38474. * @param sound define the cound to add
  38475. * @ignoreNaming
  38476. */
  38477. AddSound(sound: Sound): void;
  38478. /**
  38479. * Removes a sound to this sound track
  38480. * @param sound define the cound to remove
  38481. * @ignoreNaming
  38482. */
  38483. RemoveSound(sound: Sound): void;
  38484. /**
  38485. * Set a global volume for the full sound track.
  38486. * @param newVolume Define the new volume of the sound track
  38487. */
  38488. setVolume(newVolume: number): void;
  38489. /**
  38490. * Switch the panning model to HRTF:
  38491. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38493. */
  38494. switchPanningModelToHRTF(): void;
  38495. /**
  38496. * Switch the panning model to Equal Power:
  38497. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38499. */
  38500. switchPanningModelToEqualPower(): void;
  38501. /**
  38502. * Connect the sound track to an audio analyser allowing some amazing
  38503. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38505. * @param analyser The analyser to connect to the engine
  38506. */
  38507. connectToAnalyser(analyser: Analyser): void;
  38508. }
  38509. }
  38510. declare module "babylonjs/Audio/audioSceneComponent" {
  38511. import { Sound } from "babylonjs/Audio/sound";
  38512. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38513. import { Nullable } from "babylonjs/types";
  38514. import { Vector3 } from "babylonjs/Maths/math.vector";
  38515. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38516. import { Scene } from "babylonjs/scene";
  38517. import { AbstractScene } from "babylonjs/abstractScene";
  38518. import "babylonjs/Audio/audioEngine";
  38519. module "babylonjs/abstractScene" {
  38520. interface AbstractScene {
  38521. /**
  38522. * The list of sounds used in the scene.
  38523. */
  38524. sounds: Nullable<Array<Sound>>;
  38525. }
  38526. }
  38527. module "babylonjs/scene" {
  38528. interface Scene {
  38529. /**
  38530. * @hidden
  38531. * Backing field
  38532. */
  38533. _mainSoundTrack: SoundTrack;
  38534. /**
  38535. * The main sound track played by the scene.
  38536. * It cotains your primary collection of sounds.
  38537. */
  38538. mainSoundTrack: SoundTrack;
  38539. /**
  38540. * The list of sound tracks added to the scene
  38541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38542. */
  38543. soundTracks: Nullable<Array<SoundTrack>>;
  38544. /**
  38545. * Gets a sound using a given name
  38546. * @param name defines the name to search for
  38547. * @return the found sound or null if not found at all.
  38548. */
  38549. getSoundByName(name: string): Nullable<Sound>;
  38550. /**
  38551. * Gets or sets if audio support is enabled
  38552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38553. */
  38554. audioEnabled: boolean;
  38555. /**
  38556. * Gets or sets if audio will be output to headphones
  38557. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38558. */
  38559. headphone: boolean;
  38560. /**
  38561. * Gets or sets custom audio listener position provider
  38562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38563. */
  38564. audioListenerPositionProvider: Nullable<() => Vector3>;
  38565. /**
  38566. * Gets or sets a refresh rate when using 3D audio positioning
  38567. */
  38568. audioPositioningRefreshRate: number;
  38569. }
  38570. }
  38571. /**
  38572. * Defines the sound scene component responsible to manage any sounds
  38573. * in a given scene.
  38574. */
  38575. export class AudioSceneComponent implements ISceneSerializableComponent {
  38576. /**
  38577. * The component name helpfull to identify the component in the list of scene components.
  38578. */
  38579. readonly name: string;
  38580. /**
  38581. * The scene the component belongs to.
  38582. */
  38583. scene: Scene;
  38584. private _audioEnabled;
  38585. /**
  38586. * Gets whether audio is enabled or not.
  38587. * Please use related enable/disable method to switch state.
  38588. */
  38589. get audioEnabled(): boolean;
  38590. private _headphone;
  38591. /**
  38592. * Gets whether audio is outputing to headphone or not.
  38593. * Please use the according Switch methods to change output.
  38594. */
  38595. get headphone(): boolean;
  38596. /**
  38597. * Gets or sets a refresh rate when using 3D audio positioning
  38598. */
  38599. audioPositioningRefreshRate: number;
  38600. private _audioListenerPositionProvider;
  38601. /**
  38602. * Gets the current audio listener position provider
  38603. */
  38604. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38605. /**
  38606. * Sets a custom listener position for all sounds in the scene
  38607. * By default, this is the position of the first active camera
  38608. */
  38609. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38610. /**
  38611. * Creates a new instance of the component for the given scene
  38612. * @param scene Defines the scene to register the component in
  38613. */
  38614. constructor(scene: Scene);
  38615. /**
  38616. * Registers the component in a given scene
  38617. */
  38618. register(): void;
  38619. /**
  38620. * Rebuilds the elements related to this component in case of
  38621. * context lost for instance.
  38622. */
  38623. rebuild(): void;
  38624. /**
  38625. * Serializes the component data to the specified json object
  38626. * @param serializationObject The object to serialize to
  38627. */
  38628. serialize(serializationObject: any): void;
  38629. /**
  38630. * Adds all the elements from the container to the scene
  38631. * @param container the container holding the elements
  38632. */
  38633. addFromContainer(container: AbstractScene): void;
  38634. /**
  38635. * Removes all the elements in the container from the scene
  38636. * @param container contains the elements to remove
  38637. * @param dispose if the removed element should be disposed (default: false)
  38638. */
  38639. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38640. /**
  38641. * Disposes the component and the associated ressources.
  38642. */
  38643. dispose(): void;
  38644. /**
  38645. * Disables audio in the associated scene.
  38646. */
  38647. disableAudio(): void;
  38648. /**
  38649. * Enables audio in the associated scene.
  38650. */
  38651. enableAudio(): void;
  38652. /**
  38653. * Switch audio to headphone output.
  38654. */
  38655. switchAudioModeForHeadphones(): void;
  38656. /**
  38657. * Switch audio to normal speakers.
  38658. */
  38659. switchAudioModeForNormalSpeakers(): void;
  38660. private _cachedCameraDirection;
  38661. private _cachedCameraPosition;
  38662. private _lastCheck;
  38663. private _afterRender;
  38664. }
  38665. }
  38666. declare module "babylonjs/Audio/weightedsound" {
  38667. import { Sound } from "babylonjs/Audio/sound";
  38668. /**
  38669. * Wraps one or more Sound objects and selects one with random weight for playback.
  38670. */
  38671. export class WeightedSound {
  38672. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38673. loop: boolean;
  38674. private _coneInnerAngle;
  38675. private _coneOuterAngle;
  38676. private _volume;
  38677. /** A Sound is currently playing. */
  38678. isPlaying: boolean;
  38679. /** A Sound is currently paused. */
  38680. isPaused: boolean;
  38681. private _sounds;
  38682. private _weights;
  38683. private _currentIndex?;
  38684. /**
  38685. * Creates a new WeightedSound from the list of sounds given.
  38686. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38687. * @param sounds Array of Sounds that will be selected from.
  38688. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38689. */
  38690. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38691. /**
  38692. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38693. */
  38694. get directionalConeInnerAngle(): number;
  38695. /**
  38696. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38697. */
  38698. set directionalConeInnerAngle(value: number);
  38699. /**
  38700. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38701. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38702. */
  38703. get directionalConeOuterAngle(): number;
  38704. /**
  38705. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38706. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38707. */
  38708. set directionalConeOuterAngle(value: number);
  38709. /**
  38710. * Playback volume.
  38711. */
  38712. get volume(): number;
  38713. /**
  38714. * Playback volume.
  38715. */
  38716. set volume(value: number);
  38717. private _onended;
  38718. /**
  38719. * Suspend playback
  38720. */
  38721. pause(): void;
  38722. /**
  38723. * Stop playback
  38724. */
  38725. stop(): void;
  38726. /**
  38727. * Start playback.
  38728. * @param startOffset Position the clip head at a specific time in seconds.
  38729. */
  38730. play(startOffset?: number): void;
  38731. }
  38732. }
  38733. declare module "babylonjs/Audio/index" {
  38734. export * from "babylonjs/Audio/analyser";
  38735. export * from "babylonjs/Audio/audioEngine";
  38736. export * from "babylonjs/Audio/audioSceneComponent";
  38737. export * from "babylonjs/Audio/sound";
  38738. export * from "babylonjs/Audio/soundTrack";
  38739. export * from "babylonjs/Audio/weightedsound";
  38740. }
  38741. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38742. import { Behavior } from "babylonjs/Behaviors/behavior";
  38743. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38744. import { BackEase } from "babylonjs/Animations/easing";
  38745. /**
  38746. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38747. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38748. */
  38749. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38750. /**
  38751. * Gets the name of the behavior.
  38752. */
  38753. get name(): string;
  38754. /**
  38755. * The easing function used by animations
  38756. */
  38757. static EasingFunction: BackEase;
  38758. /**
  38759. * The easing mode used by animations
  38760. */
  38761. static EasingMode: number;
  38762. /**
  38763. * The duration of the animation, in milliseconds
  38764. */
  38765. transitionDuration: number;
  38766. /**
  38767. * Length of the distance animated by the transition when lower radius is reached
  38768. */
  38769. lowerRadiusTransitionRange: number;
  38770. /**
  38771. * Length of the distance animated by the transition when upper radius is reached
  38772. */
  38773. upperRadiusTransitionRange: number;
  38774. private _autoTransitionRange;
  38775. /**
  38776. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38777. */
  38778. get autoTransitionRange(): boolean;
  38779. /**
  38780. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38781. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38782. */
  38783. set autoTransitionRange(value: boolean);
  38784. private _attachedCamera;
  38785. private _onAfterCheckInputsObserver;
  38786. private _onMeshTargetChangedObserver;
  38787. /**
  38788. * Initializes the behavior.
  38789. */
  38790. init(): void;
  38791. /**
  38792. * Attaches the behavior to its arc rotate camera.
  38793. * @param camera Defines the camera to attach the behavior to
  38794. */
  38795. attach(camera: ArcRotateCamera): void;
  38796. /**
  38797. * Detaches the behavior from its current arc rotate camera.
  38798. */
  38799. detach(): void;
  38800. private _radiusIsAnimating;
  38801. private _radiusBounceTransition;
  38802. private _animatables;
  38803. private _cachedWheelPrecision;
  38804. /**
  38805. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38806. * @param radiusLimit The limit to check against.
  38807. * @return Bool to indicate if at limit.
  38808. */
  38809. private _isRadiusAtLimit;
  38810. /**
  38811. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38812. * @param radiusDelta The delta by which to animate to. Can be negative.
  38813. */
  38814. private _applyBoundRadiusAnimation;
  38815. /**
  38816. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38817. */
  38818. protected _clearAnimationLocks(): void;
  38819. /**
  38820. * Stops and removes all animations that have been applied to the camera
  38821. */
  38822. stopAllAnimations(): void;
  38823. }
  38824. }
  38825. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38826. import { Behavior } from "babylonjs/Behaviors/behavior";
  38827. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38828. import { ExponentialEase } from "babylonjs/Animations/easing";
  38829. import { Nullable } from "babylonjs/types";
  38830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38831. import { Vector3 } from "babylonjs/Maths/math.vector";
  38832. /**
  38833. * 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.
  38834. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38835. */
  38836. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38837. /**
  38838. * Gets the name of the behavior.
  38839. */
  38840. get name(): string;
  38841. private _mode;
  38842. private _radiusScale;
  38843. private _positionScale;
  38844. private _defaultElevation;
  38845. private _elevationReturnTime;
  38846. private _elevationReturnWaitTime;
  38847. private _zoomStopsAnimation;
  38848. private _framingTime;
  38849. /**
  38850. * The easing function used by animations
  38851. */
  38852. static EasingFunction: ExponentialEase;
  38853. /**
  38854. * The easing mode used by animations
  38855. */
  38856. static EasingMode: number;
  38857. /**
  38858. * Sets the current mode used by the behavior
  38859. */
  38860. set mode(mode: number);
  38861. /**
  38862. * Gets current mode used by the behavior.
  38863. */
  38864. get mode(): number;
  38865. /**
  38866. * Sets the scale applied to the radius (1 by default)
  38867. */
  38868. set radiusScale(radius: number);
  38869. /**
  38870. * Gets the scale applied to the radius
  38871. */
  38872. get radiusScale(): number;
  38873. /**
  38874. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38875. */
  38876. set positionScale(scale: number);
  38877. /**
  38878. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38879. */
  38880. get positionScale(): number;
  38881. /**
  38882. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38883. * behaviour is triggered, in radians.
  38884. */
  38885. set defaultElevation(elevation: number);
  38886. /**
  38887. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38888. * behaviour is triggered, in radians.
  38889. */
  38890. get defaultElevation(): number;
  38891. /**
  38892. * Sets the time (in milliseconds) taken to return to the default beta position.
  38893. * Negative value indicates camera should not return to default.
  38894. */
  38895. set elevationReturnTime(speed: number);
  38896. /**
  38897. * Gets the time (in milliseconds) taken to return to the default beta position.
  38898. * Negative value indicates camera should not return to default.
  38899. */
  38900. get elevationReturnTime(): number;
  38901. /**
  38902. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38903. */
  38904. set elevationReturnWaitTime(time: number);
  38905. /**
  38906. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38907. */
  38908. get elevationReturnWaitTime(): number;
  38909. /**
  38910. * Sets the flag that indicates if user zooming should stop animation.
  38911. */
  38912. set zoomStopsAnimation(flag: boolean);
  38913. /**
  38914. * Gets the flag that indicates if user zooming should stop animation.
  38915. */
  38916. get zoomStopsAnimation(): boolean;
  38917. /**
  38918. * Sets the transition time when framing the mesh, in milliseconds
  38919. */
  38920. set framingTime(time: number);
  38921. /**
  38922. * Gets the transition time when framing the mesh, in milliseconds
  38923. */
  38924. get framingTime(): number;
  38925. /**
  38926. * Define if the behavior should automatically change the configured
  38927. * camera limits and sensibilities.
  38928. */
  38929. autoCorrectCameraLimitsAndSensibility: boolean;
  38930. private _onPrePointerObservableObserver;
  38931. private _onAfterCheckInputsObserver;
  38932. private _onMeshTargetChangedObserver;
  38933. private _attachedCamera;
  38934. private _isPointerDown;
  38935. private _lastInteractionTime;
  38936. /**
  38937. * Initializes the behavior.
  38938. */
  38939. init(): void;
  38940. /**
  38941. * Attaches the behavior to its arc rotate camera.
  38942. * @param camera Defines the camera to attach the behavior to
  38943. */
  38944. attach(camera: ArcRotateCamera): void;
  38945. /**
  38946. * Detaches the behavior from its current arc rotate camera.
  38947. */
  38948. detach(): void;
  38949. private _animatables;
  38950. private _betaIsAnimating;
  38951. private _betaTransition;
  38952. private _radiusTransition;
  38953. private _vectorTransition;
  38954. /**
  38955. * Targets the given mesh and updates zoom level accordingly.
  38956. * @param mesh The mesh to target.
  38957. * @param radius Optional. If a cached radius position already exists, overrides default.
  38958. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38959. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38960. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38961. */
  38962. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38963. /**
  38964. * Targets the given mesh with its children and updates zoom level accordingly.
  38965. * @param mesh The mesh to target.
  38966. * @param radius Optional. If a cached radius position already exists, overrides default.
  38967. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38968. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38969. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38970. */
  38971. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38972. /**
  38973. * Targets the given meshes with their children and updates zoom level accordingly.
  38974. * @param meshes The mesh to target.
  38975. * @param radius Optional. If a cached radius position already exists, overrides default.
  38976. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38977. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38978. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38979. */
  38980. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38981. /**
  38982. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38983. * @param minimumWorld Determines the smaller position of the bounding box extend
  38984. * @param maximumWorld Determines the bigger position of the bounding box extend
  38985. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38986. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38987. */
  38988. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38989. /**
  38990. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38991. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38992. * frustum width.
  38993. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38994. * to fully enclose the mesh in the viewing frustum.
  38995. */
  38996. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38997. /**
  38998. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38999. * is automatically returned to its default position (expected to be above ground plane).
  39000. */
  39001. private _maintainCameraAboveGround;
  39002. /**
  39003. * Returns the frustum slope based on the canvas ratio and camera FOV
  39004. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39005. */
  39006. private _getFrustumSlope;
  39007. /**
  39008. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39009. */
  39010. private _clearAnimationLocks;
  39011. /**
  39012. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39013. */
  39014. private _applyUserInteraction;
  39015. /**
  39016. * Stops and removes all animations that have been applied to the camera
  39017. */
  39018. stopAllAnimations(): void;
  39019. /**
  39020. * Gets a value indicating if the user is moving the camera
  39021. */
  39022. get isUserIsMoving(): boolean;
  39023. /**
  39024. * The camera can move all the way towards the mesh.
  39025. */
  39026. static IgnoreBoundsSizeMode: number;
  39027. /**
  39028. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39029. */
  39030. static FitFrustumSidesMode: number;
  39031. }
  39032. }
  39033. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39034. import { Nullable } from "babylonjs/types";
  39035. import { Camera } from "babylonjs/Cameras/camera";
  39036. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39037. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39038. /**
  39039. * Base class for Camera Pointer Inputs.
  39040. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39041. * for example usage.
  39042. */
  39043. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39044. /**
  39045. * Defines the camera the input is attached to.
  39046. */
  39047. abstract camera: Camera;
  39048. /**
  39049. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39050. */
  39051. protected _altKey: boolean;
  39052. protected _ctrlKey: boolean;
  39053. protected _metaKey: boolean;
  39054. protected _shiftKey: boolean;
  39055. /**
  39056. * Which mouse buttons were pressed at time of last mouse event.
  39057. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39058. */
  39059. protected _buttonsPressed: number;
  39060. /**
  39061. * Defines the buttons associated with the input to handle camera move.
  39062. */
  39063. buttons: number[];
  39064. /**
  39065. * Attach the input controls to a specific dom element to get the input from.
  39066. * @param element Defines the element the controls should be listened from
  39067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39068. */
  39069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39070. /**
  39071. * Detach the current controls from the specified dom element.
  39072. * @param element Defines the element to stop listening the inputs from
  39073. */
  39074. detachControl(element: Nullable<HTMLElement>): void;
  39075. /**
  39076. * Gets the class name of the current input.
  39077. * @returns the class name
  39078. */
  39079. getClassName(): string;
  39080. /**
  39081. * Get the friendly name associated with the input class.
  39082. * @returns the input friendly name
  39083. */
  39084. getSimpleName(): string;
  39085. /**
  39086. * Called on pointer POINTERDOUBLETAP event.
  39087. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39088. */
  39089. protected onDoubleTap(type: string): void;
  39090. /**
  39091. * Called on pointer POINTERMOVE event if only a single touch is active.
  39092. * Override this method to provide functionality.
  39093. */
  39094. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39095. /**
  39096. * Called on pointer POINTERMOVE event if multiple touches are active.
  39097. * Override this method to provide functionality.
  39098. */
  39099. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39100. /**
  39101. * Called on JS contextmenu event.
  39102. * Override this method to provide functionality.
  39103. */
  39104. protected onContextMenu(evt: PointerEvent): void;
  39105. /**
  39106. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39107. * press.
  39108. * Override this method to provide functionality.
  39109. */
  39110. protected onButtonDown(evt: PointerEvent): void;
  39111. /**
  39112. * Called each time a new POINTERUP event occurs. Ie, for each button
  39113. * release.
  39114. * Override this method to provide functionality.
  39115. */
  39116. protected onButtonUp(evt: PointerEvent): void;
  39117. /**
  39118. * Called when window becomes inactive.
  39119. * Override this method to provide functionality.
  39120. */
  39121. protected onLostFocus(): void;
  39122. private _pointerInput;
  39123. private _observer;
  39124. private _onLostFocus;
  39125. private pointA;
  39126. private pointB;
  39127. }
  39128. }
  39129. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39130. import { Nullable } from "babylonjs/types";
  39131. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39132. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39133. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39134. /**
  39135. * Manage the pointers inputs to control an arc rotate camera.
  39136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39137. */
  39138. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39139. /**
  39140. * Defines the camera the input is attached to.
  39141. */
  39142. camera: ArcRotateCamera;
  39143. /**
  39144. * Gets the class name of the current input.
  39145. * @returns the class name
  39146. */
  39147. getClassName(): string;
  39148. /**
  39149. * Defines the buttons associated with the input to handle camera move.
  39150. */
  39151. buttons: number[];
  39152. /**
  39153. * Defines the pointer angular sensibility along the X axis or how fast is
  39154. * the camera rotating.
  39155. */
  39156. angularSensibilityX: number;
  39157. /**
  39158. * Defines the pointer angular sensibility along the Y axis or how fast is
  39159. * the camera rotating.
  39160. */
  39161. angularSensibilityY: number;
  39162. /**
  39163. * Defines the pointer pinch precision or how fast is the camera zooming.
  39164. */
  39165. pinchPrecision: number;
  39166. /**
  39167. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39168. * from 0.
  39169. * It defines the percentage of current camera.radius to use as delta when
  39170. * pinch zoom is used.
  39171. */
  39172. pinchDeltaPercentage: number;
  39173. /**
  39174. * Defines the pointer panning sensibility or how fast is the camera moving.
  39175. */
  39176. panningSensibility: number;
  39177. /**
  39178. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39179. */
  39180. multiTouchPanning: boolean;
  39181. /**
  39182. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39183. * zoom (pinch) through multitouch.
  39184. */
  39185. multiTouchPanAndZoom: boolean;
  39186. /**
  39187. * Revers pinch action direction.
  39188. */
  39189. pinchInwards: boolean;
  39190. private _isPanClick;
  39191. private _twoFingerActivityCount;
  39192. private _isPinching;
  39193. /**
  39194. * Called on pointer POINTERMOVE event if only a single touch is active.
  39195. */
  39196. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39197. /**
  39198. * Called on pointer POINTERDOUBLETAP event.
  39199. */
  39200. protected onDoubleTap(type: string): void;
  39201. /**
  39202. * Called on pointer POINTERMOVE event if multiple touches are active.
  39203. */
  39204. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39205. /**
  39206. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39207. * press.
  39208. */
  39209. protected onButtonDown(evt: PointerEvent): void;
  39210. /**
  39211. * Called each time a new POINTERUP event occurs. Ie, for each button
  39212. * release.
  39213. */
  39214. protected onButtonUp(evt: PointerEvent): void;
  39215. /**
  39216. * Called when window becomes inactive.
  39217. */
  39218. protected onLostFocus(): void;
  39219. }
  39220. }
  39221. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39222. import { Nullable } from "babylonjs/types";
  39223. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39224. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39225. /**
  39226. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39228. */
  39229. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39230. /**
  39231. * Defines the camera the input is attached to.
  39232. */
  39233. camera: ArcRotateCamera;
  39234. /**
  39235. * Defines the list of key codes associated with the up action (increase alpha)
  39236. */
  39237. keysUp: number[];
  39238. /**
  39239. * Defines the list of key codes associated with the down action (decrease alpha)
  39240. */
  39241. keysDown: number[];
  39242. /**
  39243. * Defines the list of key codes associated with the left action (increase beta)
  39244. */
  39245. keysLeft: number[];
  39246. /**
  39247. * Defines the list of key codes associated with the right action (decrease beta)
  39248. */
  39249. keysRight: number[];
  39250. /**
  39251. * Defines the list of key codes associated with the reset action.
  39252. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39253. */
  39254. keysReset: number[];
  39255. /**
  39256. * Defines the panning sensibility of the inputs.
  39257. * (How fast is the camera paning)
  39258. */
  39259. panningSensibility: number;
  39260. /**
  39261. * Defines the zooming sensibility of the inputs.
  39262. * (How fast is the camera zooming)
  39263. */
  39264. zoomingSensibility: number;
  39265. /**
  39266. * Defines wether maintaining the alt key down switch the movement mode from
  39267. * orientation to zoom.
  39268. */
  39269. useAltToZoom: boolean;
  39270. /**
  39271. * Rotation speed of the camera
  39272. */
  39273. angularSpeed: number;
  39274. private _keys;
  39275. private _ctrlPressed;
  39276. private _altPressed;
  39277. private _onCanvasBlurObserver;
  39278. private _onKeyboardObserver;
  39279. private _engine;
  39280. private _scene;
  39281. /**
  39282. * Attach the input controls to a specific dom element to get the input from.
  39283. * @param element Defines the element the controls should be listened from
  39284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39285. */
  39286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39287. /**
  39288. * Detach the current controls from the specified dom element.
  39289. * @param element Defines the element to stop listening the inputs from
  39290. */
  39291. detachControl(element: Nullable<HTMLElement>): void;
  39292. /**
  39293. * Update the current camera state depending on the inputs that have been used this frame.
  39294. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39295. */
  39296. checkInputs(): void;
  39297. /**
  39298. * Gets the class name of the current intput.
  39299. * @returns the class name
  39300. */
  39301. getClassName(): string;
  39302. /**
  39303. * Get the friendly name associated with the input class.
  39304. * @returns the input friendly name
  39305. */
  39306. getSimpleName(): string;
  39307. }
  39308. }
  39309. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39310. import { Nullable } from "babylonjs/types";
  39311. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39312. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39313. /**
  39314. * Manage the mouse wheel inputs to control an arc rotate camera.
  39315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39316. */
  39317. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39318. /**
  39319. * Defines the camera the input is attached to.
  39320. */
  39321. camera: ArcRotateCamera;
  39322. /**
  39323. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39324. */
  39325. wheelPrecision: number;
  39326. /**
  39327. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39328. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39329. */
  39330. wheelDeltaPercentage: number;
  39331. private _wheel;
  39332. private _observer;
  39333. private computeDeltaFromMouseWheelLegacyEvent;
  39334. /**
  39335. * Attach the input controls to a specific dom element to get the input from.
  39336. * @param element Defines the element the controls should be listened from
  39337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39338. */
  39339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39340. /**
  39341. * Detach the current controls from the specified dom element.
  39342. * @param element Defines the element to stop listening the inputs from
  39343. */
  39344. detachControl(element: Nullable<HTMLElement>): void;
  39345. /**
  39346. * Gets the class name of the current intput.
  39347. * @returns the class name
  39348. */
  39349. getClassName(): string;
  39350. /**
  39351. * Get the friendly name associated with the input class.
  39352. * @returns the input friendly name
  39353. */
  39354. getSimpleName(): string;
  39355. }
  39356. }
  39357. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39358. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39359. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39360. /**
  39361. * Default Inputs manager for the ArcRotateCamera.
  39362. * It groups all the default supported inputs for ease of use.
  39363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39364. */
  39365. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39366. /**
  39367. * Instantiates a new ArcRotateCameraInputsManager.
  39368. * @param camera Defines the camera the inputs belong to
  39369. */
  39370. constructor(camera: ArcRotateCamera);
  39371. /**
  39372. * Add mouse wheel input support to the input manager.
  39373. * @returns the current input manager
  39374. */
  39375. addMouseWheel(): ArcRotateCameraInputsManager;
  39376. /**
  39377. * Add pointers input support to the input manager.
  39378. * @returns the current input manager
  39379. */
  39380. addPointers(): ArcRotateCameraInputsManager;
  39381. /**
  39382. * Add keyboard input support to the input manager.
  39383. * @returns the current input manager
  39384. */
  39385. addKeyboard(): ArcRotateCameraInputsManager;
  39386. }
  39387. }
  39388. declare module "babylonjs/Cameras/arcRotateCamera" {
  39389. import { Observable } from "babylonjs/Misc/observable";
  39390. import { Nullable } from "babylonjs/types";
  39391. import { Scene } from "babylonjs/scene";
  39392. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39394. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39395. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39396. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39397. import { Camera } from "babylonjs/Cameras/camera";
  39398. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39399. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39400. import { Collider } from "babylonjs/Collisions/collider";
  39401. /**
  39402. * This represents an orbital type of camera.
  39403. *
  39404. * 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.
  39405. * 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.
  39406. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39407. */
  39408. export class ArcRotateCamera extends TargetCamera {
  39409. /**
  39410. * Defines the rotation angle of the camera along the longitudinal axis.
  39411. */
  39412. alpha: number;
  39413. /**
  39414. * Defines the rotation angle of the camera along the latitudinal axis.
  39415. */
  39416. beta: number;
  39417. /**
  39418. * Defines the radius of the camera from it s target point.
  39419. */
  39420. radius: number;
  39421. protected _target: Vector3;
  39422. protected _targetHost: Nullable<AbstractMesh>;
  39423. /**
  39424. * Defines the target point of the camera.
  39425. * The camera looks towards it form the radius distance.
  39426. */
  39427. get target(): Vector3;
  39428. set target(value: Vector3);
  39429. /**
  39430. * Define the current local position of the camera in the scene
  39431. */
  39432. get position(): Vector3;
  39433. set position(newPosition: Vector3);
  39434. protected _upVector: Vector3;
  39435. protected _upToYMatrix: Matrix;
  39436. protected _YToUpMatrix: Matrix;
  39437. /**
  39438. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39439. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39440. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39441. */
  39442. set upVector(vec: Vector3);
  39443. get upVector(): Vector3;
  39444. /**
  39445. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39446. */
  39447. setMatUp(): void;
  39448. /**
  39449. * Current inertia value on the longitudinal axis.
  39450. * The bigger this number the longer it will take for the camera to stop.
  39451. */
  39452. inertialAlphaOffset: number;
  39453. /**
  39454. * Current inertia value on the latitudinal axis.
  39455. * The bigger this number the longer it will take for the camera to stop.
  39456. */
  39457. inertialBetaOffset: number;
  39458. /**
  39459. * Current inertia value on the radius axis.
  39460. * The bigger this number the longer it will take for the camera to stop.
  39461. */
  39462. inertialRadiusOffset: number;
  39463. /**
  39464. * Minimum allowed angle on the longitudinal axis.
  39465. * This can help limiting how the Camera is able to move in the scene.
  39466. */
  39467. lowerAlphaLimit: Nullable<number>;
  39468. /**
  39469. * Maximum allowed angle on the longitudinal axis.
  39470. * This can help limiting how the Camera is able to move in the scene.
  39471. */
  39472. upperAlphaLimit: Nullable<number>;
  39473. /**
  39474. * Minimum allowed angle on the latitudinal axis.
  39475. * This can help limiting how the Camera is able to move in the scene.
  39476. */
  39477. lowerBetaLimit: number;
  39478. /**
  39479. * Maximum allowed angle on the latitudinal axis.
  39480. * This can help limiting how the Camera is able to move in the scene.
  39481. */
  39482. upperBetaLimit: number;
  39483. /**
  39484. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39485. * This can help limiting how the Camera is able to move in the scene.
  39486. */
  39487. lowerRadiusLimit: Nullable<number>;
  39488. /**
  39489. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39490. * This can help limiting how the Camera is able to move in the scene.
  39491. */
  39492. upperRadiusLimit: Nullable<number>;
  39493. /**
  39494. * Defines the current inertia value used during panning of the camera along the X axis.
  39495. */
  39496. inertialPanningX: number;
  39497. /**
  39498. * Defines the current inertia value used during panning of the camera along the Y axis.
  39499. */
  39500. inertialPanningY: number;
  39501. /**
  39502. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39503. * Basically if your fingers moves away from more than this distance you will be considered
  39504. * in pinch mode.
  39505. */
  39506. pinchToPanMaxDistance: number;
  39507. /**
  39508. * Defines the maximum distance the camera can pan.
  39509. * This could help keeping the cammera always in your scene.
  39510. */
  39511. panningDistanceLimit: Nullable<number>;
  39512. /**
  39513. * Defines the target of the camera before paning.
  39514. */
  39515. panningOriginTarget: Vector3;
  39516. /**
  39517. * Defines the value of the inertia used during panning.
  39518. * 0 would mean stop inertia and one would mean no decelleration at all.
  39519. */
  39520. panningInertia: number;
  39521. /**
  39522. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39523. */
  39524. get angularSensibilityX(): number;
  39525. set angularSensibilityX(value: number);
  39526. /**
  39527. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39528. */
  39529. get angularSensibilityY(): number;
  39530. set angularSensibilityY(value: number);
  39531. /**
  39532. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39533. */
  39534. get pinchPrecision(): number;
  39535. set pinchPrecision(value: number);
  39536. /**
  39537. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39538. * It will be used instead of pinchDeltaPrecision if different from 0.
  39539. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39540. */
  39541. get pinchDeltaPercentage(): number;
  39542. set pinchDeltaPercentage(value: number);
  39543. /**
  39544. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39545. */
  39546. get panningSensibility(): number;
  39547. set panningSensibility(value: number);
  39548. /**
  39549. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39550. */
  39551. get keysUp(): number[];
  39552. set keysUp(value: number[]);
  39553. /**
  39554. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39555. */
  39556. get keysDown(): number[];
  39557. set keysDown(value: number[]);
  39558. /**
  39559. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39560. */
  39561. get keysLeft(): number[];
  39562. set keysLeft(value: number[]);
  39563. /**
  39564. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39565. */
  39566. get keysRight(): number[];
  39567. set keysRight(value: number[]);
  39568. /**
  39569. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39570. */
  39571. get wheelPrecision(): number;
  39572. set wheelPrecision(value: number);
  39573. /**
  39574. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39575. * It will be used instead of pinchDeltaPrecision if different from 0.
  39576. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39577. */
  39578. get wheelDeltaPercentage(): number;
  39579. set wheelDeltaPercentage(value: number);
  39580. /**
  39581. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39582. */
  39583. zoomOnFactor: number;
  39584. /**
  39585. * Defines a screen offset for the camera position.
  39586. */
  39587. targetScreenOffset: Vector2;
  39588. /**
  39589. * Allows the camera to be completely reversed.
  39590. * If false the camera can not arrive upside down.
  39591. */
  39592. allowUpsideDown: boolean;
  39593. /**
  39594. * Define if double tap/click is used to restore the previously saved state of the camera.
  39595. */
  39596. useInputToRestoreState: boolean;
  39597. /** @hidden */
  39598. _viewMatrix: Matrix;
  39599. /** @hidden */
  39600. _useCtrlForPanning: boolean;
  39601. /** @hidden */
  39602. _panningMouseButton: number;
  39603. /**
  39604. * Defines the input associated to the camera.
  39605. */
  39606. inputs: ArcRotateCameraInputsManager;
  39607. /** @hidden */
  39608. _reset: () => void;
  39609. /**
  39610. * Defines the allowed panning axis.
  39611. */
  39612. panningAxis: Vector3;
  39613. protected _localDirection: Vector3;
  39614. protected _transformedDirection: Vector3;
  39615. private _bouncingBehavior;
  39616. /**
  39617. * Gets the bouncing behavior of the camera if it has been enabled.
  39618. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39619. */
  39620. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39621. /**
  39622. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39623. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39624. */
  39625. get useBouncingBehavior(): boolean;
  39626. set useBouncingBehavior(value: boolean);
  39627. private _framingBehavior;
  39628. /**
  39629. * Gets the framing behavior of the camera if it has been enabled.
  39630. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39631. */
  39632. get framingBehavior(): Nullable<FramingBehavior>;
  39633. /**
  39634. * Defines if the framing behavior of the camera is enabled on the camera.
  39635. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39636. */
  39637. get useFramingBehavior(): boolean;
  39638. set useFramingBehavior(value: boolean);
  39639. private _autoRotationBehavior;
  39640. /**
  39641. * Gets the auto rotation behavior of the camera if it has been enabled.
  39642. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39643. */
  39644. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39645. /**
  39646. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39647. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39648. */
  39649. get useAutoRotationBehavior(): boolean;
  39650. set useAutoRotationBehavior(value: boolean);
  39651. /**
  39652. * Observable triggered when the mesh target has been changed on the camera.
  39653. */
  39654. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39655. /**
  39656. * Event raised when the camera is colliding with a mesh.
  39657. */
  39658. onCollide: (collidedMesh: AbstractMesh) => void;
  39659. /**
  39660. * Defines whether the camera should check collision with the objects oh the scene.
  39661. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39662. */
  39663. checkCollisions: boolean;
  39664. /**
  39665. * Defines the collision radius of the camera.
  39666. * This simulates a sphere around the camera.
  39667. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39668. */
  39669. collisionRadius: Vector3;
  39670. protected _collider: Collider;
  39671. protected _previousPosition: Vector3;
  39672. protected _collisionVelocity: Vector3;
  39673. protected _newPosition: Vector3;
  39674. protected _previousAlpha: number;
  39675. protected _previousBeta: number;
  39676. protected _previousRadius: number;
  39677. protected _collisionTriggered: boolean;
  39678. protected _targetBoundingCenter: Nullable<Vector3>;
  39679. private _computationVector;
  39680. /**
  39681. * Instantiates a new ArcRotateCamera in a given scene
  39682. * @param name Defines the name of the camera
  39683. * @param alpha Defines the camera rotation along the logitudinal axis
  39684. * @param beta Defines the camera rotation along the latitudinal axis
  39685. * @param radius Defines the camera distance from its target
  39686. * @param target Defines the camera target
  39687. * @param scene Defines the scene the camera belongs to
  39688. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39689. */
  39690. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39691. /** @hidden */
  39692. _initCache(): void;
  39693. /** @hidden */
  39694. _updateCache(ignoreParentClass?: boolean): void;
  39695. protected _getTargetPosition(): Vector3;
  39696. private _storedAlpha;
  39697. private _storedBeta;
  39698. private _storedRadius;
  39699. private _storedTarget;
  39700. private _storedTargetScreenOffset;
  39701. /**
  39702. * Stores the current state of the camera (alpha, beta, radius and target)
  39703. * @returns the camera itself
  39704. */
  39705. storeState(): Camera;
  39706. /**
  39707. * @hidden
  39708. * Restored camera state. You must call storeState() first
  39709. */
  39710. _restoreStateValues(): boolean;
  39711. /** @hidden */
  39712. _isSynchronizedViewMatrix(): boolean;
  39713. /**
  39714. * Attached controls to the current camera.
  39715. * @param element Defines the element the controls should be listened from
  39716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39717. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39718. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39719. */
  39720. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39721. /**
  39722. * Detach the current controls from the camera.
  39723. * The camera will stop reacting to inputs.
  39724. * @param element Defines the element to stop listening the inputs from
  39725. */
  39726. detachControl(element: HTMLElement): void;
  39727. /** @hidden */
  39728. _checkInputs(): void;
  39729. protected _checkLimits(): void;
  39730. /**
  39731. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39732. */
  39733. rebuildAnglesAndRadius(): void;
  39734. /**
  39735. * Use a position to define the current camera related information like alpha, beta and radius
  39736. * @param position Defines the position to set the camera at
  39737. */
  39738. setPosition(position: Vector3): void;
  39739. /**
  39740. * Defines the target the camera should look at.
  39741. * This will automatically adapt alpha beta and radius to fit within the new target.
  39742. * @param target Defines the new target as a Vector or a mesh
  39743. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39744. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39745. */
  39746. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39747. /** @hidden */
  39748. _getViewMatrix(): Matrix;
  39749. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39750. /**
  39751. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39752. * @param meshes Defines the mesh to zoom on
  39753. * @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)
  39754. */
  39755. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39756. /**
  39757. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39758. * The target will be changed but the radius
  39759. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39760. * @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)
  39761. */
  39762. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39763. min: Vector3;
  39764. max: Vector3;
  39765. distance: number;
  39766. }, doNotUpdateMaxZ?: boolean): void;
  39767. /**
  39768. * @override
  39769. * Override Camera.createRigCamera
  39770. */
  39771. createRigCamera(name: string, cameraIndex: number): Camera;
  39772. /**
  39773. * @hidden
  39774. * @override
  39775. * Override Camera._updateRigCameras
  39776. */
  39777. _updateRigCameras(): void;
  39778. /**
  39779. * Destroy the camera and release the current resources hold by it.
  39780. */
  39781. dispose(): void;
  39782. /**
  39783. * Gets the current object class name.
  39784. * @return the class name
  39785. */
  39786. getClassName(): string;
  39787. }
  39788. }
  39789. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39790. import { Behavior } from "babylonjs/Behaviors/behavior";
  39791. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39792. /**
  39793. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39794. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39795. */
  39796. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39797. /**
  39798. * Gets the name of the behavior.
  39799. */
  39800. get name(): string;
  39801. private _zoomStopsAnimation;
  39802. private _idleRotationSpeed;
  39803. private _idleRotationWaitTime;
  39804. private _idleRotationSpinupTime;
  39805. /**
  39806. * Sets the flag that indicates if user zooming should stop animation.
  39807. */
  39808. set zoomStopsAnimation(flag: boolean);
  39809. /**
  39810. * Gets the flag that indicates if user zooming should stop animation.
  39811. */
  39812. get zoomStopsAnimation(): boolean;
  39813. /**
  39814. * Sets the default speed at which the camera rotates around the model.
  39815. */
  39816. set idleRotationSpeed(speed: number);
  39817. /**
  39818. * Gets the default speed at which the camera rotates around the model.
  39819. */
  39820. get idleRotationSpeed(): number;
  39821. /**
  39822. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39823. */
  39824. set idleRotationWaitTime(time: number);
  39825. /**
  39826. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39827. */
  39828. get idleRotationWaitTime(): number;
  39829. /**
  39830. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39831. */
  39832. set idleRotationSpinupTime(time: number);
  39833. /**
  39834. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39835. */
  39836. get idleRotationSpinupTime(): number;
  39837. /**
  39838. * Gets a value indicating if the camera is currently rotating because of this behavior
  39839. */
  39840. get rotationInProgress(): boolean;
  39841. private _onPrePointerObservableObserver;
  39842. private _onAfterCheckInputsObserver;
  39843. private _attachedCamera;
  39844. private _isPointerDown;
  39845. private _lastFrameTime;
  39846. private _lastInteractionTime;
  39847. private _cameraRotationSpeed;
  39848. /**
  39849. * Initializes the behavior.
  39850. */
  39851. init(): void;
  39852. /**
  39853. * Attaches the behavior to its arc rotate camera.
  39854. * @param camera Defines the camera to attach the behavior to
  39855. */
  39856. attach(camera: ArcRotateCamera): void;
  39857. /**
  39858. * Detaches the behavior from its current arc rotate camera.
  39859. */
  39860. detach(): void;
  39861. /**
  39862. * Returns true if user is scrolling.
  39863. * @return true if user is scrolling.
  39864. */
  39865. private _userIsZooming;
  39866. private _lastFrameRadius;
  39867. private _shouldAnimationStopForInteraction;
  39868. /**
  39869. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39870. */
  39871. private _applyUserInteraction;
  39872. private _userIsMoving;
  39873. }
  39874. }
  39875. declare module "babylonjs/Behaviors/Cameras/index" {
  39876. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39877. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39878. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39879. }
  39880. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39881. import { Mesh } from "babylonjs/Meshes/mesh";
  39882. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39883. import { Behavior } from "babylonjs/Behaviors/behavior";
  39884. /**
  39885. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39886. */
  39887. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39888. private ui;
  39889. /**
  39890. * The name of the behavior
  39891. */
  39892. name: string;
  39893. /**
  39894. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39895. */
  39896. distanceAwayFromFace: number;
  39897. /**
  39898. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39899. */
  39900. distanceAwayFromBottomOfFace: number;
  39901. private _faceVectors;
  39902. private _target;
  39903. private _scene;
  39904. private _onRenderObserver;
  39905. private _tmpMatrix;
  39906. private _tmpVector;
  39907. /**
  39908. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39909. * @param ui The transform node that should be attched to the mesh
  39910. */
  39911. constructor(ui: TransformNode);
  39912. /**
  39913. * Initializes the behavior
  39914. */
  39915. init(): void;
  39916. private _closestFace;
  39917. private _zeroVector;
  39918. private _lookAtTmpMatrix;
  39919. private _lookAtToRef;
  39920. /**
  39921. * Attaches the AttachToBoxBehavior to the passed in mesh
  39922. * @param target The mesh that the specified node will be attached to
  39923. */
  39924. attach(target: Mesh): void;
  39925. /**
  39926. * Detaches the behavior from the mesh
  39927. */
  39928. detach(): void;
  39929. }
  39930. }
  39931. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39932. import { Behavior } from "babylonjs/Behaviors/behavior";
  39933. import { Mesh } from "babylonjs/Meshes/mesh";
  39934. /**
  39935. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39936. */
  39937. export class FadeInOutBehavior implements Behavior<Mesh> {
  39938. /**
  39939. * Time in milliseconds to delay before fading in (Default: 0)
  39940. */
  39941. delay: number;
  39942. /**
  39943. * Time in milliseconds for the mesh to fade in (Default: 300)
  39944. */
  39945. fadeInTime: number;
  39946. private _millisecondsPerFrame;
  39947. private _hovered;
  39948. private _hoverValue;
  39949. private _ownerNode;
  39950. /**
  39951. * Instatiates the FadeInOutBehavior
  39952. */
  39953. constructor();
  39954. /**
  39955. * The name of the behavior
  39956. */
  39957. get name(): string;
  39958. /**
  39959. * Initializes the behavior
  39960. */
  39961. init(): void;
  39962. /**
  39963. * Attaches the fade behavior on the passed in mesh
  39964. * @param ownerNode The mesh that will be faded in/out once attached
  39965. */
  39966. attach(ownerNode: Mesh): void;
  39967. /**
  39968. * Detaches the behavior from the mesh
  39969. */
  39970. detach(): void;
  39971. /**
  39972. * Triggers the mesh to begin fading in or out
  39973. * @param value if the object should fade in or out (true to fade in)
  39974. */
  39975. fadeIn(value: boolean): void;
  39976. private _update;
  39977. private _setAllVisibility;
  39978. }
  39979. }
  39980. declare module "babylonjs/Misc/pivotTools" {
  39981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39982. /**
  39983. * Class containing a set of static utilities functions for managing Pivots
  39984. * @hidden
  39985. */
  39986. export class PivotTools {
  39987. private static _PivotCached;
  39988. private static _OldPivotPoint;
  39989. private static _PivotTranslation;
  39990. private static _PivotTmpVector;
  39991. /** @hidden */
  39992. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39993. /** @hidden */
  39994. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39995. }
  39996. }
  39997. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39998. import { Scene } from "babylonjs/scene";
  39999. import { Vector4 } from "babylonjs/Maths/math.vector";
  40000. import { Mesh } from "babylonjs/Meshes/mesh";
  40001. import { Nullable } from "babylonjs/types";
  40002. import { Plane } from "babylonjs/Maths/math.plane";
  40003. /**
  40004. * Class containing static functions to help procedurally build meshes
  40005. */
  40006. export class PlaneBuilder {
  40007. /**
  40008. * Creates a plane mesh
  40009. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40010. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40011. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40015. * @param name defines the name of the mesh
  40016. * @param options defines the options used to create the mesh
  40017. * @param scene defines the hosting scene
  40018. * @returns the plane mesh
  40019. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40020. */
  40021. static CreatePlane(name: string, options: {
  40022. size?: number;
  40023. width?: number;
  40024. height?: number;
  40025. sideOrientation?: number;
  40026. frontUVs?: Vector4;
  40027. backUVs?: Vector4;
  40028. updatable?: boolean;
  40029. sourcePlane?: Plane;
  40030. }, scene?: Nullable<Scene>): Mesh;
  40031. }
  40032. }
  40033. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40034. import { Behavior } from "babylonjs/Behaviors/behavior";
  40035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40036. import { Observable } from "babylonjs/Misc/observable";
  40037. import { Vector3 } from "babylonjs/Maths/math.vector";
  40038. import { Ray } from "babylonjs/Culling/ray";
  40039. import "babylonjs/Meshes/Builders/planeBuilder";
  40040. /**
  40041. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40042. */
  40043. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40044. private static _AnyMouseID;
  40045. /**
  40046. * Abstract mesh the behavior is set on
  40047. */
  40048. attachedNode: AbstractMesh;
  40049. private _dragPlane;
  40050. private _scene;
  40051. private _pointerObserver;
  40052. private _beforeRenderObserver;
  40053. private static _planeScene;
  40054. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40055. /**
  40056. * 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)
  40057. */
  40058. maxDragAngle: number;
  40059. /**
  40060. * @hidden
  40061. */
  40062. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40063. /**
  40064. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40065. */
  40066. currentDraggingPointerID: number;
  40067. /**
  40068. * The last position where the pointer hit the drag plane in world space
  40069. */
  40070. lastDragPosition: Vector3;
  40071. /**
  40072. * If the behavior is currently in a dragging state
  40073. */
  40074. dragging: boolean;
  40075. /**
  40076. * 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)
  40077. */
  40078. dragDeltaRatio: number;
  40079. /**
  40080. * If the drag plane orientation should be updated during the dragging (Default: true)
  40081. */
  40082. updateDragPlane: boolean;
  40083. private _debugMode;
  40084. private _moving;
  40085. /**
  40086. * Fires each time the attached mesh is dragged with the pointer
  40087. * * delta between last drag position and current drag position in world space
  40088. * * dragDistance along the drag axis
  40089. * * dragPlaneNormal normal of the current drag plane used during the drag
  40090. * * dragPlanePoint in world space where the drag intersects the drag plane
  40091. */
  40092. onDragObservable: Observable<{
  40093. delta: Vector3;
  40094. dragPlanePoint: Vector3;
  40095. dragPlaneNormal: Vector3;
  40096. dragDistance: number;
  40097. pointerId: number;
  40098. }>;
  40099. /**
  40100. * Fires each time a drag begins (eg. mouse down on mesh)
  40101. */
  40102. onDragStartObservable: Observable<{
  40103. dragPlanePoint: Vector3;
  40104. pointerId: number;
  40105. }>;
  40106. /**
  40107. * Fires each time a drag ends (eg. mouse release after drag)
  40108. */
  40109. onDragEndObservable: Observable<{
  40110. dragPlanePoint: Vector3;
  40111. pointerId: number;
  40112. }>;
  40113. /**
  40114. * If the attached mesh should be moved when dragged
  40115. */
  40116. moveAttached: boolean;
  40117. /**
  40118. * If the drag behavior will react to drag events (Default: true)
  40119. */
  40120. enabled: boolean;
  40121. /**
  40122. * If pointer events should start and release the drag (Default: true)
  40123. */
  40124. startAndReleaseDragOnPointerEvents: boolean;
  40125. /**
  40126. * If camera controls should be detached during the drag
  40127. */
  40128. detachCameraControls: boolean;
  40129. /**
  40130. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40131. */
  40132. useObjectOrienationForDragging: boolean;
  40133. private _options;
  40134. /**
  40135. * Gets the options used by the behavior
  40136. */
  40137. get options(): {
  40138. dragAxis?: Vector3;
  40139. dragPlaneNormal?: Vector3;
  40140. };
  40141. /**
  40142. * Sets the options used by the behavior
  40143. */
  40144. set options(options: {
  40145. dragAxis?: Vector3;
  40146. dragPlaneNormal?: Vector3;
  40147. });
  40148. /**
  40149. * Creates a pointer drag behavior that can be attached to a mesh
  40150. * @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)
  40151. */
  40152. constructor(options?: {
  40153. dragAxis?: Vector3;
  40154. dragPlaneNormal?: Vector3;
  40155. });
  40156. /**
  40157. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40158. */
  40159. validateDrag: (targetPosition: Vector3) => boolean;
  40160. /**
  40161. * The name of the behavior
  40162. */
  40163. get name(): string;
  40164. /**
  40165. * Initializes the behavior
  40166. */
  40167. init(): void;
  40168. private _tmpVector;
  40169. private _alternatePickedPoint;
  40170. private _worldDragAxis;
  40171. private _targetPosition;
  40172. private _attachedElement;
  40173. /**
  40174. * Attaches the drag behavior the passed in mesh
  40175. * @param ownerNode The mesh that will be dragged around once attached
  40176. * @param predicate Predicate to use for pick filtering
  40177. */
  40178. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40179. /**
  40180. * Force relase the drag action by code.
  40181. */
  40182. releaseDrag(): void;
  40183. private _startDragRay;
  40184. private _lastPointerRay;
  40185. /**
  40186. * Simulates the start of a pointer drag event on the behavior
  40187. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40188. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40189. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40190. */
  40191. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40192. private _startDrag;
  40193. private _dragDelta;
  40194. private _moveDrag;
  40195. private _pickWithRayOnDragPlane;
  40196. private _pointA;
  40197. private _pointB;
  40198. private _pointC;
  40199. private _lineA;
  40200. private _lineB;
  40201. private _localAxis;
  40202. private _lookAt;
  40203. private _updateDragPlanePosition;
  40204. /**
  40205. * Detaches the behavior from the mesh
  40206. */
  40207. detach(): void;
  40208. }
  40209. }
  40210. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40211. import { Mesh } from "babylonjs/Meshes/mesh";
  40212. import { Behavior } from "babylonjs/Behaviors/behavior";
  40213. /**
  40214. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40215. */
  40216. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40217. private _dragBehaviorA;
  40218. private _dragBehaviorB;
  40219. private _startDistance;
  40220. private _initialScale;
  40221. private _targetScale;
  40222. private _ownerNode;
  40223. private _sceneRenderObserver;
  40224. /**
  40225. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40226. */
  40227. constructor();
  40228. /**
  40229. * The name of the behavior
  40230. */
  40231. get name(): string;
  40232. /**
  40233. * Initializes the behavior
  40234. */
  40235. init(): void;
  40236. private _getCurrentDistance;
  40237. /**
  40238. * Attaches the scale behavior the passed in mesh
  40239. * @param ownerNode The mesh that will be scaled around once attached
  40240. */
  40241. attach(ownerNode: Mesh): void;
  40242. /**
  40243. * Detaches the behavior from the mesh
  40244. */
  40245. detach(): void;
  40246. }
  40247. }
  40248. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40249. import { Behavior } from "babylonjs/Behaviors/behavior";
  40250. import { Mesh } from "babylonjs/Meshes/mesh";
  40251. import { Observable } from "babylonjs/Misc/observable";
  40252. /**
  40253. * 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
  40254. */
  40255. export class SixDofDragBehavior implements Behavior<Mesh> {
  40256. private static _virtualScene;
  40257. private _ownerNode;
  40258. private _sceneRenderObserver;
  40259. private _scene;
  40260. private _targetPosition;
  40261. private _virtualOriginMesh;
  40262. private _virtualDragMesh;
  40263. private _pointerObserver;
  40264. private _moving;
  40265. private _startingOrientation;
  40266. /**
  40267. * 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)
  40268. */
  40269. private zDragFactor;
  40270. /**
  40271. * If the object should rotate to face the drag origin
  40272. */
  40273. rotateDraggedObject: boolean;
  40274. /**
  40275. * If the behavior is currently in a dragging state
  40276. */
  40277. dragging: boolean;
  40278. /**
  40279. * 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)
  40280. */
  40281. dragDeltaRatio: number;
  40282. /**
  40283. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40284. */
  40285. currentDraggingPointerID: number;
  40286. /**
  40287. * If camera controls should be detached during the drag
  40288. */
  40289. detachCameraControls: boolean;
  40290. /**
  40291. * Fires each time a drag starts
  40292. */
  40293. onDragStartObservable: Observable<{}>;
  40294. /**
  40295. * Fires each time a drag ends (eg. mouse release after drag)
  40296. */
  40297. onDragEndObservable: Observable<{}>;
  40298. /**
  40299. * 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
  40300. */
  40301. constructor();
  40302. /**
  40303. * The name of the behavior
  40304. */
  40305. get name(): string;
  40306. /**
  40307. * Initializes the behavior
  40308. */
  40309. init(): void;
  40310. /**
  40311. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40312. */
  40313. private get _pointerCamera();
  40314. /**
  40315. * Attaches the scale behavior the passed in mesh
  40316. * @param ownerNode The mesh that will be scaled around once attached
  40317. */
  40318. attach(ownerNode: Mesh): void;
  40319. /**
  40320. * Detaches the behavior from the mesh
  40321. */
  40322. detach(): void;
  40323. }
  40324. }
  40325. declare module "babylonjs/Behaviors/Meshes/index" {
  40326. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40327. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40328. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40329. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40330. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40331. }
  40332. declare module "babylonjs/Behaviors/index" {
  40333. export * from "babylonjs/Behaviors/behavior";
  40334. export * from "babylonjs/Behaviors/Cameras/index";
  40335. export * from "babylonjs/Behaviors/Meshes/index";
  40336. }
  40337. declare module "babylonjs/Bones/boneIKController" {
  40338. import { Bone } from "babylonjs/Bones/bone";
  40339. import { Vector3 } from "babylonjs/Maths/math.vector";
  40340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40341. import { Nullable } from "babylonjs/types";
  40342. /**
  40343. * Class used to apply inverse kinematics to bones
  40344. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40345. */
  40346. export class BoneIKController {
  40347. private static _tmpVecs;
  40348. private static _tmpQuat;
  40349. private static _tmpMats;
  40350. /**
  40351. * Gets or sets the target mesh
  40352. */
  40353. targetMesh: AbstractMesh;
  40354. /** Gets or sets the mesh used as pole */
  40355. poleTargetMesh: AbstractMesh;
  40356. /**
  40357. * Gets or sets the bone used as pole
  40358. */
  40359. poleTargetBone: Nullable<Bone>;
  40360. /**
  40361. * Gets or sets the target position
  40362. */
  40363. targetPosition: Vector3;
  40364. /**
  40365. * Gets or sets the pole target position
  40366. */
  40367. poleTargetPosition: Vector3;
  40368. /**
  40369. * Gets or sets the pole target local offset
  40370. */
  40371. poleTargetLocalOffset: Vector3;
  40372. /**
  40373. * Gets or sets the pole angle
  40374. */
  40375. poleAngle: number;
  40376. /**
  40377. * Gets or sets the mesh associated with the controller
  40378. */
  40379. mesh: AbstractMesh;
  40380. /**
  40381. * 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)
  40382. */
  40383. slerpAmount: number;
  40384. private _bone1Quat;
  40385. private _bone1Mat;
  40386. private _bone2Ang;
  40387. private _bone1;
  40388. private _bone2;
  40389. private _bone1Length;
  40390. private _bone2Length;
  40391. private _maxAngle;
  40392. private _maxReach;
  40393. private _rightHandedSystem;
  40394. private _bendAxis;
  40395. private _slerping;
  40396. private _adjustRoll;
  40397. /**
  40398. * Gets or sets maximum allowed angle
  40399. */
  40400. get maxAngle(): number;
  40401. set maxAngle(value: number);
  40402. /**
  40403. * Creates a new BoneIKController
  40404. * @param mesh defines the mesh to control
  40405. * @param bone defines the bone to control
  40406. * @param options defines options to set up the controller
  40407. */
  40408. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40409. targetMesh?: AbstractMesh;
  40410. poleTargetMesh?: AbstractMesh;
  40411. poleTargetBone?: Bone;
  40412. poleTargetLocalOffset?: Vector3;
  40413. poleAngle?: number;
  40414. bendAxis?: Vector3;
  40415. maxAngle?: number;
  40416. slerpAmount?: number;
  40417. });
  40418. private _setMaxAngle;
  40419. /**
  40420. * Force the controller to update the bones
  40421. */
  40422. update(): void;
  40423. }
  40424. }
  40425. declare module "babylonjs/Bones/boneLookController" {
  40426. import { Vector3 } from "babylonjs/Maths/math.vector";
  40427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40428. import { Bone } from "babylonjs/Bones/bone";
  40429. import { Space } from "babylonjs/Maths/math.axis";
  40430. /**
  40431. * Class used to make a bone look toward a point in space
  40432. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40433. */
  40434. export class BoneLookController {
  40435. private static _tmpVecs;
  40436. private static _tmpQuat;
  40437. private static _tmpMats;
  40438. /**
  40439. * The target Vector3 that the bone will look at
  40440. */
  40441. target: Vector3;
  40442. /**
  40443. * The mesh that the bone is attached to
  40444. */
  40445. mesh: AbstractMesh;
  40446. /**
  40447. * The bone that will be looking to the target
  40448. */
  40449. bone: Bone;
  40450. /**
  40451. * The up axis of the coordinate system that is used when the bone is rotated
  40452. */
  40453. upAxis: Vector3;
  40454. /**
  40455. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40456. */
  40457. upAxisSpace: Space;
  40458. /**
  40459. * Used to make an adjustment to the yaw of the bone
  40460. */
  40461. adjustYaw: number;
  40462. /**
  40463. * Used to make an adjustment to the pitch of the bone
  40464. */
  40465. adjustPitch: number;
  40466. /**
  40467. * Used to make an adjustment to the roll of the bone
  40468. */
  40469. adjustRoll: number;
  40470. /**
  40471. * 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)
  40472. */
  40473. slerpAmount: number;
  40474. private _minYaw;
  40475. private _maxYaw;
  40476. private _minPitch;
  40477. private _maxPitch;
  40478. private _minYawSin;
  40479. private _minYawCos;
  40480. private _maxYawSin;
  40481. private _maxYawCos;
  40482. private _midYawConstraint;
  40483. private _minPitchTan;
  40484. private _maxPitchTan;
  40485. private _boneQuat;
  40486. private _slerping;
  40487. private _transformYawPitch;
  40488. private _transformYawPitchInv;
  40489. private _firstFrameSkipped;
  40490. private _yawRange;
  40491. private _fowardAxis;
  40492. /**
  40493. * Gets or sets the minimum yaw angle that the bone can look to
  40494. */
  40495. get minYaw(): number;
  40496. set minYaw(value: number);
  40497. /**
  40498. * Gets or sets the maximum yaw angle that the bone can look to
  40499. */
  40500. get maxYaw(): number;
  40501. set maxYaw(value: number);
  40502. /**
  40503. * Gets or sets the minimum pitch angle that the bone can look to
  40504. */
  40505. get minPitch(): number;
  40506. set minPitch(value: number);
  40507. /**
  40508. * Gets or sets the maximum pitch angle that the bone can look to
  40509. */
  40510. get maxPitch(): number;
  40511. set maxPitch(value: number);
  40512. /**
  40513. * Create a BoneLookController
  40514. * @param mesh the mesh that the bone belongs to
  40515. * @param bone the bone that will be looking to the target
  40516. * @param target the target Vector3 to look at
  40517. * @param options optional settings:
  40518. * * maxYaw: the maximum angle the bone will yaw to
  40519. * * minYaw: the minimum angle the bone will yaw to
  40520. * * maxPitch: the maximum angle the bone will pitch to
  40521. * * minPitch: the minimum angle the bone will yaw to
  40522. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40523. * * upAxis: the up axis of the coordinate system
  40524. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40525. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40526. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40527. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40528. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40529. * * adjustRoll: used to make an adjustment to the roll of the bone
  40530. **/
  40531. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40532. maxYaw?: number;
  40533. minYaw?: number;
  40534. maxPitch?: number;
  40535. minPitch?: number;
  40536. slerpAmount?: number;
  40537. upAxis?: Vector3;
  40538. upAxisSpace?: Space;
  40539. yawAxis?: Vector3;
  40540. pitchAxis?: Vector3;
  40541. adjustYaw?: number;
  40542. adjustPitch?: number;
  40543. adjustRoll?: number;
  40544. });
  40545. /**
  40546. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40547. */
  40548. update(): void;
  40549. private _getAngleDiff;
  40550. private _getAngleBetween;
  40551. private _isAngleBetween;
  40552. }
  40553. }
  40554. declare module "babylonjs/Bones/index" {
  40555. export * from "babylonjs/Bones/bone";
  40556. export * from "babylonjs/Bones/boneIKController";
  40557. export * from "babylonjs/Bones/boneLookController";
  40558. export * from "babylonjs/Bones/skeleton";
  40559. }
  40560. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40561. import { Nullable } from "babylonjs/types";
  40562. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40563. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40564. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40565. /**
  40566. * Manage the gamepad inputs to control an arc rotate camera.
  40567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40568. */
  40569. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40570. /**
  40571. * Defines the camera the input is attached to.
  40572. */
  40573. camera: ArcRotateCamera;
  40574. /**
  40575. * Defines the gamepad the input is gathering event from.
  40576. */
  40577. gamepad: Nullable<Gamepad>;
  40578. /**
  40579. * Defines the gamepad rotation sensiblity.
  40580. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40581. */
  40582. gamepadRotationSensibility: number;
  40583. /**
  40584. * Defines the gamepad move sensiblity.
  40585. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40586. */
  40587. gamepadMoveSensibility: number;
  40588. private _yAxisScale;
  40589. /**
  40590. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40591. */
  40592. get invertYAxis(): boolean;
  40593. set invertYAxis(value: boolean);
  40594. private _onGamepadConnectedObserver;
  40595. private _onGamepadDisconnectedObserver;
  40596. /**
  40597. * Attach the input controls to a specific dom element to get the input from.
  40598. * @param element Defines the element the controls should be listened from
  40599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40600. */
  40601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40602. /**
  40603. * Detach the current controls from the specified dom element.
  40604. * @param element Defines the element to stop listening the inputs from
  40605. */
  40606. detachControl(element: Nullable<HTMLElement>): void;
  40607. /**
  40608. * Update the current camera state depending on the inputs that have been used this frame.
  40609. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40610. */
  40611. checkInputs(): void;
  40612. /**
  40613. * Gets the class name of the current intput.
  40614. * @returns the class name
  40615. */
  40616. getClassName(): string;
  40617. /**
  40618. * Get the friendly name associated with the input class.
  40619. * @returns the input friendly name
  40620. */
  40621. getSimpleName(): string;
  40622. }
  40623. }
  40624. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40625. import { Nullable } from "babylonjs/types";
  40626. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40627. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40628. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40629. interface ArcRotateCameraInputsManager {
  40630. /**
  40631. * Add orientation input support to the input manager.
  40632. * @returns the current input manager
  40633. */
  40634. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40635. }
  40636. }
  40637. /**
  40638. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40640. */
  40641. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40642. /**
  40643. * Defines the camera the input is attached to.
  40644. */
  40645. camera: ArcRotateCamera;
  40646. /**
  40647. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40648. */
  40649. alphaCorrection: number;
  40650. /**
  40651. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40652. */
  40653. gammaCorrection: number;
  40654. private _alpha;
  40655. private _gamma;
  40656. private _dirty;
  40657. private _deviceOrientationHandler;
  40658. /**
  40659. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40660. */
  40661. constructor();
  40662. /**
  40663. * Attach the input controls to a specific dom element to get the input from.
  40664. * @param element Defines the element the controls should be listened from
  40665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40666. */
  40667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40668. /** @hidden */
  40669. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40670. /**
  40671. * Update the current camera state depending on the inputs that have been used this frame.
  40672. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40673. */
  40674. checkInputs(): void;
  40675. /**
  40676. * Detach the current controls from the specified dom element.
  40677. * @param element Defines the element to stop listening the inputs from
  40678. */
  40679. detachControl(element: Nullable<HTMLElement>): void;
  40680. /**
  40681. * Gets the class name of the current intput.
  40682. * @returns the class name
  40683. */
  40684. getClassName(): string;
  40685. /**
  40686. * Get the friendly name associated with the input class.
  40687. * @returns the input friendly name
  40688. */
  40689. getSimpleName(): string;
  40690. }
  40691. }
  40692. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40693. import { Nullable } from "babylonjs/types";
  40694. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40695. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40696. /**
  40697. * Listen to mouse events to control the camera.
  40698. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40699. */
  40700. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40701. /**
  40702. * Defines the camera the input is attached to.
  40703. */
  40704. camera: FlyCamera;
  40705. /**
  40706. * Defines if touch is enabled. (Default is true.)
  40707. */
  40708. touchEnabled: boolean;
  40709. /**
  40710. * Defines the buttons associated with the input to handle camera rotation.
  40711. */
  40712. buttons: number[];
  40713. /**
  40714. * Assign buttons for Yaw control.
  40715. */
  40716. buttonsYaw: number[];
  40717. /**
  40718. * Assign buttons for Pitch control.
  40719. */
  40720. buttonsPitch: number[];
  40721. /**
  40722. * Assign buttons for Roll control.
  40723. */
  40724. buttonsRoll: number[];
  40725. /**
  40726. * Detect if any button is being pressed while mouse is moved.
  40727. * -1 = Mouse locked.
  40728. * 0 = Left button.
  40729. * 1 = Middle Button.
  40730. * 2 = Right Button.
  40731. */
  40732. activeButton: number;
  40733. /**
  40734. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40735. * Higher values reduce its sensitivity.
  40736. */
  40737. angularSensibility: number;
  40738. private _mousemoveCallback;
  40739. private _observer;
  40740. private _rollObserver;
  40741. private previousPosition;
  40742. private noPreventDefault;
  40743. private element;
  40744. /**
  40745. * Listen to mouse events to control the camera.
  40746. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40747. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40748. */
  40749. constructor(touchEnabled?: boolean);
  40750. /**
  40751. * Attach the mouse control to the HTML DOM element.
  40752. * @param element Defines the element that listens to the input events.
  40753. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40754. */
  40755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40756. /**
  40757. * Detach the current controls from the specified dom element.
  40758. * @param element Defines the element to stop listening the inputs from
  40759. */
  40760. detachControl(element: Nullable<HTMLElement>): void;
  40761. /**
  40762. * Gets the class name of the current input.
  40763. * @returns the class name.
  40764. */
  40765. getClassName(): string;
  40766. /**
  40767. * Get the friendly name associated with the input class.
  40768. * @returns the input's friendly name.
  40769. */
  40770. getSimpleName(): string;
  40771. private _pointerInput;
  40772. private _onMouseMove;
  40773. /**
  40774. * Rotate camera by mouse offset.
  40775. */
  40776. private rotateCamera;
  40777. }
  40778. }
  40779. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40780. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40781. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40782. /**
  40783. * Default Inputs manager for the FlyCamera.
  40784. * It groups all the default supported inputs for ease of use.
  40785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40786. */
  40787. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40788. /**
  40789. * Instantiates a new FlyCameraInputsManager.
  40790. * @param camera Defines the camera the inputs belong to.
  40791. */
  40792. constructor(camera: FlyCamera);
  40793. /**
  40794. * Add keyboard input support to the input manager.
  40795. * @returns the new FlyCameraKeyboardMoveInput().
  40796. */
  40797. addKeyboard(): FlyCameraInputsManager;
  40798. /**
  40799. * Add mouse input support to the input manager.
  40800. * @param touchEnabled Enable touch screen support.
  40801. * @returns the new FlyCameraMouseInput().
  40802. */
  40803. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40804. }
  40805. }
  40806. declare module "babylonjs/Cameras/flyCamera" {
  40807. import { Scene } from "babylonjs/scene";
  40808. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40810. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40811. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40812. /**
  40813. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40814. * such as in a 3D Space Shooter or a Flight Simulator.
  40815. */
  40816. export class FlyCamera extends TargetCamera {
  40817. /**
  40818. * Define the collision ellipsoid of the camera.
  40819. * This is helpful for simulating a camera body, like a player's body.
  40820. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40821. */
  40822. ellipsoid: Vector3;
  40823. /**
  40824. * Define an offset for the position of the ellipsoid around the camera.
  40825. * This can be helpful if the camera is attached away from the player's body center,
  40826. * such as at its head.
  40827. */
  40828. ellipsoidOffset: Vector3;
  40829. /**
  40830. * Enable or disable collisions of the camera with the rest of the scene objects.
  40831. */
  40832. checkCollisions: boolean;
  40833. /**
  40834. * Enable or disable gravity on the camera.
  40835. */
  40836. applyGravity: boolean;
  40837. /**
  40838. * Define the current direction the camera is moving to.
  40839. */
  40840. cameraDirection: Vector3;
  40841. /**
  40842. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40843. * This overrides and empties cameraRotation.
  40844. */
  40845. rotationQuaternion: Quaternion;
  40846. /**
  40847. * Track Roll to maintain the wanted Rolling when looking around.
  40848. */
  40849. _trackRoll: number;
  40850. /**
  40851. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40852. */
  40853. rollCorrect: number;
  40854. /**
  40855. * Mimic a banked turn, Rolling the camera when Yawing.
  40856. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40857. */
  40858. bankedTurn: boolean;
  40859. /**
  40860. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40861. */
  40862. bankedTurnLimit: number;
  40863. /**
  40864. * Value of 0 disables the banked Roll.
  40865. * Value of 1 is equal to the Yaw angle in radians.
  40866. */
  40867. bankedTurnMultiplier: number;
  40868. /**
  40869. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40870. */
  40871. inputs: FlyCameraInputsManager;
  40872. /**
  40873. * Gets the input sensibility for mouse input.
  40874. * Higher values reduce sensitivity.
  40875. */
  40876. get angularSensibility(): number;
  40877. /**
  40878. * Sets the input sensibility for a mouse input.
  40879. * Higher values reduce sensitivity.
  40880. */
  40881. set angularSensibility(value: number);
  40882. /**
  40883. * Get the keys for camera movement forward.
  40884. */
  40885. get keysForward(): number[];
  40886. /**
  40887. * Set the keys for camera movement forward.
  40888. */
  40889. set keysForward(value: number[]);
  40890. /**
  40891. * Get the keys for camera movement backward.
  40892. */
  40893. get keysBackward(): number[];
  40894. set keysBackward(value: number[]);
  40895. /**
  40896. * Get the keys for camera movement up.
  40897. */
  40898. get keysUp(): number[];
  40899. /**
  40900. * Set the keys for camera movement up.
  40901. */
  40902. set keysUp(value: number[]);
  40903. /**
  40904. * Get the keys for camera movement down.
  40905. */
  40906. get keysDown(): number[];
  40907. /**
  40908. * Set the keys for camera movement down.
  40909. */
  40910. set keysDown(value: number[]);
  40911. /**
  40912. * Get the keys for camera movement left.
  40913. */
  40914. get keysLeft(): number[];
  40915. /**
  40916. * Set the keys for camera movement left.
  40917. */
  40918. set keysLeft(value: number[]);
  40919. /**
  40920. * Set the keys for camera movement right.
  40921. */
  40922. get keysRight(): number[];
  40923. /**
  40924. * Set the keys for camera movement right.
  40925. */
  40926. set keysRight(value: number[]);
  40927. /**
  40928. * Event raised when the camera collides with a mesh in the scene.
  40929. */
  40930. onCollide: (collidedMesh: AbstractMesh) => void;
  40931. private _collider;
  40932. private _needMoveForGravity;
  40933. private _oldPosition;
  40934. private _diffPosition;
  40935. private _newPosition;
  40936. /** @hidden */
  40937. _localDirection: Vector3;
  40938. /** @hidden */
  40939. _transformedDirection: Vector3;
  40940. /**
  40941. * Instantiates a FlyCamera.
  40942. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40943. * such as in a 3D Space Shooter or a Flight Simulator.
  40944. * @param name Define the name of the camera in the scene.
  40945. * @param position Define the starting position of the camera in the scene.
  40946. * @param scene Define the scene the camera belongs to.
  40947. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40948. */
  40949. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40950. /**
  40951. * Attach a control to the HTML DOM element.
  40952. * @param element Defines the element that listens to the input events.
  40953. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40954. */
  40955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40956. /**
  40957. * Detach a control from the HTML DOM element.
  40958. * The camera will stop reacting to that input.
  40959. * @param element Defines the element that listens to the input events.
  40960. */
  40961. detachControl(element: HTMLElement): void;
  40962. private _collisionMask;
  40963. /**
  40964. * Get the mask that the camera ignores in collision events.
  40965. */
  40966. get collisionMask(): number;
  40967. /**
  40968. * Set the mask that the camera ignores in collision events.
  40969. */
  40970. set collisionMask(mask: number);
  40971. /** @hidden */
  40972. _collideWithWorld(displacement: Vector3): void;
  40973. /** @hidden */
  40974. private _onCollisionPositionChange;
  40975. /** @hidden */
  40976. _checkInputs(): void;
  40977. /** @hidden */
  40978. _decideIfNeedsToMove(): boolean;
  40979. /** @hidden */
  40980. _updatePosition(): void;
  40981. /**
  40982. * Restore the Roll to its target value at the rate specified.
  40983. * @param rate - Higher means slower restoring.
  40984. * @hidden
  40985. */
  40986. restoreRoll(rate: number): void;
  40987. /**
  40988. * Destroy the camera and release the current resources held by it.
  40989. */
  40990. dispose(): void;
  40991. /**
  40992. * Get the current object class name.
  40993. * @returns the class name.
  40994. */
  40995. getClassName(): string;
  40996. }
  40997. }
  40998. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40999. import { Nullable } from "babylonjs/types";
  41000. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41001. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41002. /**
  41003. * Listen to keyboard events to control the camera.
  41004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41005. */
  41006. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41007. /**
  41008. * Defines the camera the input is attached to.
  41009. */
  41010. camera: FlyCamera;
  41011. /**
  41012. * The list of keyboard keys used to control the forward move of the camera.
  41013. */
  41014. keysForward: number[];
  41015. /**
  41016. * The list of keyboard keys used to control the backward move of the camera.
  41017. */
  41018. keysBackward: number[];
  41019. /**
  41020. * The list of keyboard keys used to control the forward move of the camera.
  41021. */
  41022. keysUp: number[];
  41023. /**
  41024. * The list of keyboard keys used to control the backward move of the camera.
  41025. */
  41026. keysDown: number[];
  41027. /**
  41028. * The list of keyboard keys used to control the right strafe move of the camera.
  41029. */
  41030. keysRight: number[];
  41031. /**
  41032. * The list of keyboard keys used to control the left strafe move of the camera.
  41033. */
  41034. keysLeft: number[];
  41035. private _keys;
  41036. private _onCanvasBlurObserver;
  41037. private _onKeyboardObserver;
  41038. private _engine;
  41039. private _scene;
  41040. /**
  41041. * Attach the input controls to a specific dom element to get the input from.
  41042. * @param element Defines the element the controls should be listened from
  41043. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41044. */
  41045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41046. /**
  41047. * Detach the current controls from the specified dom element.
  41048. * @param element Defines the element to stop listening the inputs from
  41049. */
  41050. detachControl(element: Nullable<HTMLElement>): void;
  41051. /**
  41052. * Gets the class name of the current intput.
  41053. * @returns the class name
  41054. */
  41055. getClassName(): string;
  41056. /** @hidden */
  41057. _onLostFocus(e: FocusEvent): void;
  41058. /**
  41059. * Get the friendly name associated with the input class.
  41060. * @returns the input friendly name
  41061. */
  41062. getSimpleName(): string;
  41063. /**
  41064. * Update the current camera state depending on the inputs that have been used this frame.
  41065. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41066. */
  41067. checkInputs(): void;
  41068. }
  41069. }
  41070. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41071. import { Nullable } from "babylonjs/types";
  41072. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41073. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41074. /**
  41075. * Manage the mouse wheel inputs to control a follow camera.
  41076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41077. */
  41078. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41079. /**
  41080. * Defines the camera the input is attached to.
  41081. */
  41082. camera: FollowCamera;
  41083. /**
  41084. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41085. */
  41086. axisControlRadius: boolean;
  41087. /**
  41088. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41089. */
  41090. axisControlHeight: boolean;
  41091. /**
  41092. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41093. */
  41094. axisControlRotation: boolean;
  41095. /**
  41096. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41097. * relation to mouseWheel events.
  41098. */
  41099. wheelPrecision: number;
  41100. /**
  41101. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41102. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41103. */
  41104. wheelDeltaPercentage: number;
  41105. private _wheel;
  41106. private _observer;
  41107. /**
  41108. * Attach the input controls to a specific dom element to get the input from.
  41109. * @param element Defines the element the controls should be listened from
  41110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41111. */
  41112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41113. /**
  41114. * Detach the current controls from the specified dom element.
  41115. * @param element Defines the element to stop listening the inputs from
  41116. */
  41117. detachControl(element: Nullable<HTMLElement>): void;
  41118. /**
  41119. * Gets the class name of the current intput.
  41120. * @returns the class name
  41121. */
  41122. getClassName(): string;
  41123. /**
  41124. * Get the friendly name associated with the input class.
  41125. * @returns the input friendly name
  41126. */
  41127. getSimpleName(): string;
  41128. }
  41129. }
  41130. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41131. import { Nullable } from "babylonjs/types";
  41132. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41133. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41134. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41135. /**
  41136. * Manage the pointers inputs to control an follow camera.
  41137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41138. */
  41139. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41140. /**
  41141. * Defines the camera the input is attached to.
  41142. */
  41143. camera: FollowCamera;
  41144. /**
  41145. * Gets the class name of the current input.
  41146. * @returns the class name
  41147. */
  41148. getClassName(): string;
  41149. /**
  41150. * Defines the pointer angular sensibility along the X axis or how fast is
  41151. * the camera rotating.
  41152. * A negative number will reverse the axis direction.
  41153. */
  41154. angularSensibilityX: number;
  41155. /**
  41156. * Defines the pointer angular sensibility along the Y axis or how fast is
  41157. * the camera rotating.
  41158. * A negative number will reverse the axis direction.
  41159. */
  41160. angularSensibilityY: number;
  41161. /**
  41162. * Defines the pointer pinch precision or how fast is the camera zooming.
  41163. * A negative number will reverse the axis direction.
  41164. */
  41165. pinchPrecision: number;
  41166. /**
  41167. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41168. * from 0.
  41169. * It defines the percentage of current camera.radius to use as delta when
  41170. * pinch zoom is used.
  41171. */
  41172. pinchDeltaPercentage: number;
  41173. /**
  41174. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41175. */
  41176. axisXControlRadius: boolean;
  41177. /**
  41178. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41179. */
  41180. axisXControlHeight: boolean;
  41181. /**
  41182. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41183. */
  41184. axisXControlRotation: boolean;
  41185. /**
  41186. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41187. */
  41188. axisYControlRadius: boolean;
  41189. /**
  41190. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41191. */
  41192. axisYControlHeight: boolean;
  41193. /**
  41194. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41195. */
  41196. axisYControlRotation: boolean;
  41197. /**
  41198. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41199. */
  41200. axisPinchControlRadius: boolean;
  41201. /**
  41202. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41203. */
  41204. axisPinchControlHeight: boolean;
  41205. /**
  41206. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41207. */
  41208. axisPinchControlRotation: boolean;
  41209. /**
  41210. * Log error messages if basic misconfiguration has occurred.
  41211. */
  41212. warningEnable: boolean;
  41213. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41214. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41215. private _warningCounter;
  41216. private _warning;
  41217. }
  41218. }
  41219. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41220. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41221. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41222. /**
  41223. * Default Inputs manager for the FollowCamera.
  41224. * It groups all the default supported inputs for ease of use.
  41225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41226. */
  41227. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41228. /**
  41229. * Instantiates a new FollowCameraInputsManager.
  41230. * @param camera Defines the camera the inputs belong to
  41231. */
  41232. constructor(camera: FollowCamera);
  41233. /**
  41234. * Add keyboard input support to the input manager.
  41235. * @returns the current input manager
  41236. */
  41237. addKeyboard(): FollowCameraInputsManager;
  41238. /**
  41239. * Add mouse wheel input support to the input manager.
  41240. * @returns the current input manager
  41241. */
  41242. addMouseWheel(): FollowCameraInputsManager;
  41243. /**
  41244. * Add pointers input support to the input manager.
  41245. * @returns the current input manager
  41246. */
  41247. addPointers(): FollowCameraInputsManager;
  41248. /**
  41249. * Add orientation input support to the input manager.
  41250. * @returns the current input manager
  41251. */
  41252. addVRDeviceOrientation(): FollowCameraInputsManager;
  41253. }
  41254. }
  41255. declare module "babylonjs/Cameras/followCamera" {
  41256. import { Nullable } from "babylonjs/types";
  41257. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41258. import { Scene } from "babylonjs/scene";
  41259. import { Vector3 } from "babylonjs/Maths/math.vector";
  41260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41261. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41262. /**
  41263. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41264. * an arc rotate version arcFollowCamera are available.
  41265. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41266. */
  41267. export class FollowCamera extends TargetCamera {
  41268. /**
  41269. * Distance the follow camera should follow an object at
  41270. */
  41271. radius: number;
  41272. /**
  41273. * Minimum allowed distance of the camera to the axis of rotation
  41274. * (The camera can not get closer).
  41275. * This can help limiting how the Camera is able to move in the scene.
  41276. */
  41277. lowerRadiusLimit: Nullable<number>;
  41278. /**
  41279. * Maximum allowed distance of the camera to the axis of rotation
  41280. * (The camera can not get further).
  41281. * This can help limiting how the Camera is able to move in the scene.
  41282. */
  41283. upperRadiusLimit: Nullable<number>;
  41284. /**
  41285. * Define a rotation offset between the camera and the object it follows
  41286. */
  41287. rotationOffset: number;
  41288. /**
  41289. * Minimum allowed angle to camera position relative to target object.
  41290. * This can help limiting how the Camera is able to move in the scene.
  41291. */
  41292. lowerRotationOffsetLimit: Nullable<number>;
  41293. /**
  41294. * Maximum allowed angle to camera position relative to target object.
  41295. * This can help limiting how the Camera is able to move in the scene.
  41296. */
  41297. upperRotationOffsetLimit: Nullable<number>;
  41298. /**
  41299. * Define a height offset between the camera and the object it follows.
  41300. * It can help following an object from the top (like a car chaing a plane)
  41301. */
  41302. heightOffset: number;
  41303. /**
  41304. * Minimum allowed height of camera position relative to target object.
  41305. * This can help limiting how the Camera is able to move in the scene.
  41306. */
  41307. lowerHeightOffsetLimit: Nullable<number>;
  41308. /**
  41309. * Maximum allowed height of camera position relative to target object.
  41310. * This can help limiting how the Camera is able to move in the scene.
  41311. */
  41312. upperHeightOffsetLimit: Nullable<number>;
  41313. /**
  41314. * Define how fast the camera can accelerate to follow it s target.
  41315. */
  41316. cameraAcceleration: number;
  41317. /**
  41318. * Define the speed limit of the camera following an object.
  41319. */
  41320. maxCameraSpeed: number;
  41321. /**
  41322. * Define the target of the camera.
  41323. */
  41324. lockedTarget: Nullable<AbstractMesh>;
  41325. /**
  41326. * Defines the input associated with the camera.
  41327. */
  41328. inputs: FollowCameraInputsManager;
  41329. /**
  41330. * Instantiates the follow camera.
  41331. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41332. * @param name Define the name of the camera in the scene
  41333. * @param position Define the position of the camera
  41334. * @param scene Define the scene the camera belong to
  41335. * @param lockedTarget Define the target of the camera
  41336. */
  41337. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41338. private _follow;
  41339. /**
  41340. * Attached controls to the current camera.
  41341. * @param element Defines the element the controls should be listened from
  41342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41343. */
  41344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41345. /**
  41346. * Detach the current controls from the camera.
  41347. * The camera will stop reacting to inputs.
  41348. * @param element Defines the element to stop listening the inputs from
  41349. */
  41350. detachControl(element: HTMLElement): void;
  41351. /** @hidden */
  41352. _checkInputs(): void;
  41353. private _checkLimits;
  41354. /**
  41355. * Gets the camera class name.
  41356. * @returns the class name
  41357. */
  41358. getClassName(): string;
  41359. }
  41360. /**
  41361. * Arc Rotate version of the follow camera.
  41362. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41363. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41364. */
  41365. export class ArcFollowCamera extends TargetCamera {
  41366. /** The longitudinal angle of the camera */
  41367. alpha: number;
  41368. /** The latitudinal angle of the camera */
  41369. beta: number;
  41370. /** The radius of the camera from its target */
  41371. radius: number;
  41372. /** Define the camera target (the messh it should follow) */
  41373. target: Nullable<AbstractMesh>;
  41374. private _cartesianCoordinates;
  41375. /**
  41376. * Instantiates a new ArcFollowCamera
  41377. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41378. * @param name Define the name of the camera
  41379. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41380. * @param beta Define the rotation angle of the camera around the elevation axis
  41381. * @param radius Define the radius of the camera from its target point
  41382. * @param target Define the target of the camera
  41383. * @param scene Define the scene the camera belongs to
  41384. */
  41385. constructor(name: string,
  41386. /** The longitudinal angle of the camera */
  41387. alpha: number,
  41388. /** The latitudinal angle of the camera */
  41389. beta: number,
  41390. /** The radius of the camera from its target */
  41391. radius: number,
  41392. /** Define the camera target (the messh it should follow) */
  41393. target: Nullable<AbstractMesh>, scene: Scene);
  41394. private _follow;
  41395. /** @hidden */
  41396. _checkInputs(): void;
  41397. /**
  41398. * Returns the class name of the object.
  41399. * It is mostly used internally for serialization purposes.
  41400. */
  41401. getClassName(): string;
  41402. }
  41403. }
  41404. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41405. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41406. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41407. import { Nullable } from "babylonjs/types";
  41408. /**
  41409. * Manage the keyboard inputs to control the movement of a follow camera.
  41410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41411. */
  41412. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41413. /**
  41414. * Defines the camera the input is attached to.
  41415. */
  41416. camera: FollowCamera;
  41417. /**
  41418. * Defines the list of key codes associated with the up action (increase heightOffset)
  41419. */
  41420. keysHeightOffsetIncr: number[];
  41421. /**
  41422. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41423. */
  41424. keysHeightOffsetDecr: number[];
  41425. /**
  41426. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41427. */
  41428. keysHeightOffsetModifierAlt: boolean;
  41429. /**
  41430. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41431. */
  41432. keysHeightOffsetModifierCtrl: boolean;
  41433. /**
  41434. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41435. */
  41436. keysHeightOffsetModifierShift: boolean;
  41437. /**
  41438. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41439. */
  41440. keysRotationOffsetIncr: number[];
  41441. /**
  41442. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41443. */
  41444. keysRotationOffsetDecr: number[];
  41445. /**
  41446. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41447. */
  41448. keysRotationOffsetModifierAlt: boolean;
  41449. /**
  41450. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41451. */
  41452. keysRotationOffsetModifierCtrl: boolean;
  41453. /**
  41454. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41455. */
  41456. keysRotationOffsetModifierShift: boolean;
  41457. /**
  41458. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41459. */
  41460. keysRadiusIncr: number[];
  41461. /**
  41462. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41463. */
  41464. keysRadiusDecr: number[];
  41465. /**
  41466. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41467. */
  41468. keysRadiusModifierAlt: boolean;
  41469. /**
  41470. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41471. */
  41472. keysRadiusModifierCtrl: boolean;
  41473. /**
  41474. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41475. */
  41476. keysRadiusModifierShift: boolean;
  41477. /**
  41478. * Defines the rate of change of heightOffset.
  41479. */
  41480. heightSensibility: number;
  41481. /**
  41482. * Defines the rate of change of rotationOffset.
  41483. */
  41484. rotationSensibility: number;
  41485. /**
  41486. * Defines the rate of change of radius.
  41487. */
  41488. radiusSensibility: number;
  41489. private _keys;
  41490. private _ctrlPressed;
  41491. private _altPressed;
  41492. private _shiftPressed;
  41493. private _onCanvasBlurObserver;
  41494. private _onKeyboardObserver;
  41495. private _engine;
  41496. private _scene;
  41497. /**
  41498. * Attach the input controls to a specific dom element to get the input from.
  41499. * @param element Defines the element the controls should be listened from
  41500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41501. */
  41502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41503. /**
  41504. * Detach the current controls from the specified dom element.
  41505. * @param element Defines the element to stop listening the inputs from
  41506. */
  41507. detachControl(element: Nullable<HTMLElement>): void;
  41508. /**
  41509. * Update the current camera state depending on the inputs that have been used this frame.
  41510. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41511. */
  41512. checkInputs(): void;
  41513. /**
  41514. * Gets the class name of the current input.
  41515. * @returns the class name
  41516. */
  41517. getClassName(): string;
  41518. /**
  41519. * Get the friendly name associated with the input class.
  41520. * @returns the input friendly name
  41521. */
  41522. getSimpleName(): string;
  41523. /**
  41524. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41525. * allow modification of the heightOffset value.
  41526. */
  41527. private _modifierHeightOffset;
  41528. /**
  41529. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41530. * allow modification of the rotationOffset value.
  41531. */
  41532. private _modifierRotationOffset;
  41533. /**
  41534. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41535. * allow modification of the radius value.
  41536. */
  41537. private _modifierRadius;
  41538. }
  41539. }
  41540. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41541. import { Nullable } from "babylonjs/types";
  41542. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41543. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41544. import { Observable } from "babylonjs/Misc/observable";
  41545. module "babylonjs/Cameras/freeCameraInputsManager" {
  41546. interface FreeCameraInputsManager {
  41547. /**
  41548. * @hidden
  41549. */
  41550. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41551. /**
  41552. * Add orientation input support to the input manager.
  41553. * @returns the current input manager
  41554. */
  41555. addDeviceOrientation(): FreeCameraInputsManager;
  41556. }
  41557. }
  41558. /**
  41559. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41560. * Screen rotation is taken into account.
  41561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41562. */
  41563. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41564. private _camera;
  41565. private _screenOrientationAngle;
  41566. private _constantTranform;
  41567. private _screenQuaternion;
  41568. private _alpha;
  41569. private _beta;
  41570. private _gamma;
  41571. /**
  41572. * Can be used to detect if a device orientation sensor is available on a device
  41573. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41574. * @returns a promise that will resolve on orientation change
  41575. */
  41576. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41577. /**
  41578. * @hidden
  41579. */
  41580. _onDeviceOrientationChangedObservable: Observable<void>;
  41581. /**
  41582. * Instantiates a new input
  41583. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41584. */
  41585. constructor();
  41586. /**
  41587. * Define the camera controlled by the input.
  41588. */
  41589. get camera(): FreeCamera;
  41590. set camera(camera: FreeCamera);
  41591. /**
  41592. * Attach the input controls to a specific dom element to get the input from.
  41593. * @param element Defines the element the controls should be listened from
  41594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41595. */
  41596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41597. private _orientationChanged;
  41598. private _deviceOrientation;
  41599. /**
  41600. * Detach the current controls from the specified dom element.
  41601. * @param element Defines the element to stop listening the inputs from
  41602. */
  41603. detachControl(element: Nullable<HTMLElement>): void;
  41604. /**
  41605. * Update the current camera state depending on the inputs that have been used this frame.
  41606. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41607. */
  41608. checkInputs(): void;
  41609. /**
  41610. * Gets the class name of the current intput.
  41611. * @returns the class name
  41612. */
  41613. getClassName(): string;
  41614. /**
  41615. * Get the friendly name associated with the input class.
  41616. * @returns the input friendly name
  41617. */
  41618. getSimpleName(): string;
  41619. }
  41620. }
  41621. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41622. import { Nullable } from "babylonjs/types";
  41623. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41624. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41625. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41626. /**
  41627. * Manage the gamepad inputs to control a free camera.
  41628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41629. */
  41630. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41631. /**
  41632. * Define the camera the input is attached to.
  41633. */
  41634. camera: FreeCamera;
  41635. /**
  41636. * Define the Gamepad controlling the input
  41637. */
  41638. gamepad: Nullable<Gamepad>;
  41639. /**
  41640. * Defines the gamepad rotation sensiblity.
  41641. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41642. */
  41643. gamepadAngularSensibility: number;
  41644. /**
  41645. * Defines the gamepad move sensiblity.
  41646. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41647. */
  41648. gamepadMoveSensibility: number;
  41649. private _yAxisScale;
  41650. /**
  41651. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41652. */
  41653. get invertYAxis(): boolean;
  41654. set invertYAxis(value: boolean);
  41655. private _onGamepadConnectedObserver;
  41656. private _onGamepadDisconnectedObserver;
  41657. private _cameraTransform;
  41658. private _deltaTransform;
  41659. private _vector3;
  41660. private _vector2;
  41661. /**
  41662. * Attach the input controls to a specific dom element to get the input from.
  41663. * @param element Defines the element the controls should be listened from
  41664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41665. */
  41666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41667. /**
  41668. * Detach the current controls from the specified dom element.
  41669. * @param element Defines the element to stop listening the inputs from
  41670. */
  41671. detachControl(element: Nullable<HTMLElement>): void;
  41672. /**
  41673. * Update the current camera state depending on the inputs that have been used this frame.
  41674. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41675. */
  41676. checkInputs(): void;
  41677. /**
  41678. * Gets the class name of the current intput.
  41679. * @returns the class name
  41680. */
  41681. getClassName(): string;
  41682. /**
  41683. * Get the friendly name associated with the input class.
  41684. * @returns the input friendly name
  41685. */
  41686. getSimpleName(): string;
  41687. }
  41688. }
  41689. declare module "babylonjs/Misc/virtualJoystick" {
  41690. import { Nullable } from "babylonjs/types";
  41691. import { Vector3 } from "babylonjs/Maths/math.vector";
  41692. /**
  41693. * Defines the potential axis of a Joystick
  41694. */
  41695. export enum JoystickAxis {
  41696. /** X axis */
  41697. X = 0,
  41698. /** Y axis */
  41699. Y = 1,
  41700. /** Z axis */
  41701. Z = 2
  41702. }
  41703. /**
  41704. * Class used to define virtual joystick (used in touch mode)
  41705. */
  41706. export class VirtualJoystick {
  41707. /**
  41708. * Gets or sets a boolean indicating that left and right values must be inverted
  41709. */
  41710. reverseLeftRight: boolean;
  41711. /**
  41712. * Gets or sets a boolean indicating that up and down values must be inverted
  41713. */
  41714. reverseUpDown: boolean;
  41715. /**
  41716. * Gets the offset value for the position (ie. the change of the position value)
  41717. */
  41718. deltaPosition: Vector3;
  41719. /**
  41720. * Gets a boolean indicating if the virtual joystick was pressed
  41721. */
  41722. pressed: boolean;
  41723. /**
  41724. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41725. */
  41726. static Canvas: Nullable<HTMLCanvasElement>;
  41727. private static _globalJoystickIndex;
  41728. private static vjCanvasContext;
  41729. private static vjCanvasWidth;
  41730. private static vjCanvasHeight;
  41731. private static halfWidth;
  41732. private _action;
  41733. private _axisTargetedByLeftAndRight;
  41734. private _axisTargetedByUpAndDown;
  41735. private _joystickSensibility;
  41736. private _inversedSensibility;
  41737. private _joystickPointerID;
  41738. private _joystickColor;
  41739. private _joystickPointerPos;
  41740. private _joystickPreviousPointerPos;
  41741. private _joystickPointerStartPos;
  41742. private _deltaJoystickVector;
  41743. private _leftJoystick;
  41744. private _touches;
  41745. private _onPointerDownHandlerRef;
  41746. private _onPointerMoveHandlerRef;
  41747. private _onPointerUpHandlerRef;
  41748. private _onResize;
  41749. /**
  41750. * Creates a new virtual joystick
  41751. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41752. */
  41753. constructor(leftJoystick?: boolean);
  41754. /**
  41755. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41756. * @param newJoystickSensibility defines the new sensibility
  41757. */
  41758. setJoystickSensibility(newJoystickSensibility: number): void;
  41759. private _onPointerDown;
  41760. private _onPointerMove;
  41761. private _onPointerUp;
  41762. /**
  41763. * Change the color of the virtual joystick
  41764. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41765. */
  41766. setJoystickColor(newColor: string): void;
  41767. /**
  41768. * Defines a callback to call when the joystick is touched
  41769. * @param action defines the callback
  41770. */
  41771. setActionOnTouch(action: () => any): void;
  41772. /**
  41773. * Defines which axis you'd like to control for left & right
  41774. * @param axis defines the axis to use
  41775. */
  41776. setAxisForLeftRight(axis: JoystickAxis): void;
  41777. /**
  41778. * Defines which axis you'd like to control for up & down
  41779. * @param axis defines the axis to use
  41780. */
  41781. setAxisForUpDown(axis: JoystickAxis): void;
  41782. private _drawVirtualJoystick;
  41783. /**
  41784. * Release internal HTML canvas
  41785. */
  41786. releaseCanvas(): void;
  41787. }
  41788. }
  41789. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41790. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41791. import { Nullable } from "babylonjs/types";
  41792. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41793. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41794. module "babylonjs/Cameras/freeCameraInputsManager" {
  41795. interface FreeCameraInputsManager {
  41796. /**
  41797. * Add virtual joystick input support to the input manager.
  41798. * @returns the current input manager
  41799. */
  41800. addVirtualJoystick(): FreeCameraInputsManager;
  41801. }
  41802. }
  41803. /**
  41804. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41806. */
  41807. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41808. /**
  41809. * Defines the camera the input is attached to.
  41810. */
  41811. camera: FreeCamera;
  41812. private _leftjoystick;
  41813. private _rightjoystick;
  41814. /**
  41815. * Gets the left stick of the virtual joystick.
  41816. * @returns The virtual Joystick
  41817. */
  41818. getLeftJoystick(): VirtualJoystick;
  41819. /**
  41820. * Gets the right stick of the virtual joystick.
  41821. * @returns The virtual Joystick
  41822. */
  41823. getRightJoystick(): VirtualJoystick;
  41824. /**
  41825. * Update the current camera state depending on the inputs that have been used this frame.
  41826. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41827. */
  41828. checkInputs(): void;
  41829. /**
  41830. * Attach the input controls to a specific dom element to get the input from.
  41831. * @param element Defines the element the controls should be listened from
  41832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41833. */
  41834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41835. /**
  41836. * Detach the current controls from the specified dom element.
  41837. * @param element Defines the element to stop listening the inputs from
  41838. */
  41839. detachControl(element: Nullable<HTMLElement>): void;
  41840. /**
  41841. * Gets the class name of the current intput.
  41842. * @returns the class name
  41843. */
  41844. getClassName(): string;
  41845. /**
  41846. * Get the friendly name associated with the input class.
  41847. * @returns the input friendly name
  41848. */
  41849. getSimpleName(): string;
  41850. }
  41851. }
  41852. declare module "babylonjs/Cameras/Inputs/index" {
  41853. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41854. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41855. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41856. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41857. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41858. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41859. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41860. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41861. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41862. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41863. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41864. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41865. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41866. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41867. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41868. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41869. }
  41870. declare module "babylonjs/Cameras/touchCamera" {
  41871. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41872. import { Scene } from "babylonjs/scene";
  41873. import { Vector3 } from "babylonjs/Maths/math.vector";
  41874. /**
  41875. * This represents a FPS type of camera controlled by touch.
  41876. * This is like a universal camera minus the Gamepad controls.
  41877. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41878. */
  41879. export class TouchCamera extends FreeCamera {
  41880. /**
  41881. * Defines the touch sensibility for rotation.
  41882. * The higher the faster.
  41883. */
  41884. get touchAngularSensibility(): number;
  41885. set touchAngularSensibility(value: number);
  41886. /**
  41887. * Defines the touch sensibility for move.
  41888. * The higher the faster.
  41889. */
  41890. get touchMoveSensibility(): number;
  41891. set touchMoveSensibility(value: number);
  41892. /**
  41893. * Instantiates a new touch camera.
  41894. * This represents a FPS type of camera controlled by touch.
  41895. * This is like a universal camera minus the Gamepad controls.
  41896. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41897. * @param name Define the name of the camera in the scene
  41898. * @param position Define the start position of the camera in the scene
  41899. * @param scene Define the scene the camera belongs to
  41900. */
  41901. constructor(name: string, position: Vector3, scene: Scene);
  41902. /**
  41903. * Gets the current object class name.
  41904. * @return the class name
  41905. */
  41906. getClassName(): string;
  41907. /** @hidden */
  41908. _setupInputs(): void;
  41909. }
  41910. }
  41911. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41912. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41913. import { Scene } from "babylonjs/scene";
  41914. import { Vector3 } from "babylonjs/Maths/math.vector";
  41915. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41916. import { Axis } from "babylonjs/Maths/math.axis";
  41917. /**
  41918. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41919. * being tilted forward or back and left or right.
  41920. */
  41921. export class DeviceOrientationCamera extends FreeCamera {
  41922. private _initialQuaternion;
  41923. private _quaternionCache;
  41924. private _tmpDragQuaternion;
  41925. private _disablePointerInputWhenUsingDeviceOrientation;
  41926. /**
  41927. * Creates a new device orientation camera
  41928. * @param name The name of the camera
  41929. * @param position The start position camera
  41930. * @param scene The scene the camera belongs to
  41931. */
  41932. constructor(name: string, position: Vector3, scene: Scene);
  41933. /**
  41934. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41935. */
  41936. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41937. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41938. private _dragFactor;
  41939. /**
  41940. * Enabled turning on the y axis when the orientation sensor is active
  41941. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41942. */
  41943. enableHorizontalDragging(dragFactor?: number): void;
  41944. /**
  41945. * Gets the current instance class name ("DeviceOrientationCamera").
  41946. * This helps avoiding instanceof at run time.
  41947. * @returns the class name
  41948. */
  41949. getClassName(): string;
  41950. /**
  41951. * @hidden
  41952. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41953. */
  41954. _checkInputs(): void;
  41955. /**
  41956. * Reset the camera to its default orientation on the specified axis only.
  41957. * @param axis The axis to reset
  41958. */
  41959. resetToCurrentRotation(axis?: Axis): void;
  41960. }
  41961. }
  41962. declare module "babylonjs/Gamepads/xboxGamepad" {
  41963. import { Observable } from "babylonjs/Misc/observable";
  41964. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41965. /**
  41966. * Defines supported buttons for XBox360 compatible gamepads
  41967. */
  41968. export enum Xbox360Button {
  41969. /** A */
  41970. A = 0,
  41971. /** B */
  41972. B = 1,
  41973. /** X */
  41974. X = 2,
  41975. /** Y */
  41976. Y = 3,
  41977. /** Start */
  41978. Start = 4,
  41979. /** Back */
  41980. Back = 5,
  41981. /** Left button */
  41982. LB = 6,
  41983. /** Right button */
  41984. RB = 7,
  41985. /** Left stick */
  41986. LeftStick = 8,
  41987. /** Right stick */
  41988. RightStick = 9
  41989. }
  41990. /** Defines values for XBox360 DPad */
  41991. export enum Xbox360Dpad {
  41992. /** Up */
  41993. Up = 0,
  41994. /** Down */
  41995. Down = 1,
  41996. /** Left */
  41997. Left = 2,
  41998. /** Right */
  41999. Right = 3
  42000. }
  42001. /**
  42002. * Defines a XBox360 gamepad
  42003. */
  42004. export class Xbox360Pad extends Gamepad {
  42005. private _leftTrigger;
  42006. private _rightTrigger;
  42007. private _onlefttriggerchanged;
  42008. private _onrighttriggerchanged;
  42009. private _onbuttondown;
  42010. private _onbuttonup;
  42011. private _ondpaddown;
  42012. private _ondpadup;
  42013. /** Observable raised when a button is pressed */
  42014. onButtonDownObservable: Observable<Xbox360Button>;
  42015. /** Observable raised when a button is released */
  42016. onButtonUpObservable: Observable<Xbox360Button>;
  42017. /** Observable raised when a pad is pressed */
  42018. onPadDownObservable: Observable<Xbox360Dpad>;
  42019. /** Observable raised when a pad is released */
  42020. onPadUpObservable: Observable<Xbox360Dpad>;
  42021. private _buttonA;
  42022. private _buttonB;
  42023. private _buttonX;
  42024. private _buttonY;
  42025. private _buttonBack;
  42026. private _buttonStart;
  42027. private _buttonLB;
  42028. private _buttonRB;
  42029. private _buttonLeftStick;
  42030. private _buttonRightStick;
  42031. private _dPadUp;
  42032. private _dPadDown;
  42033. private _dPadLeft;
  42034. private _dPadRight;
  42035. private _isXboxOnePad;
  42036. /**
  42037. * Creates a new XBox360 gamepad object
  42038. * @param id defines the id of this gamepad
  42039. * @param index defines its index
  42040. * @param gamepad defines the internal HTML gamepad object
  42041. * @param xboxOne defines if it is a XBox One gamepad
  42042. */
  42043. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42044. /**
  42045. * Defines the callback to call when left trigger is pressed
  42046. * @param callback defines the callback to use
  42047. */
  42048. onlefttriggerchanged(callback: (value: number) => void): void;
  42049. /**
  42050. * Defines the callback to call when right trigger is pressed
  42051. * @param callback defines the callback to use
  42052. */
  42053. onrighttriggerchanged(callback: (value: number) => void): void;
  42054. /**
  42055. * Gets the left trigger value
  42056. */
  42057. get leftTrigger(): number;
  42058. /**
  42059. * Sets the left trigger value
  42060. */
  42061. set leftTrigger(newValue: number);
  42062. /**
  42063. * Gets the right trigger value
  42064. */
  42065. get rightTrigger(): number;
  42066. /**
  42067. * Sets the right trigger value
  42068. */
  42069. set rightTrigger(newValue: number);
  42070. /**
  42071. * Defines the callback to call when a button is pressed
  42072. * @param callback defines the callback to use
  42073. */
  42074. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42075. /**
  42076. * Defines the callback to call when a button is released
  42077. * @param callback defines the callback to use
  42078. */
  42079. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42080. /**
  42081. * Defines the callback to call when a pad is pressed
  42082. * @param callback defines the callback to use
  42083. */
  42084. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42085. /**
  42086. * Defines the callback to call when a pad is released
  42087. * @param callback defines the callback to use
  42088. */
  42089. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42090. private _setButtonValue;
  42091. private _setDPadValue;
  42092. /**
  42093. * Gets the value of the `A` button
  42094. */
  42095. get buttonA(): number;
  42096. /**
  42097. * Sets the value of the `A` button
  42098. */
  42099. set buttonA(value: number);
  42100. /**
  42101. * Gets the value of the `B` button
  42102. */
  42103. get buttonB(): number;
  42104. /**
  42105. * Sets the value of the `B` button
  42106. */
  42107. set buttonB(value: number);
  42108. /**
  42109. * Gets the value of the `X` button
  42110. */
  42111. get buttonX(): number;
  42112. /**
  42113. * Sets the value of the `X` button
  42114. */
  42115. set buttonX(value: number);
  42116. /**
  42117. * Gets the value of the `Y` button
  42118. */
  42119. get buttonY(): number;
  42120. /**
  42121. * Sets the value of the `Y` button
  42122. */
  42123. set buttonY(value: number);
  42124. /**
  42125. * Gets the value of the `Start` button
  42126. */
  42127. get buttonStart(): number;
  42128. /**
  42129. * Sets the value of the `Start` button
  42130. */
  42131. set buttonStart(value: number);
  42132. /**
  42133. * Gets the value of the `Back` button
  42134. */
  42135. get buttonBack(): number;
  42136. /**
  42137. * Sets the value of the `Back` button
  42138. */
  42139. set buttonBack(value: number);
  42140. /**
  42141. * Gets the value of the `Left` button
  42142. */
  42143. get buttonLB(): number;
  42144. /**
  42145. * Sets the value of the `Left` button
  42146. */
  42147. set buttonLB(value: number);
  42148. /**
  42149. * Gets the value of the `Right` button
  42150. */
  42151. get buttonRB(): number;
  42152. /**
  42153. * Sets the value of the `Right` button
  42154. */
  42155. set buttonRB(value: number);
  42156. /**
  42157. * Gets the value of the Left joystick
  42158. */
  42159. get buttonLeftStick(): number;
  42160. /**
  42161. * Sets the value of the Left joystick
  42162. */
  42163. set buttonLeftStick(value: number);
  42164. /**
  42165. * Gets the value of the Right joystick
  42166. */
  42167. get buttonRightStick(): number;
  42168. /**
  42169. * Sets the value of the Right joystick
  42170. */
  42171. set buttonRightStick(value: number);
  42172. /**
  42173. * Gets the value of D-pad up
  42174. */
  42175. get dPadUp(): number;
  42176. /**
  42177. * Sets the value of D-pad up
  42178. */
  42179. set dPadUp(value: number);
  42180. /**
  42181. * Gets the value of D-pad down
  42182. */
  42183. get dPadDown(): number;
  42184. /**
  42185. * Sets the value of D-pad down
  42186. */
  42187. set dPadDown(value: number);
  42188. /**
  42189. * Gets the value of D-pad left
  42190. */
  42191. get dPadLeft(): number;
  42192. /**
  42193. * Sets the value of D-pad left
  42194. */
  42195. set dPadLeft(value: number);
  42196. /**
  42197. * Gets the value of D-pad right
  42198. */
  42199. get dPadRight(): number;
  42200. /**
  42201. * Sets the value of D-pad right
  42202. */
  42203. set dPadRight(value: number);
  42204. /**
  42205. * Force the gamepad to synchronize with device values
  42206. */
  42207. update(): void;
  42208. /**
  42209. * Disposes the gamepad
  42210. */
  42211. dispose(): void;
  42212. }
  42213. }
  42214. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42215. import { Observable } from "babylonjs/Misc/observable";
  42216. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42217. /**
  42218. * Defines supported buttons for DualShock compatible gamepads
  42219. */
  42220. export enum DualShockButton {
  42221. /** Cross */
  42222. Cross = 0,
  42223. /** Circle */
  42224. Circle = 1,
  42225. /** Square */
  42226. Square = 2,
  42227. /** Triangle */
  42228. Triangle = 3,
  42229. /** Options */
  42230. Options = 4,
  42231. /** Share */
  42232. Share = 5,
  42233. /** L1 */
  42234. L1 = 6,
  42235. /** R1 */
  42236. R1 = 7,
  42237. /** Left stick */
  42238. LeftStick = 8,
  42239. /** Right stick */
  42240. RightStick = 9
  42241. }
  42242. /** Defines values for DualShock DPad */
  42243. export enum DualShockDpad {
  42244. /** Up */
  42245. Up = 0,
  42246. /** Down */
  42247. Down = 1,
  42248. /** Left */
  42249. Left = 2,
  42250. /** Right */
  42251. Right = 3
  42252. }
  42253. /**
  42254. * Defines a DualShock gamepad
  42255. */
  42256. export class DualShockPad extends Gamepad {
  42257. private _leftTrigger;
  42258. private _rightTrigger;
  42259. private _onlefttriggerchanged;
  42260. private _onrighttriggerchanged;
  42261. private _onbuttondown;
  42262. private _onbuttonup;
  42263. private _ondpaddown;
  42264. private _ondpadup;
  42265. /** Observable raised when a button is pressed */
  42266. onButtonDownObservable: Observable<DualShockButton>;
  42267. /** Observable raised when a button is released */
  42268. onButtonUpObservable: Observable<DualShockButton>;
  42269. /** Observable raised when a pad is pressed */
  42270. onPadDownObservable: Observable<DualShockDpad>;
  42271. /** Observable raised when a pad is released */
  42272. onPadUpObservable: Observable<DualShockDpad>;
  42273. private _buttonCross;
  42274. private _buttonCircle;
  42275. private _buttonSquare;
  42276. private _buttonTriangle;
  42277. private _buttonShare;
  42278. private _buttonOptions;
  42279. private _buttonL1;
  42280. private _buttonR1;
  42281. private _buttonLeftStick;
  42282. private _buttonRightStick;
  42283. private _dPadUp;
  42284. private _dPadDown;
  42285. private _dPadLeft;
  42286. private _dPadRight;
  42287. /**
  42288. * Creates a new DualShock gamepad object
  42289. * @param id defines the id of this gamepad
  42290. * @param index defines its index
  42291. * @param gamepad defines the internal HTML gamepad object
  42292. */
  42293. constructor(id: string, index: number, gamepad: any);
  42294. /**
  42295. * Defines the callback to call when left trigger is pressed
  42296. * @param callback defines the callback to use
  42297. */
  42298. onlefttriggerchanged(callback: (value: number) => void): void;
  42299. /**
  42300. * Defines the callback to call when right trigger is pressed
  42301. * @param callback defines the callback to use
  42302. */
  42303. onrighttriggerchanged(callback: (value: number) => void): void;
  42304. /**
  42305. * Gets the left trigger value
  42306. */
  42307. get leftTrigger(): number;
  42308. /**
  42309. * Sets the left trigger value
  42310. */
  42311. set leftTrigger(newValue: number);
  42312. /**
  42313. * Gets the right trigger value
  42314. */
  42315. get rightTrigger(): number;
  42316. /**
  42317. * Sets the right trigger value
  42318. */
  42319. set rightTrigger(newValue: number);
  42320. /**
  42321. * Defines the callback to call when a button is pressed
  42322. * @param callback defines the callback to use
  42323. */
  42324. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42325. /**
  42326. * Defines the callback to call when a button is released
  42327. * @param callback defines the callback to use
  42328. */
  42329. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42330. /**
  42331. * Defines the callback to call when a pad is pressed
  42332. * @param callback defines the callback to use
  42333. */
  42334. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42335. /**
  42336. * Defines the callback to call when a pad is released
  42337. * @param callback defines the callback to use
  42338. */
  42339. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42340. private _setButtonValue;
  42341. private _setDPadValue;
  42342. /**
  42343. * Gets the value of the `Cross` button
  42344. */
  42345. get buttonCross(): number;
  42346. /**
  42347. * Sets the value of the `Cross` button
  42348. */
  42349. set buttonCross(value: number);
  42350. /**
  42351. * Gets the value of the `Circle` button
  42352. */
  42353. get buttonCircle(): number;
  42354. /**
  42355. * Sets the value of the `Circle` button
  42356. */
  42357. set buttonCircle(value: number);
  42358. /**
  42359. * Gets the value of the `Square` button
  42360. */
  42361. get buttonSquare(): number;
  42362. /**
  42363. * Sets the value of the `Square` button
  42364. */
  42365. set buttonSquare(value: number);
  42366. /**
  42367. * Gets the value of the `Triangle` button
  42368. */
  42369. get buttonTriangle(): number;
  42370. /**
  42371. * Sets the value of the `Triangle` button
  42372. */
  42373. set buttonTriangle(value: number);
  42374. /**
  42375. * Gets the value of the `Options` button
  42376. */
  42377. get buttonOptions(): number;
  42378. /**
  42379. * Sets the value of the `Options` button
  42380. */
  42381. set buttonOptions(value: number);
  42382. /**
  42383. * Gets the value of the `Share` button
  42384. */
  42385. get buttonShare(): number;
  42386. /**
  42387. * Sets the value of the `Share` button
  42388. */
  42389. set buttonShare(value: number);
  42390. /**
  42391. * Gets the value of the `L1` button
  42392. */
  42393. get buttonL1(): number;
  42394. /**
  42395. * Sets the value of the `L1` button
  42396. */
  42397. set buttonL1(value: number);
  42398. /**
  42399. * Gets the value of the `R1` button
  42400. */
  42401. get buttonR1(): number;
  42402. /**
  42403. * Sets the value of the `R1` button
  42404. */
  42405. set buttonR1(value: number);
  42406. /**
  42407. * Gets the value of the Left joystick
  42408. */
  42409. get buttonLeftStick(): number;
  42410. /**
  42411. * Sets the value of the Left joystick
  42412. */
  42413. set buttonLeftStick(value: number);
  42414. /**
  42415. * Gets the value of the Right joystick
  42416. */
  42417. get buttonRightStick(): number;
  42418. /**
  42419. * Sets the value of the Right joystick
  42420. */
  42421. set buttonRightStick(value: number);
  42422. /**
  42423. * Gets the value of D-pad up
  42424. */
  42425. get dPadUp(): number;
  42426. /**
  42427. * Sets the value of D-pad up
  42428. */
  42429. set dPadUp(value: number);
  42430. /**
  42431. * Gets the value of D-pad down
  42432. */
  42433. get dPadDown(): number;
  42434. /**
  42435. * Sets the value of D-pad down
  42436. */
  42437. set dPadDown(value: number);
  42438. /**
  42439. * Gets the value of D-pad left
  42440. */
  42441. get dPadLeft(): number;
  42442. /**
  42443. * Sets the value of D-pad left
  42444. */
  42445. set dPadLeft(value: number);
  42446. /**
  42447. * Gets the value of D-pad right
  42448. */
  42449. get dPadRight(): number;
  42450. /**
  42451. * Sets the value of D-pad right
  42452. */
  42453. set dPadRight(value: number);
  42454. /**
  42455. * Force the gamepad to synchronize with device values
  42456. */
  42457. update(): void;
  42458. /**
  42459. * Disposes the gamepad
  42460. */
  42461. dispose(): void;
  42462. }
  42463. }
  42464. declare module "babylonjs/Gamepads/gamepadManager" {
  42465. import { Observable } from "babylonjs/Misc/observable";
  42466. import { Nullable } from "babylonjs/types";
  42467. import { Scene } from "babylonjs/scene";
  42468. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42469. /**
  42470. * Manager for handling gamepads
  42471. */
  42472. export class GamepadManager {
  42473. private _scene?;
  42474. private _babylonGamepads;
  42475. private _oneGamepadConnected;
  42476. /** @hidden */
  42477. _isMonitoring: boolean;
  42478. private _gamepadEventSupported;
  42479. private _gamepadSupport?;
  42480. /**
  42481. * observable to be triggered when the gamepad controller has been connected
  42482. */
  42483. onGamepadConnectedObservable: Observable<Gamepad>;
  42484. /**
  42485. * observable to be triggered when the gamepad controller has been disconnected
  42486. */
  42487. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42488. private _onGamepadConnectedEvent;
  42489. private _onGamepadDisconnectedEvent;
  42490. /**
  42491. * Initializes the gamepad manager
  42492. * @param _scene BabylonJS scene
  42493. */
  42494. constructor(_scene?: Scene | undefined);
  42495. /**
  42496. * The gamepads in the game pad manager
  42497. */
  42498. get gamepads(): Gamepad[];
  42499. /**
  42500. * Get the gamepad controllers based on type
  42501. * @param type The type of gamepad controller
  42502. * @returns Nullable gamepad
  42503. */
  42504. getGamepadByType(type?: number): Nullable<Gamepad>;
  42505. /**
  42506. * Disposes the gamepad manager
  42507. */
  42508. dispose(): void;
  42509. private _addNewGamepad;
  42510. private _startMonitoringGamepads;
  42511. private _stopMonitoringGamepads;
  42512. /** @hidden */
  42513. _checkGamepadsStatus(): void;
  42514. private _updateGamepadObjects;
  42515. }
  42516. }
  42517. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42518. import { Nullable } from "babylonjs/types";
  42519. import { Scene } from "babylonjs/scene";
  42520. import { ISceneComponent } from "babylonjs/sceneComponent";
  42521. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42522. module "babylonjs/scene" {
  42523. interface Scene {
  42524. /** @hidden */
  42525. _gamepadManager: Nullable<GamepadManager>;
  42526. /**
  42527. * Gets the gamepad manager associated with the scene
  42528. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42529. */
  42530. gamepadManager: GamepadManager;
  42531. }
  42532. }
  42533. module "babylonjs/Cameras/freeCameraInputsManager" {
  42534. /**
  42535. * Interface representing a free camera inputs manager
  42536. */
  42537. interface FreeCameraInputsManager {
  42538. /**
  42539. * Adds gamepad input support to the FreeCameraInputsManager.
  42540. * @returns the FreeCameraInputsManager
  42541. */
  42542. addGamepad(): FreeCameraInputsManager;
  42543. }
  42544. }
  42545. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42546. /**
  42547. * Interface representing an arc rotate camera inputs manager
  42548. */
  42549. interface ArcRotateCameraInputsManager {
  42550. /**
  42551. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42552. * @returns the camera inputs manager
  42553. */
  42554. addGamepad(): ArcRotateCameraInputsManager;
  42555. }
  42556. }
  42557. /**
  42558. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42559. */
  42560. export class GamepadSystemSceneComponent implements ISceneComponent {
  42561. /**
  42562. * The component name helpfull to identify the component in the list of scene components.
  42563. */
  42564. readonly name: string;
  42565. /**
  42566. * The scene the component belongs to.
  42567. */
  42568. scene: Scene;
  42569. /**
  42570. * Creates a new instance of the component for the given scene
  42571. * @param scene Defines the scene to register the component in
  42572. */
  42573. constructor(scene: Scene);
  42574. /**
  42575. * Registers the component in a given scene
  42576. */
  42577. register(): void;
  42578. /**
  42579. * Rebuilds the elements related to this component in case of
  42580. * context lost for instance.
  42581. */
  42582. rebuild(): void;
  42583. /**
  42584. * Disposes the component and the associated ressources
  42585. */
  42586. dispose(): void;
  42587. private _beforeCameraUpdate;
  42588. }
  42589. }
  42590. declare module "babylonjs/Cameras/universalCamera" {
  42591. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42592. import { Scene } from "babylonjs/scene";
  42593. import { Vector3 } from "babylonjs/Maths/math.vector";
  42594. import "babylonjs/Gamepads/gamepadSceneComponent";
  42595. /**
  42596. * 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,
  42597. * which still works and will still be found in many Playgrounds.
  42598. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42599. */
  42600. export class UniversalCamera extends TouchCamera {
  42601. /**
  42602. * Defines the gamepad rotation sensiblity.
  42603. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42604. */
  42605. get gamepadAngularSensibility(): number;
  42606. set gamepadAngularSensibility(value: number);
  42607. /**
  42608. * Defines the gamepad move sensiblity.
  42609. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42610. */
  42611. get gamepadMoveSensibility(): number;
  42612. set gamepadMoveSensibility(value: number);
  42613. /**
  42614. * 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,
  42615. * which still works and will still be found in many Playgrounds.
  42616. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42617. * @param name Define the name of the camera in the scene
  42618. * @param position Define the start position of the camera in the scene
  42619. * @param scene Define the scene the camera belongs to
  42620. */
  42621. constructor(name: string, position: Vector3, scene: Scene);
  42622. /**
  42623. * Gets the current object class name.
  42624. * @return the class name
  42625. */
  42626. getClassName(): string;
  42627. }
  42628. }
  42629. declare module "babylonjs/Cameras/gamepadCamera" {
  42630. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42631. import { Scene } from "babylonjs/scene";
  42632. import { Vector3 } from "babylonjs/Maths/math.vector";
  42633. /**
  42634. * This represents a FPS type of camera. This is only here for back compat purpose.
  42635. * Please use the UniversalCamera instead as both are identical.
  42636. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42637. */
  42638. export class GamepadCamera extends UniversalCamera {
  42639. /**
  42640. * Instantiates a new Gamepad Camera
  42641. * This represents a FPS type of camera. This is only here for back compat purpose.
  42642. * Please use the UniversalCamera instead as both are identical.
  42643. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42644. * @param name Define the name of the camera in the scene
  42645. * @param position Define the start position of the camera in the scene
  42646. * @param scene Define the scene the camera belongs to
  42647. */
  42648. constructor(name: string, position: Vector3, scene: Scene);
  42649. /**
  42650. * Gets the current object class name.
  42651. * @return the class name
  42652. */
  42653. getClassName(): string;
  42654. }
  42655. }
  42656. declare module "babylonjs/Shaders/pass.fragment" {
  42657. /** @hidden */
  42658. export var passPixelShader: {
  42659. name: string;
  42660. shader: string;
  42661. };
  42662. }
  42663. declare module "babylonjs/Shaders/passCube.fragment" {
  42664. /** @hidden */
  42665. export var passCubePixelShader: {
  42666. name: string;
  42667. shader: string;
  42668. };
  42669. }
  42670. declare module "babylonjs/PostProcesses/passPostProcess" {
  42671. import { Nullable } from "babylonjs/types";
  42672. import { Camera } from "babylonjs/Cameras/camera";
  42673. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42674. import { Engine } from "babylonjs/Engines/engine";
  42675. import "babylonjs/Shaders/pass.fragment";
  42676. import "babylonjs/Shaders/passCube.fragment";
  42677. /**
  42678. * PassPostProcess which produces an output the same as it's input
  42679. */
  42680. export class PassPostProcess extends PostProcess {
  42681. /**
  42682. * Creates the PassPostProcess
  42683. * @param name The name of the effect.
  42684. * @param options The required width/height ratio to downsize to before computing the render pass.
  42685. * @param camera The camera to apply the render pass to.
  42686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42687. * @param engine The engine which the post process will be applied. (default: current engine)
  42688. * @param reusable If the post process can be reused on the same frame. (default: false)
  42689. * @param textureType The type of texture to be used when performing the post processing.
  42690. * @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)
  42691. */
  42692. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42693. }
  42694. /**
  42695. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42696. */
  42697. export class PassCubePostProcess extends PostProcess {
  42698. private _face;
  42699. /**
  42700. * Gets or sets the cube face to display.
  42701. * * 0 is +X
  42702. * * 1 is -X
  42703. * * 2 is +Y
  42704. * * 3 is -Y
  42705. * * 4 is +Z
  42706. * * 5 is -Z
  42707. */
  42708. get face(): number;
  42709. set face(value: number);
  42710. /**
  42711. * Creates the PassCubePostProcess
  42712. * @param name The name of the effect.
  42713. * @param options The required width/height ratio to downsize to before computing the render pass.
  42714. * @param camera The camera to apply the render pass to.
  42715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42716. * @param engine The engine which the post process will be applied. (default: current engine)
  42717. * @param reusable If the post process can be reused on the same frame. (default: false)
  42718. * @param textureType The type of texture to be used when performing the post processing.
  42719. * @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)
  42720. */
  42721. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42722. }
  42723. }
  42724. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42725. /** @hidden */
  42726. export var anaglyphPixelShader: {
  42727. name: string;
  42728. shader: string;
  42729. };
  42730. }
  42731. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42732. import { Engine } from "babylonjs/Engines/engine";
  42733. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42734. import { Camera } from "babylonjs/Cameras/camera";
  42735. import "babylonjs/Shaders/anaglyph.fragment";
  42736. /**
  42737. * Postprocess used to generate anaglyphic rendering
  42738. */
  42739. export class AnaglyphPostProcess extends PostProcess {
  42740. private _passedProcess;
  42741. /**
  42742. * Creates a new AnaglyphPostProcess
  42743. * @param name defines postprocess name
  42744. * @param options defines creation options or target ratio scale
  42745. * @param rigCameras defines cameras using this postprocess
  42746. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42747. * @param engine defines hosting engine
  42748. * @param reusable defines if the postprocess will be reused multiple times per frame
  42749. */
  42750. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42751. }
  42752. }
  42753. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42754. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42755. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42756. import { Scene } from "babylonjs/scene";
  42757. import { Vector3 } from "babylonjs/Maths/math.vector";
  42758. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42759. /**
  42760. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42761. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42762. */
  42763. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42764. /**
  42765. * Creates a new AnaglyphArcRotateCamera
  42766. * @param name defines camera name
  42767. * @param alpha defines alpha angle (in radians)
  42768. * @param beta defines beta angle (in radians)
  42769. * @param radius defines radius
  42770. * @param target defines camera target
  42771. * @param interaxialDistance defines distance between each color axis
  42772. * @param scene defines the hosting scene
  42773. */
  42774. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42775. /**
  42776. * Gets camera class name
  42777. * @returns AnaglyphArcRotateCamera
  42778. */
  42779. getClassName(): string;
  42780. }
  42781. }
  42782. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42783. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42784. import { Scene } from "babylonjs/scene";
  42785. import { Vector3 } from "babylonjs/Maths/math.vector";
  42786. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42787. /**
  42788. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42789. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42790. */
  42791. export class AnaglyphFreeCamera extends FreeCamera {
  42792. /**
  42793. * Creates a new AnaglyphFreeCamera
  42794. * @param name defines camera name
  42795. * @param position defines initial position
  42796. * @param interaxialDistance defines distance between each color axis
  42797. * @param scene defines the hosting scene
  42798. */
  42799. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42800. /**
  42801. * Gets camera class name
  42802. * @returns AnaglyphFreeCamera
  42803. */
  42804. getClassName(): string;
  42805. }
  42806. }
  42807. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42808. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42809. import { Scene } from "babylonjs/scene";
  42810. import { Vector3 } from "babylonjs/Maths/math.vector";
  42811. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42812. /**
  42813. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42814. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42815. */
  42816. export class AnaglyphGamepadCamera extends GamepadCamera {
  42817. /**
  42818. * Creates a new AnaglyphGamepadCamera
  42819. * @param name defines camera name
  42820. * @param position defines initial position
  42821. * @param interaxialDistance defines distance between each color axis
  42822. * @param scene defines the hosting scene
  42823. */
  42824. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42825. /**
  42826. * Gets camera class name
  42827. * @returns AnaglyphGamepadCamera
  42828. */
  42829. getClassName(): string;
  42830. }
  42831. }
  42832. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42833. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42834. import { Scene } from "babylonjs/scene";
  42835. import { Vector3 } from "babylonjs/Maths/math.vector";
  42836. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42837. /**
  42838. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42839. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42840. */
  42841. export class AnaglyphUniversalCamera extends UniversalCamera {
  42842. /**
  42843. * Creates a new AnaglyphUniversalCamera
  42844. * @param name defines camera name
  42845. * @param position defines initial position
  42846. * @param interaxialDistance defines distance between each color axis
  42847. * @param scene defines the hosting scene
  42848. */
  42849. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42850. /**
  42851. * Gets camera class name
  42852. * @returns AnaglyphUniversalCamera
  42853. */
  42854. getClassName(): string;
  42855. }
  42856. }
  42857. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42858. /** @hidden */
  42859. export var stereoscopicInterlacePixelShader: {
  42860. name: string;
  42861. shader: string;
  42862. };
  42863. }
  42864. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42865. import { Camera } from "babylonjs/Cameras/camera";
  42866. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42867. import { Engine } from "babylonjs/Engines/engine";
  42868. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42869. /**
  42870. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42871. */
  42872. export class StereoscopicInterlacePostProcess extends PostProcess {
  42873. private _stepSize;
  42874. private _passedProcess;
  42875. /**
  42876. * Initializes a StereoscopicInterlacePostProcess
  42877. * @param name The name of the effect.
  42878. * @param rigCameras The rig cameras to be appled to the post process
  42879. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42881. * @param engine The engine which the post process will be applied. (default: current engine)
  42882. * @param reusable If the post process can be reused on the same frame. (default: false)
  42883. */
  42884. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42885. }
  42886. }
  42887. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42888. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42889. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42890. import { Scene } from "babylonjs/scene";
  42891. import { Vector3 } from "babylonjs/Maths/math.vector";
  42892. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42893. /**
  42894. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42895. * @see http://doc.babylonjs.com/features/cameras
  42896. */
  42897. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42898. /**
  42899. * Creates a new StereoscopicArcRotateCamera
  42900. * @param name defines camera name
  42901. * @param alpha defines alpha angle (in radians)
  42902. * @param beta defines beta angle (in radians)
  42903. * @param radius defines radius
  42904. * @param target defines camera target
  42905. * @param interaxialDistance defines distance between each color axis
  42906. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42907. * @param scene defines the hosting scene
  42908. */
  42909. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42910. /**
  42911. * Gets camera class name
  42912. * @returns StereoscopicArcRotateCamera
  42913. */
  42914. getClassName(): string;
  42915. }
  42916. }
  42917. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42918. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42919. import { Scene } from "babylonjs/scene";
  42920. import { Vector3 } from "babylonjs/Maths/math.vector";
  42921. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42922. /**
  42923. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42924. * @see http://doc.babylonjs.com/features/cameras
  42925. */
  42926. export class StereoscopicFreeCamera extends FreeCamera {
  42927. /**
  42928. * Creates a new StereoscopicFreeCamera
  42929. * @param name defines camera name
  42930. * @param position defines initial position
  42931. * @param interaxialDistance defines distance between each color axis
  42932. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42933. * @param scene defines the hosting scene
  42934. */
  42935. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42936. /**
  42937. * Gets camera class name
  42938. * @returns StereoscopicFreeCamera
  42939. */
  42940. getClassName(): string;
  42941. }
  42942. }
  42943. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42944. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42945. import { Scene } from "babylonjs/scene";
  42946. import { Vector3 } from "babylonjs/Maths/math.vector";
  42947. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42948. /**
  42949. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42950. * @see http://doc.babylonjs.com/features/cameras
  42951. */
  42952. export class StereoscopicGamepadCamera extends GamepadCamera {
  42953. /**
  42954. * Creates a new StereoscopicGamepadCamera
  42955. * @param name defines camera name
  42956. * @param position defines initial position
  42957. * @param interaxialDistance defines distance between each color axis
  42958. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42959. * @param scene defines the hosting scene
  42960. */
  42961. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42962. /**
  42963. * Gets camera class name
  42964. * @returns StereoscopicGamepadCamera
  42965. */
  42966. getClassName(): string;
  42967. }
  42968. }
  42969. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42970. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42971. import { Scene } from "babylonjs/scene";
  42972. import { Vector3 } from "babylonjs/Maths/math.vector";
  42973. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42974. /**
  42975. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42976. * @see http://doc.babylonjs.com/features/cameras
  42977. */
  42978. export class StereoscopicUniversalCamera extends UniversalCamera {
  42979. /**
  42980. * Creates a new StereoscopicUniversalCamera
  42981. * @param name defines camera name
  42982. * @param position defines initial position
  42983. * @param interaxialDistance defines distance between each color axis
  42984. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42985. * @param scene defines the hosting scene
  42986. */
  42987. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42988. /**
  42989. * Gets camera class name
  42990. * @returns StereoscopicUniversalCamera
  42991. */
  42992. getClassName(): string;
  42993. }
  42994. }
  42995. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42996. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42997. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42998. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42999. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43000. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43001. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43002. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43003. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43004. }
  43005. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43006. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43007. import { Scene } from "babylonjs/scene";
  43008. import { Vector3 } from "babylonjs/Maths/math.vector";
  43009. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43010. /**
  43011. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43012. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43013. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43014. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43015. */
  43016. export class VirtualJoysticksCamera extends FreeCamera {
  43017. /**
  43018. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43019. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43020. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43021. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43022. * @param name Define the name of the camera in the scene
  43023. * @param position Define the start position of the camera in the scene
  43024. * @param scene Define the scene the camera belongs to
  43025. */
  43026. constructor(name: string, position: Vector3, scene: Scene);
  43027. /**
  43028. * Gets the current object class name.
  43029. * @return the class name
  43030. */
  43031. getClassName(): string;
  43032. }
  43033. }
  43034. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43035. import { Matrix } from "babylonjs/Maths/math.vector";
  43036. /**
  43037. * This represents all the required metrics to create a VR camera.
  43038. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43039. */
  43040. export class VRCameraMetrics {
  43041. /**
  43042. * Define the horizontal resolution off the screen.
  43043. */
  43044. hResolution: number;
  43045. /**
  43046. * Define the vertical resolution off the screen.
  43047. */
  43048. vResolution: number;
  43049. /**
  43050. * Define the horizontal screen size.
  43051. */
  43052. hScreenSize: number;
  43053. /**
  43054. * Define the vertical screen size.
  43055. */
  43056. vScreenSize: number;
  43057. /**
  43058. * Define the vertical screen center position.
  43059. */
  43060. vScreenCenter: number;
  43061. /**
  43062. * Define the distance of the eyes to the screen.
  43063. */
  43064. eyeToScreenDistance: number;
  43065. /**
  43066. * Define the distance between both lenses
  43067. */
  43068. lensSeparationDistance: number;
  43069. /**
  43070. * Define the distance between both viewer's eyes.
  43071. */
  43072. interpupillaryDistance: number;
  43073. /**
  43074. * Define the distortion factor of the VR postprocess.
  43075. * Please, touch with care.
  43076. */
  43077. distortionK: number[];
  43078. /**
  43079. * Define the chromatic aberration correction factors for the VR post process.
  43080. */
  43081. chromaAbCorrection: number[];
  43082. /**
  43083. * Define the scale factor of the post process.
  43084. * The smaller the better but the slower.
  43085. */
  43086. postProcessScaleFactor: number;
  43087. /**
  43088. * Define an offset for the lens center.
  43089. */
  43090. lensCenterOffset: number;
  43091. /**
  43092. * Define if the current vr camera should compensate the distortion of the lense or not.
  43093. */
  43094. compensateDistortion: boolean;
  43095. /**
  43096. * Defines if multiview should be enabled when rendering (Default: false)
  43097. */
  43098. multiviewEnabled: boolean;
  43099. /**
  43100. * Gets the rendering aspect ratio based on the provided resolutions.
  43101. */
  43102. get aspectRatio(): number;
  43103. /**
  43104. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43105. */
  43106. get aspectRatioFov(): number;
  43107. /**
  43108. * @hidden
  43109. */
  43110. get leftHMatrix(): Matrix;
  43111. /**
  43112. * @hidden
  43113. */
  43114. get rightHMatrix(): Matrix;
  43115. /**
  43116. * @hidden
  43117. */
  43118. get leftPreViewMatrix(): Matrix;
  43119. /**
  43120. * @hidden
  43121. */
  43122. get rightPreViewMatrix(): Matrix;
  43123. /**
  43124. * Get the default VRMetrics based on the most generic setup.
  43125. * @returns the default vr metrics
  43126. */
  43127. static GetDefault(): VRCameraMetrics;
  43128. }
  43129. }
  43130. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43131. /** @hidden */
  43132. export var vrDistortionCorrectionPixelShader: {
  43133. name: string;
  43134. shader: string;
  43135. };
  43136. }
  43137. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43138. import { Camera } from "babylonjs/Cameras/camera";
  43139. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43141. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43142. /**
  43143. * VRDistortionCorrectionPostProcess used for mobile VR
  43144. */
  43145. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43146. private _isRightEye;
  43147. private _distortionFactors;
  43148. private _postProcessScaleFactor;
  43149. private _lensCenterOffset;
  43150. private _scaleIn;
  43151. private _scaleFactor;
  43152. private _lensCenter;
  43153. /**
  43154. * Initializes the VRDistortionCorrectionPostProcess
  43155. * @param name The name of the effect.
  43156. * @param camera The camera to apply the render pass to.
  43157. * @param isRightEye If this is for the right eye distortion
  43158. * @param vrMetrics All the required metrics for the VR camera
  43159. */
  43160. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43161. }
  43162. }
  43163. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43164. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43165. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43166. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43167. import { Scene } from "babylonjs/scene";
  43168. import { Vector3 } from "babylonjs/Maths/math.vector";
  43169. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43170. import "babylonjs/Cameras/RigModes/vrRigMode";
  43171. /**
  43172. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43173. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43174. */
  43175. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43176. /**
  43177. * Creates a new VRDeviceOrientationArcRotateCamera
  43178. * @param name defines camera name
  43179. * @param alpha defines the camera rotation along the logitudinal axis
  43180. * @param beta defines the camera rotation along the latitudinal axis
  43181. * @param radius defines the camera distance from its target
  43182. * @param target defines the camera target
  43183. * @param scene defines the scene the camera belongs to
  43184. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43185. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43186. */
  43187. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43188. /**
  43189. * Gets camera class name
  43190. * @returns VRDeviceOrientationArcRotateCamera
  43191. */
  43192. getClassName(): string;
  43193. }
  43194. }
  43195. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43196. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43197. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43198. import { Scene } from "babylonjs/scene";
  43199. import { Vector3 } from "babylonjs/Maths/math.vector";
  43200. import "babylonjs/Cameras/RigModes/vrRigMode";
  43201. /**
  43202. * Camera used to simulate VR rendering (based on FreeCamera)
  43203. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43204. */
  43205. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43206. /**
  43207. * Creates a new VRDeviceOrientationFreeCamera
  43208. * @param name defines camera name
  43209. * @param position defines the start position of the camera
  43210. * @param scene defines the scene the camera belongs to
  43211. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43212. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43213. */
  43214. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43215. /**
  43216. * Gets camera class name
  43217. * @returns VRDeviceOrientationFreeCamera
  43218. */
  43219. getClassName(): string;
  43220. }
  43221. }
  43222. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43223. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43224. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43225. import { Scene } from "babylonjs/scene";
  43226. import { Vector3 } from "babylonjs/Maths/math.vector";
  43227. import "babylonjs/Gamepads/gamepadSceneComponent";
  43228. /**
  43229. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43230. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43231. */
  43232. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43233. /**
  43234. * Creates a new VRDeviceOrientationGamepadCamera
  43235. * @param name defines camera name
  43236. * @param position defines the start position of the camera
  43237. * @param scene defines the scene the camera belongs to
  43238. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43239. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43240. */
  43241. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43242. /**
  43243. * Gets camera class name
  43244. * @returns VRDeviceOrientationGamepadCamera
  43245. */
  43246. getClassName(): string;
  43247. }
  43248. }
  43249. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43250. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43251. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43252. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43253. /** @hidden */
  43254. export var imageProcessingPixelShader: {
  43255. name: string;
  43256. shader: string;
  43257. };
  43258. }
  43259. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43260. import { Nullable } from "babylonjs/types";
  43261. import { Color4 } from "babylonjs/Maths/math.color";
  43262. import { Camera } from "babylonjs/Cameras/camera";
  43263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43264. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43265. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43266. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43267. import { Engine } from "babylonjs/Engines/engine";
  43268. import "babylonjs/Shaders/imageProcessing.fragment";
  43269. import "babylonjs/Shaders/postprocess.vertex";
  43270. /**
  43271. * ImageProcessingPostProcess
  43272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43273. */
  43274. export class ImageProcessingPostProcess extends PostProcess {
  43275. /**
  43276. * Default configuration related to image processing available in the PBR Material.
  43277. */
  43278. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43279. /**
  43280. * Gets the image processing configuration used either in this material.
  43281. */
  43282. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43283. /**
  43284. * Sets the Default image processing configuration used either in the this material.
  43285. *
  43286. * If sets to null, the scene one is in use.
  43287. */
  43288. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43289. /**
  43290. * Keep track of the image processing observer to allow dispose and replace.
  43291. */
  43292. private _imageProcessingObserver;
  43293. /**
  43294. * Attaches a new image processing configuration to the PBR Material.
  43295. * @param configuration
  43296. */
  43297. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43298. /**
  43299. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43300. */
  43301. get colorCurves(): Nullable<ColorCurves>;
  43302. /**
  43303. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43304. */
  43305. set colorCurves(value: Nullable<ColorCurves>);
  43306. /**
  43307. * Gets wether the color curves effect is enabled.
  43308. */
  43309. get colorCurvesEnabled(): boolean;
  43310. /**
  43311. * Sets wether the color curves effect is enabled.
  43312. */
  43313. set colorCurvesEnabled(value: boolean);
  43314. /**
  43315. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43316. */
  43317. get colorGradingTexture(): Nullable<BaseTexture>;
  43318. /**
  43319. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43320. */
  43321. set colorGradingTexture(value: Nullable<BaseTexture>);
  43322. /**
  43323. * Gets wether the color grading effect is enabled.
  43324. */
  43325. get colorGradingEnabled(): boolean;
  43326. /**
  43327. * Gets wether the color grading effect is enabled.
  43328. */
  43329. set colorGradingEnabled(value: boolean);
  43330. /**
  43331. * Gets exposure used in the effect.
  43332. */
  43333. get exposure(): number;
  43334. /**
  43335. * Sets exposure used in the effect.
  43336. */
  43337. set exposure(value: number);
  43338. /**
  43339. * Gets wether tonemapping is enabled or not.
  43340. */
  43341. get toneMappingEnabled(): boolean;
  43342. /**
  43343. * Sets wether tonemapping is enabled or not
  43344. */
  43345. set toneMappingEnabled(value: boolean);
  43346. /**
  43347. * Gets the type of tone mapping effect.
  43348. */
  43349. get toneMappingType(): number;
  43350. /**
  43351. * Sets the type of tone mapping effect.
  43352. */
  43353. set toneMappingType(value: number);
  43354. /**
  43355. * Gets contrast used in the effect.
  43356. */
  43357. get contrast(): number;
  43358. /**
  43359. * Sets contrast used in the effect.
  43360. */
  43361. set contrast(value: number);
  43362. /**
  43363. * Gets Vignette stretch size.
  43364. */
  43365. get vignetteStretch(): number;
  43366. /**
  43367. * Sets Vignette stretch size.
  43368. */
  43369. set vignetteStretch(value: number);
  43370. /**
  43371. * Gets Vignette centre X Offset.
  43372. */
  43373. get vignetteCentreX(): number;
  43374. /**
  43375. * Sets Vignette centre X Offset.
  43376. */
  43377. set vignetteCentreX(value: number);
  43378. /**
  43379. * Gets Vignette centre Y Offset.
  43380. */
  43381. get vignetteCentreY(): number;
  43382. /**
  43383. * Sets Vignette centre Y Offset.
  43384. */
  43385. set vignetteCentreY(value: number);
  43386. /**
  43387. * Gets Vignette weight or intensity of the vignette effect.
  43388. */
  43389. get vignetteWeight(): number;
  43390. /**
  43391. * Sets Vignette weight or intensity of the vignette effect.
  43392. */
  43393. set vignetteWeight(value: number);
  43394. /**
  43395. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43396. * if vignetteEnabled is set to true.
  43397. */
  43398. get vignetteColor(): Color4;
  43399. /**
  43400. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43401. * if vignetteEnabled is set to true.
  43402. */
  43403. set vignetteColor(value: Color4);
  43404. /**
  43405. * Gets Camera field of view used by the Vignette effect.
  43406. */
  43407. get vignetteCameraFov(): number;
  43408. /**
  43409. * Sets Camera field of view used by the Vignette effect.
  43410. */
  43411. set vignetteCameraFov(value: number);
  43412. /**
  43413. * Gets the vignette blend mode allowing different kind of effect.
  43414. */
  43415. get vignetteBlendMode(): number;
  43416. /**
  43417. * Sets the vignette blend mode allowing different kind of effect.
  43418. */
  43419. set vignetteBlendMode(value: number);
  43420. /**
  43421. * Gets wether the vignette effect is enabled.
  43422. */
  43423. get vignetteEnabled(): boolean;
  43424. /**
  43425. * Sets wether the vignette effect is enabled.
  43426. */
  43427. set vignetteEnabled(value: boolean);
  43428. private _fromLinearSpace;
  43429. /**
  43430. * Gets wether the input of the processing is in Gamma or Linear Space.
  43431. */
  43432. get fromLinearSpace(): boolean;
  43433. /**
  43434. * Sets wether the input of the processing is in Gamma or Linear Space.
  43435. */
  43436. set fromLinearSpace(value: boolean);
  43437. /**
  43438. * Defines cache preventing GC.
  43439. */
  43440. private _defines;
  43441. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43442. /**
  43443. * "ImageProcessingPostProcess"
  43444. * @returns "ImageProcessingPostProcess"
  43445. */
  43446. getClassName(): string;
  43447. protected _updateParameters(): void;
  43448. dispose(camera?: Camera): void;
  43449. }
  43450. }
  43451. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43452. import { Scene } from "babylonjs/scene";
  43453. import { Color3 } from "babylonjs/Maths/math.color";
  43454. import { Mesh } from "babylonjs/Meshes/mesh";
  43455. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43456. import { Nullable } from "babylonjs/types";
  43457. /**
  43458. * Class containing static functions to help procedurally build meshes
  43459. */
  43460. export class GroundBuilder {
  43461. /**
  43462. * Creates a ground mesh
  43463. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43464. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43466. * @param name defines the name of the mesh
  43467. * @param options defines the options used to create the mesh
  43468. * @param scene defines the hosting scene
  43469. * @returns the ground mesh
  43470. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43471. */
  43472. static CreateGround(name: string, options: {
  43473. width?: number;
  43474. height?: number;
  43475. subdivisions?: number;
  43476. subdivisionsX?: number;
  43477. subdivisionsY?: number;
  43478. updatable?: boolean;
  43479. }, scene: any): Mesh;
  43480. /**
  43481. * Creates a tiled ground mesh
  43482. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43483. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43484. * * 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
  43485. * * 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
  43486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43487. * @param name defines the name of the mesh
  43488. * @param options defines the options used to create the mesh
  43489. * @param scene defines the hosting scene
  43490. * @returns the tiled ground mesh
  43491. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43492. */
  43493. static CreateTiledGround(name: string, options: {
  43494. xmin: number;
  43495. zmin: number;
  43496. xmax: number;
  43497. zmax: number;
  43498. subdivisions?: {
  43499. w: number;
  43500. h: number;
  43501. };
  43502. precision?: {
  43503. w: number;
  43504. h: number;
  43505. };
  43506. updatable?: boolean;
  43507. }, scene?: Nullable<Scene>): Mesh;
  43508. /**
  43509. * Creates a ground mesh from a height map
  43510. * * The parameter `url` sets the URL of the height map image resource.
  43511. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43512. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43513. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43514. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43515. * * 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.
  43516. * * 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).
  43517. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43519. * @param name defines the name of the mesh
  43520. * @param url defines the url to the height map
  43521. * @param options defines the options used to create the mesh
  43522. * @param scene defines the hosting scene
  43523. * @returns the ground mesh
  43524. * @see https://doc.babylonjs.com/babylon101/height_map
  43525. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43526. */
  43527. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43528. width?: number;
  43529. height?: number;
  43530. subdivisions?: number;
  43531. minHeight?: number;
  43532. maxHeight?: number;
  43533. colorFilter?: Color3;
  43534. alphaFilter?: number;
  43535. updatable?: boolean;
  43536. onReady?: (mesh: GroundMesh) => void;
  43537. }, scene?: Nullable<Scene>): GroundMesh;
  43538. }
  43539. }
  43540. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43541. import { Vector4 } from "babylonjs/Maths/math.vector";
  43542. import { Mesh } from "babylonjs/Meshes/mesh";
  43543. /**
  43544. * Class containing static functions to help procedurally build meshes
  43545. */
  43546. export class TorusBuilder {
  43547. /**
  43548. * Creates a torus mesh
  43549. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43550. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43551. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43555. * @param name defines the name of the mesh
  43556. * @param options defines the options used to create the mesh
  43557. * @param scene defines the hosting scene
  43558. * @returns the torus mesh
  43559. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43560. */
  43561. static CreateTorus(name: string, options: {
  43562. diameter?: number;
  43563. thickness?: number;
  43564. tessellation?: number;
  43565. updatable?: boolean;
  43566. sideOrientation?: number;
  43567. frontUVs?: Vector4;
  43568. backUVs?: Vector4;
  43569. }, scene: any): Mesh;
  43570. }
  43571. }
  43572. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43573. import { Vector4 } from "babylonjs/Maths/math.vector";
  43574. import { Color4 } from "babylonjs/Maths/math.color";
  43575. import { Mesh } from "babylonjs/Meshes/mesh";
  43576. /**
  43577. * Class containing static functions to help procedurally build meshes
  43578. */
  43579. export class CylinderBuilder {
  43580. /**
  43581. * Creates a cylinder or a cone mesh
  43582. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43583. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43584. * * 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.
  43585. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43586. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43587. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43588. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43589. * * 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).
  43590. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43591. * * 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).
  43592. * * 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
  43593. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43594. * * 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
  43595. * * 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.
  43596. * * If `enclose` is false, a ring surface is one element.
  43597. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43598. * * 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
  43599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43602. * @param name defines the name of the mesh
  43603. * @param options defines the options used to create the mesh
  43604. * @param scene defines the hosting scene
  43605. * @returns the cylinder mesh
  43606. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43607. */
  43608. static CreateCylinder(name: string, options: {
  43609. height?: number;
  43610. diameterTop?: number;
  43611. diameterBottom?: number;
  43612. diameter?: number;
  43613. tessellation?: number;
  43614. subdivisions?: number;
  43615. arc?: number;
  43616. faceColors?: Color4[];
  43617. faceUV?: Vector4[];
  43618. updatable?: boolean;
  43619. hasRings?: boolean;
  43620. enclose?: boolean;
  43621. cap?: number;
  43622. sideOrientation?: number;
  43623. frontUVs?: Vector4;
  43624. backUVs?: Vector4;
  43625. }, scene: any): Mesh;
  43626. }
  43627. }
  43628. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43629. import { Nullable } from "babylonjs/types";
  43630. import { IDisposable } from "babylonjs/scene";
  43631. /**
  43632. * States of the webXR experience
  43633. */
  43634. export enum WebXRState {
  43635. /**
  43636. * Transitioning to being in XR mode
  43637. */
  43638. ENTERING_XR = 0,
  43639. /**
  43640. * Transitioning to non XR mode
  43641. */
  43642. EXITING_XR = 1,
  43643. /**
  43644. * In XR mode and presenting
  43645. */
  43646. IN_XR = 2,
  43647. /**
  43648. * Not entered XR mode
  43649. */
  43650. NOT_IN_XR = 3
  43651. }
  43652. /**
  43653. * Abstraction of the XR render target
  43654. */
  43655. export interface WebXRRenderTarget extends IDisposable {
  43656. /**
  43657. * xrpresent context of the canvas which can be used to display/mirror xr content
  43658. */
  43659. canvasContext: WebGLRenderingContext;
  43660. /**
  43661. * xr layer for the canvas
  43662. */
  43663. xrLayer: Nullable<XRWebGLLayer>;
  43664. /**
  43665. * Initializes the xr layer for the session
  43666. * @param xrSession xr session
  43667. * @returns a promise that will resolve once the XR Layer has been created
  43668. */
  43669. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43670. }
  43671. }
  43672. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43673. import { Nullable } from "babylonjs/types";
  43674. import { Observable } from "babylonjs/Misc/observable";
  43675. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43676. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43677. /**
  43678. * COnfiguration object for WebXR output canvas
  43679. */
  43680. export class WebXRManagedOutputCanvasOptions {
  43681. /**
  43682. * Options for this XR Layer output
  43683. */
  43684. canvasOptions: XRWebGLLayerOptions;
  43685. /**
  43686. * CSS styling for a newly created canvas (if not provided)
  43687. */
  43688. newCanvasCssStyle?: string;
  43689. /**
  43690. * Get the default values of the configuration object
  43691. * @returns default values of this configuration object
  43692. */
  43693. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43694. }
  43695. /**
  43696. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43697. */
  43698. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43699. private configuration;
  43700. private _engine;
  43701. private _canvas;
  43702. /**
  43703. * xrpresent context of the canvas which can be used to display/mirror xr content
  43704. */
  43705. canvasContext: WebGLRenderingContext;
  43706. /**
  43707. * xr layer for the canvas
  43708. */
  43709. xrLayer: Nullable<XRWebGLLayer>;
  43710. /**
  43711. * Initializes the xr layer for the session
  43712. * @param xrSession xr session
  43713. * @returns a promise that will resolve once the XR Layer has been created
  43714. */
  43715. initializeXRLayerAsync(xrSession: any): any;
  43716. /**
  43717. * Initializes the canvas to be added/removed upon entering/exiting xr
  43718. * @param engine the Babylon engine
  43719. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43720. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43721. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43722. */
  43723. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43724. /**
  43725. * Disposes of the object
  43726. */
  43727. dispose(): void;
  43728. private _setManagedOutputCanvas;
  43729. private _addCanvas;
  43730. private _removeCanvas;
  43731. }
  43732. }
  43733. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43734. import { Observable } from "babylonjs/Misc/observable";
  43735. import { Nullable } from "babylonjs/types";
  43736. import { IDisposable, Scene } from "babylonjs/scene";
  43737. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43738. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43739. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43740. /**
  43741. * Manages an XRSession to work with Babylon's engine
  43742. * @see https://doc.babylonjs.com/how_to/webxr
  43743. */
  43744. export class WebXRSessionManager implements IDisposable {
  43745. /** The scene which the session should be created for */
  43746. scene: Scene;
  43747. /**
  43748. * Fires every time a new xrFrame arrives which can be used to update the camera
  43749. */
  43750. onXRFrameObservable: Observable<XRFrame>;
  43751. /**
  43752. * Fires when the xr session is ended either by the device or manually done
  43753. */
  43754. onXRSessionEnded: Observable<any>;
  43755. /**
  43756. * Fires when the xr session is ended either by the device or manually done
  43757. */
  43758. onXRSessionInit: Observable<XRSession>;
  43759. /**
  43760. * Underlying xr session
  43761. */
  43762. session: XRSession;
  43763. /**
  43764. * Type of reference space used when creating the session
  43765. */
  43766. referenceSpace: XRReferenceSpace;
  43767. /**
  43768. * Current XR frame
  43769. */
  43770. currentFrame: Nullable<XRFrame>;
  43771. /** WebXR timestamp updated every frame */
  43772. currentTimestamp: number;
  43773. private _xrNavigator;
  43774. private baseLayer;
  43775. private _rttProvider;
  43776. private _sessionEnded;
  43777. /**
  43778. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43779. * @param scene The scene which the session should be created for
  43780. */
  43781. constructor(
  43782. /** The scene which the session should be created for */
  43783. scene: Scene);
  43784. /**
  43785. * Initializes the manager
  43786. * After initialization enterXR can be called to start an XR session
  43787. * @returns Promise which resolves after it is initialized
  43788. */
  43789. initializeAsync(): Promise<void>;
  43790. /**
  43791. * Initializes an xr session
  43792. * @param xrSessionMode mode to initialize
  43793. * @param optionalFeatures defines optional values to pass to the session builder
  43794. * @returns a promise which will resolve once the session has been initialized
  43795. */
  43796. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43797. /**
  43798. * Sets the reference space on the xr session
  43799. * @param referenceSpace space to set
  43800. * @returns a promise that will resolve once the reference space has been set
  43801. */
  43802. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43803. /**
  43804. * Updates the render state of the session
  43805. * @param state state to set
  43806. * @returns a promise that resolves once the render state has been updated
  43807. */
  43808. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43809. /**
  43810. * Starts rendering to the xr layer
  43811. * @returns a promise that will resolve once rendering has started
  43812. */
  43813. startRenderingToXRAsync(): Promise<void>;
  43814. /**
  43815. * Gets the correct render target texture to be rendered this frame for this eye
  43816. * @param eye the eye for which to get the render target
  43817. * @returns the render target for the specified eye
  43818. */
  43819. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43820. /**
  43821. * Stops the xrSession and restores the renderloop
  43822. * @returns Promise which resolves after it exits XR
  43823. */
  43824. exitXRAsync(): Promise<void>;
  43825. /**
  43826. * Checks if a session would be supported for the creation options specified
  43827. * @param sessionMode session mode to check if supported eg. immersive-vr
  43828. * @returns true if supported
  43829. */
  43830. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43831. /**
  43832. * Creates a WebXRRenderTarget object for the XR session
  43833. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43834. * @param options optional options to provide when creating a new render target
  43835. * @returns a WebXR render target to which the session can render
  43836. */
  43837. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43838. /**
  43839. * @hidden
  43840. * Converts the render layer of xrSession to a render target
  43841. * @param session session to create render target for
  43842. * @param scene scene the new render target should be created for
  43843. * @param baseLayer the webgl layer to create the render target for
  43844. */
  43845. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43846. /**
  43847. * Disposes of the session manager
  43848. */
  43849. dispose(): void;
  43850. /**
  43851. * Gets a promise returning true when fullfiled if the given session mode is supported
  43852. * @param sessionMode defines the session to test
  43853. * @returns a promise
  43854. */
  43855. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43856. }
  43857. }
  43858. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43859. import { Scene } from "babylonjs/scene";
  43860. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43861. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43862. /**
  43863. * WebXR Camera which holds the views for the xrSession
  43864. * @see https://doc.babylonjs.com/how_to/webxr
  43865. */
  43866. export class WebXRCamera extends FreeCamera {
  43867. /**
  43868. * Is the camera in debug mode. Used when using an emulator
  43869. */
  43870. debugMode: boolean;
  43871. /**
  43872. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43873. * @param name the name of the camera
  43874. * @param scene the scene to add the camera to
  43875. */
  43876. constructor(name: string, scene: Scene);
  43877. private _updateNumberOfRigCameras;
  43878. /** @hidden */
  43879. _updateForDualEyeDebugging(): void;
  43880. /**
  43881. * Updates the cameras position from the current pose information of the XR session
  43882. * @param xrSessionManager the session containing pose information
  43883. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43884. */
  43885. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43886. }
  43887. }
  43888. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43889. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43890. import { IDisposable } from "babylonjs/scene";
  43891. /**
  43892. * Defining the interface required for a (webxr) feature
  43893. */
  43894. export interface IWebXRFeature extends IDisposable {
  43895. /**
  43896. * Attach the feature to the session
  43897. * Will usually be called by the features manager
  43898. *
  43899. * @returns true if successful.
  43900. */
  43901. attach(): boolean;
  43902. /**
  43903. * Detach the feature from the session
  43904. * Will usually be called by the features manager
  43905. *
  43906. * @returns true if successful.
  43907. */
  43908. detach(): boolean;
  43909. }
  43910. /**
  43911. * Defining the constructor of a feature. Used to register the modules.
  43912. */
  43913. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43914. /**
  43915. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43916. * It is mainly used in AR sessions.
  43917. *
  43918. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43919. */
  43920. export class WebXRFeaturesManager implements IDisposable {
  43921. private _xrSessionManager;
  43922. private static readonly _AvailableFeatures;
  43923. /**
  43924. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43925. * Mainly used internally.
  43926. *
  43927. * @param featureName the name of the feature to register
  43928. * @param constructorFunction the function used to construct the module
  43929. * @param version the (babylon) version of the module
  43930. * @param stable is that a stable version of this module
  43931. */
  43932. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43933. /**
  43934. * Returns a constructor of a specific feature.
  43935. *
  43936. * @param featureName the name of the feature to construct
  43937. * @param version the version of the feature to load
  43938. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43939. * @param options optional options provided to the module.
  43940. * @returns a function that, when called, will return a new instance of this feature
  43941. */
  43942. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43943. /**
  43944. * Return the latest unstable version of this feature
  43945. * @param featureName the name of the feature to search
  43946. * @returns the version number. if not found will return -1
  43947. */
  43948. static GetLatestVersionOfFeature(featureName: string): number;
  43949. /**
  43950. * Return the latest stable version of this feature
  43951. * @param featureName the name of the feature to search
  43952. * @returns the version number. if not found will return -1
  43953. */
  43954. static GetStableVersionOfFeature(featureName: string): number;
  43955. /**
  43956. * Can be used to return the list of features currently registered
  43957. *
  43958. * @returns an Array of available features
  43959. */
  43960. static GetAvailableFeatures(): string[];
  43961. /**
  43962. * Gets the versions available for a specific feature
  43963. * @param featureName the name of the feature
  43964. * @returns an array with the available versions
  43965. */
  43966. static GetAvailableVersions(featureName: string): string[];
  43967. private _features;
  43968. /**
  43969. * constructs a new features manages.
  43970. *
  43971. * @param _xrSessionManager an instance of WebXRSessionManager
  43972. */
  43973. constructor(_xrSessionManager: WebXRSessionManager);
  43974. /**
  43975. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  43976. *
  43977. * @param featureName the name of the feature to load or the class of the feature
  43978. * @param version optional version to load. if not provided the latest version will be enabled
  43979. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43980. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43981. * @returns a new constructed feature or throws an error if feature not found.
  43982. */
  43983. enableFeature(featureName: string | {
  43984. Name: string;
  43985. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43986. /**
  43987. * Used to disable an already-enabled feature
  43988. * @param featureName the feature to disable
  43989. * @returns true if disable was successful
  43990. */
  43991. disableFeature(featureName: string | {
  43992. Name: string;
  43993. }): boolean;
  43994. /**
  43995. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43996. * Can be used during a session to start a feature
  43997. * @param featureName the name of feature to attach
  43998. */
  43999. attachFeature(featureName: string): void;
  44000. /**
  44001. * Can be used inside a session or when the session ends to detach a specific feature
  44002. * @param featureName the name of the feature to detach
  44003. */
  44004. detachFeature(featureName: string): void;
  44005. /**
  44006. * Get the list of enabled features
  44007. * @returns an array of enabled features
  44008. */
  44009. getEnabledFeatures(): string[];
  44010. /**
  44011. * get the implementation of an enabled feature.
  44012. * @param featureName the name of the feature to load
  44013. * @returns the feature class, if found
  44014. */
  44015. getEnabledFeature(featureName: string): IWebXRFeature;
  44016. /**
  44017. * dispose this features manager
  44018. */
  44019. dispose(): void;
  44020. }
  44021. }
  44022. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44023. import { Observable } from "babylonjs/Misc/observable";
  44024. import { IDisposable, Scene } from "babylonjs/scene";
  44025. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  44026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44027. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44028. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44029. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44030. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44031. /**
  44032. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44033. * @see https://doc.babylonjs.com/how_to/webxr
  44034. */
  44035. export class WebXRExperienceHelper implements IDisposable {
  44036. private scene;
  44037. /**
  44038. * 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
  44039. */
  44040. container: AbstractMesh;
  44041. /**
  44042. * Camera used to render xr content
  44043. */
  44044. camera: WebXRCamera;
  44045. /**
  44046. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44047. */
  44048. state: WebXRState;
  44049. private _setState;
  44050. private static _TmpVector;
  44051. /**
  44052. * Fires when the state of the experience helper has changed
  44053. */
  44054. onStateChangedObservable: Observable<WebXRState>;
  44055. /** Session manager used to keep track of xr session */
  44056. sessionManager: WebXRSessionManager;
  44057. /** A features manager for this xr session */
  44058. featuresManager: WebXRFeaturesManager;
  44059. private _nonVRCamera;
  44060. private _originalSceneAutoClear;
  44061. private _supported;
  44062. /**
  44063. * Creates the experience helper
  44064. * @param scene the scene to attach the experience helper to
  44065. * @returns a promise for the experience helper
  44066. */
  44067. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44068. /**
  44069. * Creates a WebXRExperienceHelper
  44070. * @param scene The scene the helper should be created in
  44071. */
  44072. private constructor();
  44073. /**
  44074. * Exits XR mode and returns the scene to its original state
  44075. * @returns promise that resolves after xr mode has exited
  44076. */
  44077. exitXRAsync(): Promise<void>;
  44078. /**
  44079. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44080. * @param sessionMode options for the XR session
  44081. * @param referenceSpaceType frame of reference of the XR session
  44082. * @param renderTarget the output canvas that will be used to enter XR mode
  44083. * @returns promise that resolves after xr mode has entered
  44084. */
  44085. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44086. /**
  44087. * Updates the global position of the camera by moving the camera's container
  44088. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  44089. * @param position The desired global position of the camera
  44090. */
  44091. setPositionOfCameraUsingContainer(position: Vector3): void;
  44092. /**
  44093. * Rotates the xr camera by rotating the camera's container around the camera's position
  44094. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  44095. * @param rotation the desired quaternion rotation to apply to the camera
  44096. */
  44097. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  44098. /**
  44099. * Disposes of the experience helper
  44100. */
  44101. dispose(): void;
  44102. }
  44103. }
  44104. declare module "babylonjs/Cameras/XR/webXRController" {
  44105. import { Nullable } from "babylonjs/types";
  44106. import { Observable } from "babylonjs/Misc/observable";
  44107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44108. import { Ray } from "babylonjs/Culling/ray";
  44109. import { Scene } from "babylonjs/scene";
  44110. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44111. /**
  44112. * Represents an XR input
  44113. */
  44114. export class WebXRController {
  44115. private scene;
  44116. /** The underlying input source for the controller */
  44117. inputSource: XRInputSource;
  44118. private parentContainer;
  44119. /**
  44120. * 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
  44121. */
  44122. grip?: AbstractMesh;
  44123. /**
  44124. * Pointer which can be used to select objects or attach a visible laser to
  44125. */
  44126. pointer: AbstractMesh;
  44127. private _gamepadMode;
  44128. /**
  44129. * If available, this is the gamepad object related to this controller.
  44130. * Using this object it is possible to get click events and trackpad changes of the
  44131. * webxr controller that is currently being used.
  44132. */
  44133. gamepadController?: WebVRController;
  44134. /**
  44135. * Event that fires when the controller is removed/disposed
  44136. */
  44137. onDisposeObservable: Observable<{}>;
  44138. private _tmpQuaternion;
  44139. private _tmpVector;
  44140. /**
  44141. * Creates the controller
  44142. * @see https://doc.babylonjs.com/how_to/webxr
  44143. * @param scene the scene which the controller should be associated to
  44144. * @param inputSource the underlying input source for the controller
  44145. * @param parentContainer parent that the controller meshes should be children of
  44146. */
  44147. constructor(scene: Scene,
  44148. /** The underlying input source for the controller */
  44149. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  44150. /**
  44151. * Updates the controller pose based on the given XRFrame
  44152. * @param xrFrame xr frame to update the pose with
  44153. * @param referenceSpace reference space to use
  44154. */
  44155. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44156. /**
  44157. * Gets a world space ray coming from the controller
  44158. * @param result the resulting ray
  44159. */
  44160. getWorldPointerRayToRef(result: Ray): void;
  44161. /**
  44162. * Get the scene associated with this controller
  44163. * @returns the scene object
  44164. */
  44165. getScene(): Scene;
  44166. /**
  44167. * Disposes of the object
  44168. */
  44169. dispose(): void;
  44170. }
  44171. }
  44172. declare module "babylonjs/Cameras/XR/webXRInput" {
  44173. import { Observable } from "babylonjs/Misc/observable";
  44174. import { IDisposable } from "babylonjs/scene";
  44175. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44176. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44177. /**
  44178. * XR input used to track XR inputs such as controllers/rays
  44179. */
  44180. export class WebXRInput implements IDisposable {
  44181. /**
  44182. * Base experience the input listens to
  44183. */
  44184. baseExperience: WebXRExperienceHelper;
  44185. /**
  44186. * XR controllers being tracked
  44187. */
  44188. controllers: Array<WebXRController>;
  44189. private _frameObserver;
  44190. private _stateObserver;
  44191. /**
  44192. * Event when a controller has been connected/added
  44193. */
  44194. onControllerAddedObservable: Observable<WebXRController>;
  44195. /**
  44196. * Event when a controller has been removed/disconnected
  44197. */
  44198. onControllerRemovedObservable: Observable<WebXRController>;
  44199. /**
  44200. * Initializes the WebXRInput
  44201. * @param baseExperience experience helper which the input should be created for
  44202. */
  44203. constructor(
  44204. /**
  44205. * Base experience the input listens to
  44206. */
  44207. baseExperience: WebXRExperienceHelper);
  44208. private _onInputSourcesChange;
  44209. private _addAndRemoveControllers;
  44210. /**
  44211. * Disposes of the object
  44212. */
  44213. dispose(): void;
  44214. }
  44215. }
  44216. declare module "babylonjs/Loading/sceneLoader" {
  44217. import { Observable } from "babylonjs/Misc/observable";
  44218. import { Nullable } from "babylonjs/types";
  44219. import { Scene } from "babylonjs/scene";
  44220. import { Engine } from "babylonjs/Engines/engine";
  44221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44222. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44223. import { AssetContainer } from "babylonjs/assetContainer";
  44224. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44225. import { Skeleton } from "babylonjs/Bones/skeleton";
  44226. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44227. import { WebRequest } from "babylonjs/Misc/webRequest";
  44228. /**
  44229. * Class used to represent data loading progression
  44230. */
  44231. export class SceneLoaderProgressEvent {
  44232. /** defines if data length to load can be evaluated */
  44233. readonly lengthComputable: boolean;
  44234. /** defines the loaded data length */
  44235. readonly loaded: number;
  44236. /** defines the data length to load */
  44237. readonly total: number;
  44238. /**
  44239. * Create a new progress event
  44240. * @param lengthComputable defines if data length to load can be evaluated
  44241. * @param loaded defines the loaded data length
  44242. * @param total defines the data length to load
  44243. */
  44244. constructor(
  44245. /** defines if data length to load can be evaluated */
  44246. lengthComputable: boolean,
  44247. /** defines the loaded data length */
  44248. loaded: number,
  44249. /** defines the data length to load */
  44250. total: number);
  44251. /**
  44252. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44253. * @param event defines the source event
  44254. * @returns a new SceneLoaderProgressEvent
  44255. */
  44256. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44257. }
  44258. /**
  44259. * Interface used by SceneLoader plugins to define supported file extensions
  44260. */
  44261. export interface ISceneLoaderPluginExtensions {
  44262. /**
  44263. * Defines the list of supported extensions
  44264. */
  44265. [extension: string]: {
  44266. isBinary: boolean;
  44267. };
  44268. }
  44269. /**
  44270. * Interface used by SceneLoader plugin factory
  44271. */
  44272. export interface ISceneLoaderPluginFactory {
  44273. /**
  44274. * Defines the name of the factory
  44275. */
  44276. name: string;
  44277. /**
  44278. * Function called to create a new plugin
  44279. * @return the new plugin
  44280. */
  44281. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44282. /**
  44283. * The callback that returns true if the data can be directly loaded.
  44284. * @param data string containing the file data
  44285. * @returns if the data can be loaded directly
  44286. */
  44287. canDirectLoad?(data: string): boolean;
  44288. }
  44289. /**
  44290. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44291. */
  44292. export interface ISceneLoaderPluginBase {
  44293. /**
  44294. * The friendly name of this plugin.
  44295. */
  44296. name: string;
  44297. /**
  44298. * The file extensions supported by this plugin.
  44299. */
  44300. extensions: string | ISceneLoaderPluginExtensions;
  44301. /**
  44302. * The callback called when loading from a url.
  44303. * @param scene scene loading this url
  44304. * @param url url to load
  44305. * @param onSuccess callback called when the file successfully loads
  44306. * @param onProgress callback called while file is loading (if the server supports this mode)
  44307. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44308. * @param onError callback called when the file fails to load
  44309. * @returns a file request object
  44310. */
  44311. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44312. /**
  44313. * The callback called when loading from a file object.
  44314. * @param scene scene loading this file
  44315. * @param file defines the file to load
  44316. * @param onSuccess defines the callback to call when data is loaded
  44317. * @param onProgress defines the callback to call during loading process
  44318. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44319. * @param onError defines the callback to call when an error occurs
  44320. * @returns a file request object
  44321. */
  44322. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44323. /**
  44324. * The callback that returns true if the data can be directly loaded.
  44325. * @param data string containing the file data
  44326. * @returns if the data can be loaded directly
  44327. */
  44328. canDirectLoad?(data: string): boolean;
  44329. /**
  44330. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44331. * @param scene scene loading this data
  44332. * @param data string containing the data
  44333. * @returns data to pass to the plugin
  44334. */
  44335. directLoad?(scene: Scene, data: string): any;
  44336. /**
  44337. * The callback that allows custom handling of the root url based on the response url.
  44338. * @param rootUrl the original root url
  44339. * @param responseURL the response url if available
  44340. * @returns the new root url
  44341. */
  44342. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44343. }
  44344. /**
  44345. * Interface used to define a SceneLoader plugin
  44346. */
  44347. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44348. /**
  44349. * Import meshes into a scene.
  44350. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44351. * @param scene The scene to import into
  44352. * @param data The data to import
  44353. * @param rootUrl The root url for scene and resources
  44354. * @param meshes The meshes array to import into
  44355. * @param particleSystems The particle systems array to import into
  44356. * @param skeletons The skeletons array to import into
  44357. * @param onError The callback when import fails
  44358. * @returns True if successful or false otherwise
  44359. */
  44360. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44361. /**
  44362. * Load into a scene.
  44363. * @param scene The scene to load into
  44364. * @param data The data to import
  44365. * @param rootUrl The root url for scene and resources
  44366. * @param onError The callback when import fails
  44367. * @returns True if successful or false otherwise
  44368. */
  44369. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44370. /**
  44371. * Load into an asset container.
  44372. * @param scene The scene to load into
  44373. * @param data The data to import
  44374. * @param rootUrl The root url for scene and resources
  44375. * @param onError The callback when import fails
  44376. * @returns The loaded asset container
  44377. */
  44378. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44379. }
  44380. /**
  44381. * Interface used to define an async SceneLoader plugin
  44382. */
  44383. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44384. /**
  44385. * Import meshes into a scene.
  44386. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44387. * @param scene The scene to import into
  44388. * @param data The data to import
  44389. * @param rootUrl The root url for scene and resources
  44390. * @param onProgress The callback when the load progresses
  44391. * @param fileName Defines the name of the file to load
  44392. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44393. */
  44394. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44395. meshes: AbstractMesh[];
  44396. particleSystems: IParticleSystem[];
  44397. skeletons: Skeleton[];
  44398. animationGroups: AnimationGroup[];
  44399. }>;
  44400. /**
  44401. * Load into a scene.
  44402. * @param scene The scene to load into
  44403. * @param data The data to import
  44404. * @param rootUrl The root url for scene and resources
  44405. * @param onProgress The callback when the load progresses
  44406. * @param fileName Defines the name of the file to load
  44407. * @returns Nothing
  44408. */
  44409. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44410. /**
  44411. * Load into an asset container.
  44412. * @param scene The scene to load into
  44413. * @param data The data to import
  44414. * @param rootUrl The root url for scene and resources
  44415. * @param onProgress The callback when the load progresses
  44416. * @param fileName Defines the name of the file to load
  44417. * @returns The loaded asset container
  44418. */
  44419. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44420. }
  44421. /**
  44422. * Mode that determines how to handle old animation groups before loading new ones.
  44423. */
  44424. export enum SceneLoaderAnimationGroupLoadingMode {
  44425. /**
  44426. * Reset all old animations to initial state then dispose them.
  44427. */
  44428. Clean = 0,
  44429. /**
  44430. * Stop all old animations.
  44431. */
  44432. Stop = 1,
  44433. /**
  44434. * Restart old animations from first frame.
  44435. */
  44436. Sync = 2,
  44437. /**
  44438. * Old animations remains untouched.
  44439. */
  44440. NoSync = 3
  44441. }
  44442. /**
  44443. * Class used to load scene from various file formats using registered plugins
  44444. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44445. */
  44446. export class SceneLoader {
  44447. /**
  44448. * No logging while loading
  44449. */
  44450. static readonly NO_LOGGING: number;
  44451. /**
  44452. * Minimal logging while loading
  44453. */
  44454. static readonly MINIMAL_LOGGING: number;
  44455. /**
  44456. * Summary logging while loading
  44457. */
  44458. static readonly SUMMARY_LOGGING: number;
  44459. /**
  44460. * Detailled logging while loading
  44461. */
  44462. static readonly DETAILED_LOGGING: number;
  44463. /**
  44464. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44465. */
  44466. static get ForceFullSceneLoadingForIncremental(): boolean;
  44467. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44468. /**
  44469. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44470. */
  44471. static get ShowLoadingScreen(): boolean;
  44472. static set ShowLoadingScreen(value: boolean);
  44473. /**
  44474. * Defines the current logging level (while loading the scene)
  44475. * @ignorenaming
  44476. */
  44477. static get loggingLevel(): number;
  44478. static set loggingLevel(value: number);
  44479. /**
  44480. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44481. */
  44482. static get CleanBoneMatrixWeights(): boolean;
  44483. static set CleanBoneMatrixWeights(value: boolean);
  44484. /**
  44485. * Event raised when a plugin is used to load a scene
  44486. */
  44487. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44488. private static _registeredPlugins;
  44489. private static _getDefaultPlugin;
  44490. private static _getPluginForExtension;
  44491. private static _getPluginForDirectLoad;
  44492. private static _getPluginForFilename;
  44493. private static _getDirectLoad;
  44494. private static _loadData;
  44495. private static _getFileInfo;
  44496. /**
  44497. * Gets a plugin that can load the given extension
  44498. * @param extension defines the extension to load
  44499. * @returns a plugin or null if none works
  44500. */
  44501. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44502. /**
  44503. * Gets a boolean indicating that the given extension can be loaded
  44504. * @param extension defines the extension to load
  44505. * @returns true if the extension is supported
  44506. */
  44507. static IsPluginForExtensionAvailable(extension: string): boolean;
  44508. /**
  44509. * Adds a new plugin to the list of registered plugins
  44510. * @param plugin defines the plugin to add
  44511. */
  44512. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44513. /**
  44514. * Import meshes into a scene
  44515. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44516. * @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)
  44517. * @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)
  44518. * @param scene the instance of BABYLON.Scene to append to
  44519. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44520. * @param onProgress a callback with a progress event for each file being loaded
  44521. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44522. * @param pluginExtension the extension used to determine the plugin
  44523. * @returns The loaded plugin
  44524. */
  44525. 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>;
  44526. /**
  44527. * Import meshes into a scene
  44528. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44529. * @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)
  44530. * @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)
  44531. * @param scene the instance of BABYLON.Scene to append to
  44532. * @param onProgress a callback with a progress event for each file being loaded
  44533. * @param pluginExtension the extension used to determine the plugin
  44534. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44535. */
  44536. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44537. meshes: AbstractMesh[];
  44538. particleSystems: IParticleSystem[];
  44539. skeletons: Skeleton[];
  44540. animationGroups: AnimationGroup[];
  44541. }>;
  44542. /**
  44543. * Load a scene
  44544. * @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)
  44545. * @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)
  44546. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44547. * @param onSuccess a callback with the scene when import succeeds
  44548. * @param onProgress a callback with a progress event for each file being loaded
  44549. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44550. * @param pluginExtension the extension used to determine the plugin
  44551. * @returns The loaded plugin
  44552. */
  44553. 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>;
  44554. /**
  44555. * Load a scene
  44556. * @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)
  44557. * @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)
  44558. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44559. * @param onProgress a callback with a progress event for each file being loaded
  44560. * @param pluginExtension the extension used to determine the plugin
  44561. * @returns The loaded scene
  44562. */
  44563. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44564. /**
  44565. * Append a scene
  44566. * @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)
  44567. * @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)
  44568. * @param scene is the instance of BABYLON.Scene to append to
  44569. * @param onSuccess a callback with the scene when import succeeds
  44570. * @param onProgress a callback with a progress event for each file being loaded
  44571. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44572. * @param pluginExtension the extension used to determine the plugin
  44573. * @returns The loaded plugin
  44574. */
  44575. 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>;
  44576. /**
  44577. * Append a scene
  44578. * @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)
  44579. * @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)
  44580. * @param scene is the instance of BABYLON.Scene to append to
  44581. * @param onProgress a callback with a progress event for each file being loaded
  44582. * @param pluginExtension the extension used to determine the plugin
  44583. * @returns The given scene
  44584. */
  44585. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44586. /**
  44587. * Load a scene into an asset container
  44588. * @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)
  44589. * @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)
  44590. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44591. * @param onSuccess a callback with the scene when import succeeds
  44592. * @param onProgress a callback with a progress event for each file being loaded
  44593. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44594. * @param pluginExtension the extension used to determine the plugin
  44595. * @returns The loaded plugin
  44596. */
  44597. 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>;
  44598. /**
  44599. * Load a scene into an asset container
  44600. * @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)
  44601. * @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)
  44602. * @param scene is the instance of Scene to append to
  44603. * @param onProgress a callback with a progress event for each file being loaded
  44604. * @param pluginExtension the extension used to determine the plugin
  44605. * @returns The loaded asset container
  44606. */
  44607. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44608. /**
  44609. * Import animations from a file into a scene
  44610. * @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)
  44611. * @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)
  44612. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44613. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44614. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44615. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44616. * @param onSuccess a callback with the scene when import succeeds
  44617. * @param onProgress a callback with a progress event for each file being loaded
  44618. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44619. */
  44620. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  44621. /**
  44622. * Import animations from a file into a scene
  44623. * @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)
  44624. * @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)
  44625. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44626. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44627. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44628. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44629. * @param onSuccess a callback with the scene when import succeeds
  44630. * @param onProgress a callback with a progress event for each file being loaded
  44631. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44632. * @returns the updated scene with imported animations
  44633. */
  44634. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  44635. }
  44636. }
  44637. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44638. import { Scene } from "babylonjs/scene";
  44639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44640. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44641. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44642. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44643. /**
  44644. * Generic Controller
  44645. */
  44646. export class GenericController extends WebVRController {
  44647. /**
  44648. * Base Url for the controller model.
  44649. */
  44650. static readonly MODEL_BASE_URL: string;
  44651. /**
  44652. * File name for the controller model.
  44653. */
  44654. static readonly MODEL_FILENAME: string;
  44655. /**
  44656. * Creates a new GenericController from a gamepad
  44657. * @param vrGamepad the gamepad that the controller should be created from
  44658. */
  44659. constructor(vrGamepad: any);
  44660. /**
  44661. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44662. * @param scene scene in which to add meshes
  44663. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44664. */
  44665. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44666. /**
  44667. * Called once for each button that changed state since the last frame
  44668. * @param buttonIdx Which button index changed
  44669. * @param state New state of the button
  44670. * @param changes Which properties on the state changed since last frame
  44671. */
  44672. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44673. }
  44674. }
  44675. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44676. import { Observable } from "babylonjs/Misc/observable";
  44677. import { Scene } from "babylonjs/scene";
  44678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44679. import { Ray } from "babylonjs/Culling/ray";
  44680. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44681. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44682. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44683. /**
  44684. * Defines the WindowsMotionController object that the state of the windows motion controller
  44685. */
  44686. export class WindowsMotionController extends WebVRController {
  44687. /**
  44688. * The base url used to load the left and right controller models
  44689. */
  44690. static MODEL_BASE_URL: string;
  44691. /**
  44692. * The name of the left controller model file
  44693. */
  44694. static MODEL_LEFT_FILENAME: string;
  44695. /**
  44696. * The name of the right controller model file
  44697. */
  44698. static MODEL_RIGHT_FILENAME: string;
  44699. /**
  44700. * The controller name prefix for this controller type
  44701. */
  44702. static readonly GAMEPAD_ID_PREFIX: string;
  44703. /**
  44704. * The controller id pattern for this controller type
  44705. */
  44706. private static readonly GAMEPAD_ID_PATTERN;
  44707. private _loadedMeshInfo;
  44708. protected readonly _mapping: {
  44709. buttons: string[];
  44710. buttonMeshNames: {
  44711. 'trigger': string;
  44712. 'menu': string;
  44713. 'grip': string;
  44714. 'thumbstick': string;
  44715. 'trackpad': string;
  44716. };
  44717. buttonObservableNames: {
  44718. 'trigger': string;
  44719. 'menu': string;
  44720. 'grip': string;
  44721. 'thumbstick': string;
  44722. 'trackpad': string;
  44723. };
  44724. axisMeshNames: string[];
  44725. pointingPoseMeshName: string;
  44726. };
  44727. /**
  44728. * Fired when the trackpad on this controller is clicked
  44729. */
  44730. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44731. /**
  44732. * Fired when the trackpad on this controller is modified
  44733. */
  44734. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44735. /**
  44736. * The current x and y values of this controller's trackpad
  44737. */
  44738. trackpad: StickValues;
  44739. /**
  44740. * Creates a new WindowsMotionController from a gamepad
  44741. * @param vrGamepad the gamepad that the controller should be created from
  44742. */
  44743. constructor(vrGamepad: any);
  44744. /**
  44745. * Fired when the trigger on this controller is modified
  44746. */
  44747. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44748. /**
  44749. * Fired when the menu button on this controller is modified
  44750. */
  44751. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44752. /**
  44753. * Fired when the grip button on this controller is modified
  44754. */
  44755. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44756. /**
  44757. * Fired when the thumbstick button on this controller is modified
  44758. */
  44759. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44760. /**
  44761. * Fired when the touchpad button on this controller is modified
  44762. */
  44763. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44764. /**
  44765. * Fired when the touchpad values on this controller are modified
  44766. */
  44767. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  44768. protected _updateTrackpad(): void;
  44769. /**
  44770. * Called once per frame by the engine.
  44771. */
  44772. update(): void;
  44773. /**
  44774. * Called once for each button that changed state since the last frame
  44775. * @param buttonIdx Which button index changed
  44776. * @param state New state of the button
  44777. * @param changes Which properties on the state changed since last frame
  44778. */
  44779. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44780. /**
  44781. * Moves the buttons on the controller mesh based on their current state
  44782. * @param buttonName the name of the button to move
  44783. * @param buttonValue the value of the button which determines the buttons new position
  44784. */
  44785. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44786. /**
  44787. * Moves the axis on the controller mesh based on its current state
  44788. * @param axis the index of the axis
  44789. * @param axisValue the value of the axis which determines the meshes new position
  44790. * @hidden
  44791. */
  44792. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44793. /**
  44794. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44795. * @param scene scene in which to add meshes
  44796. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44797. */
  44798. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44799. /**
  44800. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44801. * can be transformed by button presses and axes values, based on this._mapping.
  44802. *
  44803. * @param scene scene in which the meshes exist
  44804. * @param meshes list of meshes that make up the controller model to process
  44805. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44806. */
  44807. private processModel;
  44808. private createMeshInfo;
  44809. /**
  44810. * Gets the ray of the controller in the direction the controller is pointing
  44811. * @param length the length the resulting ray should be
  44812. * @returns a ray in the direction the controller is pointing
  44813. */
  44814. getForwardRay(length?: number): Ray;
  44815. /**
  44816. * Disposes of the controller
  44817. */
  44818. dispose(): void;
  44819. }
  44820. /**
  44821. * This class represents a new windows motion controller in XR.
  44822. */
  44823. export class XRWindowsMotionController extends WindowsMotionController {
  44824. /**
  44825. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44826. */
  44827. protected readonly _mapping: {
  44828. buttons: string[];
  44829. buttonMeshNames: {
  44830. 'trigger': string;
  44831. 'menu': string;
  44832. 'grip': string;
  44833. 'thumbstick': string;
  44834. 'trackpad': string;
  44835. };
  44836. buttonObservableNames: {
  44837. 'trigger': string;
  44838. 'menu': string;
  44839. 'grip': string;
  44840. 'thumbstick': string;
  44841. 'trackpad': string;
  44842. };
  44843. axisMeshNames: string[];
  44844. pointingPoseMeshName: string;
  44845. };
  44846. /**
  44847. * Construct a new XR-Based windows motion controller
  44848. *
  44849. * @param gamepadInfo the gamepad object from the browser
  44850. */
  44851. constructor(gamepadInfo: any);
  44852. /**
  44853. * holds the thumbstick values (X,Y)
  44854. */
  44855. thumbstickValues: StickValues;
  44856. /**
  44857. * Fired when the thumbstick on this controller is clicked
  44858. */
  44859. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44860. /**
  44861. * Fired when the thumbstick on this controller is modified
  44862. */
  44863. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44864. /**
  44865. * Fired when the touchpad button on this controller is modified
  44866. */
  44867. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44868. /**
  44869. * Fired when the touchpad values on this controller are modified
  44870. */
  44871. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44872. /**
  44873. * Fired when the thumbstick button on this controller is modified
  44874. * here to prevent breaking changes
  44875. */
  44876. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44877. /**
  44878. * updating the thumbstick(!) and not the trackpad.
  44879. * This is named this way due to the difference between WebVR and XR and to avoid
  44880. * changing the parent class.
  44881. */
  44882. protected _updateTrackpad(): void;
  44883. /**
  44884. * Disposes the class with joy
  44885. */
  44886. dispose(): void;
  44887. }
  44888. }
  44889. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44890. import { Observable } from "babylonjs/Misc/observable";
  44891. import { Scene } from "babylonjs/scene";
  44892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44893. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44894. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44895. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44896. /**
  44897. * Oculus Touch Controller
  44898. */
  44899. export class OculusTouchController extends WebVRController {
  44900. /**
  44901. * Base Url for the controller model.
  44902. */
  44903. static MODEL_BASE_URL: string;
  44904. /**
  44905. * File name for the left controller model.
  44906. */
  44907. static MODEL_LEFT_FILENAME: string;
  44908. /**
  44909. * File name for the right controller model.
  44910. */
  44911. static MODEL_RIGHT_FILENAME: string;
  44912. /**
  44913. * Base Url for the Quest controller model.
  44914. */
  44915. static QUEST_MODEL_BASE_URL: string;
  44916. /**
  44917. * @hidden
  44918. * If the controllers are running on a device that needs the updated Quest controller models
  44919. */
  44920. static _IsQuest: boolean;
  44921. /**
  44922. * Fired when the secondary trigger on this controller is modified
  44923. */
  44924. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44925. /**
  44926. * Fired when the thumb rest on this controller is modified
  44927. */
  44928. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44929. /**
  44930. * Creates a new OculusTouchController from a gamepad
  44931. * @param vrGamepad the gamepad that the controller should be created from
  44932. */
  44933. constructor(vrGamepad: any);
  44934. /**
  44935. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44936. * @param scene scene in which to add meshes
  44937. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44938. */
  44939. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44940. /**
  44941. * Fired when the A button on this controller is modified
  44942. */
  44943. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44944. /**
  44945. * Fired when the B button on this controller is modified
  44946. */
  44947. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44948. /**
  44949. * Fired when the X button on this controller is modified
  44950. */
  44951. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44952. /**
  44953. * Fired when the Y button on this controller is modified
  44954. */
  44955. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44956. /**
  44957. * Called once for each button that changed state since the last frame
  44958. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44959. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44960. * 2) secondary trigger (same)
  44961. * 3) A (right) X (left), touch, pressed = value
  44962. * 4) B / Y
  44963. * 5) thumb rest
  44964. * @param buttonIdx Which button index changed
  44965. * @param state New state of the button
  44966. * @param changes Which properties on the state changed since last frame
  44967. */
  44968. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44969. }
  44970. }
  44971. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44972. import { Scene } from "babylonjs/scene";
  44973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44974. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44975. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44976. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44977. import { Observable } from "babylonjs/Misc/observable";
  44978. /**
  44979. * Vive Controller
  44980. */
  44981. export class ViveController extends WebVRController {
  44982. /**
  44983. * Base Url for the controller model.
  44984. */
  44985. static MODEL_BASE_URL: string;
  44986. /**
  44987. * File name for the controller model.
  44988. */
  44989. static MODEL_FILENAME: string;
  44990. /**
  44991. * Creates a new ViveController from a gamepad
  44992. * @param vrGamepad the gamepad that the controller should be created from
  44993. */
  44994. constructor(vrGamepad: any);
  44995. /**
  44996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44997. * @param scene scene in which to add meshes
  44998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44999. */
  45000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45001. /**
  45002. * Fired when the left button on this controller is modified
  45003. */
  45004. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45005. /**
  45006. * Fired when the right button on this controller is modified
  45007. */
  45008. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45009. /**
  45010. * Fired when the menu button on this controller is modified
  45011. */
  45012. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45013. /**
  45014. * Called once for each button that changed state since the last frame
  45015. * Vive mapping:
  45016. * 0: touchpad
  45017. * 1: trigger
  45018. * 2: left AND right buttons
  45019. * 3: menu button
  45020. * @param buttonIdx Which button index changed
  45021. * @param state New state of the button
  45022. * @param changes Which properties on the state changed since last frame
  45023. */
  45024. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45025. }
  45026. }
  45027. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  45028. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45029. import { Observable } from "babylonjs/Misc/observable";
  45030. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45031. /**
  45032. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  45033. */
  45034. export class WebXRControllerModelLoader {
  45035. /**
  45036. * an observable that triggers when a new model (the mesh itself) was initialized.
  45037. * To know when the mesh was loaded use the controller's own modelLoaded() method
  45038. */
  45039. onControllerModelLoaded: Observable<WebXRController>;
  45040. /**
  45041. * Creates the WebXRControllerModelLoader
  45042. * @param input xr input that creates the controllers
  45043. */
  45044. constructor(input: WebXRInput);
  45045. }
  45046. }
  45047. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  45048. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45049. /**
  45050. * Handles pointer input automatically for the pointer of XR controllers
  45051. */
  45052. export class WebXRControllerPointerSelection {
  45053. private static _idCounter;
  45054. private _tmpRay;
  45055. /**
  45056. * Creates a WebXRControllerPointerSelection
  45057. * @param input input manager to setup pointer selection
  45058. */
  45059. constructor(input: WebXRInput);
  45060. private _convertNormalToDirectionOfRay;
  45061. private _updatePointerDistance;
  45062. }
  45063. }
  45064. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  45065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45066. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45067. /**
  45068. * Enables teleportation
  45069. */
  45070. export class WebXRControllerTeleportation {
  45071. private _teleportationFillColor;
  45072. private _teleportationBorderColor;
  45073. private _tmpRay;
  45074. private _tmpVector;
  45075. /**
  45076. * when set to true (default) teleportation will wait for thumbstick changes.
  45077. * When set to false teleportation will be disabled.
  45078. *
  45079. * If set to false while teleporting results can be unexpected.
  45080. */
  45081. enabled: boolean;
  45082. /**
  45083. * Creates a WebXRControllerTeleportation
  45084. * @param input input manager to add teleportation to
  45085. * @param floorMeshes floormeshes which can be teleported to
  45086. */
  45087. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  45088. }
  45089. }
  45090. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45091. import { Nullable } from "babylonjs/types";
  45092. import { Observable } from "babylonjs/Misc/observable";
  45093. import { IDisposable, Scene } from "babylonjs/scene";
  45094. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45095. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45096. /**
  45097. * Button which can be used to enter a different mode of XR
  45098. */
  45099. export class WebXREnterExitUIButton {
  45100. /** button element */
  45101. element: HTMLElement;
  45102. /** XR initialization options for the button */
  45103. sessionMode: XRSessionMode;
  45104. /** Reference space type */
  45105. referenceSpaceType: XRReferenceSpaceType;
  45106. /**
  45107. * Creates a WebXREnterExitUIButton
  45108. * @param element button element
  45109. * @param sessionMode XR initialization session mode
  45110. * @param referenceSpaceType the type of reference space to be used
  45111. */
  45112. constructor(
  45113. /** button element */
  45114. element: HTMLElement,
  45115. /** XR initialization options for the button */
  45116. sessionMode: XRSessionMode,
  45117. /** Reference space type */
  45118. referenceSpaceType: XRReferenceSpaceType);
  45119. /**
  45120. * Overwritable function which can be used to update the button's visuals when the state changes
  45121. * @param activeButton the current active button in the UI
  45122. */
  45123. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45124. }
  45125. /**
  45126. * Options to create the webXR UI
  45127. */
  45128. export class WebXREnterExitUIOptions {
  45129. /**
  45130. * Context to enter xr with
  45131. */
  45132. renderTarget?: Nullable<WebXRRenderTarget>;
  45133. /**
  45134. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45135. */
  45136. customButtons?: Array<WebXREnterExitUIButton>;
  45137. /**
  45138. * A session mode to use when creating the default button.
  45139. * Default is immersive-vr
  45140. */
  45141. sessionMode?: XRSessionMode;
  45142. /**
  45143. * A reference space type to use when creating the default button.
  45144. * Default is local-floor
  45145. */
  45146. referenceSpaceType?: XRReferenceSpaceType;
  45147. }
  45148. /**
  45149. * UI to allow the user to enter/exit XR mode
  45150. */
  45151. export class WebXREnterExitUI implements IDisposable {
  45152. private scene;
  45153. /** version of the options passed to this UI */
  45154. options: WebXREnterExitUIOptions;
  45155. private _overlay;
  45156. private _buttons;
  45157. private _activeButton;
  45158. /**
  45159. * Fired every time the active button is changed.
  45160. *
  45161. * When xr is entered via a button that launches xr that button will be the callback parameter
  45162. *
  45163. * When exiting xr the callback parameter will be null)
  45164. */
  45165. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45166. /**
  45167. * Creates UI to allow the user to enter/exit XR mode
  45168. * @param scene the scene to add the ui to
  45169. * @param helper the xr experience helper to enter/exit xr with
  45170. * @param options options to configure the UI
  45171. * @returns the created ui
  45172. */
  45173. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45174. /**
  45175. *
  45176. * @param scene babylon scene object to use
  45177. * @param options (read-only) version of the options passed to this UI
  45178. */
  45179. private constructor();
  45180. private _updateButtons;
  45181. /**
  45182. * Disposes of the object
  45183. */
  45184. dispose(): void;
  45185. }
  45186. }
  45187. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45188. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45189. import { Scene } from "babylonjs/scene";
  45190. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45191. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45192. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45193. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45194. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45195. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45197. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45198. /**
  45199. * Options for the default xr helper
  45200. */
  45201. export class WebXRDefaultExperienceOptions {
  45202. /**
  45203. * Floor meshes that should be used for teleporting
  45204. */
  45205. floorMeshes: Array<AbstractMesh>;
  45206. /**
  45207. * Enable or disable default UI to enter XR
  45208. */
  45209. disableDefaultUI?: boolean;
  45210. /**
  45211. * optional configuration for the output canvas
  45212. */
  45213. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45214. /**
  45215. * optional UI options. This can be used among other to change session mode and reference space type
  45216. */
  45217. uiOptions?: WebXREnterExitUIOptions;
  45218. }
  45219. /**
  45220. * Default experience which provides a similar setup to the previous webVRExperience
  45221. */
  45222. export class WebXRDefaultExperience {
  45223. /**
  45224. * Base experience
  45225. */
  45226. baseExperience: WebXRExperienceHelper;
  45227. /**
  45228. * Input experience extension
  45229. */
  45230. input: WebXRInput;
  45231. /**
  45232. * Loads the controller models
  45233. */
  45234. controllerModelLoader: WebXRControllerModelLoader;
  45235. /**
  45236. * Enables laser pointer and selection
  45237. */
  45238. pointerSelection: WebXRControllerPointerSelection;
  45239. /**
  45240. * Enables teleportation
  45241. */
  45242. teleportation: WebXRControllerTeleportation;
  45243. /**
  45244. * Enables ui for entering/exiting xr
  45245. */
  45246. enterExitUI: WebXREnterExitUI;
  45247. /**
  45248. * Default target xr should render to
  45249. */
  45250. renderTarget: WebXRRenderTarget;
  45251. /**
  45252. * Creates the default xr experience
  45253. * @param scene scene
  45254. * @param options options for basic configuration
  45255. * @returns resulting WebXRDefaultExperience
  45256. */
  45257. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45258. private constructor();
  45259. /**
  45260. * DIsposes of the experience helper
  45261. */
  45262. dispose(): void;
  45263. }
  45264. }
  45265. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45266. import { Observable } from "babylonjs/Misc/observable";
  45267. import { Nullable } from "babylonjs/types";
  45268. import { Camera } from "babylonjs/Cameras/camera";
  45269. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45270. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45271. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45272. import { Scene } from "babylonjs/scene";
  45273. import { Vector3 } from "babylonjs/Maths/math.vector";
  45274. import { Color3 } from "babylonjs/Maths/math.color";
  45275. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45277. import { Mesh } from "babylonjs/Meshes/mesh";
  45278. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45279. import { EasingFunction } from "babylonjs/Animations/easing";
  45280. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45281. import "babylonjs/Meshes/Builders/groundBuilder";
  45282. import "babylonjs/Meshes/Builders/torusBuilder";
  45283. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45284. import "babylonjs/Gamepads/gamepadSceneComponent";
  45285. import "babylonjs/Animations/animatable";
  45286. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45287. /**
  45288. * Options to modify the vr teleportation behavior.
  45289. */
  45290. export interface VRTeleportationOptions {
  45291. /**
  45292. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45293. */
  45294. floorMeshName?: string;
  45295. /**
  45296. * A list of meshes to be used as the teleportation floor. (default: empty)
  45297. */
  45298. floorMeshes?: Mesh[];
  45299. /**
  45300. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45301. */
  45302. teleportationMode?: number;
  45303. /**
  45304. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45305. */
  45306. teleportationTime?: number;
  45307. /**
  45308. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45309. */
  45310. teleportationSpeed?: number;
  45311. /**
  45312. * The easing function used in the animation or null for Linear. (default CircleEase)
  45313. */
  45314. easingFunction?: EasingFunction;
  45315. }
  45316. /**
  45317. * Options to modify the vr experience helper's behavior.
  45318. */
  45319. export interface VRExperienceHelperOptions extends WebVROptions {
  45320. /**
  45321. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45322. */
  45323. createDeviceOrientationCamera?: boolean;
  45324. /**
  45325. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45326. */
  45327. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45328. /**
  45329. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45330. */
  45331. laserToggle?: boolean;
  45332. /**
  45333. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45334. */
  45335. floorMeshes?: Mesh[];
  45336. /**
  45337. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45338. */
  45339. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45340. /**
  45341. * Defines if WebXR should be used instead of WebVR (if available)
  45342. */
  45343. useXR?: boolean;
  45344. }
  45345. /**
  45346. * Event containing information after VR has been entered
  45347. */
  45348. export class OnAfterEnteringVRObservableEvent {
  45349. /**
  45350. * If entering vr was successful
  45351. */
  45352. success: boolean;
  45353. }
  45354. /**
  45355. * Helps to quickly add VR support to an existing scene.
  45356. * See http://doc.babylonjs.com/how_to/webvr_helper
  45357. */
  45358. export class VRExperienceHelper {
  45359. /** Options to modify the vr experience helper's behavior. */
  45360. webVROptions: VRExperienceHelperOptions;
  45361. private _scene;
  45362. private _position;
  45363. private _btnVR;
  45364. private _btnVRDisplayed;
  45365. private _webVRsupported;
  45366. private _webVRready;
  45367. private _webVRrequesting;
  45368. private _webVRpresenting;
  45369. private _hasEnteredVR;
  45370. private _fullscreenVRpresenting;
  45371. private _inputElement;
  45372. private _webVRCamera;
  45373. private _vrDeviceOrientationCamera;
  45374. private _deviceOrientationCamera;
  45375. private _existingCamera;
  45376. private _onKeyDown;
  45377. private _onVrDisplayPresentChange;
  45378. private _onVRDisplayChanged;
  45379. private _onVRRequestPresentStart;
  45380. private _onVRRequestPresentComplete;
  45381. /**
  45382. * 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)
  45383. */
  45384. enableGazeEvenWhenNoPointerLock: boolean;
  45385. /**
  45386. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45387. */
  45388. exitVROnDoubleTap: boolean;
  45389. /**
  45390. * Observable raised right before entering VR.
  45391. */
  45392. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45393. /**
  45394. * Observable raised when entering VR has completed.
  45395. */
  45396. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45397. /**
  45398. * Observable raised when exiting VR.
  45399. */
  45400. onExitingVRObservable: Observable<VRExperienceHelper>;
  45401. /**
  45402. * Observable raised when controller mesh is loaded.
  45403. */
  45404. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45405. /** Return this.onEnteringVRObservable
  45406. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45407. */
  45408. get onEnteringVR(): Observable<VRExperienceHelper>;
  45409. /** Return this.onExitingVRObservable
  45410. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45411. */
  45412. get onExitingVR(): Observable<VRExperienceHelper>;
  45413. /** Return this.onControllerMeshLoadedObservable
  45414. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45415. */
  45416. get onControllerMeshLoaded(): Observable<WebVRController>;
  45417. private _rayLength;
  45418. private _useCustomVRButton;
  45419. private _teleportationRequested;
  45420. private _teleportActive;
  45421. private _floorMeshName;
  45422. private _floorMeshesCollection;
  45423. private _teleportationMode;
  45424. private _teleportationTime;
  45425. private _teleportationSpeed;
  45426. private _teleportationEasing;
  45427. private _rotationAllowed;
  45428. private _teleportBackwardsVector;
  45429. private _teleportationTarget;
  45430. private _isDefaultTeleportationTarget;
  45431. private _postProcessMove;
  45432. private _teleportationFillColor;
  45433. private _teleportationBorderColor;
  45434. private _rotationAngle;
  45435. private _haloCenter;
  45436. private _cameraGazer;
  45437. private _padSensibilityUp;
  45438. private _padSensibilityDown;
  45439. private _leftController;
  45440. private _rightController;
  45441. /**
  45442. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45443. */
  45444. onNewMeshSelected: Observable<AbstractMesh>;
  45445. /**
  45446. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45447. * This observable will provide the mesh and the controller used to select the mesh
  45448. */
  45449. onMeshSelectedWithController: Observable<{
  45450. mesh: AbstractMesh;
  45451. controller: WebVRController;
  45452. }>;
  45453. /**
  45454. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45455. */
  45456. onNewMeshPicked: Observable<PickingInfo>;
  45457. private _circleEase;
  45458. /**
  45459. * Observable raised before camera teleportation
  45460. */
  45461. onBeforeCameraTeleport: Observable<Vector3>;
  45462. /**
  45463. * Observable raised after camera teleportation
  45464. */
  45465. onAfterCameraTeleport: Observable<Vector3>;
  45466. /**
  45467. * Observable raised when current selected mesh gets unselected
  45468. */
  45469. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45470. private _raySelectionPredicate;
  45471. /**
  45472. * To be optionaly changed by user to define custom ray selection
  45473. */
  45474. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45475. /**
  45476. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45477. */
  45478. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45479. /**
  45480. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45481. */
  45482. teleportationEnabled: boolean;
  45483. private _defaultHeight;
  45484. private _teleportationInitialized;
  45485. private _interactionsEnabled;
  45486. private _interactionsRequested;
  45487. private _displayGaze;
  45488. private _displayLaserPointer;
  45489. /**
  45490. * The mesh used to display where the user is going to teleport.
  45491. */
  45492. get teleportationTarget(): Mesh;
  45493. /**
  45494. * Sets the mesh to be used to display where the user is going to teleport.
  45495. */
  45496. set teleportationTarget(value: Mesh);
  45497. /**
  45498. * 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
  45499. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45500. * See http://doc.babylonjs.com/resources/baking_transformations
  45501. */
  45502. get gazeTrackerMesh(): Mesh;
  45503. set gazeTrackerMesh(value: Mesh);
  45504. /**
  45505. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45506. */
  45507. updateGazeTrackerScale: boolean;
  45508. /**
  45509. * If the gaze trackers color should be updated when selecting meshes
  45510. */
  45511. updateGazeTrackerColor: boolean;
  45512. /**
  45513. * If the controller laser color should be updated when selecting meshes
  45514. */
  45515. updateControllerLaserColor: boolean;
  45516. /**
  45517. * The gaze tracking mesh corresponding to the left controller
  45518. */
  45519. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45520. /**
  45521. * The gaze tracking mesh corresponding to the right controller
  45522. */
  45523. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45524. /**
  45525. * If the ray of the gaze should be displayed.
  45526. */
  45527. get displayGaze(): boolean;
  45528. /**
  45529. * Sets if the ray of the gaze should be displayed.
  45530. */
  45531. set displayGaze(value: boolean);
  45532. /**
  45533. * If the ray of the LaserPointer should be displayed.
  45534. */
  45535. get displayLaserPointer(): boolean;
  45536. /**
  45537. * Sets if the ray of the LaserPointer should be displayed.
  45538. */
  45539. set displayLaserPointer(value: boolean);
  45540. /**
  45541. * The deviceOrientationCamera used as the camera when not in VR.
  45542. */
  45543. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45544. /**
  45545. * Based on the current WebVR support, returns the current VR camera used.
  45546. */
  45547. get currentVRCamera(): Nullable<Camera>;
  45548. /**
  45549. * The webVRCamera which is used when in VR.
  45550. */
  45551. get webVRCamera(): WebVRFreeCamera;
  45552. /**
  45553. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45554. */
  45555. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45556. /**
  45557. * The html button that is used to trigger entering into VR.
  45558. */
  45559. get vrButton(): Nullable<HTMLButtonElement>;
  45560. private get _teleportationRequestInitiated();
  45561. /**
  45562. * Defines wether or not Pointer lock should be requested when switching to
  45563. * full screen.
  45564. */
  45565. requestPointerLockOnFullScreen: boolean;
  45566. /**
  45567. * If asking to force XR, this will be populated with the default xr experience
  45568. */
  45569. xr: WebXRDefaultExperience;
  45570. /**
  45571. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45572. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45573. */
  45574. xrTestDone: boolean;
  45575. /**
  45576. * Instantiates a VRExperienceHelper.
  45577. * Helps to quickly add VR support to an existing scene.
  45578. * @param scene The scene the VRExperienceHelper belongs to.
  45579. * @param webVROptions Options to modify the vr experience helper's behavior.
  45580. */
  45581. constructor(scene: Scene,
  45582. /** Options to modify the vr experience helper's behavior. */
  45583. webVROptions?: VRExperienceHelperOptions);
  45584. private completeVRInit;
  45585. private _onDefaultMeshLoaded;
  45586. private _onResize;
  45587. private _onFullscreenChange;
  45588. /**
  45589. * Gets a value indicating if we are currently in VR mode.
  45590. */
  45591. get isInVRMode(): boolean;
  45592. private onVrDisplayPresentChange;
  45593. private onVRDisplayChanged;
  45594. private moveButtonToBottomRight;
  45595. private displayVRButton;
  45596. private updateButtonVisibility;
  45597. private _cachedAngularSensibility;
  45598. /**
  45599. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45600. * Otherwise, will use the fullscreen API.
  45601. */
  45602. enterVR(): void;
  45603. /**
  45604. * Attempt to exit VR, or fullscreen.
  45605. */
  45606. exitVR(): void;
  45607. /**
  45608. * The position of the vr experience helper.
  45609. */
  45610. get position(): Vector3;
  45611. /**
  45612. * Sets the position of the vr experience helper.
  45613. */
  45614. set position(value: Vector3);
  45615. /**
  45616. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45617. */
  45618. enableInteractions(): void;
  45619. private get _noControllerIsActive();
  45620. private beforeRender;
  45621. private _isTeleportationFloor;
  45622. /**
  45623. * Adds a floor mesh to be used for teleportation.
  45624. * @param floorMesh the mesh to be used for teleportation.
  45625. */
  45626. addFloorMesh(floorMesh: Mesh): void;
  45627. /**
  45628. * Removes a floor mesh from being used for teleportation.
  45629. * @param floorMesh the mesh to be removed.
  45630. */
  45631. removeFloorMesh(floorMesh: Mesh): void;
  45632. /**
  45633. * Enables interactions and teleportation using the VR controllers and gaze.
  45634. * @param vrTeleportationOptions options to modify teleportation behavior.
  45635. */
  45636. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45637. private _onNewGamepadConnected;
  45638. private _tryEnableInteractionOnController;
  45639. private _onNewGamepadDisconnected;
  45640. private _enableInteractionOnController;
  45641. private _checkTeleportWithRay;
  45642. private _checkRotate;
  45643. private _checkTeleportBackwards;
  45644. private _enableTeleportationOnController;
  45645. private _createTeleportationCircles;
  45646. private _displayTeleportationTarget;
  45647. private _hideTeleportationTarget;
  45648. private _rotateCamera;
  45649. private _moveTeleportationSelectorTo;
  45650. private _workingVector;
  45651. private _workingQuaternion;
  45652. private _workingMatrix;
  45653. /**
  45654. * Time Constant Teleportation Mode
  45655. */
  45656. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45657. /**
  45658. * Speed Constant Teleportation Mode
  45659. */
  45660. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45661. /**
  45662. * Teleports the users feet to the desired location
  45663. * @param location The location where the user's feet should be placed
  45664. */
  45665. teleportCamera(location: Vector3): void;
  45666. private _convertNormalToDirectionOfRay;
  45667. private _castRayAndSelectObject;
  45668. private _notifySelectedMeshUnselected;
  45669. /**
  45670. * Sets the color of the laser ray from the vr controllers.
  45671. * @param color new color for the ray.
  45672. */
  45673. changeLaserColor(color: Color3): void;
  45674. /**
  45675. * Sets the color of the ray from the vr headsets gaze.
  45676. * @param color new color for the ray.
  45677. */
  45678. changeGazeColor(color: Color3): void;
  45679. /**
  45680. * Exits VR and disposes of the vr experience helper
  45681. */
  45682. dispose(): void;
  45683. /**
  45684. * Gets the name of the VRExperienceHelper class
  45685. * @returns "VRExperienceHelper"
  45686. */
  45687. getClassName(): string;
  45688. }
  45689. }
  45690. declare module "babylonjs/Cameras/VR/index" {
  45691. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45692. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45693. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45694. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45695. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45696. export * from "babylonjs/Cameras/VR/webVRCamera";
  45697. }
  45698. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45699. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45700. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45701. import { Observable } from "babylonjs/Misc/observable";
  45702. import { Matrix } from "babylonjs/Maths/math.vector";
  45703. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45704. /**
  45705. * Options used for hit testing
  45706. */
  45707. export interface IWebXRHitTestOptions {
  45708. /**
  45709. * Only test when user interacted with the scene. Default - hit test every frame
  45710. */
  45711. testOnPointerDownOnly?: boolean;
  45712. /**
  45713. * The node to use to transform the local results to world coordinates
  45714. */
  45715. worldParentNode?: TransformNode;
  45716. }
  45717. /**
  45718. * Interface defining the babylon result of raycasting/hit-test
  45719. */
  45720. export interface IWebXRHitResult {
  45721. /**
  45722. * The native hit test result
  45723. */
  45724. xrHitResult: XRHitResult;
  45725. /**
  45726. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45727. */
  45728. transformationMatrix: Matrix;
  45729. }
  45730. /**
  45731. * The currently-working hit-test module.
  45732. * Hit test (or raycasting) is used to interact with the real world.
  45733. * For further information read here - https://github.com/immersive-web/hit-test
  45734. */
  45735. export class WebXRHitTestLegacy implements IWebXRFeature {
  45736. private _xrSessionManager;
  45737. /**
  45738. * options to use when constructing this feature
  45739. */
  45740. readonly options: IWebXRHitTestOptions;
  45741. /**
  45742. * The module's name
  45743. */
  45744. static readonly Name: string;
  45745. /**
  45746. * The (Babylon) version of this module.
  45747. * This is an integer representing the implementation version.
  45748. * This number does not correspond to the webxr specs version
  45749. */
  45750. static readonly Version: number;
  45751. /**
  45752. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45753. * @param event the (select) event to use to select with
  45754. * @param referenceSpace the reference space to use for this hit test
  45755. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45756. */
  45757. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45758. /**
  45759. * execute a hit test with an XR Ray
  45760. *
  45761. * @param xrSession a native xrSession that will execute this hit test
  45762. * @param xrRay the ray (position and direction) to use for raycasting
  45763. * @param referenceSpace native XR reference space to use for the hit-test
  45764. * @param filter filter function that will filter the results
  45765. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45766. */
  45767. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45768. /**
  45769. * Triggered when new babylon (transformed) hit test results are available
  45770. */
  45771. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45772. /**
  45773. * Creates a new instance of the (legacy version) hit test feature
  45774. * @param _xrSessionManager an instance of WebXRSessionManager
  45775. * @param options options to use when constructing this feature
  45776. */
  45777. constructor(_xrSessionManager: WebXRSessionManager,
  45778. /**
  45779. * options to use when constructing this feature
  45780. */
  45781. options?: IWebXRHitTestOptions);
  45782. private _onSelectEnabled;
  45783. private _xrFrameObserver;
  45784. private _attached;
  45785. /**
  45786. * Populated with the last native XR Hit Results
  45787. */
  45788. lastNativeXRHitResults: XRHitResult[];
  45789. /**
  45790. * attach this feature
  45791. * Will usually be called by the features manager
  45792. *
  45793. * @returns true if successful.
  45794. */
  45795. attach(): boolean;
  45796. /**
  45797. * detach this feature.
  45798. * Will usually be called by the features manager
  45799. *
  45800. * @returns true if successful.
  45801. */
  45802. detach(): boolean;
  45803. private _onHitTestResults;
  45804. private _onSelect;
  45805. /**
  45806. * Dispose this feature and all of the resources attached
  45807. */
  45808. dispose(): void;
  45809. }
  45810. }
  45811. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  45812. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45813. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45814. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45815. import { Observable } from "babylonjs/Misc/observable";
  45816. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  45817. /**
  45818. * Options used in the plane detector module
  45819. */
  45820. export interface IWebXRPlaneDetectorOptions {
  45821. /**
  45822. * The node to use to transform the local results to world coordinates
  45823. */
  45824. worldParentNode?: TransformNode;
  45825. }
  45826. /**
  45827. * A babylon interface for a webxr plane.
  45828. * A Plane is actually a polygon, built from N points in space
  45829. */
  45830. export interface IWebXRPlane {
  45831. /**
  45832. * a babylon-assigned ID for this polygon
  45833. */
  45834. id: number;
  45835. /**
  45836. * the native xr-plane object
  45837. */
  45838. xrPlane: XRPlane;
  45839. /**
  45840. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45841. */
  45842. polygonDefinition: Array<Vector3>;
  45843. /**
  45844. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45845. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45846. */
  45847. transformationMatrix: Matrix;
  45848. }
  45849. /**
  45850. * The plane detector is used to detect planes in the real world when in AR
  45851. * For more information see https://github.com/immersive-web/real-world-geometry/
  45852. */
  45853. export class WebXRPlaneDetector implements IWebXRFeature {
  45854. private _xrSessionManager;
  45855. private _options;
  45856. /**
  45857. * The module's name
  45858. */
  45859. static readonly Name: string;
  45860. /**
  45861. * The (Babylon) version of this module.
  45862. * This is an integer representing the implementation version.
  45863. * This number does not correspond to the webxr specs version
  45864. */
  45865. static readonly Version: number;
  45866. /**
  45867. * Observers registered here will be executed when a new plane was added to the session
  45868. */
  45869. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45870. /**
  45871. * Observers registered here will be executed when a plane is no longer detected in the session
  45872. */
  45873. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45874. /**
  45875. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45876. * This can execute N times every frame
  45877. */
  45878. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45879. private _enabled;
  45880. private _attached;
  45881. private _detectedPlanes;
  45882. private _lastFrameDetected;
  45883. private _observerTracked;
  45884. /**
  45885. * construct a new Plane Detector
  45886. * @param _xrSessionManager an instance of xr Session manager
  45887. * @param _options configuration to use when constructing this feature
  45888. */
  45889. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45890. /**
  45891. * attach this feature
  45892. * Will usually be called by the features manager
  45893. *
  45894. * @returns true if successful.
  45895. */
  45896. attach(): boolean;
  45897. /**
  45898. * detach this feature.
  45899. * Will usually be called by the features manager
  45900. *
  45901. * @returns true if successful.
  45902. */
  45903. detach(): boolean;
  45904. /**
  45905. * Dispose this feature and all of the resources attached
  45906. */
  45907. dispose(): void;
  45908. private _updatePlaneWithXRPlane;
  45909. /**
  45910. * avoiding using Array.find for global support.
  45911. * @param xrPlane the plane to find in the array
  45912. */
  45913. private findIndexInPlaneArray;
  45914. }
  45915. }
  45916. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  45917. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45918. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45919. import { Observable } from "babylonjs/Misc/observable";
  45920. import { Matrix } from "babylonjs/Maths/math.vector";
  45921. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45922. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  45923. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  45924. /**
  45925. * Configuration options of the anchor system
  45926. */
  45927. export interface IWebXRAnchorSystemOptions {
  45928. /**
  45929. * a node that will be used to convert local to world coordinates
  45930. */
  45931. worldParentNode?: TransformNode;
  45932. /**
  45933. * should the anchor system use plane detection.
  45934. * If set to true, the plane-detection feature should be set using setPlaneDetector
  45935. */
  45936. usePlaneDetection?: boolean;
  45937. /**
  45938. * Should a new anchor be added every time a select event is triggered
  45939. */
  45940. addAnchorOnSelect?: boolean;
  45941. }
  45942. /**
  45943. * A babylon container for an XR Anchor
  45944. */
  45945. export interface IWebXRAnchor {
  45946. /**
  45947. * A babylon-assigned ID for this anchor
  45948. */
  45949. id: number;
  45950. /**
  45951. * The native anchor object
  45952. */
  45953. xrAnchor: XRAnchor;
  45954. /**
  45955. * Transformation matrix to apply to an object attached to this anchor
  45956. */
  45957. transformationMatrix: Matrix;
  45958. }
  45959. /**
  45960. * An implementation of the anchor system of WebXR.
  45961. * Note that the current documented implementation is not available in any browser. Future implementations
  45962. * will use the frame to create an anchor and not the session or a detected plane
  45963. * For further information see https://github.com/immersive-web/anchors/
  45964. */
  45965. export class WebXRAnchorSystem implements IWebXRFeature {
  45966. private _xrSessionManager;
  45967. private _options;
  45968. /**
  45969. * The module's name
  45970. */
  45971. static readonly Name: string;
  45972. /**
  45973. * The (Babylon) version of this module.
  45974. * This is an integer representing the implementation version.
  45975. * This number does not correspond to the webxr specs version
  45976. */
  45977. static readonly Version: number;
  45978. /**
  45979. * Observers registered here will be executed when a new anchor was added to the session
  45980. */
  45981. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  45982. /**
  45983. * Observers registered here will be executed when an existing anchor updates
  45984. * This can execute N times every frame
  45985. */
  45986. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  45987. /**
  45988. * Observers registered here will be executed when an anchor was removed from the session
  45989. */
  45990. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  45991. private _planeDetector;
  45992. private _hitTestModule;
  45993. private _enabled;
  45994. private _attached;
  45995. private _trackedAnchors;
  45996. private _lastFrameDetected;
  45997. private _observerTracked;
  45998. /**
  45999. * constructs a new anchor system
  46000. * @param _xrSessionManager an instance of WebXRSessionManager
  46001. * @param _options configuration object for this feature
  46002. */
  46003. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46004. /**
  46005. * set the plane detector to use in order to create anchors from frames
  46006. * @param planeDetector the plane-detector module to use
  46007. * @param enable enable plane-anchors. default is true
  46008. */
  46009. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46010. /**
  46011. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46012. * @param hitTestModule the hit-test module to use.
  46013. */
  46014. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46015. /**
  46016. * attach this feature
  46017. * Will usually be called by the features manager
  46018. *
  46019. * @returns true if successful.
  46020. */
  46021. attach(): boolean;
  46022. /**
  46023. * detach this feature.
  46024. * Will usually be called by the features manager
  46025. *
  46026. * @returns true if successful.
  46027. */
  46028. detach(): boolean;
  46029. /**
  46030. * Dispose this feature and all of the resources attached
  46031. */
  46032. dispose(): void;
  46033. private _onSelect;
  46034. /**
  46035. * Add anchor at a specific XR point.
  46036. *
  46037. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46038. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46039. * @returns a promise the fulfills when the anchor was created
  46040. */
  46041. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46042. private _updateAnchorWithXRFrame;
  46043. /**
  46044. * avoiding using Array.find for global support.
  46045. * @param xrAnchor the plane to find in the array
  46046. */
  46047. private _findIndexInAnchorArray;
  46048. }
  46049. }
  46050. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46051. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46052. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46054. import { Observable } from "babylonjs/Misc/observable";
  46055. /**
  46056. * Options interface for the background remover plugin
  46057. */
  46058. export interface IWebXRBackgroundRemoverOptions {
  46059. /**
  46060. * don't disable the environment helper
  46061. */
  46062. ignoreEnvironmentHelper?: boolean;
  46063. /**
  46064. * flags to configure the removal of the environment helper.
  46065. * If not set, the entire background will be removed. If set, flags should be set as well.
  46066. */
  46067. environmentHelperRemovalFlags?: {
  46068. /**
  46069. * Should the skybox be removed (default false)
  46070. */
  46071. skyBox?: boolean;
  46072. /**
  46073. * Should the ground be removed (default false)
  46074. */
  46075. ground?: boolean;
  46076. };
  46077. /**
  46078. * Further background meshes to disable when entering AR
  46079. */
  46080. backgroundMeshes?: AbstractMesh[];
  46081. }
  46082. /**
  46083. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46084. */
  46085. export class WebXRBackgroundRemover implements IWebXRFeature {
  46086. private _xrSessionManager;
  46087. /**
  46088. * read-only options to be used in this module
  46089. */
  46090. readonly options: IWebXRBackgroundRemoverOptions;
  46091. /**
  46092. * The module's name
  46093. */
  46094. static readonly Name: string;
  46095. /**
  46096. * The (Babylon) version of this module.
  46097. * This is an integer representing the implementation version.
  46098. * This number does not correspond to the webxr specs version
  46099. */
  46100. static readonly Version: number;
  46101. /**
  46102. * registered observers will be triggered when the background state changes
  46103. */
  46104. onBackgroundStateChangedObservable: Observable<boolean>;
  46105. /**
  46106. * constructs a new background remover module
  46107. * @param _xrSessionManager the session manager for this module
  46108. * @param options read-only options to be used in this module
  46109. */
  46110. constructor(_xrSessionManager: WebXRSessionManager,
  46111. /**
  46112. * read-only options to be used in this module
  46113. */
  46114. options?: IWebXRBackgroundRemoverOptions);
  46115. /**
  46116. * attach this feature
  46117. * Will usually be called by the features manager
  46118. *
  46119. * @returns true if successful.
  46120. */
  46121. attach(): boolean;
  46122. /**
  46123. * detach this feature.
  46124. * Will usually be called by the features manager
  46125. *
  46126. * @returns true if successful.
  46127. */
  46128. detach(): boolean;
  46129. private _setBackgroundState;
  46130. /**
  46131. * Dispose this feature and all of the resources attached
  46132. */
  46133. dispose(): void;
  46134. }
  46135. }
  46136. declare module "babylonjs/Cameras/XR/features/index" {
  46137. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46138. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46139. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46140. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46141. }
  46142. declare module "babylonjs/Cameras/XR/index" {
  46143. export * from "babylonjs/Cameras/XR/webXRCamera";
  46144. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  46145. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46146. export * from "babylonjs/Cameras/XR/webXRInput";
  46147. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  46148. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  46149. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  46150. export * from "babylonjs/Cameras/XR/webXRController";
  46151. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46152. export * from "babylonjs/Cameras/XR/webXRTypes";
  46153. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  46154. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46155. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46156. export * from "babylonjs/Cameras/XR/features/index";
  46157. }
  46158. declare module "babylonjs/Cameras/RigModes/index" {
  46159. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46160. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46161. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46162. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46163. }
  46164. declare module "babylonjs/Cameras/index" {
  46165. export * from "babylonjs/Cameras/Inputs/index";
  46166. export * from "babylonjs/Cameras/cameraInputsManager";
  46167. export * from "babylonjs/Cameras/camera";
  46168. export * from "babylonjs/Cameras/targetCamera";
  46169. export * from "babylonjs/Cameras/freeCamera";
  46170. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46171. export * from "babylonjs/Cameras/touchCamera";
  46172. export * from "babylonjs/Cameras/arcRotateCamera";
  46173. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46174. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46175. export * from "babylonjs/Cameras/flyCamera";
  46176. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46177. export * from "babylonjs/Cameras/followCamera";
  46178. export * from "babylonjs/Cameras/followCameraInputsManager";
  46179. export * from "babylonjs/Cameras/gamepadCamera";
  46180. export * from "babylonjs/Cameras/Stereoscopic/index";
  46181. export * from "babylonjs/Cameras/universalCamera";
  46182. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46183. export * from "babylonjs/Cameras/VR/index";
  46184. export * from "babylonjs/Cameras/XR/index";
  46185. export * from "babylonjs/Cameras/RigModes/index";
  46186. }
  46187. declare module "babylonjs/Collisions/index" {
  46188. export * from "babylonjs/Collisions/collider";
  46189. export * from "babylonjs/Collisions/collisionCoordinator";
  46190. export * from "babylonjs/Collisions/pickingInfo";
  46191. export * from "babylonjs/Collisions/intersectionInfo";
  46192. export * from "babylonjs/Collisions/meshCollisionData";
  46193. }
  46194. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46195. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46196. import { Vector3 } from "babylonjs/Maths/math.vector";
  46197. import { Ray } from "babylonjs/Culling/ray";
  46198. import { Plane } from "babylonjs/Maths/math.plane";
  46199. /**
  46200. * Contains an array of blocks representing the octree
  46201. */
  46202. export interface IOctreeContainer<T> {
  46203. /**
  46204. * Blocks within the octree
  46205. */
  46206. blocks: Array<OctreeBlock<T>>;
  46207. }
  46208. /**
  46209. * Class used to store a cell in an octree
  46210. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46211. */
  46212. export class OctreeBlock<T> {
  46213. /**
  46214. * Gets the content of the current block
  46215. */
  46216. entries: T[];
  46217. /**
  46218. * Gets the list of block children
  46219. */
  46220. blocks: Array<OctreeBlock<T>>;
  46221. private _depth;
  46222. private _maxDepth;
  46223. private _capacity;
  46224. private _minPoint;
  46225. private _maxPoint;
  46226. private _boundingVectors;
  46227. private _creationFunc;
  46228. /**
  46229. * Creates a new block
  46230. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46231. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46232. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46233. * @param depth defines the current depth of this block in the octree
  46234. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46235. * @param creationFunc defines a callback to call when an element is added to the block
  46236. */
  46237. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46238. /**
  46239. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46240. */
  46241. get capacity(): number;
  46242. /**
  46243. * Gets the minimum vector (in world space) of the block's bounding box
  46244. */
  46245. get minPoint(): Vector3;
  46246. /**
  46247. * Gets the maximum vector (in world space) of the block's bounding box
  46248. */
  46249. get maxPoint(): Vector3;
  46250. /**
  46251. * Add a new element to this block
  46252. * @param entry defines the element to add
  46253. */
  46254. addEntry(entry: T): void;
  46255. /**
  46256. * Remove an element from this block
  46257. * @param entry defines the element to remove
  46258. */
  46259. removeEntry(entry: T): void;
  46260. /**
  46261. * Add an array of elements to this block
  46262. * @param entries defines the array of elements to add
  46263. */
  46264. addEntries(entries: T[]): void;
  46265. /**
  46266. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46267. * @param frustumPlanes defines the frustum planes to test
  46268. * @param selection defines the array to store current content if selection is positive
  46269. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46270. */
  46271. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46272. /**
  46273. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46274. * @param sphereCenter defines the bounding sphere center
  46275. * @param sphereRadius defines the bounding sphere radius
  46276. * @param selection defines the array to store current content if selection is positive
  46277. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46278. */
  46279. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46280. /**
  46281. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46282. * @param ray defines the ray to test with
  46283. * @param selection defines the array to store current content if selection is positive
  46284. */
  46285. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46286. /**
  46287. * Subdivide the content into child blocks (this block will then be empty)
  46288. */
  46289. createInnerBlocks(): void;
  46290. /**
  46291. * @hidden
  46292. */
  46293. 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;
  46294. }
  46295. }
  46296. declare module "babylonjs/Culling/Octrees/octree" {
  46297. import { SmartArray } from "babylonjs/Misc/smartArray";
  46298. import { Vector3 } from "babylonjs/Maths/math.vector";
  46299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46301. import { Ray } from "babylonjs/Culling/ray";
  46302. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46303. import { Plane } from "babylonjs/Maths/math.plane";
  46304. /**
  46305. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46306. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46307. */
  46308. export class Octree<T> {
  46309. /** 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.) */
  46310. maxDepth: number;
  46311. /**
  46312. * Blocks within the octree containing objects
  46313. */
  46314. blocks: Array<OctreeBlock<T>>;
  46315. /**
  46316. * Content stored in the octree
  46317. */
  46318. dynamicContent: T[];
  46319. private _maxBlockCapacity;
  46320. private _selectionContent;
  46321. private _creationFunc;
  46322. /**
  46323. * Creates a octree
  46324. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46325. * @param creationFunc function to be used to instatiate the octree
  46326. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46327. * @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.)
  46328. */
  46329. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46330. /** 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.) */
  46331. maxDepth?: number);
  46332. /**
  46333. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46334. * @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);
  46335. * @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);
  46336. * @param entries meshes to be added to the octree blocks
  46337. */
  46338. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46339. /**
  46340. * Adds a mesh to the octree
  46341. * @param entry Mesh to add to the octree
  46342. */
  46343. addMesh(entry: T): void;
  46344. /**
  46345. * Remove an element from the octree
  46346. * @param entry defines the element to remove
  46347. */
  46348. removeMesh(entry: T): void;
  46349. /**
  46350. * Selects an array of meshes within the frustum
  46351. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46352. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46353. * @returns array of meshes within the frustum
  46354. */
  46355. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46356. /**
  46357. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46358. * @param sphereCenter defines the bounding sphere center
  46359. * @param sphereRadius defines the bounding sphere radius
  46360. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46361. * @returns an array of objects that intersect the sphere
  46362. */
  46363. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46364. /**
  46365. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46366. * @param ray defines the ray to test with
  46367. * @returns array of intersected objects
  46368. */
  46369. intersectsRay(ray: Ray): SmartArray<T>;
  46370. /**
  46371. * Adds a mesh into the octree block if it intersects the block
  46372. */
  46373. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46374. /**
  46375. * Adds a submesh into the octree block if it intersects the block
  46376. */
  46377. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46378. }
  46379. }
  46380. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  46381. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  46382. import { Scene } from "babylonjs/scene";
  46383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46385. import { Ray } from "babylonjs/Culling/ray";
  46386. import { Octree } from "babylonjs/Culling/Octrees/octree";
  46387. import { Collider } from "babylonjs/Collisions/collider";
  46388. module "babylonjs/scene" {
  46389. interface Scene {
  46390. /**
  46391. * @hidden
  46392. * Backing Filed
  46393. */
  46394. _selectionOctree: Octree<AbstractMesh>;
  46395. /**
  46396. * Gets the octree used to boost mesh selection (picking)
  46397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46398. */
  46399. selectionOctree: Octree<AbstractMesh>;
  46400. /**
  46401. * Creates or updates the octree used to boost selection (picking)
  46402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46403. * @param maxCapacity defines the maximum capacity per leaf
  46404. * @param maxDepth defines the maximum depth of the octree
  46405. * @returns an octree of AbstractMesh
  46406. */
  46407. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46408. }
  46409. }
  46410. module "babylonjs/Meshes/abstractMesh" {
  46411. interface AbstractMesh {
  46412. /**
  46413. * @hidden
  46414. * Backing Field
  46415. */
  46416. _submeshesOctree: Octree<SubMesh>;
  46417. /**
  46418. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46419. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46420. * @param maxCapacity defines the maximum size of each block (64 by default)
  46421. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46422. * @returns the new octree
  46423. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46424. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46425. */
  46426. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46427. }
  46428. }
  46429. /**
  46430. * Defines the octree scene component responsible to manage any octrees
  46431. * in a given scene.
  46432. */
  46433. export class OctreeSceneComponent {
  46434. /**
  46435. * The component name help to identify the component in the list of scene components.
  46436. */
  46437. readonly name: string;
  46438. /**
  46439. * The scene the component belongs to.
  46440. */
  46441. scene: Scene;
  46442. /**
  46443. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46444. */
  46445. readonly checksIsEnabled: boolean;
  46446. /**
  46447. * Creates a new instance of the component for the given scene
  46448. * @param scene Defines the scene to register the component in
  46449. */
  46450. constructor(scene: Scene);
  46451. /**
  46452. * Registers the component in a given scene
  46453. */
  46454. register(): void;
  46455. /**
  46456. * Return the list of active meshes
  46457. * @returns the list of active meshes
  46458. */
  46459. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46460. /**
  46461. * Return the list of active sub meshes
  46462. * @param mesh The mesh to get the candidates sub meshes from
  46463. * @returns the list of active sub meshes
  46464. */
  46465. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46466. private _tempRay;
  46467. /**
  46468. * Return the list of sub meshes intersecting with a given local ray
  46469. * @param mesh defines the mesh to find the submesh for
  46470. * @param localRay defines the ray in local space
  46471. * @returns the list of intersecting sub meshes
  46472. */
  46473. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46474. /**
  46475. * Return the list of sub meshes colliding with a collider
  46476. * @param mesh defines the mesh to find the submesh for
  46477. * @param collider defines the collider to evaluate the collision against
  46478. * @returns the list of colliding sub meshes
  46479. */
  46480. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46481. /**
  46482. * Rebuilds the elements related to this component in case of
  46483. * context lost for instance.
  46484. */
  46485. rebuild(): void;
  46486. /**
  46487. * Disposes the component and the associated ressources.
  46488. */
  46489. dispose(): void;
  46490. }
  46491. }
  46492. declare module "babylonjs/Culling/Octrees/index" {
  46493. export * from "babylonjs/Culling/Octrees/octree";
  46494. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46495. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46496. }
  46497. declare module "babylonjs/Culling/index" {
  46498. export * from "babylonjs/Culling/boundingBox";
  46499. export * from "babylonjs/Culling/boundingInfo";
  46500. export * from "babylonjs/Culling/boundingSphere";
  46501. export * from "babylonjs/Culling/Octrees/index";
  46502. export * from "babylonjs/Culling/ray";
  46503. }
  46504. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46505. import { IDisposable, Scene } from "babylonjs/scene";
  46506. import { Nullable } from "babylonjs/types";
  46507. import { Observable } from "babylonjs/Misc/observable";
  46508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46509. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46510. import { Camera } from "babylonjs/Cameras/camera";
  46511. /**
  46512. * Renders a layer on top of an existing scene
  46513. */
  46514. export class UtilityLayerRenderer implements IDisposable {
  46515. /** the original scene that will be rendered on top of */
  46516. originalScene: Scene;
  46517. private _pointerCaptures;
  46518. private _lastPointerEvents;
  46519. private static _DefaultUtilityLayer;
  46520. private static _DefaultKeepDepthUtilityLayer;
  46521. private _sharedGizmoLight;
  46522. private _renderCamera;
  46523. /**
  46524. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46525. * @returns the camera that is used when rendering the utility layer
  46526. */
  46527. getRenderCamera(): Nullable<Camera>;
  46528. /**
  46529. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46530. * @param cam the camera that should be used when rendering the utility layer
  46531. */
  46532. setRenderCamera(cam: Nullable<Camera>): void;
  46533. /**
  46534. * @hidden
  46535. * Light which used by gizmos to get light shading
  46536. */
  46537. _getSharedGizmoLight(): HemisphericLight;
  46538. /**
  46539. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46540. */
  46541. pickUtilitySceneFirst: boolean;
  46542. /**
  46543. * 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)
  46544. */
  46545. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46546. /**
  46547. * 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)
  46548. */
  46549. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46550. /**
  46551. * The scene that is rendered on top of the original scene
  46552. */
  46553. utilityLayerScene: Scene;
  46554. /**
  46555. * If the utility layer should automatically be rendered on top of existing scene
  46556. */
  46557. shouldRender: boolean;
  46558. /**
  46559. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46560. */
  46561. onlyCheckPointerDownEvents: boolean;
  46562. /**
  46563. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46564. */
  46565. processAllEvents: boolean;
  46566. /**
  46567. * Observable raised when the pointer move from the utility layer scene to the main scene
  46568. */
  46569. onPointerOutObservable: Observable<number>;
  46570. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46571. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46572. private _afterRenderObserver;
  46573. private _sceneDisposeObserver;
  46574. private _originalPointerObserver;
  46575. /**
  46576. * Instantiates a UtilityLayerRenderer
  46577. * @param originalScene the original scene that will be rendered on top of
  46578. * @param handleEvents boolean indicating if the utility layer should handle events
  46579. */
  46580. constructor(
  46581. /** the original scene that will be rendered on top of */
  46582. originalScene: Scene, handleEvents?: boolean);
  46583. private _notifyObservers;
  46584. /**
  46585. * Renders the utility layers scene on top of the original scene
  46586. */
  46587. render(): void;
  46588. /**
  46589. * Disposes of the renderer
  46590. */
  46591. dispose(): void;
  46592. private _updateCamera;
  46593. }
  46594. }
  46595. declare module "babylonjs/Gizmos/gizmo" {
  46596. import { Nullable } from "babylonjs/types";
  46597. import { IDisposable } from "babylonjs/scene";
  46598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46599. import { Mesh } from "babylonjs/Meshes/mesh";
  46600. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46601. /**
  46602. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46603. */
  46604. export class Gizmo implements IDisposable {
  46605. /** The utility layer the gizmo will be added to */
  46606. gizmoLayer: UtilityLayerRenderer;
  46607. /**
  46608. * The root mesh of the gizmo
  46609. */
  46610. _rootMesh: Mesh;
  46611. private _attachedMesh;
  46612. /**
  46613. * Ratio for the scale of the gizmo (Default: 1)
  46614. */
  46615. scaleRatio: number;
  46616. /**
  46617. * If a custom mesh has been set (Default: false)
  46618. */
  46619. protected _customMeshSet: boolean;
  46620. /**
  46621. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46622. * * When set, interactions will be enabled
  46623. */
  46624. get attachedMesh(): Nullable<AbstractMesh>;
  46625. set attachedMesh(value: Nullable<AbstractMesh>);
  46626. /**
  46627. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46628. * @param mesh The mesh to replace the default mesh of the gizmo
  46629. */
  46630. setCustomMesh(mesh: Mesh): void;
  46631. /**
  46632. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46633. */
  46634. updateGizmoRotationToMatchAttachedMesh: boolean;
  46635. /**
  46636. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46637. */
  46638. updateGizmoPositionToMatchAttachedMesh: boolean;
  46639. /**
  46640. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46641. */
  46642. updateScale: boolean;
  46643. protected _interactionsEnabled: boolean;
  46644. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46645. private _beforeRenderObserver;
  46646. private _tempVector;
  46647. /**
  46648. * Creates a gizmo
  46649. * @param gizmoLayer The utility layer the gizmo will be added to
  46650. */
  46651. constructor(
  46652. /** The utility layer the gizmo will be added to */
  46653. gizmoLayer?: UtilityLayerRenderer);
  46654. /**
  46655. * Updates the gizmo to match the attached mesh's position/rotation
  46656. */
  46657. protected _update(): void;
  46658. /**
  46659. * Disposes of the gizmo
  46660. */
  46661. dispose(): void;
  46662. }
  46663. }
  46664. declare module "babylonjs/Gizmos/planeDragGizmo" {
  46665. import { Observable } from "babylonjs/Misc/observable";
  46666. import { Nullable } from "babylonjs/types";
  46667. import { Vector3 } from "babylonjs/Maths/math.vector";
  46668. import { Color3 } from "babylonjs/Maths/math.color";
  46669. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46671. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46672. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46673. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46674. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46675. import { Scene } from "babylonjs/scene";
  46676. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46677. /**
  46678. * Single plane drag gizmo
  46679. */
  46680. export class PlaneDragGizmo extends Gizmo {
  46681. /**
  46682. * Drag behavior responsible for the gizmos dragging interactions
  46683. */
  46684. dragBehavior: PointerDragBehavior;
  46685. private _pointerObserver;
  46686. /**
  46687. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46688. */
  46689. snapDistance: number;
  46690. /**
  46691. * Event that fires each time the gizmo snaps to a new location.
  46692. * * snapDistance is the the change in distance
  46693. */
  46694. onSnapObservable: Observable<{
  46695. snapDistance: number;
  46696. }>;
  46697. private _plane;
  46698. private _coloredMaterial;
  46699. private _hoverMaterial;
  46700. private _isEnabled;
  46701. private _parent;
  46702. /** @hidden */
  46703. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46704. /** @hidden */
  46705. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46706. /**
  46707. * Creates a PlaneDragGizmo
  46708. * @param gizmoLayer The utility layer the gizmo will be added to
  46709. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46710. * @param color The color of the gizmo
  46711. */
  46712. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46713. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46714. /**
  46715. * If the gizmo is enabled
  46716. */
  46717. set isEnabled(value: boolean);
  46718. get isEnabled(): boolean;
  46719. /**
  46720. * Disposes of the gizmo
  46721. */
  46722. dispose(): void;
  46723. }
  46724. }
  46725. declare module "babylonjs/Gizmos/positionGizmo" {
  46726. import { Observable } from "babylonjs/Misc/observable";
  46727. import { Nullable } from "babylonjs/types";
  46728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46729. import { Mesh } from "babylonjs/Meshes/mesh";
  46730. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46731. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  46732. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  46733. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46734. /**
  46735. * Gizmo that enables dragging a mesh along 3 axis
  46736. */
  46737. export class PositionGizmo extends Gizmo {
  46738. /**
  46739. * Internal gizmo used for interactions on the x axis
  46740. */
  46741. xGizmo: AxisDragGizmo;
  46742. /**
  46743. * Internal gizmo used for interactions on the y axis
  46744. */
  46745. yGizmo: AxisDragGizmo;
  46746. /**
  46747. * Internal gizmo used for interactions on the z axis
  46748. */
  46749. zGizmo: AxisDragGizmo;
  46750. /**
  46751. * Internal gizmo used for interactions on the yz plane
  46752. */
  46753. xPlaneGizmo: PlaneDragGizmo;
  46754. /**
  46755. * Internal gizmo used for interactions on the xz plane
  46756. */
  46757. yPlaneGizmo: PlaneDragGizmo;
  46758. /**
  46759. * Internal gizmo used for interactions on the xy plane
  46760. */
  46761. zPlaneGizmo: PlaneDragGizmo;
  46762. /**
  46763. * private variables
  46764. */
  46765. private _meshAttached;
  46766. private _updateGizmoRotationToMatchAttachedMesh;
  46767. private _snapDistance;
  46768. private _scaleRatio;
  46769. /** Fires an event when any of it's sub gizmos are dragged */
  46770. onDragStartObservable: Observable<unknown>;
  46771. /** Fires an event when any of it's sub gizmos are released from dragging */
  46772. onDragEndObservable: Observable<unknown>;
  46773. /**
  46774. * If set to true, planar drag is enabled
  46775. */
  46776. private _planarGizmoEnabled;
  46777. get attachedMesh(): Nullable<AbstractMesh>;
  46778. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46779. /**
  46780. * Creates a PositionGizmo
  46781. * @param gizmoLayer The utility layer the gizmo will be added to
  46782. */
  46783. constructor(gizmoLayer?: UtilityLayerRenderer);
  46784. /**
  46785. * If the planar drag gizmo is enabled
  46786. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46787. */
  46788. set planarGizmoEnabled(value: boolean);
  46789. get planarGizmoEnabled(): boolean;
  46790. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46791. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46792. /**
  46793. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46794. */
  46795. set snapDistance(value: number);
  46796. get snapDistance(): number;
  46797. /**
  46798. * Ratio for the scale of the gizmo (Default: 1)
  46799. */
  46800. set scaleRatio(value: number);
  46801. get scaleRatio(): number;
  46802. /**
  46803. * Disposes of the gizmo
  46804. */
  46805. dispose(): void;
  46806. /**
  46807. * CustomMeshes are not supported by this gizmo
  46808. * @param mesh The mesh to replace the default mesh of the gizmo
  46809. */
  46810. setCustomMesh(mesh: Mesh): void;
  46811. }
  46812. }
  46813. declare module "babylonjs/Gizmos/axisDragGizmo" {
  46814. import { Observable } from "babylonjs/Misc/observable";
  46815. import { Nullable } from "babylonjs/types";
  46816. import { Vector3 } from "babylonjs/Maths/math.vector";
  46817. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46819. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46820. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46821. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46822. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46823. import { Scene } from "babylonjs/scene";
  46824. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46825. import { Color3 } from "babylonjs/Maths/math.color";
  46826. /**
  46827. * Single axis drag gizmo
  46828. */
  46829. export class AxisDragGizmo extends Gizmo {
  46830. /**
  46831. * Drag behavior responsible for the gizmos dragging interactions
  46832. */
  46833. dragBehavior: PointerDragBehavior;
  46834. private _pointerObserver;
  46835. /**
  46836. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46837. */
  46838. snapDistance: number;
  46839. /**
  46840. * Event that fires each time the gizmo snaps to a new location.
  46841. * * snapDistance is the the change in distance
  46842. */
  46843. onSnapObservable: Observable<{
  46844. snapDistance: number;
  46845. }>;
  46846. private _isEnabled;
  46847. private _parent;
  46848. private _arrow;
  46849. private _coloredMaterial;
  46850. private _hoverMaterial;
  46851. /** @hidden */
  46852. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46853. /** @hidden */
  46854. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46855. /**
  46856. * Creates an AxisDragGizmo
  46857. * @param gizmoLayer The utility layer the gizmo will be added to
  46858. * @param dragAxis The axis which the gizmo will be able to drag on
  46859. * @param color The color of the gizmo
  46860. */
  46861. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46862. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46863. /**
  46864. * If the gizmo is enabled
  46865. */
  46866. set isEnabled(value: boolean);
  46867. get isEnabled(): boolean;
  46868. /**
  46869. * Disposes of the gizmo
  46870. */
  46871. dispose(): void;
  46872. }
  46873. }
  46874. declare module "babylonjs/Debug/axesViewer" {
  46875. import { Vector3 } from "babylonjs/Maths/math.vector";
  46876. import { Nullable } from "babylonjs/types";
  46877. import { Scene } from "babylonjs/scene";
  46878. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46879. /**
  46880. * The Axes viewer will show 3 axes in a specific point in space
  46881. */
  46882. export class AxesViewer {
  46883. private _xAxis;
  46884. private _yAxis;
  46885. private _zAxis;
  46886. private _scaleLinesFactor;
  46887. private _instanced;
  46888. /**
  46889. * Gets the hosting scene
  46890. */
  46891. scene: Scene;
  46892. /**
  46893. * Gets or sets a number used to scale line length
  46894. */
  46895. scaleLines: number;
  46896. /** Gets the node hierarchy used to render x-axis */
  46897. get xAxis(): TransformNode;
  46898. /** Gets the node hierarchy used to render y-axis */
  46899. get yAxis(): TransformNode;
  46900. /** Gets the node hierarchy used to render z-axis */
  46901. get zAxis(): TransformNode;
  46902. /**
  46903. * Creates a new AxesViewer
  46904. * @param scene defines the hosting scene
  46905. * @param scaleLines defines a number used to scale line length (1 by default)
  46906. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46907. * @param xAxis defines the node hierarchy used to render the x-axis
  46908. * @param yAxis defines the node hierarchy used to render the y-axis
  46909. * @param zAxis defines the node hierarchy used to render the z-axis
  46910. */
  46911. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46912. /**
  46913. * Force the viewer to update
  46914. * @param position defines the position of the viewer
  46915. * @param xaxis defines the x axis of the viewer
  46916. * @param yaxis defines the y axis of the viewer
  46917. * @param zaxis defines the z axis of the viewer
  46918. */
  46919. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46920. /**
  46921. * Creates an instance of this axes viewer.
  46922. * @returns a new axes viewer with instanced meshes
  46923. */
  46924. createInstance(): AxesViewer;
  46925. /** Releases resources */
  46926. dispose(): void;
  46927. private static _SetRenderingGroupId;
  46928. }
  46929. }
  46930. declare module "babylonjs/Debug/boneAxesViewer" {
  46931. import { Nullable } from "babylonjs/types";
  46932. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  46933. import { Vector3 } from "babylonjs/Maths/math.vector";
  46934. import { Mesh } from "babylonjs/Meshes/mesh";
  46935. import { Bone } from "babylonjs/Bones/bone";
  46936. import { Scene } from "babylonjs/scene";
  46937. /**
  46938. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46939. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46940. */
  46941. export class BoneAxesViewer extends AxesViewer {
  46942. /**
  46943. * Gets or sets the target mesh where to display the axes viewer
  46944. */
  46945. mesh: Nullable<Mesh>;
  46946. /**
  46947. * Gets or sets the target bone where to display the axes viewer
  46948. */
  46949. bone: Nullable<Bone>;
  46950. /** Gets current position */
  46951. pos: Vector3;
  46952. /** Gets direction of X axis */
  46953. xaxis: Vector3;
  46954. /** Gets direction of Y axis */
  46955. yaxis: Vector3;
  46956. /** Gets direction of Z axis */
  46957. zaxis: Vector3;
  46958. /**
  46959. * Creates a new BoneAxesViewer
  46960. * @param scene defines the hosting scene
  46961. * @param bone defines the target bone
  46962. * @param mesh defines the target mesh
  46963. * @param scaleLines defines a scaling factor for line length (1 by default)
  46964. */
  46965. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46966. /**
  46967. * Force the viewer to update
  46968. */
  46969. update(): void;
  46970. /** Releases resources */
  46971. dispose(): void;
  46972. }
  46973. }
  46974. declare module "babylonjs/Debug/debugLayer" {
  46975. import { Scene } from "babylonjs/scene";
  46976. /**
  46977. * Interface used to define scene explorer extensibility option
  46978. */
  46979. export interface IExplorerExtensibilityOption {
  46980. /**
  46981. * Define the option label
  46982. */
  46983. label: string;
  46984. /**
  46985. * Defines the action to execute on click
  46986. */
  46987. action: (entity: any) => void;
  46988. }
  46989. /**
  46990. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46991. */
  46992. export interface IExplorerExtensibilityGroup {
  46993. /**
  46994. * Defines a predicate to test if a given type mut be extended
  46995. */
  46996. predicate: (entity: any) => boolean;
  46997. /**
  46998. * Gets the list of options added to a type
  46999. */
  47000. entries: IExplorerExtensibilityOption[];
  47001. }
  47002. /**
  47003. * Interface used to define the options to use to create the Inspector
  47004. */
  47005. export interface IInspectorOptions {
  47006. /**
  47007. * Display in overlay mode (default: false)
  47008. */
  47009. overlay?: boolean;
  47010. /**
  47011. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47012. */
  47013. globalRoot?: HTMLElement;
  47014. /**
  47015. * Display the Scene explorer
  47016. */
  47017. showExplorer?: boolean;
  47018. /**
  47019. * Display the property inspector
  47020. */
  47021. showInspector?: boolean;
  47022. /**
  47023. * Display in embed mode (both panes on the right)
  47024. */
  47025. embedMode?: boolean;
  47026. /**
  47027. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47028. */
  47029. handleResize?: boolean;
  47030. /**
  47031. * Allow the panes to popup (default: true)
  47032. */
  47033. enablePopup?: boolean;
  47034. /**
  47035. * Allow the panes to be closed by users (default: true)
  47036. */
  47037. enableClose?: boolean;
  47038. /**
  47039. * Optional list of extensibility entries
  47040. */
  47041. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47042. /**
  47043. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47044. */
  47045. inspectorURL?: string;
  47046. /**
  47047. * Optional initial tab (default to DebugLayerTab.Properties)
  47048. */
  47049. initialTab?: DebugLayerTab;
  47050. }
  47051. module "babylonjs/scene" {
  47052. interface Scene {
  47053. /**
  47054. * @hidden
  47055. * Backing field
  47056. */
  47057. _debugLayer: DebugLayer;
  47058. /**
  47059. * Gets the debug layer (aka Inspector) associated with the scene
  47060. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47061. */
  47062. debugLayer: DebugLayer;
  47063. }
  47064. }
  47065. /**
  47066. * Enum of inspector action tab
  47067. */
  47068. export enum DebugLayerTab {
  47069. /**
  47070. * Properties tag (default)
  47071. */
  47072. Properties = 0,
  47073. /**
  47074. * Debug tab
  47075. */
  47076. Debug = 1,
  47077. /**
  47078. * Statistics tab
  47079. */
  47080. Statistics = 2,
  47081. /**
  47082. * Tools tab
  47083. */
  47084. Tools = 3,
  47085. /**
  47086. * Settings tab
  47087. */
  47088. Settings = 4
  47089. }
  47090. /**
  47091. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47092. * what is happening in your scene
  47093. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47094. */
  47095. export class DebugLayer {
  47096. /**
  47097. * Define the url to get the inspector script from.
  47098. * By default it uses the babylonjs CDN.
  47099. * @ignoreNaming
  47100. */
  47101. static InspectorURL: string;
  47102. private _scene;
  47103. private BJSINSPECTOR;
  47104. private _onPropertyChangedObservable?;
  47105. /**
  47106. * Observable triggered when a property is changed through the inspector.
  47107. */
  47108. get onPropertyChangedObservable(): any;
  47109. /**
  47110. * Instantiates a new debug layer.
  47111. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47112. * what is happening in your scene
  47113. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47114. * @param scene Defines the scene to inspect
  47115. */
  47116. constructor(scene: Scene);
  47117. /** Creates the inspector window. */
  47118. private _createInspector;
  47119. /**
  47120. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47121. * @param entity defines the entity to select
  47122. * @param lineContainerTitle defines the specific block to highlight
  47123. */
  47124. select(entity: any, lineContainerTitle?: string): void;
  47125. /** Get the inspector from bundle or global */
  47126. private _getGlobalInspector;
  47127. /**
  47128. * Get if the inspector is visible or not.
  47129. * @returns true if visible otherwise, false
  47130. */
  47131. isVisible(): boolean;
  47132. /**
  47133. * Hide the inspector and close its window.
  47134. */
  47135. hide(): void;
  47136. /**
  47137. * Launch the debugLayer.
  47138. * @param config Define the configuration of the inspector
  47139. * @return a promise fulfilled when the debug layer is visible
  47140. */
  47141. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47142. }
  47143. }
  47144. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47145. import { Nullable } from "babylonjs/types";
  47146. import { Scene } from "babylonjs/scene";
  47147. import { Vector4 } from "babylonjs/Maths/math.vector";
  47148. import { Color4 } from "babylonjs/Maths/math.color";
  47149. import { Mesh } from "babylonjs/Meshes/mesh";
  47150. /**
  47151. * Class containing static functions to help procedurally build meshes
  47152. */
  47153. export class BoxBuilder {
  47154. /**
  47155. * Creates a box mesh
  47156. * * The parameter `size` sets the size (float) of each box side (default 1)
  47157. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47158. * * 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)
  47159. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47163. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47164. * @param name defines the name of the mesh
  47165. * @param options defines the options used to create the mesh
  47166. * @param scene defines the hosting scene
  47167. * @returns the box mesh
  47168. */
  47169. static CreateBox(name: string, options: {
  47170. size?: number;
  47171. width?: number;
  47172. height?: number;
  47173. depth?: number;
  47174. faceUV?: Vector4[];
  47175. faceColors?: Color4[];
  47176. sideOrientation?: number;
  47177. frontUVs?: Vector4;
  47178. backUVs?: Vector4;
  47179. wrap?: boolean;
  47180. topBaseAt?: number;
  47181. bottomBaseAt?: number;
  47182. updatable?: boolean;
  47183. }, scene?: Nullable<Scene>): Mesh;
  47184. }
  47185. }
  47186. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  47187. import { Vector4 } from "babylonjs/Maths/math.vector";
  47188. import { Mesh } from "babylonjs/Meshes/mesh";
  47189. import { Scene } from "babylonjs/scene";
  47190. import { Nullable } from "babylonjs/types";
  47191. /**
  47192. * Class containing static functions to help procedurally build meshes
  47193. */
  47194. export class SphereBuilder {
  47195. /**
  47196. * Creates a sphere mesh
  47197. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47198. * * 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`)
  47199. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47200. * * 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
  47201. * * 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)
  47202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47205. * @param name defines the name of the mesh
  47206. * @param options defines the options used to create the mesh
  47207. * @param scene defines the hosting scene
  47208. * @returns the sphere mesh
  47209. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47210. */
  47211. static CreateSphere(name: string, options: {
  47212. segments?: number;
  47213. diameter?: number;
  47214. diameterX?: number;
  47215. diameterY?: number;
  47216. diameterZ?: number;
  47217. arc?: number;
  47218. slice?: number;
  47219. sideOrientation?: number;
  47220. frontUVs?: Vector4;
  47221. backUVs?: Vector4;
  47222. updatable?: boolean;
  47223. }, scene?: Nullable<Scene>): Mesh;
  47224. }
  47225. }
  47226. declare module "babylonjs/Debug/physicsViewer" {
  47227. import { Nullable } from "babylonjs/types";
  47228. import { Scene } from "babylonjs/scene";
  47229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47230. import { Mesh } from "babylonjs/Meshes/mesh";
  47231. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47232. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47233. /**
  47234. * Used to show the physics impostor around the specific mesh
  47235. */
  47236. export class PhysicsViewer {
  47237. /** @hidden */
  47238. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47239. /** @hidden */
  47240. protected _meshes: Array<Nullable<AbstractMesh>>;
  47241. /** @hidden */
  47242. protected _scene: Nullable<Scene>;
  47243. /** @hidden */
  47244. protected _numMeshes: number;
  47245. /** @hidden */
  47246. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47247. private _renderFunction;
  47248. private _utilityLayer;
  47249. private _debugBoxMesh;
  47250. private _debugSphereMesh;
  47251. private _debugCylinderMesh;
  47252. private _debugMaterial;
  47253. private _debugMeshMeshes;
  47254. /**
  47255. * Creates a new PhysicsViewer
  47256. * @param scene defines the hosting scene
  47257. */
  47258. constructor(scene: Scene);
  47259. /** @hidden */
  47260. protected _updateDebugMeshes(): void;
  47261. /**
  47262. * Renders a specified physic impostor
  47263. * @param impostor defines the impostor to render
  47264. * @param targetMesh defines the mesh represented by the impostor
  47265. * @returns the new debug mesh used to render the impostor
  47266. */
  47267. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47268. /**
  47269. * Hides a specified physic impostor
  47270. * @param impostor defines the impostor to hide
  47271. */
  47272. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47273. private _getDebugMaterial;
  47274. private _getDebugBoxMesh;
  47275. private _getDebugSphereMesh;
  47276. private _getDebugCylinderMesh;
  47277. private _getDebugMeshMesh;
  47278. private _getDebugMesh;
  47279. /** Releases all resources */
  47280. dispose(): void;
  47281. }
  47282. }
  47283. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  47284. import { Vector3 } from "babylonjs/Maths/math.vector";
  47285. import { Color4 } from "babylonjs/Maths/math.color";
  47286. import { Nullable } from "babylonjs/types";
  47287. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47288. import { Scene } from "babylonjs/scene";
  47289. /**
  47290. * Class containing static functions to help procedurally build meshes
  47291. */
  47292. export class LinesBuilder {
  47293. /**
  47294. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47295. * * 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
  47296. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47297. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47298. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47299. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47300. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47301. * * 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
  47302. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47305. * @param name defines the name of the new line system
  47306. * @param options defines the options used to create the line system
  47307. * @param scene defines the hosting scene
  47308. * @returns a new line system mesh
  47309. */
  47310. static CreateLineSystem(name: string, options: {
  47311. lines: Vector3[][];
  47312. updatable?: boolean;
  47313. instance?: Nullable<LinesMesh>;
  47314. colors?: Nullable<Color4[][]>;
  47315. useVertexAlpha?: boolean;
  47316. }, scene: Nullable<Scene>): LinesMesh;
  47317. /**
  47318. * Creates a line mesh
  47319. * 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
  47320. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47321. * * The parameter `points` is an array successive Vector3
  47322. * * 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
  47323. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47324. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47325. * * When updating an instance, remember that only point positions can change, not the number of points
  47326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47328. * @param name defines the name of the new line system
  47329. * @param options defines the options used to create the line system
  47330. * @param scene defines the hosting scene
  47331. * @returns a new line mesh
  47332. */
  47333. static CreateLines(name: string, options: {
  47334. points: Vector3[];
  47335. updatable?: boolean;
  47336. instance?: Nullable<LinesMesh>;
  47337. colors?: Color4[];
  47338. useVertexAlpha?: boolean;
  47339. }, scene?: Nullable<Scene>): LinesMesh;
  47340. /**
  47341. * Creates a dashed line mesh
  47342. * * 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
  47343. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47344. * * The parameter `points` is an array successive Vector3
  47345. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47346. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47347. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47348. * * 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
  47349. * * When updating an instance, remember that only point positions can change, not the number of points
  47350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47351. * @param name defines the name of the mesh
  47352. * @param options defines the options used to create the mesh
  47353. * @param scene defines the hosting scene
  47354. * @returns the dashed line mesh
  47355. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47356. */
  47357. static CreateDashedLines(name: string, options: {
  47358. points: Vector3[];
  47359. dashSize?: number;
  47360. gapSize?: number;
  47361. dashNb?: number;
  47362. updatable?: boolean;
  47363. instance?: LinesMesh;
  47364. }, scene?: Nullable<Scene>): LinesMesh;
  47365. }
  47366. }
  47367. declare module "babylonjs/Debug/rayHelper" {
  47368. import { Nullable } from "babylonjs/types";
  47369. import { Ray } from "babylonjs/Culling/ray";
  47370. import { Vector3 } from "babylonjs/Maths/math.vector";
  47371. import { Color3 } from "babylonjs/Maths/math.color";
  47372. import { Scene } from "babylonjs/scene";
  47373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47374. import "babylonjs/Meshes/Builders/linesBuilder";
  47375. /**
  47376. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47377. * in order to better appreciate the issue one might have.
  47378. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47379. */
  47380. export class RayHelper {
  47381. /**
  47382. * Defines the ray we are currently tryin to visualize.
  47383. */
  47384. ray: Nullable<Ray>;
  47385. private _renderPoints;
  47386. private _renderLine;
  47387. private _renderFunction;
  47388. private _scene;
  47389. private _updateToMeshFunction;
  47390. private _attachedToMesh;
  47391. private _meshSpaceDirection;
  47392. private _meshSpaceOrigin;
  47393. /**
  47394. * Helper function to create a colored helper in a scene in one line.
  47395. * @param ray Defines the ray we are currently tryin to visualize
  47396. * @param scene Defines the scene the ray is used in
  47397. * @param color Defines the color we want to see the ray in
  47398. * @returns The newly created ray helper.
  47399. */
  47400. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47401. /**
  47402. * Instantiate a new ray helper.
  47403. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47404. * in order to better appreciate the issue one might have.
  47405. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47406. * @param ray Defines the ray we are currently tryin to visualize
  47407. */
  47408. constructor(ray: Ray);
  47409. /**
  47410. * Shows the ray we are willing to debug.
  47411. * @param scene Defines the scene the ray needs to be rendered in
  47412. * @param color Defines the color the ray needs to be rendered in
  47413. */
  47414. show(scene: Scene, color?: Color3): void;
  47415. /**
  47416. * Hides the ray we are debugging.
  47417. */
  47418. hide(): void;
  47419. private _render;
  47420. /**
  47421. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47422. * @param mesh Defines the mesh we want the helper attached to
  47423. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47424. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47425. * @param length Defines the length of the ray
  47426. */
  47427. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47428. /**
  47429. * Detach the ray helper from the mesh it has previously been attached to.
  47430. */
  47431. detachFromMesh(): void;
  47432. private _updateToMesh;
  47433. /**
  47434. * Dispose the helper and release its associated resources.
  47435. */
  47436. dispose(): void;
  47437. }
  47438. }
  47439. declare module "babylonjs/Debug/skeletonViewer" {
  47440. import { Color3 } from "babylonjs/Maths/math.color";
  47441. import { Scene } from "babylonjs/scene";
  47442. import { Nullable } from "babylonjs/types";
  47443. import { Skeleton } from "babylonjs/Bones/skeleton";
  47444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47445. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47446. /**
  47447. * Class used to render a debug view of a given skeleton
  47448. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47449. */
  47450. export class SkeletonViewer {
  47451. /** defines the skeleton to render */
  47452. skeleton: Skeleton;
  47453. /** defines the mesh attached to the skeleton */
  47454. mesh: AbstractMesh;
  47455. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47456. autoUpdateBonesMatrices: boolean;
  47457. /** defines the rendering group id to use with the viewer */
  47458. renderingGroupId: number;
  47459. /** Gets or sets the color used to render the skeleton */
  47460. color: Color3;
  47461. private _scene;
  47462. private _debugLines;
  47463. private _debugMesh;
  47464. private _isEnabled;
  47465. private _renderFunction;
  47466. private _utilityLayer;
  47467. /**
  47468. * Returns the mesh used to render the bones
  47469. */
  47470. get debugMesh(): Nullable<LinesMesh>;
  47471. /**
  47472. * Creates a new SkeletonViewer
  47473. * @param skeleton defines the skeleton to render
  47474. * @param mesh defines the mesh attached to the skeleton
  47475. * @param scene defines the hosting scene
  47476. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47477. * @param renderingGroupId defines the rendering group id to use with the viewer
  47478. */
  47479. constructor(
  47480. /** defines the skeleton to render */
  47481. skeleton: Skeleton,
  47482. /** defines the mesh attached to the skeleton */
  47483. mesh: AbstractMesh, scene: Scene,
  47484. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47485. autoUpdateBonesMatrices?: boolean,
  47486. /** defines the rendering group id to use with the viewer */
  47487. renderingGroupId?: number);
  47488. /** Gets or sets a boolean indicating if the viewer is enabled */
  47489. set isEnabled(value: boolean);
  47490. get isEnabled(): boolean;
  47491. private _getBonePosition;
  47492. private _getLinesForBonesWithLength;
  47493. private _getLinesForBonesNoLength;
  47494. /** Update the viewer to sync with current skeleton state */
  47495. update(): void;
  47496. /** Release associated resources */
  47497. dispose(): void;
  47498. }
  47499. }
  47500. declare module "babylonjs/Debug/index" {
  47501. export * from "babylonjs/Debug/axesViewer";
  47502. export * from "babylonjs/Debug/boneAxesViewer";
  47503. export * from "babylonjs/Debug/debugLayer";
  47504. export * from "babylonjs/Debug/physicsViewer";
  47505. export * from "babylonjs/Debug/rayHelper";
  47506. export * from "babylonjs/Debug/skeletonViewer";
  47507. }
  47508. declare module "babylonjs/Engines/nullEngine" {
  47509. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47510. import { Scene } from "babylonjs/scene";
  47511. import { Engine } from "babylonjs/Engines/engine";
  47512. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47513. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47514. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47515. import { Effect } from "babylonjs/Materials/effect";
  47516. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47517. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47518. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47519. /**
  47520. * Options to create the null engine
  47521. */
  47522. export class NullEngineOptions {
  47523. /**
  47524. * Render width (Default: 512)
  47525. */
  47526. renderWidth: number;
  47527. /**
  47528. * Render height (Default: 256)
  47529. */
  47530. renderHeight: number;
  47531. /**
  47532. * Texture size (Default: 512)
  47533. */
  47534. textureSize: number;
  47535. /**
  47536. * If delta time between frames should be constant
  47537. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47538. */
  47539. deterministicLockstep: boolean;
  47540. /**
  47541. * Maximum about of steps between frames (Default: 4)
  47542. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47543. */
  47544. lockstepMaxSteps: number;
  47545. }
  47546. /**
  47547. * The null engine class provides support for headless version of babylon.js.
  47548. * This can be used in server side scenario or for testing purposes
  47549. */
  47550. export class NullEngine extends Engine {
  47551. private _options;
  47552. /**
  47553. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47554. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47555. * @returns true if engine is in deterministic lock step mode
  47556. */
  47557. isDeterministicLockStep(): boolean;
  47558. /**
  47559. * Gets the max steps when engine is running in deterministic lock step
  47560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47561. * @returns the max steps
  47562. */
  47563. getLockstepMaxSteps(): number;
  47564. /**
  47565. * Gets the current hardware scaling level.
  47566. * By default the hardware scaling level is computed from the window device ratio.
  47567. * 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.
  47568. * @returns a number indicating the current hardware scaling level
  47569. */
  47570. getHardwareScalingLevel(): number;
  47571. constructor(options?: NullEngineOptions);
  47572. /**
  47573. * Creates a vertex buffer
  47574. * @param vertices the data for the vertex buffer
  47575. * @returns the new WebGL static buffer
  47576. */
  47577. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47578. /**
  47579. * Creates a new index buffer
  47580. * @param indices defines the content of the index buffer
  47581. * @param updatable defines if the index buffer must be updatable
  47582. * @returns a new webGL buffer
  47583. */
  47584. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47585. /**
  47586. * Clear the current render buffer or the current render target (if any is set up)
  47587. * @param color defines the color to use
  47588. * @param backBuffer defines if the back buffer must be cleared
  47589. * @param depth defines if the depth buffer must be cleared
  47590. * @param stencil defines if the stencil buffer must be cleared
  47591. */
  47592. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47593. /**
  47594. * Gets the current render width
  47595. * @param useScreen defines if screen size must be used (or the current render target if any)
  47596. * @returns a number defining the current render width
  47597. */
  47598. getRenderWidth(useScreen?: boolean): number;
  47599. /**
  47600. * Gets the current render height
  47601. * @param useScreen defines if screen size must be used (or the current render target if any)
  47602. * @returns a number defining the current render height
  47603. */
  47604. getRenderHeight(useScreen?: boolean): number;
  47605. /**
  47606. * Set the WebGL's viewport
  47607. * @param viewport defines the viewport element to be used
  47608. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47609. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47610. */
  47611. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47612. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47613. /**
  47614. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47615. * @param pipelineContext defines the pipeline context to use
  47616. * @param uniformsNames defines the list of uniform names
  47617. * @returns an array of webGL uniform locations
  47618. */
  47619. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47620. /**
  47621. * Gets the lsit of active attributes for a given webGL program
  47622. * @param pipelineContext defines the pipeline context to use
  47623. * @param attributesNames defines the list of attribute names to get
  47624. * @returns an array of indices indicating the offset of each attribute
  47625. */
  47626. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47627. /**
  47628. * Binds an effect to the webGL context
  47629. * @param effect defines the effect to bind
  47630. */
  47631. bindSamplers(effect: Effect): void;
  47632. /**
  47633. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47634. * @param effect defines the effect to activate
  47635. */
  47636. enableEffect(effect: Effect): void;
  47637. /**
  47638. * Set various states to the webGL context
  47639. * @param culling defines backface culling state
  47640. * @param zOffset defines the value to apply to zOffset (0 by default)
  47641. * @param force defines if states must be applied even if cache is up to date
  47642. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47643. */
  47644. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47645. /**
  47646. * Set the value of an uniform to an array of int32
  47647. * @param uniform defines the webGL uniform location where to store the value
  47648. * @param array defines the array of int32 to store
  47649. */
  47650. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47651. /**
  47652. * Set the value of an uniform to an array of int32 (stored as vec2)
  47653. * @param uniform defines the webGL uniform location where to store the value
  47654. * @param array defines the array of int32 to store
  47655. */
  47656. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47657. /**
  47658. * Set the value of an uniform to an array of int32 (stored as vec3)
  47659. * @param uniform defines the webGL uniform location where to store the value
  47660. * @param array defines the array of int32 to store
  47661. */
  47662. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47663. /**
  47664. * Set the value of an uniform to an array of int32 (stored as vec4)
  47665. * @param uniform defines the webGL uniform location where to store the value
  47666. * @param array defines the array of int32 to store
  47667. */
  47668. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47669. /**
  47670. * Set the value of an uniform to an array of float32
  47671. * @param uniform defines the webGL uniform location where to store the value
  47672. * @param array defines the array of float32 to store
  47673. */
  47674. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47675. /**
  47676. * Set the value of an uniform to an array of float32 (stored as vec2)
  47677. * @param uniform defines the webGL uniform location where to store the value
  47678. * @param array defines the array of float32 to store
  47679. */
  47680. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47681. /**
  47682. * Set the value of an uniform to an array of float32 (stored as vec3)
  47683. * @param uniform defines the webGL uniform location where to store the value
  47684. * @param array defines the array of float32 to store
  47685. */
  47686. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47687. /**
  47688. * Set the value of an uniform to an array of float32 (stored as vec4)
  47689. * @param uniform defines the webGL uniform location where to store the value
  47690. * @param array defines the array of float32 to store
  47691. */
  47692. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47693. /**
  47694. * Set the value of an uniform to an array of number
  47695. * @param uniform defines the webGL uniform location where to store the value
  47696. * @param array defines the array of number to store
  47697. */
  47698. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47699. /**
  47700. * Set the value of an uniform to an array of number (stored as vec2)
  47701. * @param uniform defines the webGL uniform location where to store the value
  47702. * @param array defines the array of number to store
  47703. */
  47704. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47705. /**
  47706. * Set the value of an uniform to an array of number (stored as vec3)
  47707. * @param uniform defines the webGL uniform location where to store the value
  47708. * @param array defines the array of number to store
  47709. */
  47710. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47711. /**
  47712. * Set the value of an uniform to an array of number (stored as vec4)
  47713. * @param uniform defines the webGL uniform location where to store the value
  47714. * @param array defines the array of number to store
  47715. */
  47716. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47717. /**
  47718. * Set the value of an uniform to an array of float32 (stored as matrices)
  47719. * @param uniform defines the webGL uniform location where to store the value
  47720. * @param matrices defines the array of float32 to store
  47721. */
  47722. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47723. /**
  47724. * Set the value of an uniform to a matrix (3x3)
  47725. * @param uniform defines the webGL uniform location where to store the value
  47726. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47727. */
  47728. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47729. /**
  47730. * Set the value of an uniform to a matrix (2x2)
  47731. * @param uniform defines the webGL uniform location where to store the value
  47732. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47733. */
  47734. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47735. /**
  47736. * Set the value of an uniform to a number (float)
  47737. * @param uniform defines the webGL uniform location where to store the value
  47738. * @param value defines the float number to store
  47739. */
  47740. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47741. /**
  47742. * Set the value of an uniform to a vec2
  47743. * @param uniform defines the webGL uniform location where to store the value
  47744. * @param x defines the 1st component of the value
  47745. * @param y defines the 2nd component of the value
  47746. */
  47747. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47748. /**
  47749. * Set the value of an uniform to a vec3
  47750. * @param uniform defines the webGL uniform location where to store the value
  47751. * @param x defines the 1st component of the value
  47752. * @param y defines the 2nd component of the value
  47753. * @param z defines the 3rd component of the value
  47754. */
  47755. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47756. /**
  47757. * Set the value of an uniform to a boolean
  47758. * @param uniform defines the webGL uniform location where to store the value
  47759. * @param bool defines the boolean to store
  47760. */
  47761. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47762. /**
  47763. * Set the value of an uniform to a vec4
  47764. * @param uniform defines the webGL uniform location where to store the value
  47765. * @param x defines the 1st component of the value
  47766. * @param y defines the 2nd component of the value
  47767. * @param z defines the 3rd component of the value
  47768. * @param w defines the 4th component of the value
  47769. */
  47770. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47771. /**
  47772. * Sets the current alpha mode
  47773. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47774. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47775. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47776. */
  47777. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47778. /**
  47779. * Bind webGl buffers directly to the webGL context
  47780. * @param vertexBuffers defines the vertex buffer to bind
  47781. * @param indexBuffer defines the index buffer to bind
  47782. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47783. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47784. * @param effect defines the effect associated with the vertex buffer
  47785. */
  47786. bindBuffers(vertexBuffers: {
  47787. [key: string]: VertexBuffer;
  47788. }, indexBuffer: DataBuffer, effect: Effect): void;
  47789. /**
  47790. * Force the entire cache to be cleared
  47791. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47792. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47793. */
  47794. wipeCaches(bruteForce?: boolean): void;
  47795. /**
  47796. * Send a draw order
  47797. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47798. * @param indexStart defines the starting index
  47799. * @param indexCount defines the number of index to draw
  47800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47801. */
  47802. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47803. /**
  47804. * Draw a list of indexed primitives
  47805. * @param fillMode defines the primitive to use
  47806. * @param indexStart defines the starting index
  47807. * @param indexCount defines the number of index to draw
  47808. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47809. */
  47810. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47811. /**
  47812. * Draw a list of unindexed primitives
  47813. * @param fillMode defines the primitive to use
  47814. * @param verticesStart defines the index of first vertex to draw
  47815. * @param verticesCount defines the count of vertices to draw
  47816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47817. */
  47818. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47819. /** @hidden */
  47820. _createTexture(): WebGLTexture;
  47821. /** @hidden */
  47822. _releaseTexture(texture: InternalTexture): void;
  47823. /**
  47824. * Usually called from Texture.ts.
  47825. * Passed information to create a WebGLTexture
  47826. * @param urlArg defines a value which contains one of the following:
  47827. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47828. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47829. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47830. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47831. * @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)
  47832. * @param scene needed for loading to the correct scene
  47833. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47834. * @param onLoad optional callback to be called upon successful completion
  47835. * @param onError optional callback to be called upon failure
  47836. * @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
  47837. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47838. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47839. * @param forcedExtension defines the extension to use to pick the right loader
  47840. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  47841. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47842. */
  47843. 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;
  47844. /**
  47845. * Creates a new render target texture
  47846. * @param size defines the size of the texture
  47847. * @param options defines the options used to create the texture
  47848. * @returns a new render target texture stored in an InternalTexture
  47849. */
  47850. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47851. /**
  47852. * Update the sampling mode of a given texture
  47853. * @param samplingMode defines the required sampling mode
  47854. * @param texture defines the texture to update
  47855. */
  47856. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47857. /**
  47858. * Binds the frame buffer to the specified texture.
  47859. * @param texture The texture to render to or null for the default canvas
  47860. * @param faceIndex The face of the texture to render to in case of cube texture
  47861. * @param requiredWidth The width of the target to render to
  47862. * @param requiredHeight The height of the target to render to
  47863. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47864. * @param depthStencilTexture The depth stencil texture to use to render
  47865. * @param lodLevel defines le lod level to bind to the frame buffer
  47866. */
  47867. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47868. /**
  47869. * Unbind the current render target texture from the webGL context
  47870. * @param texture defines the render target texture to unbind
  47871. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47872. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47873. */
  47874. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47875. /**
  47876. * Creates a dynamic vertex buffer
  47877. * @param vertices the data for the dynamic vertex buffer
  47878. * @returns the new WebGL dynamic buffer
  47879. */
  47880. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47881. /**
  47882. * Update the content of a dynamic texture
  47883. * @param texture defines the texture to update
  47884. * @param canvas defines the canvas containing the source
  47885. * @param invertY defines if data must be stored with Y axis inverted
  47886. * @param premulAlpha defines if alpha is stored as premultiplied
  47887. * @param format defines the format of the data
  47888. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47889. */
  47890. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47891. /**
  47892. * Gets a boolean indicating if all created effects are ready
  47893. * @returns true if all effects are ready
  47894. */
  47895. areAllEffectsReady(): boolean;
  47896. /**
  47897. * @hidden
  47898. * Get the current error code of the webGL context
  47899. * @returns the error code
  47900. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47901. */
  47902. getError(): number;
  47903. /** @hidden */
  47904. _getUnpackAlignement(): number;
  47905. /** @hidden */
  47906. _unpackFlipY(value: boolean): void;
  47907. /**
  47908. * Update a dynamic index buffer
  47909. * @param indexBuffer defines the target index buffer
  47910. * @param indices defines the data to update
  47911. * @param offset defines the offset in the target index buffer where update should start
  47912. */
  47913. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47914. /**
  47915. * Updates a dynamic vertex buffer.
  47916. * @param vertexBuffer the vertex buffer to update
  47917. * @param vertices the data used to update the vertex buffer
  47918. * @param byteOffset the byte offset of the data (optional)
  47919. * @param byteLength the byte length of the data (optional)
  47920. */
  47921. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47922. /** @hidden */
  47923. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47924. /** @hidden */
  47925. _bindTexture(channel: number, texture: InternalTexture): void;
  47926. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47927. /**
  47928. * 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
  47929. */
  47930. releaseEffects(): void;
  47931. displayLoadingUI(): void;
  47932. hideLoadingUI(): void;
  47933. /** @hidden */
  47934. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47935. /** @hidden */
  47936. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47937. /** @hidden */
  47938. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47939. /** @hidden */
  47940. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47941. }
  47942. }
  47943. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  47944. import { Nullable, int } from "babylonjs/types";
  47945. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  47946. /** @hidden */
  47947. export class _OcclusionDataStorage {
  47948. /** @hidden */
  47949. occlusionInternalRetryCounter: number;
  47950. /** @hidden */
  47951. isOcclusionQueryInProgress: boolean;
  47952. /** @hidden */
  47953. isOccluded: boolean;
  47954. /** @hidden */
  47955. occlusionRetryCount: number;
  47956. /** @hidden */
  47957. occlusionType: number;
  47958. /** @hidden */
  47959. occlusionQueryAlgorithmType: number;
  47960. }
  47961. module "babylonjs/Engines/engine" {
  47962. interface Engine {
  47963. /**
  47964. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47965. * @return the new query
  47966. */
  47967. createQuery(): WebGLQuery;
  47968. /**
  47969. * Delete and release a webGL query
  47970. * @param query defines the query to delete
  47971. * @return the current engine
  47972. */
  47973. deleteQuery(query: WebGLQuery): Engine;
  47974. /**
  47975. * Check if a given query has resolved and got its value
  47976. * @param query defines the query to check
  47977. * @returns true if the query got its value
  47978. */
  47979. isQueryResultAvailable(query: WebGLQuery): boolean;
  47980. /**
  47981. * Gets the value of a given query
  47982. * @param query defines the query to check
  47983. * @returns the value of the query
  47984. */
  47985. getQueryResult(query: WebGLQuery): number;
  47986. /**
  47987. * Initiates an occlusion query
  47988. * @param algorithmType defines the algorithm to use
  47989. * @param query defines the query to use
  47990. * @returns the current engine
  47991. * @see http://doc.babylonjs.com/features/occlusionquery
  47992. */
  47993. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47994. /**
  47995. * Ends an occlusion query
  47996. * @see http://doc.babylonjs.com/features/occlusionquery
  47997. * @param algorithmType defines the algorithm to use
  47998. * @returns the current engine
  47999. */
  48000. endOcclusionQuery(algorithmType: number): Engine;
  48001. /**
  48002. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48003. * Please note that only one query can be issued at a time
  48004. * @returns a time token used to track the time span
  48005. */
  48006. startTimeQuery(): Nullable<_TimeToken>;
  48007. /**
  48008. * Ends a time query
  48009. * @param token defines the token used to measure the time span
  48010. * @returns the time spent (in ns)
  48011. */
  48012. endTimeQuery(token: _TimeToken): int;
  48013. /** @hidden */
  48014. _currentNonTimestampToken: Nullable<_TimeToken>;
  48015. /** @hidden */
  48016. _createTimeQuery(): WebGLQuery;
  48017. /** @hidden */
  48018. _deleteTimeQuery(query: WebGLQuery): void;
  48019. /** @hidden */
  48020. _getGlAlgorithmType(algorithmType: number): number;
  48021. /** @hidden */
  48022. _getTimeQueryResult(query: WebGLQuery): any;
  48023. /** @hidden */
  48024. _getTimeQueryAvailability(query: WebGLQuery): any;
  48025. }
  48026. }
  48027. module "babylonjs/Meshes/abstractMesh" {
  48028. interface AbstractMesh {
  48029. /**
  48030. * Backing filed
  48031. * @hidden
  48032. */
  48033. __occlusionDataStorage: _OcclusionDataStorage;
  48034. /**
  48035. * Access property
  48036. * @hidden
  48037. */
  48038. _occlusionDataStorage: _OcclusionDataStorage;
  48039. /**
  48040. * 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.
  48041. * The default value is -1 which means don't break the query and wait till the result
  48042. * @see http://doc.babylonjs.com/features/occlusionquery
  48043. */
  48044. occlusionRetryCount: number;
  48045. /**
  48046. * 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:
  48047. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48048. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48049. * * 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.
  48050. * @see http://doc.babylonjs.com/features/occlusionquery
  48051. */
  48052. occlusionType: number;
  48053. /**
  48054. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48055. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48056. * * 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.
  48057. * @see http://doc.babylonjs.com/features/occlusionquery
  48058. */
  48059. occlusionQueryAlgorithmType: number;
  48060. /**
  48061. * 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
  48062. * @see http://doc.babylonjs.com/features/occlusionquery
  48063. */
  48064. isOccluded: boolean;
  48065. /**
  48066. * Flag to check the progress status of the query
  48067. * @see http://doc.babylonjs.com/features/occlusionquery
  48068. */
  48069. isOcclusionQueryInProgress: boolean;
  48070. }
  48071. }
  48072. }
  48073. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48074. import { Nullable } from "babylonjs/types";
  48075. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48076. /** @hidden */
  48077. export var _forceTransformFeedbackToBundle: boolean;
  48078. module "babylonjs/Engines/engine" {
  48079. interface Engine {
  48080. /**
  48081. * Creates a webGL transform feedback object
  48082. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48083. * @returns the webGL transform feedback object
  48084. */
  48085. createTransformFeedback(): WebGLTransformFeedback;
  48086. /**
  48087. * Delete a webGL transform feedback object
  48088. * @param value defines the webGL transform feedback object to delete
  48089. */
  48090. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48091. /**
  48092. * Bind a webGL transform feedback object to the webgl context
  48093. * @param value defines the webGL transform feedback object to bind
  48094. */
  48095. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48096. /**
  48097. * Begins a transform feedback operation
  48098. * @param usePoints defines if points or triangles must be used
  48099. */
  48100. beginTransformFeedback(usePoints: boolean): void;
  48101. /**
  48102. * Ends a transform feedback operation
  48103. */
  48104. endTransformFeedback(): void;
  48105. /**
  48106. * Specify the varyings to use with transform feedback
  48107. * @param program defines the associated webGL program
  48108. * @param value defines the list of strings representing the varying names
  48109. */
  48110. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48111. /**
  48112. * Bind a webGL buffer for a transform feedback operation
  48113. * @param value defines the webGL buffer to bind
  48114. */
  48115. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48116. }
  48117. }
  48118. }
  48119. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48120. import { Scene } from "babylonjs/scene";
  48121. import { Engine } from "babylonjs/Engines/engine";
  48122. import { Texture } from "babylonjs/Materials/Textures/texture";
  48123. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48124. import "babylonjs/Engines/Extensions/engine.multiRender";
  48125. /**
  48126. * Creation options of the multi render target texture.
  48127. */
  48128. export interface IMultiRenderTargetOptions {
  48129. /**
  48130. * Define if the texture needs to create mip maps after render.
  48131. */
  48132. generateMipMaps?: boolean;
  48133. /**
  48134. * Define the types of all the draw buffers we want to create
  48135. */
  48136. types?: number[];
  48137. /**
  48138. * Define the sampling modes of all the draw buffers we want to create
  48139. */
  48140. samplingModes?: number[];
  48141. /**
  48142. * Define if a depth buffer is required
  48143. */
  48144. generateDepthBuffer?: boolean;
  48145. /**
  48146. * Define if a stencil buffer is required
  48147. */
  48148. generateStencilBuffer?: boolean;
  48149. /**
  48150. * Define if a depth texture is required instead of a depth buffer
  48151. */
  48152. generateDepthTexture?: boolean;
  48153. /**
  48154. * Define the number of desired draw buffers
  48155. */
  48156. textureCount?: number;
  48157. /**
  48158. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48159. */
  48160. doNotChangeAspectRatio?: boolean;
  48161. /**
  48162. * Define the default type of the buffers we are creating
  48163. */
  48164. defaultType?: number;
  48165. }
  48166. /**
  48167. * A multi render target, like a render target provides the ability to render to a texture.
  48168. * Unlike the render target, it can render to several draw buffers in one draw.
  48169. * This is specially interesting in deferred rendering or for any effects requiring more than
  48170. * just one color from a single pass.
  48171. */
  48172. export class MultiRenderTarget extends RenderTargetTexture {
  48173. private _internalTextures;
  48174. private _textures;
  48175. private _multiRenderTargetOptions;
  48176. /**
  48177. * Get if draw buffers are currently supported by the used hardware and browser.
  48178. */
  48179. get isSupported(): boolean;
  48180. /**
  48181. * Get the list of textures generated by the multi render target.
  48182. */
  48183. get textures(): Texture[];
  48184. /**
  48185. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48186. */
  48187. get depthTexture(): Texture;
  48188. /**
  48189. * Set the wrapping mode on U of all the textures we are rendering to.
  48190. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48191. */
  48192. set wrapU(wrap: number);
  48193. /**
  48194. * Set the wrapping mode on V of all the textures we are rendering to.
  48195. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48196. */
  48197. set wrapV(wrap: number);
  48198. /**
  48199. * Instantiate a new multi render target texture.
  48200. * A multi render target, like a render target provides the ability to render to a texture.
  48201. * Unlike the render target, it can render to several draw buffers in one draw.
  48202. * This is specially interesting in deferred rendering or for any effects requiring more than
  48203. * just one color from a single pass.
  48204. * @param name Define the name of the texture
  48205. * @param size Define the size of the buffers to render to
  48206. * @param count Define the number of target we are rendering into
  48207. * @param scene Define the scene the texture belongs to
  48208. * @param options Define the options used to create the multi render target
  48209. */
  48210. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48211. /** @hidden */
  48212. _rebuild(): void;
  48213. private _createInternalTextures;
  48214. private _createTextures;
  48215. /**
  48216. * Define the number of samples used if MSAA is enabled.
  48217. */
  48218. get samples(): number;
  48219. set samples(value: number);
  48220. /**
  48221. * Resize all the textures in the multi render target.
  48222. * Be carrefull as it will recreate all the data in the new texture.
  48223. * @param size Define the new size
  48224. */
  48225. resize(size: any): void;
  48226. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48227. /**
  48228. * Dispose the render targets and their associated resources
  48229. */
  48230. dispose(): void;
  48231. /**
  48232. * Release all the underlying texture used as draw buffers.
  48233. */
  48234. releaseInternalTextures(): void;
  48235. }
  48236. }
  48237. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48238. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48239. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48240. import { Nullable } from "babylonjs/types";
  48241. module "babylonjs/Engines/thinEngine" {
  48242. interface ThinEngine {
  48243. /**
  48244. * Unbind a list of render target textures from the webGL context
  48245. * This is used only when drawBuffer extension or webGL2 are active
  48246. * @param textures defines the render target textures to unbind
  48247. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48248. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48249. */
  48250. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48251. /**
  48252. * Create a multi render target texture
  48253. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48254. * @param size defines the size of the texture
  48255. * @param options defines the creation options
  48256. * @returns the cube texture as an InternalTexture
  48257. */
  48258. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48259. /**
  48260. * Update the sample count for a given multiple render target texture
  48261. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48262. * @param textures defines the textures to update
  48263. * @param samples defines the sample count to set
  48264. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48265. */
  48266. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48267. }
  48268. }
  48269. }
  48270. declare module "babylonjs/Engines/Extensions/engine.views" {
  48271. import { Camera } from "babylonjs/Cameras/camera";
  48272. import { Nullable } from "babylonjs/types";
  48273. /**
  48274. * Class used to define an additional view for the engine
  48275. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48276. */
  48277. export class EngineView {
  48278. /** Defines the canvas where to render the view */
  48279. target: HTMLCanvasElement;
  48280. /** Defines an optional camera used to render the view (will use active camera else) */
  48281. camera?: Camera;
  48282. }
  48283. module "babylonjs/Engines/engine" {
  48284. interface Engine {
  48285. /**
  48286. * Gets or sets the HTML element to use for attaching events
  48287. */
  48288. inputElement: Nullable<HTMLElement>;
  48289. /**
  48290. * Gets the current engine view
  48291. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48292. */
  48293. activeView: Nullable<EngineView>;
  48294. /** Gets or sets the list of views */
  48295. views: EngineView[];
  48296. /**
  48297. * Register a new child canvas
  48298. * @param canvas defines the canvas to register
  48299. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48300. * @returns the associated view
  48301. */
  48302. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48303. /**
  48304. * Remove a registered child canvas
  48305. * @param canvas defines the canvas to remove
  48306. * @returns the current engine
  48307. */
  48308. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48309. }
  48310. }
  48311. }
  48312. declare module "babylonjs/Engines/Extensions/index" {
  48313. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48314. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48315. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48316. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48317. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48318. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48319. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48320. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48321. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48322. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48323. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48324. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48325. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48326. export * from "babylonjs/Engines/Extensions/engine.views";
  48327. }
  48328. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48329. import { Nullable } from "babylonjs/types";
  48330. /**
  48331. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48332. */
  48333. export interface CubeMapInfo {
  48334. /**
  48335. * The pixel array for the front face.
  48336. * This is stored in format, left to right, up to down format.
  48337. */
  48338. front: Nullable<ArrayBufferView>;
  48339. /**
  48340. * The pixel array for the back face.
  48341. * This is stored in format, left to right, up to down format.
  48342. */
  48343. back: Nullable<ArrayBufferView>;
  48344. /**
  48345. * The pixel array for the left face.
  48346. * This is stored in format, left to right, up to down format.
  48347. */
  48348. left: Nullable<ArrayBufferView>;
  48349. /**
  48350. * The pixel array for the right face.
  48351. * This is stored in format, left to right, up to down format.
  48352. */
  48353. right: Nullable<ArrayBufferView>;
  48354. /**
  48355. * The pixel array for the up face.
  48356. * This is stored in format, left to right, up to down format.
  48357. */
  48358. up: Nullable<ArrayBufferView>;
  48359. /**
  48360. * The pixel array for the down face.
  48361. * This is stored in format, left to right, up to down format.
  48362. */
  48363. down: Nullable<ArrayBufferView>;
  48364. /**
  48365. * The size of the cubemap stored.
  48366. *
  48367. * Each faces will be size * size pixels.
  48368. */
  48369. size: number;
  48370. /**
  48371. * The format of the texture.
  48372. *
  48373. * RGBA, RGB.
  48374. */
  48375. format: number;
  48376. /**
  48377. * The type of the texture data.
  48378. *
  48379. * UNSIGNED_INT, FLOAT.
  48380. */
  48381. type: number;
  48382. /**
  48383. * Specifies whether the texture is in gamma space.
  48384. */
  48385. gammaSpace: boolean;
  48386. }
  48387. /**
  48388. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48389. */
  48390. export class PanoramaToCubeMapTools {
  48391. private static FACE_FRONT;
  48392. private static FACE_BACK;
  48393. private static FACE_RIGHT;
  48394. private static FACE_LEFT;
  48395. private static FACE_DOWN;
  48396. private static FACE_UP;
  48397. /**
  48398. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48399. *
  48400. * @param float32Array The source data.
  48401. * @param inputWidth The width of the input panorama.
  48402. * @param inputHeight The height of the input panorama.
  48403. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48404. * @return The cubemap data
  48405. */
  48406. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48407. private static CreateCubemapTexture;
  48408. private static CalcProjectionSpherical;
  48409. }
  48410. }
  48411. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48412. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48413. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48414. import { Nullable } from "babylonjs/types";
  48415. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48416. /**
  48417. * Helper class dealing with the extraction of spherical polynomial dataArray
  48418. * from a cube map.
  48419. */
  48420. export class CubeMapToSphericalPolynomialTools {
  48421. private static FileFaces;
  48422. /**
  48423. * Converts a texture to the according Spherical Polynomial data.
  48424. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48425. *
  48426. * @param texture The texture to extract the information from.
  48427. * @return The Spherical Polynomial data.
  48428. */
  48429. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48430. /**
  48431. * Converts a cubemap to the according Spherical Polynomial data.
  48432. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48433. *
  48434. * @param cubeInfo The Cube map to extract the information from.
  48435. * @return The Spherical Polynomial data.
  48436. */
  48437. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48438. }
  48439. }
  48440. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48441. import { Nullable } from "babylonjs/types";
  48442. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48443. module "babylonjs/Materials/Textures/baseTexture" {
  48444. interface BaseTexture {
  48445. /**
  48446. * Get the polynomial representation of the texture data.
  48447. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48448. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48449. */
  48450. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48451. }
  48452. }
  48453. }
  48454. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48455. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48456. /** @hidden */
  48457. export var rgbdEncodePixelShader: {
  48458. name: string;
  48459. shader: string;
  48460. };
  48461. }
  48462. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48463. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48464. /** @hidden */
  48465. export var rgbdDecodePixelShader: {
  48466. name: string;
  48467. shader: string;
  48468. };
  48469. }
  48470. declare module "babylonjs/Misc/environmentTextureTools" {
  48471. import { Nullable } from "babylonjs/types";
  48472. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48473. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48474. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48475. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48476. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48477. import "babylonjs/Shaders/rgbdEncode.fragment";
  48478. import "babylonjs/Shaders/rgbdDecode.fragment";
  48479. /**
  48480. * Raw texture data and descriptor sufficient for WebGL texture upload
  48481. */
  48482. export interface EnvironmentTextureInfo {
  48483. /**
  48484. * Version of the environment map
  48485. */
  48486. version: number;
  48487. /**
  48488. * Width of image
  48489. */
  48490. width: number;
  48491. /**
  48492. * Irradiance information stored in the file.
  48493. */
  48494. irradiance: any;
  48495. /**
  48496. * Specular information stored in the file.
  48497. */
  48498. specular: any;
  48499. }
  48500. /**
  48501. * Defines One Image in the file. It requires only the position in the file
  48502. * as well as the length.
  48503. */
  48504. interface BufferImageData {
  48505. /**
  48506. * Length of the image data.
  48507. */
  48508. length: number;
  48509. /**
  48510. * Position of the data from the null terminator delimiting the end of the JSON.
  48511. */
  48512. position: number;
  48513. }
  48514. /**
  48515. * Defines the specular data enclosed in the file.
  48516. * This corresponds to the version 1 of the data.
  48517. */
  48518. export interface EnvironmentTextureSpecularInfoV1 {
  48519. /**
  48520. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48521. */
  48522. specularDataPosition?: number;
  48523. /**
  48524. * This contains all the images data needed to reconstruct the cubemap.
  48525. */
  48526. mipmaps: Array<BufferImageData>;
  48527. /**
  48528. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48529. */
  48530. lodGenerationScale: number;
  48531. }
  48532. /**
  48533. * Sets of helpers addressing the serialization and deserialization of environment texture
  48534. * stored in a BabylonJS env file.
  48535. * Those files are usually stored as .env files.
  48536. */
  48537. export class EnvironmentTextureTools {
  48538. /**
  48539. * Magic number identifying the env file.
  48540. */
  48541. private static _MagicBytes;
  48542. /**
  48543. * Gets the environment info from an env file.
  48544. * @param data The array buffer containing the .env bytes.
  48545. * @returns the environment file info (the json header) if successfully parsed.
  48546. */
  48547. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48548. /**
  48549. * Creates an environment texture from a loaded cube texture.
  48550. * @param texture defines the cube texture to convert in env file
  48551. * @return a promise containing the environment data if succesfull.
  48552. */
  48553. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48554. /**
  48555. * Creates a JSON representation of the spherical data.
  48556. * @param texture defines the texture containing the polynomials
  48557. * @return the JSON representation of the spherical info
  48558. */
  48559. private static _CreateEnvTextureIrradiance;
  48560. /**
  48561. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48562. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48563. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48564. * @return the views described by info providing access to the underlying buffer
  48565. */
  48566. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48567. /**
  48568. * Uploads the texture info contained in the env file to the GPU.
  48569. * @param texture defines the internal texture to upload to
  48570. * @param arrayBuffer defines the buffer cotaining the data to load
  48571. * @param info defines the texture info retrieved through the GetEnvInfo method
  48572. * @returns a promise
  48573. */
  48574. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48575. private static _OnImageReadyAsync;
  48576. /**
  48577. * Uploads the levels of image data to the GPU.
  48578. * @param texture defines the internal texture to upload to
  48579. * @param imageData defines the array buffer views of image data [mipmap][face]
  48580. * @returns a promise
  48581. */
  48582. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48583. /**
  48584. * Uploads spherical polynomials information to the texture.
  48585. * @param texture defines the texture we are trying to upload the information to
  48586. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48587. */
  48588. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48589. /** @hidden */
  48590. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48591. }
  48592. }
  48593. declare module "babylonjs/Maths/math.vertexFormat" {
  48594. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48595. /**
  48596. * Contains position and normal vectors for a vertex
  48597. */
  48598. export class PositionNormalVertex {
  48599. /** the position of the vertex (defaut: 0,0,0) */
  48600. position: Vector3;
  48601. /** the normal of the vertex (defaut: 0,1,0) */
  48602. normal: Vector3;
  48603. /**
  48604. * Creates a PositionNormalVertex
  48605. * @param position the position of the vertex (defaut: 0,0,0)
  48606. * @param normal the normal of the vertex (defaut: 0,1,0)
  48607. */
  48608. constructor(
  48609. /** the position of the vertex (defaut: 0,0,0) */
  48610. position?: Vector3,
  48611. /** the normal of the vertex (defaut: 0,1,0) */
  48612. normal?: Vector3);
  48613. /**
  48614. * Clones the PositionNormalVertex
  48615. * @returns the cloned PositionNormalVertex
  48616. */
  48617. clone(): PositionNormalVertex;
  48618. }
  48619. /**
  48620. * Contains position, normal and uv vectors for a vertex
  48621. */
  48622. export class PositionNormalTextureVertex {
  48623. /** the position of the vertex (defaut: 0,0,0) */
  48624. position: Vector3;
  48625. /** the normal of the vertex (defaut: 0,1,0) */
  48626. normal: Vector3;
  48627. /** the uv of the vertex (default: 0,0) */
  48628. uv: Vector2;
  48629. /**
  48630. * Creates a PositionNormalTextureVertex
  48631. * @param position the position of the vertex (defaut: 0,0,0)
  48632. * @param normal the normal of the vertex (defaut: 0,1,0)
  48633. * @param uv the uv of the vertex (default: 0,0)
  48634. */
  48635. constructor(
  48636. /** the position of the vertex (defaut: 0,0,0) */
  48637. position?: Vector3,
  48638. /** the normal of the vertex (defaut: 0,1,0) */
  48639. normal?: Vector3,
  48640. /** the uv of the vertex (default: 0,0) */
  48641. uv?: Vector2);
  48642. /**
  48643. * Clones the PositionNormalTextureVertex
  48644. * @returns the cloned PositionNormalTextureVertex
  48645. */
  48646. clone(): PositionNormalTextureVertex;
  48647. }
  48648. }
  48649. declare module "babylonjs/Maths/math" {
  48650. export * from "babylonjs/Maths/math.axis";
  48651. export * from "babylonjs/Maths/math.color";
  48652. export * from "babylonjs/Maths/math.constants";
  48653. export * from "babylonjs/Maths/math.frustum";
  48654. export * from "babylonjs/Maths/math.path";
  48655. export * from "babylonjs/Maths/math.plane";
  48656. export * from "babylonjs/Maths/math.size";
  48657. export * from "babylonjs/Maths/math.vector";
  48658. export * from "babylonjs/Maths/math.vertexFormat";
  48659. export * from "babylonjs/Maths/math.viewport";
  48660. }
  48661. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  48662. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48663. /** @hidden */
  48664. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48665. private _genericAttributeLocation;
  48666. private _varyingLocationCount;
  48667. private _varyingLocationMap;
  48668. private _replacements;
  48669. private _textureCount;
  48670. private _uniforms;
  48671. lineProcessor(line: string): string;
  48672. attributeProcessor(attribute: string): string;
  48673. varyingProcessor(varying: string, isFragment: boolean): string;
  48674. uniformProcessor(uniform: string): string;
  48675. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48676. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48677. }
  48678. }
  48679. declare module "babylonjs/Engines/nativeEngine" {
  48680. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  48681. import { Engine } from "babylonjs/Engines/engine";
  48682. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48683. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48684. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48685. import { Effect } from "babylonjs/Materials/effect";
  48686. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48687. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  48688. import { IColor4Like } from "babylonjs/Maths/math.like";
  48689. import { Scene } from "babylonjs/scene";
  48690. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48691. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48692. /**
  48693. * Container for accessors for natively-stored mesh data buffers.
  48694. */
  48695. class NativeDataBuffer extends DataBuffer {
  48696. /**
  48697. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48698. */
  48699. nativeIndexBuffer?: any;
  48700. /**
  48701. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48702. */
  48703. nativeVertexBuffer?: any;
  48704. }
  48705. /** @hidden */
  48706. class NativeTexture extends InternalTexture {
  48707. getInternalTexture(): InternalTexture;
  48708. getViewCount(): number;
  48709. }
  48710. /** @hidden */
  48711. export class NativeEngine extends Engine {
  48712. private readonly _native;
  48713. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48714. private readonly INVALID_HANDLE;
  48715. getHardwareScalingLevel(): number;
  48716. constructor();
  48717. /**
  48718. * Can be used to override the current requestAnimationFrame requester.
  48719. * @hidden
  48720. */
  48721. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48722. /**
  48723. * Override default engine behavior.
  48724. * @param color
  48725. * @param backBuffer
  48726. * @param depth
  48727. * @param stencil
  48728. */
  48729. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48730. /**
  48731. * Gets host document
  48732. * @returns the host document object
  48733. */
  48734. getHostDocument(): Nullable<Document>;
  48735. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48736. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48737. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48738. recordVertexArrayObject(vertexBuffers: {
  48739. [key: string]: VertexBuffer;
  48740. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48741. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48742. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48743. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48744. /**
  48745. * Draw a list of indexed primitives
  48746. * @param fillMode defines the primitive to use
  48747. * @param indexStart defines the starting index
  48748. * @param indexCount defines the number of index to draw
  48749. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48750. */
  48751. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48752. /**
  48753. * Draw a list of unindexed primitives
  48754. * @param fillMode defines the primitive to use
  48755. * @param verticesStart defines the index of first vertex to draw
  48756. * @param verticesCount defines the count of vertices to draw
  48757. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48758. */
  48759. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48760. createPipelineContext(): IPipelineContext;
  48761. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48762. /** @hidden */
  48763. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48764. /** @hidden */
  48765. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48766. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48767. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48768. protected _setProgram(program: WebGLProgram): void;
  48769. _releaseEffect(effect: Effect): void;
  48770. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48771. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48772. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48773. bindSamplers(effect: Effect): void;
  48774. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48775. getRenderWidth(useScreen?: boolean): number;
  48776. getRenderHeight(useScreen?: boolean): number;
  48777. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48778. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48779. /**
  48780. * Set the z offset to apply to current rendering
  48781. * @param value defines the offset to apply
  48782. */
  48783. setZOffset(value: number): void;
  48784. /**
  48785. * Gets the current value of the zOffset
  48786. * @returns the current zOffset state
  48787. */
  48788. getZOffset(): number;
  48789. /**
  48790. * Enable or disable depth buffering
  48791. * @param enable defines the state to set
  48792. */
  48793. setDepthBuffer(enable: boolean): void;
  48794. /**
  48795. * Gets a boolean indicating if depth writing is enabled
  48796. * @returns the current depth writing state
  48797. */
  48798. getDepthWrite(): boolean;
  48799. /**
  48800. * Enable or disable depth writing
  48801. * @param enable defines the state to set
  48802. */
  48803. setDepthWrite(enable: boolean): void;
  48804. /**
  48805. * Enable or disable color writing
  48806. * @param enable defines the state to set
  48807. */
  48808. setColorWrite(enable: boolean): void;
  48809. /**
  48810. * Gets a boolean indicating if color writing is enabled
  48811. * @returns the current color writing state
  48812. */
  48813. getColorWrite(): boolean;
  48814. /**
  48815. * Sets alpha constants used by some alpha blending modes
  48816. * @param r defines the red component
  48817. * @param g defines the green component
  48818. * @param b defines the blue component
  48819. * @param a defines the alpha component
  48820. */
  48821. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48822. /**
  48823. * Sets the current alpha mode
  48824. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48825. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48826. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48827. */
  48828. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48829. /**
  48830. * Gets the current alpha mode
  48831. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48832. * @returns the current alpha mode
  48833. */
  48834. getAlphaMode(): number;
  48835. setInt(uniform: WebGLUniformLocation, int: number): void;
  48836. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48837. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48838. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48839. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48840. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48841. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48842. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48843. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48844. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48845. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48846. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48847. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48848. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48849. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48850. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48851. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48852. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48853. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48854. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48855. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48856. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48857. wipeCaches(bruteForce?: boolean): void;
  48858. _createTexture(): WebGLTexture;
  48859. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48860. /**
  48861. * Usually called from BABYLON.Texture.ts.
  48862. * Passed information to create a WebGLTexture
  48863. * @param urlArg defines a value which contains one of the following:
  48864. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48865. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48866. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48867. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48868. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  48869. * @param scene needed for loading to the correct scene
  48870. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  48871. * @param onLoad optional callback to be called upon successful completion
  48872. * @param onError optional callback to be called upon failure
  48873. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  48874. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48875. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48876. * @param forcedExtension defines the extension to use to pick the right loader
  48877. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48878. */
  48879. 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;
  48880. /**
  48881. * Creates a cube texture
  48882. * @param rootUrl defines the url where the files to load is located
  48883. * @param scene defines the current scene
  48884. * @param files defines the list of files to load (1 per face)
  48885. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48886. * @param onLoad defines an optional callback raised when the texture is loaded
  48887. * @param onError defines an optional callback raised if there is an issue to load the texture
  48888. * @param format defines the format of the data
  48889. * @param forcedExtension defines the extension to use to pick the right loader
  48890. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48891. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48892. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48893. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48894. * @returns the cube texture as an InternalTexture
  48895. */
  48896. 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;
  48897. private _getSamplingFilter;
  48898. private static _GetNativeTextureFormat;
  48899. createRenderTargetTexture(size: number | {
  48900. width: number;
  48901. height: number;
  48902. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48903. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48904. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48905. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48906. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48907. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48908. /**
  48909. * Updates a dynamic vertex buffer.
  48910. * @param vertexBuffer the vertex buffer to update
  48911. * @param data the data used to update the vertex buffer
  48912. * @param byteOffset the byte offset of the data (optional)
  48913. * @param byteLength the byte length of the data (optional)
  48914. */
  48915. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48916. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48917. private _updateAnisotropicLevel;
  48918. private _getAddressMode;
  48919. /** @hidden */
  48920. _bindTexture(channel: number, texture: InternalTexture): void;
  48921. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48922. releaseEffects(): void;
  48923. /** @hidden */
  48924. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48925. /** @hidden */
  48926. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48927. /** @hidden */
  48928. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48929. /** @hidden */
  48930. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48931. }
  48932. }
  48933. declare module "babylonjs/Engines/index" {
  48934. export * from "babylonjs/Engines/constants";
  48935. export * from "babylonjs/Engines/engineCapabilities";
  48936. export * from "babylonjs/Engines/instancingAttributeInfo";
  48937. export * from "babylonjs/Engines/thinEngine";
  48938. export * from "babylonjs/Engines/engine";
  48939. export * from "babylonjs/Engines/engineStore";
  48940. export * from "babylonjs/Engines/nullEngine";
  48941. export * from "babylonjs/Engines/Extensions/index";
  48942. export * from "babylonjs/Engines/IPipelineContext";
  48943. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  48944. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48945. export * from "babylonjs/Engines/nativeEngine";
  48946. }
  48947. declare module "babylonjs/Events/clipboardEvents" {
  48948. /**
  48949. * Gather the list of clipboard event types as constants.
  48950. */
  48951. export class ClipboardEventTypes {
  48952. /**
  48953. * The clipboard event is fired when a copy command is active (pressed).
  48954. */
  48955. static readonly COPY: number;
  48956. /**
  48957. * The clipboard event is fired when a cut command is active (pressed).
  48958. */
  48959. static readonly CUT: number;
  48960. /**
  48961. * The clipboard event is fired when a paste command is active (pressed).
  48962. */
  48963. static readonly PASTE: number;
  48964. }
  48965. /**
  48966. * This class is used to store clipboard related info for the onClipboardObservable event.
  48967. */
  48968. export class ClipboardInfo {
  48969. /**
  48970. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48971. */
  48972. type: number;
  48973. /**
  48974. * Defines the related dom event
  48975. */
  48976. event: ClipboardEvent;
  48977. /**
  48978. *Creates an instance of ClipboardInfo.
  48979. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48980. * @param event Defines the related dom event
  48981. */
  48982. constructor(
  48983. /**
  48984. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48985. */
  48986. type: number,
  48987. /**
  48988. * Defines the related dom event
  48989. */
  48990. event: ClipboardEvent);
  48991. /**
  48992. * Get the clipboard event's type from the keycode.
  48993. * @param keyCode Defines the keyCode for the current keyboard event.
  48994. * @return {number}
  48995. */
  48996. static GetTypeFromCharacter(keyCode: number): number;
  48997. }
  48998. }
  48999. declare module "babylonjs/Events/index" {
  49000. export * from "babylonjs/Events/keyboardEvents";
  49001. export * from "babylonjs/Events/pointerEvents";
  49002. export * from "babylonjs/Events/clipboardEvents";
  49003. }
  49004. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49005. import { Scene } from "babylonjs/scene";
  49006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49007. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49008. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49009. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49010. /**
  49011. * Google Daydream controller
  49012. */
  49013. export class DaydreamController extends WebVRController {
  49014. /**
  49015. * Base Url for the controller model.
  49016. */
  49017. static MODEL_BASE_URL: string;
  49018. /**
  49019. * File name for the controller model.
  49020. */
  49021. static MODEL_FILENAME: string;
  49022. /**
  49023. * Gamepad Id prefix used to identify Daydream Controller.
  49024. */
  49025. static readonly GAMEPAD_ID_PREFIX: string;
  49026. /**
  49027. * Creates a new DaydreamController from a gamepad
  49028. * @param vrGamepad the gamepad that the controller should be created from
  49029. */
  49030. constructor(vrGamepad: any);
  49031. /**
  49032. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49033. * @param scene scene in which to add meshes
  49034. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49035. */
  49036. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49037. /**
  49038. * Called once for each button that changed state since the last frame
  49039. * @param buttonIdx Which button index changed
  49040. * @param state New state of the button
  49041. * @param changes Which properties on the state changed since last frame
  49042. */
  49043. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49044. }
  49045. }
  49046. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49047. import { Scene } from "babylonjs/scene";
  49048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49049. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49050. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49051. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49052. /**
  49053. * Gear VR Controller
  49054. */
  49055. export class GearVRController extends WebVRController {
  49056. /**
  49057. * Base Url for the controller model.
  49058. */
  49059. static MODEL_BASE_URL: string;
  49060. /**
  49061. * File name for the controller model.
  49062. */
  49063. static MODEL_FILENAME: string;
  49064. /**
  49065. * Gamepad Id prefix used to identify this controller.
  49066. */
  49067. static readonly GAMEPAD_ID_PREFIX: string;
  49068. private readonly _buttonIndexToObservableNameMap;
  49069. /**
  49070. * Creates a new GearVRController from a gamepad
  49071. * @param vrGamepad the gamepad that the controller should be created from
  49072. */
  49073. constructor(vrGamepad: any);
  49074. /**
  49075. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49076. * @param scene scene in which to add meshes
  49077. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49078. */
  49079. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49080. /**
  49081. * Called once for each button that changed state since the last frame
  49082. * @param buttonIdx Which button index changed
  49083. * @param state New state of the button
  49084. * @param changes Which properties on the state changed since last frame
  49085. */
  49086. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49087. }
  49088. }
  49089. declare module "babylonjs/Gamepads/Controllers/index" {
  49090. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  49091. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  49092. export * from "babylonjs/Gamepads/Controllers/genericController";
  49093. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  49094. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49095. export * from "babylonjs/Gamepads/Controllers/viveController";
  49096. export * from "babylonjs/Gamepads/Controllers/webVRController";
  49097. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  49098. }
  49099. declare module "babylonjs/Gamepads/index" {
  49100. export * from "babylonjs/Gamepads/Controllers/index";
  49101. export * from "babylonjs/Gamepads/gamepad";
  49102. export * from "babylonjs/Gamepads/gamepadManager";
  49103. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  49104. export * from "babylonjs/Gamepads/xboxGamepad";
  49105. export * from "babylonjs/Gamepads/dualShockGamepad";
  49106. }
  49107. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  49108. import { Scene } from "babylonjs/scene";
  49109. import { Vector4 } from "babylonjs/Maths/math.vector";
  49110. import { Color4 } from "babylonjs/Maths/math.color";
  49111. import { Mesh } from "babylonjs/Meshes/mesh";
  49112. import { Nullable } from "babylonjs/types";
  49113. /**
  49114. * Class containing static functions to help procedurally build meshes
  49115. */
  49116. export class PolyhedronBuilder {
  49117. /**
  49118. * Creates a polyhedron mesh
  49119. * * 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
  49120. * * The parameter `size` (positive float, default 1) sets the polygon size
  49121. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49122. * * 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`
  49123. * * 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
  49124. * * 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)`)
  49125. * * 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
  49126. * * 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
  49127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49130. * @param name defines the name of the mesh
  49131. * @param options defines the options used to create the mesh
  49132. * @param scene defines the hosting scene
  49133. * @returns the polyhedron mesh
  49134. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49135. */
  49136. static CreatePolyhedron(name: string, options: {
  49137. type?: number;
  49138. size?: number;
  49139. sizeX?: number;
  49140. sizeY?: number;
  49141. sizeZ?: number;
  49142. custom?: any;
  49143. faceUV?: Vector4[];
  49144. faceColors?: Color4[];
  49145. flat?: boolean;
  49146. updatable?: boolean;
  49147. sideOrientation?: number;
  49148. frontUVs?: Vector4;
  49149. backUVs?: Vector4;
  49150. }, scene?: Nullable<Scene>): Mesh;
  49151. }
  49152. }
  49153. declare module "babylonjs/Gizmos/scaleGizmo" {
  49154. import { Observable } from "babylonjs/Misc/observable";
  49155. import { Nullable } from "babylonjs/types";
  49156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49157. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49158. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  49159. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49160. /**
  49161. * Gizmo that enables scaling a mesh along 3 axis
  49162. */
  49163. export class ScaleGizmo extends Gizmo {
  49164. /**
  49165. * Internal gizmo used for interactions on the x axis
  49166. */
  49167. xGizmo: AxisScaleGizmo;
  49168. /**
  49169. * Internal gizmo used for interactions on the y axis
  49170. */
  49171. yGizmo: AxisScaleGizmo;
  49172. /**
  49173. * Internal gizmo used for interactions on the z axis
  49174. */
  49175. zGizmo: AxisScaleGizmo;
  49176. /**
  49177. * Internal gizmo used to scale all axis equally
  49178. */
  49179. uniformScaleGizmo: AxisScaleGizmo;
  49180. private _meshAttached;
  49181. private _updateGizmoRotationToMatchAttachedMesh;
  49182. private _snapDistance;
  49183. private _scaleRatio;
  49184. private _uniformScalingMesh;
  49185. private _octahedron;
  49186. private _sensitivity;
  49187. /** Fires an event when any of it's sub gizmos are dragged */
  49188. onDragStartObservable: Observable<unknown>;
  49189. /** Fires an event when any of it's sub gizmos are released from dragging */
  49190. onDragEndObservable: Observable<unknown>;
  49191. get attachedMesh(): Nullable<AbstractMesh>;
  49192. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49193. /**
  49194. * Creates a ScaleGizmo
  49195. * @param gizmoLayer The utility layer the gizmo will be added to
  49196. */
  49197. constructor(gizmoLayer?: UtilityLayerRenderer);
  49198. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49199. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49200. /**
  49201. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49202. */
  49203. set snapDistance(value: number);
  49204. get snapDistance(): number;
  49205. /**
  49206. * Ratio for the scale of the gizmo (Default: 1)
  49207. */
  49208. set scaleRatio(value: number);
  49209. get scaleRatio(): number;
  49210. /**
  49211. * Sensitivity factor for dragging (Default: 1)
  49212. */
  49213. set sensitivity(value: number);
  49214. get sensitivity(): number;
  49215. /**
  49216. * Disposes of the gizmo
  49217. */
  49218. dispose(): void;
  49219. }
  49220. }
  49221. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  49222. import { Observable } from "babylonjs/Misc/observable";
  49223. import { Nullable } from "babylonjs/types";
  49224. import { Vector3 } from "babylonjs/Maths/math.vector";
  49225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49226. import { Mesh } from "babylonjs/Meshes/mesh";
  49227. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49228. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49229. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49230. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49231. import { Color3 } from "babylonjs/Maths/math.color";
  49232. /**
  49233. * Single axis scale gizmo
  49234. */
  49235. export class AxisScaleGizmo extends Gizmo {
  49236. /**
  49237. * Drag behavior responsible for the gizmos dragging interactions
  49238. */
  49239. dragBehavior: PointerDragBehavior;
  49240. private _pointerObserver;
  49241. /**
  49242. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49243. */
  49244. snapDistance: number;
  49245. /**
  49246. * Event that fires each time the gizmo snaps to a new location.
  49247. * * snapDistance is the the change in distance
  49248. */
  49249. onSnapObservable: Observable<{
  49250. snapDistance: number;
  49251. }>;
  49252. /**
  49253. * If the scaling operation should be done on all axis (default: false)
  49254. */
  49255. uniformScaling: boolean;
  49256. /**
  49257. * Custom sensitivity value for the drag strength
  49258. */
  49259. sensitivity: number;
  49260. private _isEnabled;
  49261. private _parent;
  49262. private _arrow;
  49263. private _coloredMaterial;
  49264. private _hoverMaterial;
  49265. /**
  49266. * Creates an AxisScaleGizmo
  49267. * @param gizmoLayer The utility layer the gizmo will be added to
  49268. * @param dragAxis The axis which the gizmo will be able to scale on
  49269. * @param color The color of the gizmo
  49270. */
  49271. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49272. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49273. /**
  49274. * If the gizmo is enabled
  49275. */
  49276. set isEnabled(value: boolean);
  49277. get isEnabled(): boolean;
  49278. /**
  49279. * Disposes of the gizmo
  49280. */
  49281. dispose(): void;
  49282. /**
  49283. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49284. * @param mesh The mesh to replace the default mesh of the gizmo
  49285. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49286. */
  49287. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49288. }
  49289. }
  49290. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  49291. import { Observable } from "babylonjs/Misc/observable";
  49292. import { Nullable } from "babylonjs/types";
  49293. import { Vector3 } from "babylonjs/Maths/math.vector";
  49294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49295. import { Mesh } from "babylonjs/Meshes/mesh";
  49296. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49297. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49298. import { Color3 } from "babylonjs/Maths/math.color";
  49299. import "babylonjs/Meshes/Builders/boxBuilder";
  49300. /**
  49301. * Bounding box gizmo
  49302. */
  49303. export class BoundingBoxGizmo extends Gizmo {
  49304. private _lineBoundingBox;
  49305. private _rotateSpheresParent;
  49306. private _scaleBoxesParent;
  49307. private _boundingDimensions;
  49308. private _renderObserver;
  49309. private _pointerObserver;
  49310. private _scaleDragSpeed;
  49311. private _tmpQuaternion;
  49312. private _tmpVector;
  49313. private _tmpRotationMatrix;
  49314. /**
  49315. * 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)
  49316. */
  49317. ignoreChildren: boolean;
  49318. /**
  49319. * 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)
  49320. */
  49321. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49322. /**
  49323. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49324. */
  49325. rotationSphereSize: number;
  49326. /**
  49327. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49328. */
  49329. scaleBoxSize: number;
  49330. /**
  49331. * 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)
  49332. */
  49333. fixedDragMeshScreenSize: boolean;
  49334. /**
  49335. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49336. */
  49337. fixedDragMeshScreenSizeDistanceFactor: number;
  49338. /**
  49339. * Fired when a rotation sphere or scale box is dragged
  49340. */
  49341. onDragStartObservable: Observable<{}>;
  49342. /**
  49343. * Fired when a scale box is dragged
  49344. */
  49345. onScaleBoxDragObservable: Observable<{}>;
  49346. /**
  49347. * Fired when a scale box drag is ended
  49348. */
  49349. onScaleBoxDragEndObservable: Observable<{}>;
  49350. /**
  49351. * Fired when a rotation sphere is dragged
  49352. */
  49353. onRotationSphereDragObservable: Observable<{}>;
  49354. /**
  49355. * Fired when a rotation sphere drag is ended
  49356. */
  49357. onRotationSphereDragEndObservable: Observable<{}>;
  49358. /**
  49359. * 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)
  49360. */
  49361. scalePivot: Nullable<Vector3>;
  49362. /**
  49363. * Mesh used as a pivot to rotate the attached mesh
  49364. */
  49365. private _anchorMesh;
  49366. private _existingMeshScale;
  49367. private _dragMesh;
  49368. private pointerDragBehavior;
  49369. private coloredMaterial;
  49370. private hoverColoredMaterial;
  49371. /**
  49372. * Sets the color of the bounding box gizmo
  49373. * @param color the color to set
  49374. */
  49375. setColor(color: Color3): void;
  49376. /**
  49377. * Creates an BoundingBoxGizmo
  49378. * @param gizmoLayer The utility layer the gizmo will be added to
  49379. * @param color The color of the gizmo
  49380. */
  49381. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49382. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49383. private _selectNode;
  49384. /**
  49385. * Updates the bounding box information for the Gizmo
  49386. */
  49387. updateBoundingBox(): void;
  49388. private _updateRotationSpheres;
  49389. private _updateScaleBoxes;
  49390. /**
  49391. * Enables rotation on the specified axis and disables rotation on the others
  49392. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49393. */
  49394. setEnabledRotationAxis(axis: string): void;
  49395. /**
  49396. * Enables/disables scaling
  49397. * @param enable if scaling should be enabled
  49398. */
  49399. setEnabledScaling(enable: boolean): void;
  49400. private _updateDummy;
  49401. /**
  49402. * Enables a pointer drag behavior on the bounding box of the gizmo
  49403. */
  49404. enableDragBehavior(): void;
  49405. /**
  49406. * Disposes of the gizmo
  49407. */
  49408. dispose(): void;
  49409. /**
  49410. * 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)
  49411. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49412. * @returns the bounding box mesh with the passed in mesh as a child
  49413. */
  49414. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49415. /**
  49416. * CustomMeshes are not supported by this gizmo
  49417. * @param mesh The mesh to replace the default mesh of the gizmo
  49418. */
  49419. setCustomMesh(mesh: Mesh): void;
  49420. }
  49421. }
  49422. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  49423. import { Observable } from "babylonjs/Misc/observable";
  49424. import { Nullable } from "babylonjs/types";
  49425. import { Vector3 } from "babylonjs/Maths/math.vector";
  49426. import { Color3 } from "babylonjs/Maths/math.color";
  49427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49428. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49429. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49430. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49431. import "babylonjs/Meshes/Builders/linesBuilder";
  49432. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49433. /**
  49434. * Single plane rotation gizmo
  49435. */
  49436. export class PlaneRotationGizmo extends Gizmo {
  49437. /**
  49438. * Drag behavior responsible for the gizmos dragging interactions
  49439. */
  49440. dragBehavior: PointerDragBehavior;
  49441. private _pointerObserver;
  49442. /**
  49443. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49444. */
  49445. snapDistance: number;
  49446. /**
  49447. * Event that fires each time the gizmo snaps to a new location.
  49448. * * snapDistance is the the change in distance
  49449. */
  49450. onSnapObservable: Observable<{
  49451. snapDistance: number;
  49452. }>;
  49453. private _isEnabled;
  49454. private _parent;
  49455. /**
  49456. * Creates a PlaneRotationGizmo
  49457. * @param gizmoLayer The utility layer the gizmo will be added to
  49458. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49459. * @param color The color of the gizmo
  49460. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49461. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49462. */
  49463. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49464. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49465. /**
  49466. * If the gizmo is enabled
  49467. */
  49468. set isEnabled(value: boolean);
  49469. get isEnabled(): boolean;
  49470. /**
  49471. * Disposes of the gizmo
  49472. */
  49473. dispose(): void;
  49474. }
  49475. }
  49476. declare module "babylonjs/Gizmos/rotationGizmo" {
  49477. import { Observable } from "babylonjs/Misc/observable";
  49478. import { Nullable } from "babylonjs/types";
  49479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49480. import { Mesh } from "babylonjs/Meshes/mesh";
  49481. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49482. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  49483. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49484. /**
  49485. * Gizmo that enables rotating a mesh along 3 axis
  49486. */
  49487. export class RotationGizmo extends Gizmo {
  49488. /**
  49489. * Internal gizmo used for interactions on the x axis
  49490. */
  49491. xGizmo: PlaneRotationGizmo;
  49492. /**
  49493. * Internal gizmo used for interactions on the y axis
  49494. */
  49495. yGizmo: PlaneRotationGizmo;
  49496. /**
  49497. * Internal gizmo used for interactions on the z axis
  49498. */
  49499. zGizmo: PlaneRotationGizmo;
  49500. /** Fires an event when any of it's sub gizmos are dragged */
  49501. onDragStartObservable: Observable<unknown>;
  49502. /** Fires an event when any of it's sub gizmos are released from dragging */
  49503. onDragEndObservable: Observable<unknown>;
  49504. private _meshAttached;
  49505. get attachedMesh(): Nullable<AbstractMesh>;
  49506. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49507. /**
  49508. * Creates a RotationGizmo
  49509. * @param gizmoLayer The utility layer the gizmo will be added to
  49510. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49511. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49512. */
  49513. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49514. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49515. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49516. /**
  49517. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49518. */
  49519. set snapDistance(value: number);
  49520. get snapDistance(): number;
  49521. /**
  49522. * Ratio for the scale of the gizmo (Default: 1)
  49523. */
  49524. set scaleRatio(value: number);
  49525. get scaleRatio(): number;
  49526. /**
  49527. * Disposes of the gizmo
  49528. */
  49529. dispose(): void;
  49530. /**
  49531. * CustomMeshes are not supported by this gizmo
  49532. * @param mesh The mesh to replace the default mesh of the gizmo
  49533. */
  49534. setCustomMesh(mesh: Mesh): void;
  49535. }
  49536. }
  49537. declare module "babylonjs/Gizmos/gizmoManager" {
  49538. import { Observable } from "babylonjs/Misc/observable";
  49539. import { Nullable } from "babylonjs/types";
  49540. import { Scene, IDisposable } from "babylonjs/scene";
  49541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49542. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49543. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49544. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49545. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  49546. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49547. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  49548. /**
  49549. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49550. */
  49551. export class GizmoManager implements IDisposable {
  49552. private scene;
  49553. /**
  49554. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49555. */
  49556. gizmos: {
  49557. positionGizmo: Nullable<PositionGizmo>;
  49558. rotationGizmo: Nullable<RotationGizmo>;
  49559. scaleGizmo: Nullable<ScaleGizmo>;
  49560. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49561. };
  49562. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49563. clearGizmoOnEmptyPointerEvent: boolean;
  49564. /** Fires an event when the manager is attached to a mesh */
  49565. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49566. private _gizmosEnabled;
  49567. private _pointerObserver;
  49568. private _attachedMesh;
  49569. private _boundingBoxColor;
  49570. private _defaultUtilityLayer;
  49571. private _defaultKeepDepthUtilityLayer;
  49572. /**
  49573. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49574. */
  49575. boundingBoxDragBehavior: SixDofDragBehavior;
  49576. /**
  49577. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49578. */
  49579. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49580. /**
  49581. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49582. */
  49583. usePointerToAttachGizmos: boolean;
  49584. /**
  49585. * Utility layer that the bounding box gizmo belongs to
  49586. */
  49587. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49588. /**
  49589. * Utility layer that all gizmos besides bounding box belong to
  49590. */
  49591. get utilityLayer(): UtilityLayerRenderer;
  49592. /**
  49593. * Instatiates a gizmo manager
  49594. * @param scene the scene to overlay the gizmos on top of
  49595. */
  49596. constructor(scene: Scene);
  49597. /**
  49598. * Attaches a set of gizmos to the specified mesh
  49599. * @param mesh The mesh the gizmo's should be attached to
  49600. */
  49601. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49602. /**
  49603. * If the position gizmo is enabled
  49604. */
  49605. set positionGizmoEnabled(value: boolean);
  49606. get positionGizmoEnabled(): boolean;
  49607. /**
  49608. * If the rotation gizmo is enabled
  49609. */
  49610. set rotationGizmoEnabled(value: boolean);
  49611. get rotationGizmoEnabled(): boolean;
  49612. /**
  49613. * If the scale gizmo is enabled
  49614. */
  49615. set scaleGizmoEnabled(value: boolean);
  49616. get scaleGizmoEnabled(): boolean;
  49617. /**
  49618. * If the boundingBox gizmo is enabled
  49619. */
  49620. set boundingBoxGizmoEnabled(value: boolean);
  49621. get boundingBoxGizmoEnabled(): boolean;
  49622. /**
  49623. * Disposes of the gizmo manager
  49624. */
  49625. dispose(): void;
  49626. }
  49627. }
  49628. declare module "babylonjs/Lights/directionalLight" {
  49629. import { Camera } from "babylonjs/Cameras/camera";
  49630. import { Scene } from "babylonjs/scene";
  49631. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49633. import { Light } from "babylonjs/Lights/light";
  49634. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49635. import { Effect } from "babylonjs/Materials/effect";
  49636. /**
  49637. * A directional light is defined by a direction (what a surprise!).
  49638. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49639. * 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.
  49640. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49641. */
  49642. export class DirectionalLight extends ShadowLight {
  49643. private _shadowFrustumSize;
  49644. /**
  49645. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49646. */
  49647. get shadowFrustumSize(): number;
  49648. /**
  49649. * Specifies a fix frustum size for the shadow generation.
  49650. */
  49651. set shadowFrustumSize(value: number);
  49652. private _shadowOrthoScale;
  49653. /**
  49654. * Gets the shadow projection scale against the optimal computed one.
  49655. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49656. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49657. */
  49658. get shadowOrthoScale(): number;
  49659. /**
  49660. * Sets the shadow projection scale against the optimal computed one.
  49661. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49662. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49663. */
  49664. set shadowOrthoScale(value: number);
  49665. /**
  49666. * Automatically compute the projection matrix to best fit (including all the casters)
  49667. * on each frame.
  49668. */
  49669. autoUpdateExtends: boolean;
  49670. private _orthoLeft;
  49671. private _orthoRight;
  49672. private _orthoTop;
  49673. private _orthoBottom;
  49674. /**
  49675. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49676. * The directional light is emitted from everywhere in the given direction.
  49677. * It can cast shadows.
  49678. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49679. * @param name The friendly name of the light
  49680. * @param direction The direction of the light
  49681. * @param scene The scene the light belongs to
  49682. */
  49683. constructor(name: string, direction: Vector3, scene: Scene);
  49684. /**
  49685. * Returns the string "DirectionalLight".
  49686. * @return The class name
  49687. */
  49688. getClassName(): string;
  49689. /**
  49690. * Returns the integer 1.
  49691. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49692. */
  49693. getTypeID(): number;
  49694. /**
  49695. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49696. * Returns the DirectionalLight Shadow projection matrix.
  49697. */
  49698. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49699. /**
  49700. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49701. * Returns the DirectionalLight Shadow projection matrix.
  49702. */
  49703. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49704. /**
  49705. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49706. * Returns the DirectionalLight Shadow projection matrix.
  49707. */
  49708. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49709. protected _buildUniformLayout(): void;
  49710. /**
  49711. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49712. * @param effect The effect to update
  49713. * @param lightIndex The index of the light in the effect to update
  49714. * @returns The directional light
  49715. */
  49716. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49717. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49718. /**
  49719. * Gets the minZ used for shadow according to both the scene and the light.
  49720. *
  49721. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49722. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49723. * @param activeCamera The camera we are returning the min for
  49724. * @returns the depth min z
  49725. */
  49726. getDepthMinZ(activeCamera: Camera): number;
  49727. /**
  49728. * Gets the maxZ used for shadow according to both the scene and the light.
  49729. *
  49730. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49731. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49732. * @param activeCamera The camera we are returning the max for
  49733. * @returns the depth max z
  49734. */
  49735. getDepthMaxZ(activeCamera: Camera): number;
  49736. /**
  49737. * Prepares the list of defines specific to the light type.
  49738. * @param defines the list of defines
  49739. * @param lightIndex defines the index of the light for the effect
  49740. */
  49741. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49742. }
  49743. }
  49744. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  49745. import { Mesh } from "babylonjs/Meshes/mesh";
  49746. /**
  49747. * Class containing static functions to help procedurally build meshes
  49748. */
  49749. export class HemisphereBuilder {
  49750. /**
  49751. * Creates a hemisphere mesh
  49752. * @param name defines the name of the mesh
  49753. * @param options defines the options used to create the mesh
  49754. * @param scene defines the hosting scene
  49755. * @returns the hemisphere mesh
  49756. */
  49757. static CreateHemisphere(name: string, options: {
  49758. segments?: number;
  49759. diameter?: number;
  49760. sideOrientation?: number;
  49761. }, scene: any): Mesh;
  49762. }
  49763. }
  49764. declare module "babylonjs/Lights/spotLight" {
  49765. import { Nullable } from "babylonjs/types";
  49766. import { Scene } from "babylonjs/scene";
  49767. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49769. import { Effect } from "babylonjs/Materials/effect";
  49770. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49771. import { Light } from "babylonjs/Lights/light";
  49772. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49773. /**
  49774. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49775. * These values define a cone of light starting from the position, emitting toward the direction.
  49776. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49777. * and the exponent defines the speed of the decay of the light with distance (reach).
  49778. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49779. */
  49780. export class SpotLight extends ShadowLight {
  49781. private _angle;
  49782. private _innerAngle;
  49783. private _cosHalfAngle;
  49784. private _lightAngleScale;
  49785. private _lightAngleOffset;
  49786. /**
  49787. * Gets the cone angle of the spot light in Radians.
  49788. */
  49789. get angle(): number;
  49790. /**
  49791. * Sets the cone angle of the spot light in Radians.
  49792. */
  49793. set angle(value: number);
  49794. /**
  49795. * Only used in gltf falloff mode, this defines the angle where
  49796. * the directional falloff will start before cutting at angle which could be seen
  49797. * as outer angle.
  49798. */
  49799. get innerAngle(): number;
  49800. /**
  49801. * Only used in gltf falloff mode, this defines the angle where
  49802. * the directional falloff will start before cutting at angle which could be seen
  49803. * as outer angle.
  49804. */
  49805. set innerAngle(value: number);
  49806. private _shadowAngleScale;
  49807. /**
  49808. * Allows scaling the angle of the light for shadow generation only.
  49809. */
  49810. get shadowAngleScale(): number;
  49811. /**
  49812. * Allows scaling the angle of the light for shadow generation only.
  49813. */
  49814. set shadowAngleScale(value: number);
  49815. /**
  49816. * The light decay speed with the distance from the emission spot.
  49817. */
  49818. exponent: number;
  49819. private _projectionTextureMatrix;
  49820. /**
  49821. * Allows reading the projecton texture
  49822. */
  49823. get projectionTextureMatrix(): Matrix;
  49824. protected _projectionTextureLightNear: number;
  49825. /**
  49826. * Gets the near clip of the Spotlight for texture projection.
  49827. */
  49828. get projectionTextureLightNear(): number;
  49829. /**
  49830. * Sets the near clip of the Spotlight for texture projection.
  49831. */
  49832. set projectionTextureLightNear(value: number);
  49833. protected _projectionTextureLightFar: number;
  49834. /**
  49835. * Gets the far clip of the Spotlight for texture projection.
  49836. */
  49837. get projectionTextureLightFar(): number;
  49838. /**
  49839. * Sets the far clip of the Spotlight for texture projection.
  49840. */
  49841. set projectionTextureLightFar(value: number);
  49842. protected _projectionTextureUpDirection: Vector3;
  49843. /**
  49844. * Gets the Up vector of the Spotlight for texture projection.
  49845. */
  49846. get projectionTextureUpDirection(): Vector3;
  49847. /**
  49848. * Sets the Up vector of the Spotlight for texture projection.
  49849. */
  49850. set projectionTextureUpDirection(value: Vector3);
  49851. private _projectionTexture;
  49852. /**
  49853. * Gets the projection texture of the light.
  49854. */
  49855. get projectionTexture(): Nullable<BaseTexture>;
  49856. /**
  49857. * Sets the projection texture of the light.
  49858. */
  49859. set projectionTexture(value: Nullable<BaseTexture>);
  49860. private _projectionTextureViewLightDirty;
  49861. private _projectionTextureProjectionLightDirty;
  49862. private _projectionTextureDirty;
  49863. private _projectionTextureViewTargetVector;
  49864. private _projectionTextureViewLightMatrix;
  49865. private _projectionTextureProjectionLightMatrix;
  49866. private _projectionTextureScalingMatrix;
  49867. /**
  49868. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49869. * It can cast shadows.
  49870. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49871. * @param name The light friendly name
  49872. * @param position The position of the spot light in the scene
  49873. * @param direction The direction of the light in the scene
  49874. * @param angle The cone angle of the light in Radians
  49875. * @param exponent The light decay speed with the distance from the emission spot
  49876. * @param scene The scene the lights belongs to
  49877. */
  49878. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49879. /**
  49880. * Returns the string "SpotLight".
  49881. * @returns the class name
  49882. */
  49883. getClassName(): string;
  49884. /**
  49885. * Returns the integer 2.
  49886. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49887. */
  49888. getTypeID(): number;
  49889. /**
  49890. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49891. */
  49892. protected _setDirection(value: Vector3): void;
  49893. /**
  49894. * Overrides the position setter to recompute the projection texture view light Matrix.
  49895. */
  49896. protected _setPosition(value: Vector3): void;
  49897. /**
  49898. * 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.
  49899. * Returns the SpotLight.
  49900. */
  49901. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49902. protected _computeProjectionTextureViewLightMatrix(): void;
  49903. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49904. /**
  49905. * Main function for light texture projection matrix computing.
  49906. */
  49907. protected _computeProjectionTextureMatrix(): void;
  49908. protected _buildUniformLayout(): void;
  49909. private _computeAngleValues;
  49910. /**
  49911. * Sets the passed Effect "effect" with the Light textures.
  49912. * @param effect The effect to update
  49913. * @param lightIndex The index of the light in the effect to update
  49914. * @returns The light
  49915. */
  49916. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49917. /**
  49918. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49919. * @param effect The effect to update
  49920. * @param lightIndex The index of the light in the effect to update
  49921. * @returns The spot light
  49922. */
  49923. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49924. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49925. /**
  49926. * Disposes the light and the associated resources.
  49927. */
  49928. dispose(): void;
  49929. /**
  49930. * Prepares the list of defines specific to the light type.
  49931. * @param defines the list of defines
  49932. * @param lightIndex defines the index of the light for the effect
  49933. */
  49934. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49935. }
  49936. }
  49937. declare module "babylonjs/Gizmos/lightGizmo" {
  49938. import { Nullable } from "babylonjs/types";
  49939. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49940. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49941. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  49942. import { Light } from "babylonjs/Lights/light";
  49943. /**
  49944. * Gizmo that enables viewing a light
  49945. */
  49946. export class LightGizmo extends Gizmo {
  49947. private _lightMesh;
  49948. private _material;
  49949. private _cachedPosition;
  49950. private _cachedForward;
  49951. private _attachedMeshParent;
  49952. /**
  49953. * Creates a LightGizmo
  49954. * @param gizmoLayer The utility layer the gizmo will be added to
  49955. */
  49956. constructor(gizmoLayer?: UtilityLayerRenderer);
  49957. private _light;
  49958. /**
  49959. * The light that the gizmo is attached to
  49960. */
  49961. set light(light: Nullable<Light>);
  49962. get light(): Nullable<Light>;
  49963. /**
  49964. * Gets the material used to render the light gizmo
  49965. */
  49966. get material(): StandardMaterial;
  49967. /**
  49968. * @hidden
  49969. * Updates the gizmo to match the attached mesh's position/rotation
  49970. */
  49971. protected _update(): void;
  49972. private static _Scale;
  49973. /**
  49974. * Creates the lines for a light mesh
  49975. */
  49976. private static _CreateLightLines;
  49977. /**
  49978. * Disposes of the light gizmo
  49979. */
  49980. dispose(): void;
  49981. private static _CreateHemisphericLightMesh;
  49982. private static _CreatePointLightMesh;
  49983. private static _CreateSpotLightMesh;
  49984. private static _CreateDirectionalLightMesh;
  49985. }
  49986. }
  49987. declare module "babylonjs/Gizmos/index" {
  49988. export * from "babylonjs/Gizmos/axisDragGizmo";
  49989. export * from "babylonjs/Gizmos/axisScaleGizmo";
  49990. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  49991. export * from "babylonjs/Gizmos/gizmo";
  49992. export * from "babylonjs/Gizmos/gizmoManager";
  49993. export * from "babylonjs/Gizmos/planeRotationGizmo";
  49994. export * from "babylonjs/Gizmos/positionGizmo";
  49995. export * from "babylonjs/Gizmos/rotationGizmo";
  49996. export * from "babylonjs/Gizmos/scaleGizmo";
  49997. export * from "babylonjs/Gizmos/lightGizmo";
  49998. export * from "babylonjs/Gizmos/planeDragGizmo";
  49999. }
  50000. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  50001. /** @hidden */
  50002. export var backgroundFragmentDeclaration: {
  50003. name: string;
  50004. shader: string;
  50005. };
  50006. }
  50007. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  50008. /** @hidden */
  50009. export var backgroundUboDeclaration: {
  50010. name: string;
  50011. shader: string;
  50012. };
  50013. }
  50014. declare module "babylonjs/Shaders/background.fragment" {
  50015. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50016. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50017. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50018. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50019. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50020. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50021. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50022. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50023. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50024. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50025. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50026. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50027. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50028. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50029. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50030. /** @hidden */
  50031. export var backgroundPixelShader: {
  50032. name: string;
  50033. shader: string;
  50034. };
  50035. }
  50036. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50037. /** @hidden */
  50038. export var backgroundVertexDeclaration: {
  50039. name: string;
  50040. shader: string;
  50041. };
  50042. }
  50043. declare module "babylonjs/Shaders/background.vertex" {
  50044. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50045. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50046. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50047. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50048. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50049. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50050. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50051. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50052. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50053. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50054. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50055. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50056. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50057. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50058. /** @hidden */
  50059. export var backgroundVertexShader: {
  50060. name: string;
  50061. shader: string;
  50062. };
  50063. }
  50064. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50065. import { Nullable, int, float } from "babylonjs/types";
  50066. import { Scene } from "babylonjs/scene";
  50067. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50068. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50070. import { Mesh } from "babylonjs/Meshes/mesh";
  50071. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50072. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50073. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50075. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  50076. import { Color3 } from "babylonjs/Maths/math.color";
  50077. import "babylonjs/Shaders/background.fragment";
  50078. import "babylonjs/Shaders/background.vertex";
  50079. /**
  50080. * Background material used to create an efficient environement around your scene.
  50081. */
  50082. export class BackgroundMaterial extends PushMaterial {
  50083. /**
  50084. * Standard reflectance value at parallel view angle.
  50085. */
  50086. static StandardReflectance0: number;
  50087. /**
  50088. * Standard reflectance value at grazing angle.
  50089. */
  50090. static StandardReflectance90: number;
  50091. protected _primaryColor: Color3;
  50092. /**
  50093. * Key light Color (multiply against the environement texture)
  50094. */
  50095. primaryColor: Color3;
  50096. protected __perceptualColor: Nullable<Color3>;
  50097. /**
  50098. * Experimental Internal Use Only.
  50099. *
  50100. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50101. * This acts as a helper to set the primary color to a more "human friendly" value.
  50102. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50103. * output color as close as possible from the chosen value.
  50104. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50105. * part of lighting setup.)
  50106. */
  50107. get _perceptualColor(): Nullable<Color3>;
  50108. set _perceptualColor(value: Nullable<Color3>);
  50109. protected _primaryColorShadowLevel: float;
  50110. /**
  50111. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50112. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50113. */
  50114. get primaryColorShadowLevel(): float;
  50115. set primaryColorShadowLevel(value: float);
  50116. protected _primaryColorHighlightLevel: float;
  50117. /**
  50118. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50119. * The primary color is used at the level chosen to define what the white area would look.
  50120. */
  50121. get primaryColorHighlightLevel(): float;
  50122. set primaryColorHighlightLevel(value: float);
  50123. protected _reflectionTexture: Nullable<BaseTexture>;
  50124. /**
  50125. * Reflection Texture used in the material.
  50126. * Should be author in a specific way for the best result (refer to the documentation).
  50127. */
  50128. reflectionTexture: Nullable<BaseTexture>;
  50129. protected _reflectionBlur: float;
  50130. /**
  50131. * Reflection Texture level of blur.
  50132. *
  50133. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50134. * texture twice.
  50135. */
  50136. reflectionBlur: float;
  50137. protected _diffuseTexture: Nullable<BaseTexture>;
  50138. /**
  50139. * Diffuse Texture used in the material.
  50140. * Should be author in a specific way for the best result (refer to the documentation).
  50141. */
  50142. diffuseTexture: Nullable<BaseTexture>;
  50143. protected _shadowLights: Nullable<IShadowLight[]>;
  50144. /**
  50145. * Specify the list of lights casting shadow on the material.
  50146. * All scene shadow lights will be included if null.
  50147. */
  50148. shadowLights: Nullable<IShadowLight[]>;
  50149. protected _shadowLevel: float;
  50150. /**
  50151. * Helps adjusting the shadow to a softer level if required.
  50152. * 0 means black shadows and 1 means no shadows.
  50153. */
  50154. shadowLevel: float;
  50155. protected _sceneCenter: Vector3;
  50156. /**
  50157. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50158. * It is usually zero but might be interesting to modify according to your setup.
  50159. */
  50160. sceneCenter: Vector3;
  50161. protected _opacityFresnel: boolean;
  50162. /**
  50163. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50164. * This helps ensuring a nice transition when the camera goes under the ground.
  50165. */
  50166. opacityFresnel: boolean;
  50167. protected _reflectionFresnel: boolean;
  50168. /**
  50169. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50170. * This helps adding a mirror texture on the ground.
  50171. */
  50172. reflectionFresnel: boolean;
  50173. protected _reflectionFalloffDistance: number;
  50174. /**
  50175. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50176. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50177. */
  50178. reflectionFalloffDistance: number;
  50179. protected _reflectionAmount: number;
  50180. /**
  50181. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50182. */
  50183. reflectionAmount: number;
  50184. protected _reflectionReflectance0: number;
  50185. /**
  50186. * This specifies the weight of the reflection at grazing angle.
  50187. */
  50188. reflectionReflectance0: number;
  50189. protected _reflectionReflectance90: number;
  50190. /**
  50191. * This specifies the weight of the reflection at a perpendicular point of view.
  50192. */
  50193. reflectionReflectance90: number;
  50194. /**
  50195. * Sets the reflection reflectance fresnel values according to the default standard
  50196. * empirically know to work well :-)
  50197. */
  50198. set reflectionStandardFresnelWeight(value: number);
  50199. protected _useRGBColor: boolean;
  50200. /**
  50201. * Helps to directly use the maps channels instead of their level.
  50202. */
  50203. useRGBColor: boolean;
  50204. protected _enableNoise: boolean;
  50205. /**
  50206. * This helps reducing the banding effect that could occur on the background.
  50207. */
  50208. enableNoise: boolean;
  50209. /**
  50210. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50211. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50212. * Recommended to be keep at 1.0 except for special cases.
  50213. */
  50214. get fovMultiplier(): number;
  50215. set fovMultiplier(value: number);
  50216. private _fovMultiplier;
  50217. /**
  50218. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50219. */
  50220. useEquirectangularFOV: boolean;
  50221. private _maxSimultaneousLights;
  50222. /**
  50223. * Number of Simultaneous lights allowed on the material.
  50224. */
  50225. maxSimultaneousLights: int;
  50226. /**
  50227. * Default configuration related to image processing available in the Background Material.
  50228. */
  50229. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50230. /**
  50231. * Keep track of the image processing observer to allow dispose and replace.
  50232. */
  50233. private _imageProcessingObserver;
  50234. /**
  50235. * Attaches a new image processing configuration to the PBR Material.
  50236. * @param configuration (if null the scene configuration will be use)
  50237. */
  50238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50239. /**
  50240. * Gets the image processing configuration used either in this material.
  50241. */
  50242. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50243. /**
  50244. * Sets the Default image processing configuration used either in the this material.
  50245. *
  50246. * If sets to null, the scene one is in use.
  50247. */
  50248. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50249. /**
  50250. * Gets wether the color curves effect is enabled.
  50251. */
  50252. get cameraColorCurvesEnabled(): boolean;
  50253. /**
  50254. * Sets wether the color curves effect is enabled.
  50255. */
  50256. set cameraColorCurvesEnabled(value: boolean);
  50257. /**
  50258. * Gets wether the color grading effect is enabled.
  50259. */
  50260. get cameraColorGradingEnabled(): boolean;
  50261. /**
  50262. * Gets wether the color grading effect is enabled.
  50263. */
  50264. set cameraColorGradingEnabled(value: boolean);
  50265. /**
  50266. * Gets wether tonemapping is enabled or not.
  50267. */
  50268. get cameraToneMappingEnabled(): boolean;
  50269. /**
  50270. * Sets wether tonemapping is enabled or not
  50271. */
  50272. set cameraToneMappingEnabled(value: boolean);
  50273. /**
  50274. * The camera exposure used on this material.
  50275. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50276. * This corresponds to a photographic exposure.
  50277. */
  50278. get cameraExposure(): float;
  50279. /**
  50280. * The camera exposure used on this material.
  50281. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50282. * This corresponds to a photographic exposure.
  50283. */
  50284. set cameraExposure(value: float);
  50285. /**
  50286. * Gets The camera contrast used on this material.
  50287. */
  50288. get cameraContrast(): float;
  50289. /**
  50290. * Sets The camera contrast used on this material.
  50291. */
  50292. set cameraContrast(value: float);
  50293. /**
  50294. * Gets the Color Grading 2D Lookup Texture.
  50295. */
  50296. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50297. /**
  50298. * Sets the Color Grading 2D Lookup Texture.
  50299. */
  50300. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50301. /**
  50302. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50303. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50304. * 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;
  50305. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50306. */
  50307. get cameraColorCurves(): Nullable<ColorCurves>;
  50308. /**
  50309. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50310. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50311. * 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;
  50312. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50313. */
  50314. set cameraColorCurves(value: Nullable<ColorCurves>);
  50315. /**
  50316. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50317. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50318. */
  50319. switchToBGR: boolean;
  50320. private _renderTargets;
  50321. private _reflectionControls;
  50322. private _white;
  50323. private _primaryShadowColor;
  50324. private _primaryHighlightColor;
  50325. /**
  50326. * Instantiates a Background Material in the given scene
  50327. * @param name The friendly name of the material
  50328. * @param scene The scene to add the material to
  50329. */
  50330. constructor(name: string, scene: Scene);
  50331. /**
  50332. * Gets a boolean indicating that current material needs to register RTT
  50333. */
  50334. get hasRenderTargetTextures(): boolean;
  50335. /**
  50336. * The entire material has been created in order to prevent overdraw.
  50337. * @returns false
  50338. */
  50339. needAlphaTesting(): boolean;
  50340. /**
  50341. * The entire material has been created in order to prevent overdraw.
  50342. * @returns true if blending is enable
  50343. */
  50344. needAlphaBlending(): boolean;
  50345. /**
  50346. * Checks wether the material is ready to be rendered for a given mesh.
  50347. * @param mesh The mesh to render
  50348. * @param subMesh The submesh to check against
  50349. * @param useInstances Specify wether or not the material is used with instances
  50350. * @returns true if all the dependencies are ready (Textures, Effects...)
  50351. */
  50352. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50353. /**
  50354. * Compute the primary color according to the chosen perceptual color.
  50355. */
  50356. private _computePrimaryColorFromPerceptualColor;
  50357. /**
  50358. * Compute the highlights and shadow colors according to their chosen levels.
  50359. */
  50360. private _computePrimaryColors;
  50361. /**
  50362. * Build the uniform buffer used in the material.
  50363. */
  50364. buildUniformLayout(): void;
  50365. /**
  50366. * Unbind the material.
  50367. */
  50368. unbind(): void;
  50369. /**
  50370. * Bind only the world matrix to the material.
  50371. * @param world The world matrix to bind.
  50372. */
  50373. bindOnlyWorldMatrix(world: Matrix): void;
  50374. /**
  50375. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50376. * @param world The world matrix to bind.
  50377. * @param subMesh The submesh to bind for.
  50378. */
  50379. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50380. /**
  50381. * Checks to see if a texture is used in the material.
  50382. * @param texture - Base texture to use.
  50383. * @returns - Boolean specifying if a texture is used in the material.
  50384. */
  50385. hasTexture(texture: BaseTexture): boolean;
  50386. /**
  50387. * Dispose the material.
  50388. * @param forceDisposeEffect Force disposal of the associated effect.
  50389. * @param forceDisposeTextures Force disposal of the associated textures.
  50390. */
  50391. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50392. /**
  50393. * Clones the material.
  50394. * @param name The cloned name.
  50395. * @returns The cloned material.
  50396. */
  50397. clone(name: string): BackgroundMaterial;
  50398. /**
  50399. * Serializes the current material to its JSON representation.
  50400. * @returns The JSON representation.
  50401. */
  50402. serialize(): any;
  50403. /**
  50404. * Gets the class name of the material
  50405. * @returns "BackgroundMaterial"
  50406. */
  50407. getClassName(): string;
  50408. /**
  50409. * Parse a JSON input to create back a background material.
  50410. * @param source The JSON data to parse
  50411. * @param scene The scene to create the parsed material in
  50412. * @param rootUrl The root url of the assets the material depends upon
  50413. * @returns the instantiated BackgroundMaterial.
  50414. */
  50415. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50416. }
  50417. }
  50418. declare module "babylonjs/Helpers/environmentHelper" {
  50419. import { Observable } from "babylonjs/Misc/observable";
  50420. import { Nullable } from "babylonjs/types";
  50421. import { Scene } from "babylonjs/scene";
  50422. import { Vector3 } from "babylonjs/Maths/math.vector";
  50423. import { Color3 } from "babylonjs/Maths/math.color";
  50424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50425. import { Mesh } from "babylonjs/Meshes/mesh";
  50426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50427. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  50428. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50429. import "babylonjs/Meshes/Builders/planeBuilder";
  50430. import "babylonjs/Meshes/Builders/boxBuilder";
  50431. /**
  50432. * Represents the different options available during the creation of
  50433. * a Environment helper.
  50434. *
  50435. * This can control the default ground, skybox and image processing setup of your scene.
  50436. */
  50437. export interface IEnvironmentHelperOptions {
  50438. /**
  50439. * Specifies wether or not to create a ground.
  50440. * True by default.
  50441. */
  50442. createGround: boolean;
  50443. /**
  50444. * Specifies the ground size.
  50445. * 15 by default.
  50446. */
  50447. groundSize: number;
  50448. /**
  50449. * The texture used on the ground for the main color.
  50450. * Comes from the BabylonJS CDN by default.
  50451. *
  50452. * Remarks: Can be either a texture or a url.
  50453. */
  50454. groundTexture: string | BaseTexture;
  50455. /**
  50456. * The color mixed in the ground texture by default.
  50457. * BabylonJS clearColor by default.
  50458. */
  50459. groundColor: Color3;
  50460. /**
  50461. * Specifies the ground opacity.
  50462. * 1 by default.
  50463. */
  50464. groundOpacity: number;
  50465. /**
  50466. * Enables the ground to receive shadows.
  50467. * True by default.
  50468. */
  50469. enableGroundShadow: boolean;
  50470. /**
  50471. * Helps preventing the shadow to be fully black on the ground.
  50472. * 0.5 by default.
  50473. */
  50474. groundShadowLevel: number;
  50475. /**
  50476. * Creates a mirror texture attach to the ground.
  50477. * false by default.
  50478. */
  50479. enableGroundMirror: boolean;
  50480. /**
  50481. * Specifies the ground mirror size ratio.
  50482. * 0.3 by default as the default kernel is 64.
  50483. */
  50484. groundMirrorSizeRatio: number;
  50485. /**
  50486. * Specifies the ground mirror blur kernel size.
  50487. * 64 by default.
  50488. */
  50489. groundMirrorBlurKernel: number;
  50490. /**
  50491. * Specifies the ground mirror visibility amount.
  50492. * 1 by default
  50493. */
  50494. groundMirrorAmount: number;
  50495. /**
  50496. * Specifies the ground mirror reflectance weight.
  50497. * This uses the standard weight of the background material to setup the fresnel effect
  50498. * of the mirror.
  50499. * 1 by default.
  50500. */
  50501. groundMirrorFresnelWeight: number;
  50502. /**
  50503. * Specifies the ground mirror Falloff distance.
  50504. * This can helps reducing the size of the reflection.
  50505. * 0 by Default.
  50506. */
  50507. groundMirrorFallOffDistance: number;
  50508. /**
  50509. * Specifies the ground mirror texture type.
  50510. * Unsigned Int by Default.
  50511. */
  50512. groundMirrorTextureType: number;
  50513. /**
  50514. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50515. * the shown objects.
  50516. */
  50517. groundYBias: number;
  50518. /**
  50519. * Specifies wether or not to create a skybox.
  50520. * True by default.
  50521. */
  50522. createSkybox: boolean;
  50523. /**
  50524. * Specifies the skybox size.
  50525. * 20 by default.
  50526. */
  50527. skyboxSize: number;
  50528. /**
  50529. * The texture used on the skybox for the main color.
  50530. * Comes from the BabylonJS CDN by default.
  50531. *
  50532. * Remarks: Can be either a texture or a url.
  50533. */
  50534. skyboxTexture: string | BaseTexture;
  50535. /**
  50536. * The color mixed in the skybox texture by default.
  50537. * BabylonJS clearColor by default.
  50538. */
  50539. skyboxColor: Color3;
  50540. /**
  50541. * The background rotation around the Y axis of the scene.
  50542. * This helps aligning the key lights of your scene with the background.
  50543. * 0 by default.
  50544. */
  50545. backgroundYRotation: number;
  50546. /**
  50547. * Compute automatically the size of the elements to best fit with the scene.
  50548. */
  50549. sizeAuto: boolean;
  50550. /**
  50551. * Default position of the rootMesh if autoSize is not true.
  50552. */
  50553. rootPosition: Vector3;
  50554. /**
  50555. * Sets up the image processing in the scene.
  50556. * true by default.
  50557. */
  50558. setupImageProcessing: boolean;
  50559. /**
  50560. * The texture used as your environment texture in the scene.
  50561. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50562. *
  50563. * Remarks: Can be either a texture or a url.
  50564. */
  50565. environmentTexture: string | BaseTexture;
  50566. /**
  50567. * The value of the exposure to apply to the scene.
  50568. * 0.6 by default if setupImageProcessing is true.
  50569. */
  50570. cameraExposure: number;
  50571. /**
  50572. * The value of the contrast to apply to the scene.
  50573. * 1.6 by default if setupImageProcessing is true.
  50574. */
  50575. cameraContrast: number;
  50576. /**
  50577. * Specifies wether or not tonemapping should be enabled in the scene.
  50578. * true by default if setupImageProcessing is true.
  50579. */
  50580. toneMappingEnabled: boolean;
  50581. }
  50582. /**
  50583. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50584. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50585. * It also helps with the default setup of your imageProcessing configuration.
  50586. */
  50587. export class EnvironmentHelper {
  50588. /**
  50589. * Default ground texture URL.
  50590. */
  50591. private static _groundTextureCDNUrl;
  50592. /**
  50593. * Default skybox texture URL.
  50594. */
  50595. private static _skyboxTextureCDNUrl;
  50596. /**
  50597. * Default environment texture URL.
  50598. */
  50599. private static _environmentTextureCDNUrl;
  50600. /**
  50601. * Creates the default options for the helper.
  50602. */
  50603. private static _getDefaultOptions;
  50604. private _rootMesh;
  50605. /**
  50606. * Gets the root mesh created by the helper.
  50607. */
  50608. get rootMesh(): Mesh;
  50609. private _skybox;
  50610. /**
  50611. * Gets the skybox created by the helper.
  50612. */
  50613. get skybox(): Nullable<Mesh>;
  50614. private _skyboxTexture;
  50615. /**
  50616. * Gets the skybox texture created by the helper.
  50617. */
  50618. get skyboxTexture(): Nullable<BaseTexture>;
  50619. private _skyboxMaterial;
  50620. /**
  50621. * Gets the skybox material created by the helper.
  50622. */
  50623. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50624. private _ground;
  50625. /**
  50626. * Gets the ground mesh created by the helper.
  50627. */
  50628. get ground(): Nullable<Mesh>;
  50629. private _groundTexture;
  50630. /**
  50631. * Gets the ground texture created by the helper.
  50632. */
  50633. get groundTexture(): Nullable<BaseTexture>;
  50634. private _groundMirror;
  50635. /**
  50636. * Gets the ground mirror created by the helper.
  50637. */
  50638. get groundMirror(): Nullable<MirrorTexture>;
  50639. /**
  50640. * Gets the ground mirror render list to helps pushing the meshes
  50641. * you wish in the ground reflection.
  50642. */
  50643. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50644. private _groundMaterial;
  50645. /**
  50646. * Gets the ground material created by the helper.
  50647. */
  50648. get groundMaterial(): Nullable<BackgroundMaterial>;
  50649. /**
  50650. * Stores the creation options.
  50651. */
  50652. private readonly _scene;
  50653. private _options;
  50654. /**
  50655. * This observable will be notified with any error during the creation of the environment,
  50656. * mainly texture creation errors.
  50657. */
  50658. onErrorObservable: Observable<{
  50659. message?: string;
  50660. exception?: any;
  50661. }>;
  50662. /**
  50663. * constructor
  50664. * @param options Defines the options we want to customize the helper
  50665. * @param scene The scene to add the material to
  50666. */
  50667. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50668. /**
  50669. * Updates the background according to the new options
  50670. * @param options
  50671. */
  50672. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50673. /**
  50674. * Sets the primary color of all the available elements.
  50675. * @param color the main color to affect to the ground and the background
  50676. */
  50677. setMainColor(color: Color3): void;
  50678. /**
  50679. * Setup the image processing according to the specified options.
  50680. */
  50681. private _setupImageProcessing;
  50682. /**
  50683. * Setup the environment texture according to the specified options.
  50684. */
  50685. private _setupEnvironmentTexture;
  50686. /**
  50687. * Setup the background according to the specified options.
  50688. */
  50689. private _setupBackground;
  50690. /**
  50691. * Get the scene sizes according to the setup.
  50692. */
  50693. private _getSceneSize;
  50694. /**
  50695. * Setup the ground according to the specified options.
  50696. */
  50697. private _setupGround;
  50698. /**
  50699. * Setup the ground material according to the specified options.
  50700. */
  50701. private _setupGroundMaterial;
  50702. /**
  50703. * Setup the ground diffuse texture according to the specified options.
  50704. */
  50705. private _setupGroundDiffuseTexture;
  50706. /**
  50707. * Setup the ground mirror texture according to the specified options.
  50708. */
  50709. private _setupGroundMirrorTexture;
  50710. /**
  50711. * Setup the ground to receive the mirror texture.
  50712. */
  50713. private _setupMirrorInGroundMaterial;
  50714. /**
  50715. * Setup the skybox according to the specified options.
  50716. */
  50717. private _setupSkybox;
  50718. /**
  50719. * Setup the skybox material according to the specified options.
  50720. */
  50721. private _setupSkyboxMaterial;
  50722. /**
  50723. * Setup the skybox reflection texture according to the specified options.
  50724. */
  50725. private _setupSkyboxReflectionTexture;
  50726. private _errorHandler;
  50727. /**
  50728. * Dispose all the elements created by the Helper.
  50729. */
  50730. dispose(): void;
  50731. }
  50732. }
  50733. declare module "babylonjs/Helpers/photoDome" {
  50734. import { Observable } from "babylonjs/Misc/observable";
  50735. import { Nullable } from "babylonjs/types";
  50736. import { Scene } from "babylonjs/scene";
  50737. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50738. import { Mesh } from "babylonjs/Meshes/mesh";
  50739. import { Texture } from "babylonjs/Materials/Textures/texture";
  50740. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50741. import "babylonjs/Meshes/Builders/sphereBuilder";
  50742. /**
  50743. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50744. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50745. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50746. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50747. */
  50748. export class PhotoDome extends TransformNode {
  50749. /**
  50750. * Define the image as a Monoscopic panoramic 360 image.
  50751. */
  50752. static readonly MODE_MONOSCOPIC: number;
  50753. /**
  50754. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50755. */
  50756. static readonly MODE_TOPBOTTOM: number;
  50757. /**
  50758. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50759. */
  50760. static readonly MODE_SIDEBYSIDE: number;
  50761. private _useDirectMapping;
  50762. /**
  50763. * The texture being displayed on the sphere
  50764. */
  50765. protected _photoTexture: Texture;
  50766. /**
  50767. * Gets or sets the texture being displayed on the sphere
  50768. */
  50769. get photoTexture(): Texture;
  50770. set photoTexture(value: Texture);
  50771. /**
  50772. * Observable raised when an error occured while loading the 360 image
  50773. */
  50774. onLoadErrorObservable: Observable<string>;
  50775. /**
  50776. * The skybox material
  50777. */
  50778. protected _material: BackgroundMaterial;
  50779. /**
  50780. * The surface used for the skybox
  50781. */
  50782. protected _mesh: Mesh;
  50783. /**
  50784. * Gets the mesh used for the skybox.
  50785. */
  50786. get mesh(): Mesh;
  50787. /**
  50788. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50789. * Also see the options.resolution property.
  50790. */
  50791. get fovMultiplier(): number;
  50792. set fovMultiplier(value: number);
  50793. private _imageMode;
  50794. /**
  50795. * Gets or set the current video mode for the video. It can be:
  50796. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50797. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50798. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50799. */
  50800. get imageMode(): number;
  50801. set imageMode(value: number);
  50802. /**
  50803. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50804. * @param name Element's name, child elements will append suffixes for their own names.
  50805. * @param urlsOfPhoto defines the url of the photo to display
  50806. * @param options defines an object containing optional or exposed sub element properties
  50807. * @param onError defines a callback called when an error occured while loading the texture
  50808. */
  50809. constructor(name: string, urlOfPhoto: string, options: {
  50810. resolution?: number;
  50811. size?: number;
  50812. useDirectMapping?: boolean;
  50813. faceForward?: boolean;
  50814. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50815. private _onBeforeCameraRenderObserver;
  50816. private _changeImageMode;
  50817. /**
  50818. * Releases resources associated with this node.
  50819. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50820. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50821. */
  50822. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50823. }
  50824. }
  50825. declare module "babylonjs/Misc/rgbdTextureTools" {
  50826. import "babylonjs/Shaders/rgbdDecode.fragment";
  50827. import "babylonjs/Engines/Extensions/engine.renderTarget";
  50828. import { Texture } from "babylonjs/Materials/Textures/texture";
  50829. /**
  50830. * Class used to host RGBD texture specific utilities
  50831. */
  50832. export class RGBDTextureTools {
  50833. /**
  50834. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50835. * @param texture the texture to expand.
  50836. */
  50837. static ExpandRGBDTexture(texture: Texture): void;
  50838. }
  50839. }
  50840. declare module "babylonjs/Misc/brdfTextureTools" {
  50841. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50842. import { Scene } from "babylonjs/scene";
  50843. /**
  50844. * Class used to host texture specific utilities
  50845. */
  50846. export class BRDFTextureTools {
  50847. /**
  50848. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50849. * @param scene defines the hosting scene
  50850. * @returns the environment BRDF texture
  50851. */
  50852. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50853. private static _environmentBRDFBase64Texture;
  50854. }
  50855. }
  50856. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  50857. import { Nullable } from "babylonjs/types";
  50858. import { Color3 } from "babylonjs/Maths/math.color";
  50859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50860. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50861. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50862. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50863. import { Engine } from "babylonjs/Engines/engine";
  50864. import { Scene } from "babylonjs/scene";
  50865. /**
  50866. * @hidden
  50867. */
  50868. export interface IMaterialClearCoatDefines {
  50869. CLEARCOAT: boolean;
  50870. CLEARCOAT_DEFAULTIOR: boolean;
  50871. CLEARCOAT_TEXTURE: boolean;
  50872. CLEARCOAT_TEXTUREDIRECTUV: number;
  50873. CLEARCOAT_BUMP: boolean;
  50874. CLEARCOAT_BUMPDIRECTUV: number;
  50875. CLEARCOAT_TINT: boolean;
  50876. CLEARCOAT_TINT_TEXTURE: boolean;
  50877. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50878. /** @hidden */
  50879. _areTexturesDirty: boolean;
  50880. }
  50881. /**
  50882. * Define the code related to the clear coat parameters of the pbr material.
  50883. */
  50884. export class PBRClearCoatConfiguration {
  50885. /**
  50886. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50887. * The default fits with a polyurethane material.
  50888. */
  50889. private static readonly _DefaultIndexOfRefraction;
  50890. private _isEnabled;
  50891. /**
  50892. * Defines if the clear coat is enabled in the material.
  50893. */
  50894. isEnabled: boolean;
  50895. /**
  50896. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50897. */
  50898. intensity: number;
  50899. /**
  50900. * Defines the clear coat layer roughness.
  50901. */
  50902. roughness: number;
  50903. private _indexOfRefraction;
  50904. /**
  50905. * Defines the index of refraction of the clear coat.
  50906. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50907. * The default fits with a polyurethane material.
  50908. * Changing the default value is more performance intensive.
  50909. */
  50910. indexOfRefraction: number;
  50911. private _texture;
  50912. /**
  50913. * Stores the clear coat values in a texture.
  50914. */
  50915. texture: Nullable<BaseTexture>;
  50916. private _bumpTexture;
  50917. /**
  50918. * Define the clear coat specific bump texture.
  50919. */
  50920. bumpTexture: Nullable<BaseTexture>;
  50921. private _isTintEnabled;
  50922. /**
  50923. * Defines if the clear coat tint is enabled in the material.
  50924. */
  50925. isTintEnabled: boolean;
  50926. /**
  50927. * Defines the clear coat tint of the material.
  50928. * This is only use if tint is enabled
  50929. */
  50930. tintColor: Color3;
  50931. /**
  50932. * Defines the distance at which the tint color should be found in the
  50933. * clear coat media.
  50934. * This is only use if tint is enabled
  50935. */
  50936. tintColorAtDistance: number;
  50937. /**
  50938. * Defines the clear coat layer thickness.
  50939. * This is only use if tint is enabled
  50940. */
  50941. tintThickness: number;
  50942. private _tintTexture;
  50943. /**
  50944. * Stores the clear tint values in a texture.
  50945. * rgb is tint
  50946. * a is a thickness factor
  50947. */
  50948. tintTexture: Nullable<BaseTexture>;
  50949. /** @hidden */
  50950. private _internalMarkAllSubMeshesAsTexturesDirty;
  50951. /** @hidden */
  50952. _markAllSubMeshesAsTexturesDirty(): void;
  50953. /**
  50954. * Instantiate a new istance of clear coat configuration.
  50955. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50956. */
  50957. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50958. /**
  50959. * Gets wehter the submesh is ready to be used or not.
  50960. * @param defines the list of "defines" to update.
  50961. * @param scene defines the scene the material belongs to.
  50962. * @param engine defines the engine the material belongs to.
  50963. * @param disableBumpMap defines wether the material disables bump or not.
  50964. * @returns - boolean indicating that the submesh is ready or not.
  50965. */
  50966. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50967. /**
  50968. * Checks to see if a texture is used in the material.
  50969. * @param defines the list of "defines" to update.
  50970. * @param scene defines the scene to the material belongs to.
  50971. */
  50972. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50973. /**
  50974. * Binds the material data.
  50975. * @param uniformBuffer defines the Uniform buffer to fill in.
  50976. * @param scene defines the scene the material belongs to.
  50977. * @param engine defines the engine the material belongs to.
  50978. * @param disableBumpMap defines wether the material disables bump or not.
  50979. * @param isFrozen defines wether the material is frozen or not.
  50980. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50981. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50982. */
  50983. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50984. /**
  50985. * Checks to see if a texture is used in the material.
  50986. * @param texture - Base texture to use.
  50987. * @returns - Boolean specifying if a texture is used in the material.
  50988. */
  50989. hasTexture(texture: BaseTexture): boolean;
  50990. /**
  50991. * Returns an array of the actively used textures.
  50992. * @param activeTextures Array of BaseTextures
  50993. */
  50994. getActiveTextures(activeTextures: BaseTexture[]): void;
  50995. /**
  50996. * Returns the animatable textures.
  50997. * @param animatables Array of animatable textures.
  50998. */
  50999. getAnimatables(animatables: IAnimatable[]): void;
  51000. /**
  51001. * Disposes the resources of the material.
  51002. * @param forceDisposeTextures - Forces the disposal of all textures.
  51003. */
  51004. dispose(forceDisposeTextures?: boolean): void;
  51005. /**
  51006. * Get the current class name of the texture useful for serialization or dynamic coding.
  51007. * @returns "PBRClearCoatConfiguration"
  51008. */
  51009. getClassName(): string;
  51010. /**
  51011. * Add fallbacks to the effect fallbacks list.
  51012. * @param defines defines the Base texture to use.
  51013. * @param fallbacks defines the current fallback list.
  51014. * @param currentRank defines the current fallback rank.
  51015. * @returns the new fallback rank.
  51016. */
  51017. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51018. /**
  51019. * Add the required uniforms to the current list.
  51020. * @param uniforms defines the current uniform list.
  51021. */
  51022. static AddUniforms(uniforms: string[]): void;
  51023. /**
  51024. * Add the required samplers to the current list.
  51025. * @param samplers defines the current sampler list.
  51026. */
  51027. static AddSamplers(samplers: string[]): void;
  51028. /**
  51029. * Add the required uniforms to the current buffer.
  51030. * @param uniformBuffer defines the current uniform buffer.
  51031. */
  51032. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51033. /**
  51034. * Makes a duplicate of the current configuration into another one.
  51035. * @param clearCoatConfiguration define the config where to copy the info
  51036. */
  51037. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51038. /**
  51039. * Serializes this clear coat configuration.
  51040. * @returns - An object with the serialized config.
  51041. */
  51042. serialize(): any;
  51043. /**
  51044. * Parses a anisotropy Configuration from a serialized object.
  51045. * @param source - Serialized object.
  51046. * @param scene Defines the scene we are parsing for
  51047. * @param rootUrl Defines the rootUrl to load from
  51048. */
  51049. parse(source: any, scene: Scene, rootUrl: string): void;
  51050. }
  51051. }
  51052. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51053. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51055. import { Vector2 } from "babylonjs/Maths/math.vector";
  51056. import { Scene } from "babylonjs/scene";
  51057. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51058. import { Nullable } from "babylonjs/types";
  51059. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51060. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51061. /**
  51062. * @hidden
  51063. */
  51064. export interface IMaterialAnisotropicDefines {
  51065. ANISOTROPIC: boolean;
  51066. ANISOTROPIC_TEXTURE: boolean;
  51067. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51068. MAINUV1: boolean;
  51069. _areTexturesDirty: boolean;
  51070. _needUVs: boolean;
  51071. }
  51072. /**
  51073. * Define the code related to the anisotropic parameters of the pbr material.
  51074. */
  51075. export class PBRAnisotropicConfiguration {
  51076. private _isEnabled;
  51077. /**
  51078. * Defines if the anisotropy is enabled in the material.
  51079. */
  51080. isEnabled: boolean;
  51081. /**
  51082. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51083. */
  51084. intensity: number;
  51085. /**
  51086. * Defines if the effect is along the tangents, bitangents or in between.
  51087. * By default, the effect is "strectching" the highlights along the tangents.
  51088. */
  51089. direction: Vector2;
  51090. private _texture;
  51091. /**
  51092. * Stores the anisotropy values in a texture.
  51093. * rg is direction (like normal from -1 to 1)
  51094. * b is a intensity
  51095. */
  51096. texture: Nullable<BaseTexture>;
  51097. /** @hidden */
  51098. private _internalMarkAllSubMeshesAsTexturesDirty;
  51099. /** @hidden */
  51100. _markAllSubMeshesAsTexturesDirty(): void;
  51101. /**
  51102. * Instantiate a new istance of anisotropy configuration.
  51103. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51104. */
  51105. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51106. /**
  51107. * Specifies that the submesh is ready to be used.
  51108. * @param defines the list of "defines" to update.
  51109. * @param scene defines the scene the material belongs to.
  51110. * @returns - boolean indicating that the submesh is ready or not.
  51111. */
  51112. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  51113. /**
  51114. * Checks to see if a texture is used in the material.
  51115. * @param defines the list of "defines" to update.
  51116. * @param mesh the mesh we are preparing the defines for.
  51117. * @param scene defines the scene the material belongs to.
  51118. */
  51119. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  51120. /**
  51121. * Binds the material data.
  51122. * @param uniformBuffer defines the Uniform buffer to fill in.
  51123. * @param scene defines the scene the material belongs to.
  51124. * @param isFrozen defines wether the material is frozen or not.
  51125. */
  51126. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51127. /**
  51128. * Checks to see if a texture is used in the material.
  51129. * @param texture - Base texture to use.
  51130. * @returns - Boolean specifying if a texture is used in the material.
  51131. */
  51132. hasTexture(texture: BaseTexture): boolean;
  51133. /**
  51134. * Returns an array of the actively used textures.
  51135. * @param activeTextures Array of BaseTextures
  51136. */
  51137. getActiveTextures(activeTextures: BaseTexture[]): void;
  51138. /**
  51139. * Returns the animatable textures.
  51140. * @param animatables Array of animatable textures.
  51141. */
  51142. getAnimatables(animatables: IAnimatable[]): void;
  51143. /**
  51144. * Disposes the resources of the material.
  51145. * @param forceDisposeTextures - Forces the disposal of all textures.
  51146. */
  51147. dispose(forceDisposeTextures?: boolean): void;
  51148. /**
  51149. * Get the current class name of the texture useful for serialization or dynamic coding.
  51150. * @returns "PBRAnisotropicConfiguration"
  51151. */
  51152. getClassName(): string;
  51153. /**
  51154. * Add fallbacks to the effect fallbacks list.
  51155. * @param defines defines the Base texture to use.
  51156. * @param fallbacks defines the current fallback list.
  51157. * @param currentRank defines the current fallback rank.
  51158. * @returns the new fallback rank.
  51159. */
  51160. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51161. /**
  51162. * Add the required uniforms to the current list.
  51163. * @param uniforms defines the current uniform list.
  51164. */
  51165. static AddUniforms(uniforms: string[]): void;
  51166. /**
  51167. * Add the required uniforms to the current buffer.
  51168. * @param uniformBuffer defines the current uniform buffer.
  51169. */
  51170. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51171. /**
  51172. * Add the required samplers to the current list.
  51173. * @param samplers defines the current sampler list.
  51174. */
  51175. static AddSamplers(samplers: string[]): void;
  51176. /**
  51177. * Makes a duplicate of the current configuration into another one.
  51178. * @param anisotropicConfiguration define the config where to copy the info
  51179. */
  51180. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  51181. /**
  51182. * Serializes this anisotropy configuration.
  51183. * @returns - An object with the serialized config.
  51184. */
  51185. serialize(): any;
  51186. /**
  51187. * Parses a anisotropy Configuration from a serialized object.
  51188. * @param source - Serialized object.
  51189. * @param scene Defines the scene we are parsing for
  51190. * @param rootUrl Defines the rootUrl to load from
  51191. */
  51192. parse(source: any, scene: Scene, rootUrl: string): void;
  51193. }
  51194. }
  51195. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  51196. import { Scene } from "babylonjs/scene";
  51197. /**
  51198. * @hidden
  51199. */
  51200. export interface IMaterialBRDFDefines {
  51201. BRDF_V_HEIGHT_CORRELATED: boolean;
  51202. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51203. SPHERICAL_HARMONICS: boolean;
  51204. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51205. /** @hidden */
  51206. _areMiscDirty: boolean;
  51207. }
  51208. /**
  51209. * Define the code related to the BRDF parameters of the pbr material.
  51210. */
  51211. export class PBRBRDFConfiguration {
  51212. /**
  51213. * Default value used for the energy conservation.
  51214. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51215. */
  51216. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  51217. /**
  51218. * Default value used for the Smith Visibility Height Correlated mode.
  51219. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51220. */
  51221. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  51222. /**
  51223. * Default value used for the IBL diffuse part.
  51224. * This can help switching back to the polynomials mode globally which is a tiny bit
  51225. * less GPU intensive at the drawback of a lower quality.
  51226. */
  51227. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  51228. /**
  51229. * Default value used for activating energy conservation for the specular workflow.
  51230. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51231. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51232. */
  51233. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  51234. private _useEnergyConservation;
  51235. /**
  51236. * Defines if the material uses energy conservation.
  51237. */
  51238. useEnergyConservation: boolean;
  51239. private _useSmithVisibilityHeightCorrelated;
  51240. /**
  51241. * LEGACY Mode set to false
  51242. * Defines if the material uses height smith correlated visibility term.
  51243. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51244. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51245. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51246. * Not relying on height correlated will also disable energy conservation.
  51247. */
  51248. useSmithVisibilityHeightCorrelated: boolean;
  51249. private _useSphericalHarmonics;
  51250. /**
  51251. * LEGACY Mode set to false
  51252. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51253. * diffuse part of the IBL.
  51254. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51255. * to the ground truth.
  51256. */
  51257. useSphericalHarmonics: boolean;
  51258. private _useSpecularGlossinessInputEnergyConservation;
  51259. /**
  51260. * Defines if the material uses energy conservation, when the specular workflow is active.
  51261. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51262. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51263. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51264. */
  51265. useSpecularGlossinessInputEnergyConservation: boolean;
  51266. /** @hidden */
  51267. private _internalMarkAllSubMeshesAsMiscDirty;
  51268. /** @hidden */
  51269. _markAllSubMeshesAsMiscDirty(): void;
  51270. /**
  51271. * Instantiate a new istance of clear coat configuration.
  51272. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51273. */
  51274. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51275. /**
  51276. * Checks to see if a texture is used in the material.
  51277. * @param defines the list of "defines" to update.
  51278. */
  51279. prepareDefines(defines: IMaterialBRDFDefines): void;
  51280. /**
  51281. * Get the current class name of the texture useful for serialization or dynamic coding.
  51282. * @returns "PBRClearCoatConfiguration"
  51283. */
  51284. getClassName(): string;
  51285. /**
  51286. * Makes a duplicate of the current configuration into another one.
  51287. * @param brdfConfiguration define the config where to copy the info
  51288. */
  51289. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51290. /**
  51291. * Serializes this BRDF configuration.
  51292. * @returns - An object with the serialized config.
  51293. */
  51294. serialize(): any;
  51295. /**
  51296. * Parses a anisotropy Configuration from a serialized object.
  51297. * @param source - Serialized object.
  51298. * @param scene Defines the scene we are parsing for
  51299. * @param rootUrl Defines the rootUrl to load from
  51300. */
  51301. parse(source: any, scene: Scene, rootUrl: string): void;
  51302. }
  51303. }
  51304. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  51305. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51306. import { Color3 } from "babylonjs/Maths/math.color";
  51307. import { Scene } from "babylonjs/scene";
  51308. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51309. import { Nullable } from "babylonjs/types";
  51310. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51311. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51312. /**
  51313. * @hidden
  51314. */
  51315. export interface IMaterialSheenDefines {
  51316. SHEEN: boolean;
  51317. SHEEN_TEXTURE: boolean;
  51318. SHEEN_TEXTUREDIRECTUV: number;
  51319. SHEEN_LINKWITHALBEDO: boolean;
  51320. /** @hidden */
  51321. _areTexturesDirty: boolean;
  51322. }
  51323. /**
  51324. * Define the code related to the Sheen parameters of the pbr material.
  51325. */
  51326. export class PBRSheenConfiguration {
  51327. private _isEnabled;
  51328. /**
  51329. * Defines if the material uses sheen.
  51330. */
  51331. isEnabled: boolean;
  51332. private _linkSheenWithAlbedo;
  51333. /**
  51334. * Defines if the sheen is linked to the sheen color.
  51335. */
  51336. linkSheenWithAlbedo: boolean;
  51337. /**
  51338. * Defines the sheen intensity.
  51339. */
  51340. intensity: number;
  51341. /**
  51342. * Defines the sheen color.
  51343. */
  51344. color: Color3;
  51345. private _texture;
  51346. /**
  51347. * Stores the sheen tint values in a texture.
  51348. * rgb is tint
  51349. * a is a intensity
  51350. */
  51351. texture: Nullable<BaseTexture>;
  51352. /** @hidden */
  51353. private _internalMarkAllSubMeshesAsTexturesDirty;
  51354. /** @hidden */
  51355. _markAllSubMeshesAsTexturesDirty(): void;
  51356. /**
  51357. * Instantiate a new istance of clear coat configuration.
  51358. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51359. */
  51360. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51361. /**
  51362. * Specifies that the submesh is ready to be used.
  51363. * @param defines the list of "defines" to update.
  51364. * @param scene defines the scene the material belongs to.
  51365. * @returns - boolean indicating that the submesh is ready or not.
  51366. */
  51367. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51368. /**
  51369. * Checks to see if a texture is used in the material.
  51370. * @param defines the list of "defines" to update.
  51371. * @param scene defines the scene the material belongs to.
  51372. */
  51373. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51374. /**
  51375. * Binds the material data.
  51376. * @param uniformBuffer defines the Uniform buffer to fill in.
  51377. * @param scene defines the scene the material belongs to.
  51378. * @param isFrozen defines wether the material is frozen or not.
  51379. */
  51380. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51381. /**
  51382. * Checks to see if a texture is used in the material.
  51383. * @param texture - Base texture to use.
  51384. * @returns - Boolean specifying if a texture is used in the material.
  51385. */
  51386. hasTexture(texture: BaseTexture): boolean;
  51387. /**
  51388. * Returns an array of the actively used textures.
  51389. * @param activeTextures Array of BaseTextures
  51390. */
  51391. getActiveTextures(activeTextures: BaseTexture[]): void;
  51392. /**
  51393. * Returns the animatable textures.
  51394. * @param animatables Array of animatable textures.
  51395. */
  51396. getAnimatables(animatables: IAnimatable[]): void;
  51397. /**
  51398. * Disposes the resources of the material.
  51399. * @param forceDisposeTextures - Forces the disposal of all textures.
  51400. */
  51401. dispose(forceDisposeTextures?: boolean): void;
  51402. /**
  51403. * Get the current class name of the texture useful for serialization or dynamic coding.
  51404. * @returns "PBRSheenConfiguration"
  51405. */
  51406. getClassName(): string;
  51407. /**
  51408. * Add fallbacks to the effect fallbacks list.
  51409. * @param defines defines the Base texture to use.
  51410. * @param fallbacks defines the current fallback list.
  51411. * @param currentRank defines the current fallback rank.
  51412. * @returns the new fallback rank.
  51413. */
  51414. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51415. /**
  51416. * Add the required uniforms to the current list.
  51417. * @param uniforms defines the current uniform list.
  51418. */
  51419. static AddUniforms(uniforms: string[]): void;
  51420. /**
  51421. * Add the required uniforms to the current buffer.
  51422. * @param uniformBuffer defines the current uniform buffer.
  51423. */
  51424. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51425. /**
  51426. * Add the required samplers to the current list.
  51427. * @param samplers defines the current sampler list.
  51428. */
  51429. static AddSamplers(samplers: string[]): void;
  51430. /**
  51431. * Makes a duplicate of the current configuration into another one.
  51432. * @param sheenConfiguration define the config where to copy the info
  51433. */
  51434. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51435. /**
  51436. * Serializes this BRDF configuration.
  51437. * @returns - An object with the serialized config.
  51438. */
  51439. serialize(): any;
  51440. /**
  51441. * Parses a anisotropy Configuration from a serialized object.
  51442. * @param source - Serialized object.
  51443. * @param scene Defines the scene we are parsing for
  51444. * @param rootUrl Defines the rootUrl to load from
  51445. */
  51446. parse(source: any, scene: Scene, rootUrl: string): void;
  51447. }
  51448. }
  51449. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  51450. import { Nullable } from "babylonjs/types";
  51451. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51452. import { Color3 } from "babylonjs/Maths/math.color";
  51453. import { SmartArray } from "babylonjs/Misc/smartArray";
  51454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51455. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51456. import { Effect } from "babylonjs/Materials/effect";
  51457. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51458. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51459. import { Engine } from "babylonjs/Engines/engine";
  51460. import { Scene } from "babylonjs/scene";
  51461. /**
  51462. * @hidden
  51463. */
  51464. export interface IMaterialSubSurfaceDefines {
  51465. SUBSURFACE: boolean;
  51466. SS_REFRACTION: boolean;
  51467. SS_TRANSLUCENCY: boolean;
  51468. SS_SCATERRING: boolean;
  51469. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51470. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51471. SS_REFRACTIONMAP_3D: boolean;
  51472. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51473. SS_LODINREFRACTIONALPHA: boolean;
  51474. SS_GAMMAREFRACTION: boolean;
  51475. SS_RGBDREFRACTION: boolean;
  51476. SS_LINEARSPECULARREFRACTION: boolean;
  51477. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51478. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51479. /** @hidden */
  51480. _areTexturesDirty: boolean;
  51481. }
  51482. /**
  51483. * Define the code related to the sub surface parameters of the pbr material.
  51484. */
  51485. export class PBRSubSurfaceConfiguration {
  51486. private _isRefractionEnabled;
  51487. /**
  51488. * Defines if the refraction is enabled in the material.
  51489. */
  51490. isRefractionEnabled: boolean;
  51491. private _isTranslucencyEnabled;
  51492. /**
  51493. * Defines if the translucency is enabled in the material.
  51494. */
  51495. isTranslucencyEnabled: boolean;
  51496. private _isScatteringEnabled;
  51497. /**
  51498. * Defines the refraction intensity of the material.
  51499. * The refraction when enabled replaces the Diffuse part of the material.
  51500. * The intensity helps transitionning between diffuse and refraction.
  51501. */
  51502. refractionIntensity: number;
  51503. /**
  51504. * Defines the translucency intensity of the material.
  51505. * When translucency has been enabled, this defines how much of the "translucency"
  51506. * is addded to the diffuse part of the material.
  51507. */
  51508. translucencyIntensity: number;
  51509. /**
  51510. * Defines the scattering intensity of the material.
  51511. * When scattering has been enabled, this defines how much of the "scattered light"
  51512. * is addded to the diffuse part of the material.
  51513. */
  51514. scatteringIntensity: number;
  51515. private _thicknessTexture;
  51516. /**
  51517. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51518. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51519. * 0 would mean minimumThickness
  51520. * 1 would mean maximumThickness
  51521. * The other channels might be use as a mask to vary the different effects intensity.
  51522. */
  51523. thicknessTexture: Nullable<BaseTexture>;
  51524. private _refractionTexture;
  51525. /**
  51526. * Defines the texture to use for refraction.
  51527. */
  51528. refractionTexture: Nullable<BaseTexture>;
  51529. private _indexOfRefraction;
  51530. /**
  51531. * Defines the index of refraction used in the material.
  51532. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51533. */
  51534. indexOfRefraction: number;
  51535. private _invertRefractionY;
  51536. /**
  51537. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51538. */
  51539. invertRefractionY: boolean;
  51540. private _linkRefractionWithTransparency;
  51541. /**
  51542. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51543. * Materials half opaque for instance using refraction could benefit from this control.
  51544. */
  51545. linkRefractionWithTransparency: boolean;
  51546. /**
  51547. * Defines the minimum thickness stored in the thickness map.
  51548. * If no thickness map is defined, this value will be used to simulate thickness.
  51549. */
  51550. minimumThickness: number;
  51551. /**
  51552. * Defines the maximum thickness stored in the thickness map.
  51553. */
  51554. maximumThickness: number;
  51555. /**
  51556. * Defines the volume tint of the material.
  51557. * This is used for both translucency and scattering.
  51558. */
  51559. tintColor: Color3;
  51560. /**
  51561. * Defines the distance at which the tint color should be found in the media.
  51562. * This is used for refraction only.
  51563. */
  51564. tintColorAtDistance: number;
  51565. /**
  51566. * Defines how far each channel transmit through the media.
  51567. * It is defined as a color to simplify it selection.
  51568. */
  51569. diffusionDistance: Color3;
  51570. private _useMaskFromThicknessTexture;
  51571. /**
  51572. * Stores the intensity of the different subsurface effects in the thickness texture.
  51573. * * the green channel is the translucency intensity.
  51574. * * the blue channel is the scattering intensity.
  51575. * * the alpha channel is the refraction intensity.
  51576. */
  51577. useMaskFromThicknessTexture: boolean;
  51578. /** @hidden */
  51579. private _internalMarkAllSubMeshesAsTexturesDirty;
  51580. /** @hidden */
  51581. _markAllSubMeshesAsTexturesDirty(): void;
  51582. /**
  51583. * Instantiate a new istance of sub surface configuration.
  51584. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51585. */
  51586. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51587. /**
  51588. * Gets wehter the submesh is ready to be used or not.
  51589. * @param defines the list of "defines" to update.
  51590. * @param scene defines the scene the material belongs to.
  51591. * @returns - boolean indicating that the submesh is ready or not.
  51592. */
  51593. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51594. /**
  51595. * Checks to see if a texture is used in the material.
  51596. * @param defines the list of "defines" to update.
  51597. * @param scene defines the scene to the material belongs to.
  51598. */
  51599. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51600. /**
  51601. * Binds the material data.
  51602. * @param uniformBuffer defines the Uniform buffer to fill in.
  51603. * @param scene defines the scene the material belongs to.
  51604. * @param engine defines the engine the material belongs to.
  51605. * @param isFrozen defines wether the material is frozen or not.
  51606. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51607. */
  51608. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51609. /**
  51610. * Unbinds the material from the mesh.
  51611. * @param activeEffect defines the effect that should be unbound from.
  51612. * @returns true if unbound, otherwise false
  51613. */
  51614. unbind(activeEffect: Effect): boolean;
  51615. /**
  51616. * Returns the texture used for refraction or null if none is used.
  51617. * @param scene defines the scene the material belongs to.
  51618. * @returns - Refraction texture if present. If no refraction texture and refraction
  51619. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51620. */
  51621. private _getRefractionTexture;
  51622. /**
  51623. * Returns true if alpha blending should be disabled.
  51624. */
  51625. get disableAlphaBlending(): boolean;
  51626. /**
  51627. * Fills the list of render target textures.
  51628. * @param renderTargets the list of render targets to update
  51629. */
  51630. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51631. /**
  51632. * Checks to see if a texture is used in the material.
  51633. * @param texture - Base texture to use.
  51634. * @returns - Boolean specifying if a texture is used in the material.
  51635. */
  51636. hasTexture(texture: BaseTexture): boolean;
  51637. /**
  51638. * Gets a boolean indicating that current material needs to register RTT
  51639. * @returns true if this uses a render target otherwise false.
  51640. */
  51641. hasRenderTargetTextures(): boolean;
  51642. /**
  51643. * Returns an array of the actively used textures.
  51644. * @param activeTextures Array of BaseTextures
  51645. */
  51646. getActiveTextures(activeTextures: BaseTexture[]): void;
  51647. /**
  51648. * Returns the animatable textures.
  51649. * @param animatables Array of animatable textures.
  51650. */
  51651. getAnimatables(animatables: IAnimatable[]): void;
  51652. /**
  51653. * Disposes the resources of the material.
  51654. * @param forceDisposeTextures - Forces the disposal of all textures.
  51655. */
  51656. dispose(forceDisposeTextures?: boolean): void;
  51657. /**
  51658. * Get the current class name of the texture useful for serialization or dynamic coding.
  51659. * @returns "PBRSubSurfaceConfiguration"
  51660. */
  51661. getClassName(): string;
  51662. /**
  51663. * Add fallbacks to the effect fallbacks list.
  51664. * @param defines defines the Base texture to use.
  51665. * @param fallbacks defines the current fallback list.
  51666. * @param currentRank defines the current fallback rank.
  51667. * @returns the new fallback rank.
  51668. */
  51669. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51670. /**
  51671. * Add the required uniforms to the current list.
  51672. * @param uniforms defines the current uniform list.
  51673. */
  51674. static AddUniforms(uniforms: string[]): void;
  51675. /**
  51676. * Add the required samplers to the current list.
  51677. * @param samplers defines the current sampler list.
  51678. */
  51679. static AddSamplers(samplers: string[]): void;
  51680. /**
  51681. * Add the required uniforms to the current buffer.
  51682. * @param uniformBuffer defines the current uniform buffer.
  51683. */
  51684. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51685. /**
  51686. * Makes a duplicate of the current configuration into another one.
  51687. * @param configuration define the config where to copy the info
  51688. */
  51689. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51690. /**
  51691. * Serializes this Sub Surface configuration.
  51692. * @returns - An object with the serialized config.
  51693. */
  51694. serialize(): any;
  51695. /**
  51696. * Parses a anisotropy Configuration from a serialized object.
  51697. * @param source - Serialized object.
  51698. * @param scene Defines the scene we are parsing for
  51699. * @param rootUrl Defines the rootUrl to load from
  51700. */
  51701. parse(source: any, scene: Scene, rootUrl: string): void;
  51702. }
  51703. }
  51704. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  51705. /** @hidden */
  51706. export var pbrFragmentDeclaration: {
  51707. name: string;
  51708. shader: string;
  51709. };
  51710. }
  51711. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  51712. /** @hidden */
  51713. export var pbrUboDeclaration: {
  51714. name: string;
  51715. shader: string;
  51716. };
  51717. }
  51718. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  51719. /** @hidden */
  51720. export var pbrFragmentExtraDeclaration: {
  51721. name: string;
  51722. shader: string;
  51723. };
  51724. }
  51725. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  51726. /** @hidden */
  51727. export var pbrFragmentSamplersDeclaration: {
  51728. name: string;
  51729. shader: string;
  51730. };
  51731. }
  51732. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  51733. /** @hidden */
  51734. export var pbrHelperFunctions: {
  51735. name: string;
  51736. shader: string;
  51737. };
  51738. }
  51739. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  51740. /** @hidden */
  51741. export var harmonicsFunctions: {
  51742. name: string;
  51743. shader: string;
  51744. };
  51745. }
  51746. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  51747. /** @hidden */
  51748. export var pbrDirectLightingSetupFunctions: {
  51749. name: string;
  51750. shader: string;
  51751. };
  51752. }
  51753. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  51754. /** @hidden */
  51755. export var pbrDirectLightingFalloffFunctions: {
  51756. name: string;
  51757. shader: string;
  51758. };
  51759. }
  51760. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  51761. /** @hidden */
  51762. export var pbrBRDFFunctions: {
  51763. name: string;
  51764. shader: string;
  51765. };
  51766. }
  51767. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  51768. /** @hidden */
  51769. export var pbrDirectLightingFunctions: {
  51770. name: string;
  51771. shader: string;
  51772. };
  51773. }
  51774. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  51775. /** @hidden */
  51776. export var pbrIBLFunctions: {
  51777. name: string;
  51778. shader: string;
  51779. };
  51780. }
  51781. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  51782. /** @hidden */
  51783. export var pbrDebug: {
  51784. name: string;
  51785. shader: string;
  51786. };
  51787. }
  51788. declare module "babylonjs/Shaders/pbr.fragment" {
  51789. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  51790. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51791. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  51792. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51793. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51794. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  51795. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51796. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51797. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51798. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51799. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51800. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  51801. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51802. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51803. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51804. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  51805. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  51806. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  51807. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  51808. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  51809. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  51810. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51811. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51812. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  51813. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  51814. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51815. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  51816. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51817. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  51818. /** @hidden */
  51819. export var pbrPixelShader: {
  51820. name: string;
  51821. shader: string;
  51822. };
  51823. }
  51824. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  51825. /** @hidden */
  51826. export var pbrVertexDeclaration: {
  51827. name: string;
  51828. shader: string;
  51829. };
  51830. }
  51831. declare module "babylonjs/Shaders/pbr.vertex" {
  51832. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  51833. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51834. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51835. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51836. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51837. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51838. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  51839. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51840. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51841. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51842. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51843. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51844. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51845. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51846. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51847. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51848. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51849. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  51850. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51851. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51852. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51853. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  51854. /** @hidden */
  51855. export var pbrVertexShader: {
  51856. name: string;
  51857. shader: string;
  51858. };
  51859. }
  51860. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  51861. import { Nullable } from "babylonjs/types";
  51862. import { Scene } from "babylonjs/scene";
  51863. import { Matrix } from "babylonjs/Maths/math.vector";
  51864. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51866. import { Mesh } from "babylonjs/Meshes/mesh";
  51867. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  51868. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  51869. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  51870. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  51871. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  51872. import { Color3 } from "babylonjs/Maths/math.color";
  51873. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  51874. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  51875. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  51876. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51878. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51879. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  51880. import "babylonjs/Shaders/pbr.fragment";
  51881. import "babylonjs/Shaders/pbr.vertex";
  51882. /**
  51883. * Manages the defines for the PBR Material.
  51884. * @hidden
  51885. */
  51886. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51887. PBR: boolean;
  51888. MAINUV1: boolean;
  51889. MAINUV2: boolean;
  51890. UV1: boolean;
  51891. UV2: boolean;
  51892. ALBEDO: boolean;
  51893. ALBEDODIRECTUV: number;
  51894. VERTEXCOLOR: boolean;
  51895. AMBIENT: boolean;
  51896. AMBIENTDIRECTUV: number;
  51897. AMBIENTINGRAYSCALE: boolean;
  51898. OPACITY: boolean;
  51899. VERTEXALPHA: boolean;
  51900. OPACITYDIRECTUV: number;
  51901. OPACITYRGB: boolean;
  51902. ALPHATEST: boolean;
  51903. DEPTHPREPASS: boolean;
  51904. ALPHABLEND: boolean;
  51905. ALPHAFROMALBEDO: boolean;
  51906. ALPHATESTVALUE: string;
  51907. SPECULAROVERALPHA: boolean;
  51908. RADIANCEOVERALPHA: boolean;
  51909. ALPHAFRESNEL: boolean;
  51910. LINEARALPHAFRESNEL: boolean;
  51911. PREMULTIPLYALPHA: boolean;
  51912. EMISSIVE: boolean;
  51913. EMISSIVEDIRECTUV: number;
  51914. REFLECTIVITY: boolean;
  51915. REFLECTIVITYDIRECTUV: number;
  51916. SPECULARTERM: boolean;
  51917. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51918. MICROSURFACEAUTOMATIC: boolean;
  51919. LODBASEDMICROSFURACE: boolean;
  51920. MICROSURFACEMAP: boolean;
  51921. MICROSURFACEMAPDIRECTUV: number;
  51922. METALLICWORKFLOW: boolean;
  51923. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51924. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51925. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51926. AOSTOREINMETALMAPRED: boolean;
  51927. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51928. ENVIRONMENTBRDF: boolean;
  51929. ENVIRONMENTBRDF_RGBD: boolean;
  51930. NORMAL: boolean;
  51931. TANGENT: boolean;
  51932. BUMP: boolean;
  51933. BUMPDIRECTUV: number;
  51934. OBJECTSPACE_NORMALMAP: boolean;
  51935. PARALLAX: boolean;
  51936. PARALLAXOCCLUSION: boolean;
  51937. NORMALXYSCALE: boolean;
  51938. LIGHTMAP: boolean;
  51939. LIGHTMAPDIRECTUV: number;
  51940. USELIGHTMAPASSHADOWMAP: boolean;
  51941. GAMMALIGHTMAP: boolean;
  51942. RGBDLIGHTMAP: boolean;
  51943. REFLECTION: boolean;
  51944. REFLECTIONMAP_3D: boolean;
  51945. REFLECTIONMAP_SPHERICAL: boolean;
  51946. REFLECTIONMAP_PLANAR: boolean;
  51947. REFLECTIONMAP_CUBIC: boolean;
  51948. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51949. REFLECTIONMAP_PROJECTION: boolean;
  51950. REFLECTIONMAP_SKYBOX: boolean;
  51951. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  51952. REFLECTIONMAP_EXPLICIT: boolean;
  51953. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51954. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51955. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51956. INVERTCUBICMAP: boolean;
  51957. USESPHERICALFROMREFLECTIONMAP: boolean;
  51958. USEIRRADIANCEMAP: boolean;
  51959. SPHERICAL_HARMONICS: boolean;
  51960. USESPHERICALINVERTEX: boolean;
  51961. REFLECTIONMAP_OPPOSITEZ: boolean;
  51962. LODINREFLECTIONALPHA: boolean;
  51963. GAMMAREFLECTION: boolean;
  51964. RGBDREFLECTION: boolean;
  51965. LINEARSPECULARREFLECTION: boolean;
  51966. RADIANCEOCCLUSION: boolean;
  51967. HORIZONOCCLUSION: boolean;
  51968. INSTANCES: boolean;
  51969. NUM_BONE_INFLUENCERS: number;
  51970. BonesPerMesh: number;
  51971. BONETEXTURE: boolean;
  51972. NONUNIFORMSCALING: boolean;
  51973. MORPHTARGETS: boolean;
  51974. MORPHTARGETS_NORMAL: boolean;
  51975. MORPHTARGETS_TANGENT: boolean;
  51976. MORPHTARGETS_UV: boolean;
  51977. NUM_MORPH_INFLUENCERS: number;
  51978. IMAGEPROCESSING: boolean;
  51979. VIGNETTE: boolean;
  51980. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51981. VIGNETTEBLENDMODEOPAQUE: boolean;
  51982. TONEMAPPING: boolean;
  51983. TONEMAPPING_ACES: boolean;
  51984. CONTRAST: boolean;
  51985. COLORCURVES: boolean;
  51986. COLORGRADING: boolean;
  51987. COLORGRADING3D: boolean;
  51988. SAMPLER3DGREENDEPTH: boolean;
  51989. SAMPLER3DBGRMAP: boolean;
  51990. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51991. EXPOSURE: boolean;
  51992. MULTIVIEW: boolean;
  51993. USEPHYSICALLIGHTFALLOFF: boolean;
  51994. USEGLTFLIGHTFALLOFF: boolean;
  51995. TWOSIDEDLIGHTING: boolean;
  51996. SHADOWFLOAT: boolean;
  51997. CLIPPLANE: boolean;
  51998. CLIPPLANE2: boolean;
  51999. CLIPPLANE3: boolean;
  52000. CLIPPLANE4: boolean;
  52001. CLIPPLANE5: boolean;
  52002. CLIPPLANE6: boolean;
  52003. POINTSIZE: boolean;
  52004. FOG: boolean;
  52005. LOGARITHMICDEPTH: boolean;
  52006. FORCENORMALFORWARD: boolean;
  52007. SPECULARAA: boolean;
  52008. CLEARCOAT: boolean;
  52009. CLEARCOAT_DEFAULTIOR: boolean;
  52010. CLEARCOAT_TEXTURE: boolean;
  52011. CLEARCOAT_TEXTUREDIRECTUV: number;
  52012. CLEARCOAT_BUMP: boolean;
  52013. CLEARCOAT_BUMPDIRECTUV: number;
  52014. CLEARCOAT_TINT: boolean;
  52015. CLEARCOAT_TINT_TEXTURE: boolean;
  52016. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52017. ANISOTROPIC: boolean;
  52018. ANISOTROPIC_TEXTURE: boolean;
  52019. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52020. BRDF_V_HEIGHT_CORRELATED: boolean;
  52021. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52022. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52023. SHEEN: boolean;
  52024. SHEEN_TEXTURE: boolean;
  52025. SHEEN_TEXTUREDIRECTUV: number;
  52026. SHEEN_LINKWITHALBEDO: boolean;
  52027. SUBSURFACE: boolean;
  52028. SS_REFRACTION: boolean;
  52029. SS_TRANSLUCENCY: boolean;
  52030. SS_SCATERRING: boolean;
  52031. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52032. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52033. SS_REFRACTIONMAP_3D: boolean;
  52034. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52035. SS_LODINREFRACTIONALPHA: boolean;
  52036. SS_GAMMAREFRACTION: boolean;
  52037. SS_RGBDREFRACTION: boolean;
  52038. SS_LINEARSPECULARREFRACTION: boolean;
  52039. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52040. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52041. UNLIT: boolean;
  52042. DEBUGMODE: number;
  52043. /**
  52044. * Initializes the PBR Material defines.
  52045. */
  52046. constructor();
  52047. /**
  52048. * Resets the PBR Material defines.
  52049. */
  52050. reset(): void;
  52051. }
  52052. /**
  52053. * The Physically based material base class of BJS.
  52054. *
  52055. * This offers the main features of a standard PBR material.
  52056. * For more information, please refer to the documentation :
  52057. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52058. */
  52059. export abstract class PBRBaseMaterial extends PushMaterial {
  52060. /**
  52061. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52062. */
  52063. static readonly PBRMATERIAL_OPAQUE: number;
  52064. /**
  52065. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52066. */
  52067. static readonly PBRMATERIAL_ALPHATEST: number;
  52068. /**
  52069. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52070. */
  52071. static readonly PBRMATERIAL_ALPHABLEND: number;
  52072. /**
  52073. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52074. * They are also discarded below the alpha cutoff threshold to improve performances.
  52075. */
  52076. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52077. /**
  52078. * Defines the default value of how much AO map is occluding the analytical lights
  52079. * (point spot...).
  52080. */
  52081. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52082. /**
  52083. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52084. */
  52085. static readonly LIGHTFALLOFF_PHYSICAL: number;
  52086. /**
  52087. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52088. * to enhance interoperability with other engines.
  52089. */
  52090. static readonly LIGHTFALLOFF_GLTF: number;
  52091. /**
  52092. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52093. * to enhance interoperability with other materials.
  52094. */
  52095. static readonly LIGHTFALLOFF_STANDARD: number;
  52096. /**
  52097. * Intensity of the direct lights e.g. the four lights available in your scene.
  52098. * This impacts both the direct diffuse and specular highlights.
  52099. */
  52100. protected _directIntensity: number;
  52101. /**
  52102. * Intensity of the emissive part of the material.
  52103. * This helps controlling the emissive effect without modifying the emissive color.
  52104. */
  52105. protected _emissiveIntensity: number;
  52106. /**
  52107. * Intensity of the environment e.g. how much the environment will light the object
  52108. * either through harmonics for rough material or through the refelction for shiny ones.
  52109. */
  52110. protected _environmentIntensity: number;
  52111. /**
  52112. * This is a special control allowing the reduction of the specular highlights coming from the
  52113. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52114. */
  52115. protected _specularIntensity: number;
  52116. /**
  52117. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52118. */
  52119. private _lightingInfos;
  52120. /**
  52121. * Debug Control allowing disabling the bump map on this material.
  52122. */
  52123. protected _disableBumpMap: boolean;
  52124. /**
  52125. * AKA Diffuse Texture in standard nomenclature.
  52126. */
  52127. protected _albedoTexture: Nullable<BaseTexture>;
  52128. /**
  52129. * AKA Occlusion Texture in other nomenclature.
  52130. */
  52131. protected _ambientTexture: Nullable<BaseTexture>;
  52132. /**
  52133. * AKA Occlusion Texture Intensity in other nomenclature.
  52134. */
  52135. protected _ambientTextureStrength: number;
  52136. /**
  52137. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52138. * 1 means it completely occludes it
  52139. * 0 mean it has no impact
  52140. */
  52141. protected _ambientTextureImpactOnAnalyticalLights: number;
  52142. /**
  52143. * Stores the alpha values in a texture.
  52144. */
  52145. protected _opacityTexture: Nullable<BaseTexture>;
  52146. /**
  52147. * Stores the reflection values in a texture.
  52148. */
  52149. protected _reflectionTexture: Nullable<BaseTexture>;
  52150. /**
  52151. * Stores the emissive values in a texture.
  52152. */
  52153. protected _emissiveTexture: Nullable<BaseTexture>;
  52154. /**
  52155. * AKA Specular texture in other nomenclature.
  52156. */
  52157. protected _reflectivityTexture: Nullable<BaseTexture>;
  52158. /**
  52159. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52160. */
  52161. protected _metallicTexture: Nullable<BaseTexture>;
  52162. /**
  52163. * Specifies the metallic scalar of the metallic/roughness workflow.
  52164. * Can also be used to scale the metalness values of the metallic texture.
  52165. */
  52166. protected _metallic: Nullable<number>;
  52167. /**
  52168. * Specifies the roughness scalar of the metallic/roughness workflow.
  52169. * Can also be used to scale the roughness values of the metallic texture.
  52170. */
  52171. protected _roughness: Nullable<number>;
  52172. /**
  52173. * Specifies the an F0 factor to help configuring the material F0.
  52174. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52175. * to 0.5 the previously hard coded value stays the same.
  52176. * Can also be used to scale the F0 values of the metallic texture.
  52177. */
  52178. protected _metallicF0Factor: number;
  52179. /**
  52180. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52181. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52182. * your expectation as it multiplies with the texture data.
  52183. */
  52184. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52185. /**
  52186. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52187. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52188. */
  52189. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52190. /**
  52191. * Stores surface normal data used to displace a mesh in a texture.
  52192. */
  52193. protected _bumpTexture: Nullable<BaseTexture>;
  52194. /**
  52195. * Stores the pre-calculated light information of a mesh in a texture.
  52196. */
  52197. protected _lightmapTexture: Nullable<BaseTexture>;
  52198. /**
  52199. * The color of a material in ambient lighting.
  52200. */
  52201. protected _ambientColor: Color3;
  52202. /**
  52203. * AKA Diffuse Color in other nomenclature.
  52204. */
  52205. protected _albedoColor: Color3;
  52206. /**
  52207. * AKA Specular Color in other nomenclature.
  52208. */
  52209. protected _reflectivityColor: Color3;
  52210. /**
  52211. * The color applied when light is reflected from a material.
  52212. */
  52213. protected _reflectionColor: Color3;
  52214. /**
  52215. * The color applied when light is emitted from a material.
  52216. */
  52217. protected _emissiveColor: Color3;
  52218. /**
  52219. * AKA Glossiness in other nomenclature.
  52220. */
  52221. protected _microSurface: number;
  52222. /**
  52223. * Specifies that the material will use the light map as a show map.
  52224. */
  52225. protected _useLightmapAsShadowmap: boolean;
  52226. /**
  52227. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52228. * makes the reflect vector face the model (under horizon).
  52229. */
  52230. protected _useHorizonOcclusion: boolean;
  52231. /**
  52232. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52233. * too much the area relying on ambient texture to define their ambient occlusion.
  52234. */
  52235. protected _useRadianceOcclusion: boolean;
  52236. /**
  52237. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52238. */
  52239. protected _useAlphaFromAlbedoTexture: boolean;
  52240. /**
  52241. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52242. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52243. */
  52244. protected _useSpecularOverAlpha: boolean;
  52245. /**
  52246. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52247. */
  52248. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52249. /**
  52250. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52251. */
  52252. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52253. /**
  52254. * Specifies if the metallic texture contains the roughness information in its green channel.
  52255. */
  52256. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52257. /**
  52258. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52259. */
  52260. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52261. /**
  52262. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52263. */
  52264. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52265. /**
  52266. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52267. */
  52268. protected _useAmbientInGrayScale: boolean;
  52269. /**
  52270. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52271. * The material will try to infer what glossiness each pixel should be.
  52272. */
  52273. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52274. /**
  52275. * Defines the falloff type used in this material.
  52276. * It by default is Physical.
  52277. */
  52278. protected _lightFalloff: number;
  52279. /**
  52280. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52281. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52282. */
  52283. protected _useRadianceOverAlpha: boolean;
  52284. /**
  52285. * Allows using an object space normal map (instead of tangent space).
  52286. */
  52287. protected _useObjectSpaceNormalMap: boolean;
  52288. /**
  52289. * Allows using the bump map in parallax mode.
  52290. */
  52291. protected _useParallax: boolean;
  52292. /**
  52293. * Allows using the bump map in parallax occlusion mode.
  52294. */
  52295. protected _useParallaxOcclusion: boolean;
  52296. /**
  52297. * Controls the scale bias of the parallax mode.
  52298. */
  52299. protected _parallaxScaleBias: number;
  52300. /**
  52301. * If sets to true, disables all the lights affecting the material.
  52302. */
  52303. protected _disableLighting: boolean;
  52304. /**
  52305. * Number of Simultaneous lights allowed on the material.
  52306. */
  52307. protected _maxSimultaneousLights: number;
  52308. /**
  52309. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52310. */
  52311. protected _invertNormalMapX: boolean;
  52312. /**
  52313. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52314. */
  52315. protected _invertNormalMapY: boolean;
  52316. /**
  52317. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52318. */
  52319. protected _twoSidedLighting: boolean;
  52320. /**
  52321. * Defines the alpha limits in alpha test mode.
  52322. */
  52323. protected _alphaCutOff: number;
  52324. /**
  52325. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52326. */
  52327. protected _forceAlphaTest: boolean;
  52328. /**
  52329. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52330. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52331. */
  52332. protected _useAlphaFresnel: boolean;
  52333. /**
  52334. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52335. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52336. */
  52337. protected _useLinearAlphaFresnel: boolean;
  52338. /**
  52339. * The transparency mode of the material.
  52340. */
  52341. protected _transparencyMode: Nullable<number>;
  52342. /**
  52343. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52344. * from cos thetav and roughness:
  52345. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52346. */
  52347. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52348. /**
  52349. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52350. */
  52351. protected _forceIrradianceInFragment: boolean;
  52352. /**
  52353. * Force normal to face away from face.
  52354. */
  52355. protected _forceNormalForward: boolean;
  52356. /**
  52357. * Enables specular anti aliasing in the PBR shader.
  52358. * It will both interacts on the Geometry for analytical and IBL lighting.
  52359. * It also prefilter the roughness map based on the bump values.
  52360. */
  52361. protected _enableSpecularAntiAliasing: boolean;
  52362. /**
  52363. * Default configuration related to image processing available in the PBR Material.
  52364. */
  52365. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52366. /**
  52367. * Keep track of the image processing observer to allow dispose and replace.
  52368. */
  52369. private _imageProcessingObserver;
  52370. /**
  52371. * Attaches a new image processing configuration to the PBR Material.
  52372. * @param configuration
  52373. */
  52374. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52375. /**
  52376. * Stores the available render targets.
  52377. */
  52378. private _renderTargets;
  52379. /**
  52380. * Sets the global ambient color for the material used in lighting calculations.
  52381. */
  52382. private _globalAmbientColor;
  52383. /**
  52384. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52385. */
  52386. private _useLogarithmicDepth;
  52387. /**
  52388. * If set to true, no lighting calculations will be applied.
  52389. */
  52390. private _unlit;
  52391. private _debugMode;
  52392. /**
  52393. * @hidden
  52394. * This is reserved for the inspector.
  52395. * Defines the material debug mode.
  52396. * It helps seeing only some components of the material while troubleshooting.
  52397. */
  52398. debugMode: number;
  52399. /**
  52400. * @hidden
  52401. * This is reserved for the inspector.
  52402. * Specify from where on screen the debug mode should start.
  52403. * The value goes from -1 (full screen) to 1 (not visible)
  52404. * It helps with side by side comparison against the final render
  52405. * This defaults to -1
  52406. */
  52407. private debugLimit;
  52408. /**
  52409. * @hidden
  52410. * This is reserved for the inspector.
  52411. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52412. * You can use the factor to better multiply the final value.
  52413. */
  52414. private debugFactor;
  52415. /**
  52416. * Defines the clear coat layer parameters for the material.
  52417. */
  52418. readonly clearCoat: PBRClearCoatConfiguration;
  52419. /**
  52420. * Defines the anisotropic parameters for the material.
  52421. */
  52422. readonly anisotropy: PBRAnisotropicConfiguration;
  52423. /**
  52424. * Defines the BRDF parameters for the material.
  52425. */
  52426. readonly brdf: PBRBRDFConfiguration;
  52427. /**
  52428. * Defines the Sheen parameters for the material.
  52429. */
  52430. readonly sheen: PBRSheenConfiguration;
  52431. /**
  52432. * Defines the SubSurface parameters for the material.
  52433. */
  52434. readonly subSurface: PBRSubSurfaceConfiguration;
  52435. /**
  52436. * Custom callback helping to override the default shader used in the material.
  52437. */
  52438. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  52439. protected _rebuildInParallel: boolean;
  52440. /**
  52441. * Instantiates a new PBRMaterial instance.
  52442. *
  52443. * @param name The material name
  52444. * @param scene The scene the material will be use in.
  52445. */
  52446. constructor(name: string, scene: Scene);
  52447. /**
  52448. * Gets a boolean indicating that current material needs to register RTT
  52449. */
  52450. get hasRenderTargetTextures(): boolean;
  52451. /**
  52452. * Gets the name of the material class.
  52453. */
  52454. getClassName(): string;
  52455. /**
  52456. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52457. */
  52458. get useLogarithmicDepth(): boolean;
  52459. /**
  52460. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52461. */
  52462. set useLogarithmicDepth(value: boolean);
  52463. /**
  52464. * Gets the current transparency mode.
  52465. */
  52466. get transparencyMode(): Nullable<number>;
  52467. /**
  52468. * Sets the transparency mode of the material.
  52469. *
  52470. * | Value | Type | Description |
  52471. * | ----- | ----------------------------------- | ----------- |
  52472. * | 0 | OPAQUE | |
  52473. * | 1 | ALPHATEST | |
  52474. * | 2 | ALPHABLEND | |
  52475. * | 3 | ALPHATESTANDBLEND | |
  52476. *
  52477. */
  52478. set transparencyMode(value: Nullable<number>);
  52479. /**
  52480. * Returns true if alpha blending should be disabled.
  52481. */
  52482. private get _disableAlphaBlending();
  52483. /**
  52484. * Specifies whether or not this material should be rendered in alpha blend mode.
  52485. */
  52486. needAlphaBlending(): boolean;
  52487. /**
  52488. * Specifies if the mesh will require alpha blending.
  52489. * @param mesh - BJS mesh.
  52490. */
  52491. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  52492. /**
  52493. * Specifies whether or not this material should be rendered in alpha test mode.
  52494. */
  52495. needAlphaTesting(): boolean;
  52496. /**
  52497. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52498. */
  52499. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52500. /**
  52501. * Gets the texture used for the alpha test.
  52502. */
  52503. getAlphaTestTexture(): Nullable<BaseTexture>;
  52504. /**
  52505. * Specifies that the submesh is ready to be used.
  52506. * @param mesh - BJS mesh.
  52507. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52508. * @param useInstances - Specifies that instances should be used.
  52509. * @returns - boolean indicating that the submesh is ready or not.
  52510. */
  52511. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52512. /**
  52513. * Specifies if the material uses metallic roughness workflow.
  52514. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52515. */
  52516. isMetallicWorkflow(): boolean;
  52517. private _prepareEffect;
  52518. private _prepareDefines;
  52519. /**
  52520. * Force shader compilation
  52521. */
  52522. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52523. /**
  52524. * Initializes the uniform buffer layout for the shader.
  52525. */
  52526. buildUniformLayout(): void;
  52527. /**
  52528. * Unbinds the material from the mesh
  52529. */
  52530. unbind(): void;
  52531. /**
  52532. * Binds the submesh data.
  52533. * @param world - The world matrix.
  52534. * @param mesh - The BJS mesh.
  52535. * @param subMesh - A submesh of the BJS mesh.
  52536. */
  52537. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52538. /**
  52539. * Returns the animatable textures.
  52540. * @returns - Array of animatable textures.
  52541. */
  52542. getAnimatables(): IAnimatable[];
  52543. /**
  52544. * Returns the texture used for reflections.
  52545. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52546. */
  52547. private _getReflectionTexture;
  52548. /**
  52549. * Returns an array of the actively used textures.
  52550. * @returns - Array of BaseTextures
  52551. */
  52552. getActiveTextures(): BaseTexture[];
  52553. /**
  52554. * Checks to see if a texture is used in the material.
  52555. * @param texture - Base texture to use.
  52556. * @returns - Boolean specifying if a texture is used in the material.
  52557. */
  52558. hasTexture(texture: BaseTexture): boolean;
  52559. /**
  52560. * Disposes the resources of the material.
  52561. * @param forceDisposeEffect - Forces the disposal of effects.
  52562. * @param forceDisposeTextures - Forces the disposal of all textures.
  52563. */
  52564. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52565. }
  52566. }
  52567. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  52568. import { Nullable } from "babylonjs/types";
  52569. import { Scene } from "babylonjs/scene";
  52570. import { Color3 } from "babylonjs/Maths/math.color";
  52571. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  52572. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  52573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52574. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52575. /**
  52576. * The Physically based material of BJS.
  52577. *
  52578. * This offers the main features of a standard PBR material.
  52579. * For more information, please refer to the documentation :
  52580. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52581. */
  52582. export class PBRMaterial extends PBRBaseMaterial {
  52583. /**
  52584. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52585. */
  52586. static readonly PBRMATERIAL_OPAQUE: number;
  52587. /**
  52588. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52589. */
  52590. static readonly PBRMATERIAL_ALPHATEST: number;
  52591. /**
  52592. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52593. */
  52594. static readonly PBRMATERIAL_ALPHABLEND: number;
  52595. /**
  52596. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52597. * They are also discarded below the alpha cutoff threshold to improve performances.
  52598. */
  52599. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52600. /**
  52601. * Defines the default value of how much AO map is occluding the analytical lights
  52602. * (point spot...).
  52603. */
  52604. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52605. /**
  52606. * Intensity of the direct lights e.g. the four lights available in your scene.
  52607. * This impacts both the direct diffuse and specular highlights.
  52608. */
  52609. directIntensity: number;
  52610. /**
  52611. * Intensity of the emissive part of the material.
  52612. * This helps controlling the emissive effect without modifying the emissive color.
  52613. */
  52614. emissiveIntensity: number;
  52615. /**
  52616. * Intensity of the environment e.g. how much the environment will light the object
  52617. * either through harmonics for rough material or through the refelction for shiny ones.
  52618. */
  52619. environmentIntensity: number;
  52620. /**
  52621. * This is a special control allowing the reduction of the specular highlights coming from the
  52622. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52623. */
  52624. specularIntensity: number;
  52625. /**
  52626. * Debug Control allowing disabling the bump map on this material.
  52627. */
  52628. disableBumpMap: boolean;
  52629. /**
  52630. * AKA Diffuse Texture in standard nomenclature.
  52631. */
  52632. albedoTexture: BaseTexture;
  52633. /**
  52634. * AKA Occlusion Texture in other nomenclature.
  52635. */
  52636. ambientTexture: BaseTexture;
  52637. /**
  52638. * AKA Occlusion Texture Intensity in other nomenclature.
  52639. */
  52640. ambientTextureStrength: number;
  52641. /**
  52642. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52643. * 1 means it completely occludes it
  52644. * 0 mean it has no impact
  52645. */
  52646. ambientTextureImpactOnAnalyticalLights: number;
  52647. /**
  52648. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52649. */
  52650. opacityTexture: BaseTexture;
  52651. /**
  52652. * Stores the reflection values in a texture.
  52653. */
  52654. reflectionTexture: Nullable<BaseTexture>;
  52655. /**
  52656. * Stores the emissive values in a texture.
  52657. */
  52658. emissiveTexture: BaseTexture;
  52659. /**
  52660. * AKA Specular texture in other nomenclature.
  52661. */
  52662. reflectivityTexture: BaseTexture;
  52663. /**
  52664. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52665. */
  52666. metallicTexture: BaseTexture;
  52667. /**
  52668. * Specifies the metallic scalar of the metallic/roughness workflow.
  52669. * Can also be used to scale the metalness values of the metallic texture.
  52670. */
  52671. metallic: Nullable<number>;
  52672. /**
  52673. * Specifies the roughness scalar of the metallic/roughness workflow.
  52674. * Can also be used to scale the roughness values of the metallic texture.
  52675. */
  52676. roughness: Nullable<number>;
  52677. /**
  52678. * Specifies the an F0 factor to help configuring the material F0.
  52679. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52680. * to 0.5 the previously hard coded value stays the same.
  52681. * Can also be used to scale the F0 values of the metallic texture.
  52682. */
  52683. metallicF0Factor: number;
  52684. /**
  52685. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52686. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52687. * your expectation as it multiplies with the texture data.
  52688. */
  52689. useMetallicF0FactorFromMetallicTexture: boolean;
  52690. /**
  52691. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52692. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52693. */
  52694. microSurfaceTexture: BaseTexture;
  52695. /**
  52696. * Stores surface normal data used to displace a mesh in a texture.
  52697. */
  52698. bumpTexture: BaseTexture;
  52699. /**
  52700. * Stores the pre-calculated light information of a mesh in a texture.
  52701. */
  52702. lightmapTexture: BaseTexture;
  52703. /**
  52704. * Stores the refracted light information in a texture.
  52705. */
  52706. get refractionTexture(): Nullable<BaseTexture>;
  52707. set refractionTexture(value: Nullable<BaseTexture>);
  52708. /**
  52709. * The color of a material in ambient lighting.
  52710. */
  52711. ambientColor: Color3;
  52712. /**
  52713. * AKA Diffuse Color in other nomenclature.
  52714. */
  52715. albedoColor: Color3;
  52716. /**
  52717. * AKA Specular Color in other nomenclature.
  52718. */
  52719. reflectivityColor: Color3;
  52720. /**
  52721. * The color reflected from the material.
  52722. */
  52723. reflectionColor: Color3;
  52724. /**
  52725. * The color emitted from the material.
  52726. */
  52727. emissiveColor: Color3;
  52728. /**
  52729. * AKA Glossiness in other nomenclature.
  52730. */
  52731. microSurface: number;
  52732. /**
  52733. * source material index of refraction (IOR)' / 'destination material IOR.
  52734. */
  52735. get indexOfRefraction(): number;
  52736. set indexOfRefraction(value: number);
  52737. /**
  52738. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52739. */
  52740. get invertRefractionY(): boolean;
  52741. set invertRefractionY(value: boolean);
  52742. /**
  52743. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52744. * Materials half opaque for instance using refraction could benefit from this control.
  52745. */
  52746. get linkRefractionWithTransparency(): boolean;
  52747. set linkRefractionWithTransparency(value: boolean);
  52748. /**
  52749. * If true, the light map contains occlusion information instead of lighting info.
  52750. */
  52751. useLightmapAsShadowmap: boolean;
  52752. /**
  52753. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52754. */
  52755. useAlphaFromAlbedoTexture: boolean;
  52756. /**
  52757. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52758. */
  52759. forceAlphaTest: boolean;
  52760. /**
  52761. * Defines the alpha limits in alpha test mode.
  52762. */
  52763. alphaCutOff: number;
  52764. /**
  52765. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52766. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52767. */
  52768. useSpecularOverAlpha: boolean;
  52769. /**
  52770. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52771. */
  52772. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52773. /**
  52774. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52775. */
  52776. useRoughnessFromMetallicTextureAlpha: boolean;
  52777. /**
  52778. * Specifies if the metallic texture contains the roughness information in its green channel.
  52779. */
  52780. useRoughnessFromMetallicTextureGreen: boolean;
  52781. /**
  52782. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52783. */
  52784. useMetallnessFromMetallicTextureBlue: boolean;
  52785. /**
  52786. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52787. */
  52788. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52789. /**
  52790. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52791. */
  52792. useAmbientInGrayScale: boolean;
  52793. /**
  52794. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52795. * The material will try to infer what glossiness each pixel should be.
  52796. */
  52797. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52798. /**
  52799. * BJS is using an harcoded light falloff based on a manually sets up range.
  52800. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52801. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52802. */
  52803. get usePhysicalLightFalloff(): boolean;
  52804. /**
  52805. * BJS is using an harcoded light falloff based on a manually sets up range.
  52806. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52807. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52808. */
  52809. set usePhysicalLightFalloff(value: boolean);
  52810. /**
  52811. * In order to support the falloff compatibility with gltf, a special mode has been added
  52812. * to reproduce the gltf light falloff.
  52813. */
  52814. get useGLTFLightFalloff(): boolean;
  52815. /**
  52816. * In order to support the falloff compatibility with gltf, a special mode has been added
  52817. * to reproduce the gltf light falloff.
  52818. */
  52819. set useGLTFLightFalloff(value: boolean);
  52820. /**
  52821. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52822. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52823. */
  52824. useRadianceOverAlpha: boolean;
  52825. /**
  52826. * Allows using an object space normal map (instead of tangent space).
  52827. */
  52828. useObjectSpaceNormalMap: boolean;
  52829. /**
  52830. * Allows using the bump map in parallax mode.
  52831. */
  52832. useParallax: boolean;
  52833. /**
  52834. * Allows using the bump map in parallax occlusion mode.
  52835. */
  52836. useParallaxOcclusion: boolean;
  52837. /**
  52838. * Controls the scale bias of the parallax mode.
  52839. */
  52840. parallaxScaleBias: number;
  52841. /**
  52842. * If sets to true, disables all the lights affecting the material.
  52843. */
  52844. disableLighting: boolean;
  52845. /**
  52846. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52847. */
  52848. forceIrradianceInFragment: boolean;
  52849. /**
  52850. * Number of Simultaneous lights allowed on the material.
  52851. */
  52852. maxSimultaneousLights: number;
  52853. /**
  52854. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52855. */
  52856. invertNormalMapX: boolean;
  52857. /**
  52858. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52859. */
  52860. invertNormalMapY: boolean;
  52861. /**
  52862. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52863. */
  52864. twoSidedLighting: boolean;
  52865. /**
  52866. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52867. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52868. */
  52869. useAlphaFresnel: boolean;
  52870. /**
  52871. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52872. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52873. */
  52874. useLinearAlphaFresnel: boolean;
  52875. /**
  52876. * Let user defines the brdf lookup texture used for IBL.
  52877. * A default 8bit version is embedded but you could point at :
  52878. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52879. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52880. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52881. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52882. */
  52883. environmentBRDFTexture: Nullable<BaseTexture>;
  52884. /**
  52885. * Force normal to face away from face.
  52886. */
  52887. forceNormalForward: boolean;
  52888. /**
  52889. * Enables specular anti aliasing in the PBR shader.
  52890. * It will both interacts on the Geometry for analytical and IBL lighting.
  52891. * It also prefilter the roughness map based on the bump values.
  52892. */
  52893. enableSpecularAntiAliasing: boolean;
  52894. /**
  52895. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52896. * makes the reflect vector face the model (under horizon).
  52897. */
  52898. useHorizonOcclusion: boolean;
  52899. /**
  52900. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52901. * too much the area relying on ambient texture to define their ambient occlusion.
  52902. */
  52903. useRadianceOcclusion: boolean;
  52904. /**
  52905. * If set to true, no lighting calculations will be applied.
  52906. */
  52907. unlit: boolean;
  52908. /**
  52909. * Gets the image processing configuration used either in this material.
  52910. */
  52911. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52912. /**
  52913. * Sets the Default image processing configuration used either in the this material.
  52914. *
  52915. * If sets to null, the scene one is in use.
  52916. */
  52917. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52918. /**
  52919. * Gets wether the color curves effect is enabled.
  52920. */
  52921. get cameraColorCurvesEnabled(): boolean;
  52922. /**
  52923. * Sets wether the color curves effect is enabled.
  52924. */
  52925. set cameraColorCurvesEnabled(value: boolean);
  52926. /**
  52927. * Gets wether the color grading effect is enabled.
  52928. */
  52929. get cameraColorGradingEnabled(): boolean;
  52930. /**
  52931. * Gets wether the color grading effect is enabled.
  52932. */
  52933. set cameraColorGradingEnabled(value: boolean);
  52934. /**
  52935. * Gets wether tonemapping is enabled or not.
  52936. */
  52937. get cameraToneMappingEnabled(): boolean;
  52938. /**
  52939. * Sets wether tonemapping is enabled or not
  52940. */
  52941. set cameraToneMappingEnabled(value: boolean);
  52942. /**
  52943. * The camera exposure used on this material.
  52944. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52945. * This corresponds to a photographic exposure.
  52946. */
  52947. get cameraExposure(): number;
  52948. /**
  52949. * The camera exposure used on this material.
  52950. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52951. * This corresponds to a photographic exposure.
  52952. */
  52953. set cameraExposure(value: number);
  52954. /**
  52955. * Gets The camera contrast used on this material.
  52956. */
  52957. get cameraContrast(): number;
  52958. /**
  52959. * Sets The camera contrast used on this material.
  52960. */
  52961. set cameraContrast(value: number);
  52962. /**
  52963. * Gets the Color Grading 2D Lookup Texture.
  52964. */
  52965. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52966. /**
  52967. * Sets the Color Grading 2D Lookup Texture.
  52968. */
  52969. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52970. /**
  52971. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52972. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52973. * 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;
  52974. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52975. */
  52976. get cameraColorCurves(): Nullable<ColorCurves>;
  52977. /**
  52978. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52979. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52980. * 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;
  52981. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52982. */
  52983. set cameraColorCurves(value: Nullable<ColorCurves>);
  52984. /**
  52985. * Instantiates a new PBRMaterial instance.
  52986. *
  52987. * @param name The material name
  52988. * @param scene The scene the material will be use in.
  52989. */
  52990. constructor(name: string, scene: Scene);
  52991. /**
  52992. * Returns the name of this material class.
  52993. */
  52994. getClassName(): string;
  52995. /**
  52996. * Makes a duplicate of the current material.
  52997. * @param name - name to use for the new material.
  52998. */
  52999. clone(name: string): PBRMaterial;
  53000. /**
  53001. * Serializes this PBR Material.
  53002. * @returns - An object with the serialized material.
  53003. */
  53004. serialize(): any;
  53005. /**
  53006. * Parses a PBR Material from a serialized object.
  53007. * @param source - Serialized object.
  53008. * @param scene - BJS scene instance.
  53009. * @param rootUrl - url for the scene object
  53010. * @returns - PBRMaterial
  53011. */
  53012. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53013. }
  53014. }
  53015. declare module "babylonjs/Misc/dds" {
  53016. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53017. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53018. import { Nullable } from "babylonjs/types";
  53019. import { Scene } from "babylonjs/scene";
  53020. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53021. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53022. /**
  53023. * Direct draw surface info
  53024. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53025. */
  53026. export interface DDSInfo {
  53027. /**
  53028. * Width of the texture
  53029. */
  53030. width: number;
  53031. /**
  53032. * Width of the texture
  53033. */
  53034. height: number;
  53035. /**
  53036. * Number of Mipmaps for the texture
  53037. * @see https://en.wikipedia.org/wiki/Mipmap
  53038. */
  53039. mipmapCount: number;
  53040. /**
  53041. * If the textures format is a known fourCC format
  53042. * @see https://www.fourcc.org/
  53043. */
  53044. isFourCC: boolean;
  53045. /**
  53046. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53047. */
  53048. isRGB: boolean;
  53049. /**
  53050. * If the texture is a lumincance format
  53051. */
  53052. isLuminance: boolean;
  53053. /**
  53054. * If this is a cube texture
  53055. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53056. */
  53057. isCube: boolean;
  53058. /**
  53059. * If the texture is a compressed format eg. FOURCC_DXT1
  53060. */
  53061. isCompressed: boolean;
  53062. /**
  53063. * The dxgiFormat of the texture
  53064. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53065. */
  53066. dxgiFormat: number;
  53067. /**
  53068. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  53069. */
  53070. textureType: number;
  53071. /**
  53072. * Sphericle polynomial created for the dds texture
  53073. */
  53074. sphericalPolynomial?: SphericalPolynomial;
  53075. }
  53076. /**
  53077. * Class used to provide DDS decompression tools
  53078. */
  53079. export class DDSTools {
  53080. /**
  53081. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  53082. */
  53083. static StoreLODInAlphaChannel: boolean;
  53084. /**
  53085. * Gets DDS information from an array buffer
  53086. * @param arrayBuffer defines the array buffer to read data from
  53087. * @returns the DDS information
  53088. */
  53089. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  53090. private static _FloatView;
  53091. private static _Int32View;
  53092. private static _ToHalfFloat;
  53093. private static _FromHalfFloat;
  53094. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  53095. private static _GetHalfFloatRGBAArrayBuffer;
  53096. private static _GetFloatRGBAArrayBuffer;
  53097. private static _GetFloatAsUIntRGBAArrayBuffer;
  53098. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  53099. private static _GetRGBAArrayBuffer;
  53100. private static _ExtractLongWordOrder;
  53101. private static _GetRGBArrayBuffer;
  53102. private static _GetLuminanceArrayBuffer;
  53103. /**
  53104. * Uploads DDS Levels to a Babylon Texture
  53105. * @hidden
  53106. */
  53107. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  53108. }
  53109. module "babylonjs/Engines/thinEngine" {
  53110. interface ThinEngine {
  53111. /**
  53112. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  53113. * @param rootUrl defines the url where the file to load is located
  53114. * @param scene defines the current scene
  53115. * @param lodScale defines scale to apply to the mip map selection
  53116. * @param lodOffset defines offset to apply to the mip map selection
  53117. * @param onLoad defines an optional callback raised when the texture is loaded
  53118. * @param onError defines an optional callback raised if there is an issue to load the texture
  53119. * @param format defines the format of the data
  53120. * @param forcedExtension defines the extension to use to pick the right loader
  53121. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  53122. * @returns the cube texture as an InternalTexture
  53123. */
  53124. 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;
  53125. }
  53126. }
  53127. }
  53128. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  53129. import { Nullable } from "babylonjs/types";
  53130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53131. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53132. /**
  53133. * Implementation of the DDS Texture Loader.
  53134. * @hidden
  53135. */
  53136. export class _DDSTextureLoader implements IInternalTextureLoader {
  53137. /**
  53138. * Defines wether the loader supports cascade loading the different faces.
  53139. */
  53140. readonly supportCascades: boolean;
  53141. /**
  53142. * This returns if the loader support the current file information.
  53143. * @param extension defines the file extension of the file being loaded
  53144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53145. * @param fallback defines the fallback internal texture if any
  53146. * @param isBase64 defines whether the texture is encoded as a base64
  53147. * @param isBuffer defines whether the texture data are stored as a buffer
  53148. * @returns true if the loader can load the specified file
  53149. */
  53150. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53151. /**
  53152. * Transform the url before loading if required.
  53153. * @param rootUrl the url of the texture
  53154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53155. * @returns the transformed texture
  53156. */
  53157. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53158. /**
  53159. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53160. * @param rootUrl the url of the texture
  53161. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53162. * @returns the fallback texture
  53163. */
  53164. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53165. /**
  53166. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53167. * @param data contains the texture data
  53168. * @param texture defines the BabylonJS internal texture
  53169. * @param createPolynomials will be true if polynomials have been requested
  53170. * @param onLoad defines the callback to trigger once the texture is ready
  53171. * @param onError defines the callback to trigger in case of error
  53172. */
  53173. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53174. /**
  53175. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53176. * @param data contains the texture data
  53177. * @param texture defines the BabylonJS internal texture
  53178. * @param callback defines the method to call once ready to upload
  53179. */
  53180. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53181. }
  53182. }
  53183. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  53184. import { Nullable } from "babylonjs/types";
  53185. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53186. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53187. /**
  53188. * Implementation of the ENV Texture Loader.
  53189. * @hidden
  53190. */
  53191. export class _ENVTextureLoader implements IInternalTextureLoader {
  53192. /**
  53193. * Defines wether the loader supports cascade loading the different faces.
  53194. */
  53195. readonly supportCascades: boolean;
  53196. /**
  53197. * This returns if the loader support the current file information.
  53198. * @param extension defines the file extension of the file being loaded
  53199. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53200. * @param fallback defines the fallback internal texture if any
  53201. * @param isBase64 defines whether the texture is encoded as a base64
  53202. * @param isBuffer defines whether the texture data are stored as a buffer
  53203. * @returns true if the loader can load the specified file
  53204. */
  53205. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53206. /**
  53207. * Transform the url before loading if required.
  53208. * @param rootUrl the url of the texture
  53209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53210. * @returns the transformed texture
  53211. */
  53212. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53213. /**
  53214. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53215. * @param rootUrl the url of the texture
  53216. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53217. * @returns the fallback texture
  53218. */
  53219. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53220. /**
  53221. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53222. * @param data contains the texture data
  53223. * @param texture defines the BabylonJS internal texture
  53224. * @param createPolynomials will be true if polynomials have been requested
  53225. * @param onLoad defines the callback to trigger once the texture is ready
  53226. * @param onError defines the callback to trigger in case of error
  53227. */
  53228. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53229. /**
  53230. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53231. * @param data contains the texture data
  53232. * @param texture defines the BabylonJS internal texture
  53233. * @param callback defines the method to call once ready to upload
  53234. */
  53235. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53236. }
  53237. }
  53238. declare module "babylonjs/Misc/khronosTextureContainer" {
  53239. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53240. /**
  53241. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53242. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53243. */
  53244. export class KhronosTextureContainer {
  53245. /** contents of the KTX container file */
  53246. arrayBuffer: any;
  53247. private static HEADER_LEN;
  53248. private static COMPRESSED_2D;
  53249. private static COMPRESSED_3D;
  53250. private static TEX_2D;
  53251. private static TEX_3D;
  53252. /**
  53253. * Gets the openGL type
  53254. */
  53255. glType: number;
  53256. /**
  53257. * Gets the openGL type size
  53258. */
  53259. glTypeSize: number;
  53260. /**
  53261. * Gets the openGL format
  53262. */
  53263. glFormat: number;
  53264. /**
  53265. * Gets the openGL internal format
  53266. */
  53267. glInternalFormat: number;
  53268. /**
  53269. * Gets the base internal format
  53270. */
  53271. glBaseInternalFormat: number;
  53272. /**
  53273. * Gets image width in pixel
  53274. */
  53275. pixelWidth: number;
  53276. /**
  53277. * Gets image height in pixel
  53278. */
  53279. pixelHeight: number;
  53280. /**
  53281. * Gets image depth in pixels
  53282. */
  53283. pixelDepth: number;
  53284. /**
  53285. * Gets the number of array elements
  53286. */
  53287. numberOfArrayElements: number;
  53288. /**
  53289. * Gets the number of faces
  53290. */
  53291. numberOfFaces: number;
  53292. /**
  53293. * Gets the number of mipmap levels
  53294. */
  53295. numberOfMipmapLevels: number;
  53296. /**
  53297. * Gets the bytes of key value data
  53298. */
  53299. bytesOfKeyValueData: number;
  53300. /**
  53301. * Gets the load type
  53302. */
  53303. loadType: number;
  53304. /**
  53305. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53306. */
  53307. isInvalid: boolean;
  53308. /**
  53309. * Creates a new KhronosTextureContainer
  53310. * @param arrayBuffer contents of the KTX container file
  53311. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53312. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53313. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53314. */
  53315. constructor(
  53316. /** contents of the KTX container file */
  53317. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53318. /**
  53319. * Uploads KTX content to a Babylon Texture.
  53320. * It is assumed that the texture has already been created & is currently bound
  53321. * @hidden
  53322. */
  53323. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53324. private _upload2DCompressedLevels;
  53325. }
  53326. }
  53327. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  53328. import { Nullable } from "babylonjs/types";
  53329. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53330. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53331. /**
  53332. * Implementation of the KTX Texture Loader.
  53333. * @hidden
  53334. */
  53335. export class _KTXTextureLoader implements IInternalTextureLoader {
  53336. /**
  53337. * Defines wether the loader supports cascade loading the different faces.
  53338. */
  53339. readonly supportCascades: boolean;
  53340. /**
  53341. * This returns if the loader support the current file information.
  53342. * @param extension defines the file extension of the file being loaded
  53343. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53344. * @param fallback defines the fallback internal texture if any
  53345. * @param isBase64 defines whether the texture is encoded as a base64
  53346. * @param isBuffer defines whether the texture data are stored as a buffer
  53347. * @returns true if the loader can load the specified file
  53348. */
  53349. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53350. /**
  53351. * Transform the url before loading if required.
  53352. * @param rootUrl the url of the texture
  53353. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53354. * @returns the transformed texture
  53355. */
  53356. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53357. /**
  53358. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53359. * @param rootUrl the url of the texture
  53360. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53361. * @returns the fallback texture
  53362. */
  53363. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53364. /**
  53365. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53366. * @param data contains the texture data
  53367. * @param texture defines the BabylonJS internal texture
  53368. * @param createPolynomials will be true if polynomials have been requested
  53369. * @param onLoad defines the callback to trigger once the texture is ready
  53370. * @param onError defines the callback to trigger in case of error
  53371. */
  53372. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53373. /**
  53374. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53375. * @param data contains the texture data
  53376. * @param texture defines the BabylonJS internal texture
  53377. * @param callback defines the method to call once ready to upload
  53378. */
  53379. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53380. }
  53381. }
  53382. declare module "babylonjs/Helpers/sceneHelpers" {
  53383. import { Nullable } from "babylonjs/types";
  53384. import { Mesh } from "babylonjs/Meshes/mesh";
  53385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53386. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  53387. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  53388. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53389. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53390. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53391. import "babylonjs/Meshes/Builders/boxBuilder";
  53392. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  53393. /** @hidden */
  53394. export var _forceSceneHelpersToBundle: boolean;
  53395. module "babylonjs/scene" {
  53396. interface Scene {
  53397. /**
  53398. * Creates a default light for the scene.
  53399. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53400. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53401. */
  53402. createDefaultLight(replace?: boolean): void;
  53403. /**
  53404. * Creates a default camera for the scene.
  53405. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53406. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53407. * @param replace has default false, when true replaces the active camera in the scene
  53408. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53409. */
  53410. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53411. /**
  53412. * Creates a default camera and a default light.
  53413. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53414. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53415. * @param replace has the default false, when true replaces the active camera/light in the scene
  53416. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53417. */
  53418. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53419. /**
  53420. * Creates a new sky box
  53421. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53422. * @param environmentTexture defines the texture to use as environment texture
  53423. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53424. * @param scale defines the overall scale of the skybox
  53425. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53426. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53427. * @returns a new mesh holding the sky box
  53428. */
  53429. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53430. /**
  53431. * Creates a new environment
  53432. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53433. * @param options defines the options you can use to configure the environment
  53434. * @returns the new EnvironmentHelper
  53435. */
  53436. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53437. /**
  53438. * Creates a new VREXperienceHelper
  53439. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53440. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53441. * @returns a new VREXperienceHelper
  53442. */
  53443. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53444. /**
  53445. * Creates a new WebXRDefaultExperience
  53446. * @see http://doc.babylonjs.com/how_to/webxr
  53447. * @param options experience options
  53448. * @returns a promise for a new WebXRDefaultExperience
  53449. */
  53450. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53451. }
  53452. }
  53453. }
  53454. declare module "babylonjs/Helpers/videoDome" {
  53455. import { Scene } from "babylonjs/scene";
  53456. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53457. import { Mesh } from "babylonjs/Meshes/mesh";
  53458. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  53459. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  53460. import "babylonjs/Meshes/Builders/sphereBuilder";
  53461. /**
  53462. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53463. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53464. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53465. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53466. */
  53467. export class VideoDome extends TransformNode {
  53468. /**
  53469. * Define the video source as a Monoscopic panoramic 360 video.
  53470. */
  53471. static readonly MODE_MONOSCOPIC: number;
  53472. /**
  53473. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53474. */
  53475. static readonly MODE_TOPBOTTOM: number;
  53476. /**
  53477. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53478. */
  53479. static readonly MODE_SIDEBYSIDE: number;
  53480. private _halfDome;
  53481. private _useDirectMapping;
  53482. /**
  53483. * The video texture being displayed on the sphere
  53484. */
  53485. protected _videoTexture: VideoTexture;
  53486. /**
  53487. * Gets the video texture being displayed on the sphere
  53488. */
  53489. get videoTexture(): VideoTexture;
  53490. /**
  53491. * The skybox material
  53492. */
  53493. protected _material: BackgroundMaterial;
  53494. /**
  53495. * The surface used for the skybox
  53496. */
  53497. protected _mesh: Mesh;
  53498. /**
  53499. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53500. */
  53501. private _halfDomeMask;
  53502. /**
  53503. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53504. * Also see the options.resolution property.
  53505. */
  53506. get fovMultiplier(): number;
  53507. set fovMultiplier(value: number);
  53508. private _videoMode;
  53509. /**
  53510. * Gets or set the current video mode for the video. It can be:
  53511. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53512. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53513. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53514. */
  53515. get videoMode(): number;
  53516. set videoMode(value: number);
  53517. /**
  53518. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53519. *
  53520. */
  53521. get halfDome(): boolean;
  53522. /**
  53523. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53524. */
  53525. set halfDome(enabled: boolean);
  53526. /**
  53527. * Oberserver used in Stereoscopic VR Mode.
  53528. */
  53529. private _onBeforeCameraRenderObserver;
  53530. /**
  53531. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53532. * @param name Element's name, child elements will append suffixes for their own names.
  53533. * @param urlsOrVideo defines the url(s) or the video element to use
  53534. * @param options An object containing optional or exposed sub element properties
  53535. */
  53536. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53537. resolution?: number;
  53538. clickToPlay?: boolean;
  53539. autoPlay?: boolean;
  53540. loop?: boolean;
  53541. size?: number;
  53542. poster?: string;
  53543. faceForward?: boolean;
  53544. useDirectMapping?: boolean;
  53545. halfDomeMode?: boolean;
  53546. }, scene: Scene);
  53547. private _changeVideoMode;
  53548. /**
  53549. * Releases resources associated with this node.
  53550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53552. */
  53553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53554. }
  53555. }
  53556. declare module "babylonjs/Helpers/index" {
  53557. export * from "babylonjs/Helpers/environmentHelper";
  53558. export * from "babylonjs/Helpers/photoDome";
  53559. export * from "babylonjs/Helpers/sceneHelpers";
  53560. export * from "babylonjs/Helpers/videoDome";
  53561. }
  53562. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  53563. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53564. import { IDisposable } from "babylonjs/scene";
  53565. import { Engine } from "babylonjs/Engines/engine";
  53566. /**
  53567. * This class can be used to get instrumentation data from a Babylon engine
  53568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53569. */
  53570. export class EngineInstrumentation implements IDisposable {
  53571. /**
  53572. * Define the instrumented engine.
  53573. */
  53574. engine: Engine;
  53575. private _captureGPUFrameTime;
  53576. private _gpuFrameTimeToken;
  53577. private _gpuFrameTime;
  53578. private _captureShaderCompilationTime;
  53579. private _shaderCompilationTime;
  53580. private _onBeginFrameObserver;
  53581. private _onEndFrameObserver;
  53582. private _onBeforeShaderCompilationObserver;
  53583. private _onAfterShaderCompilationObserver;
  53584. /**
  53585. * Gets the perf counter used for GPU frame time
  53586. */
  53587. get gpuFrameTimeCounter(): PerfCounter;
  53588. /**
  53589. * Gets the GPU frame time capture status
  53590. */
  53591. get captureGPUFrameTime(): boolean;
  53592. /**
  53593. * Enable or disable the GPU frame time capture
  53594. */
  53595. set captureGPUFrameTime(value: boolean);
  53596. /**
  53597. * Gets the perf counter used for shader compilation time
  53598. */
  53599. get shaderCompilationTimeCounter(): PerfCounter;
  53600. /**
  53601. * Gets the shader compilation time capture status
  53602. */
  53603. get captureShaderCompilationTime(): boolean;
  53604. /**
  53605. * Enable or disable the shader compilation time capture
  53606. */
  53607. set captureShaderCompilationTime(value: boolean);
  53608. /**
  53609. * Instantiates a new engine instrumentation.
  53610. * This class can be used to get instrumentation data from a Babylon engine
  53611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53612. * @param engine Defines the engine to instrument
  53613. */
  53614. constructor(
  53615. /**
  53616. * Define the instrumented engine.
  53617. */
  53618. engine: Engine);
  53619. /**
  53620. * Dispose and release associated resources.
  53621. */
  53622. dispose(): void;
  53623. }
  53624. }
  53625. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  53626. import { Scene, IDisposable } from "babylonjs/scene";
  53627. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53628. /**
  53629. * This class can be used to get instrumentation data from a Babylon engine
  53630. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53631. */
  53632. export class SceneInstrumentation implements IDisposable {
  53633. /**
  53634. * Defines the scene to instrument
  53635. */
  53636. scene: Scene;
  53637. private _captureActiveMeshesEvaluationTime;
  53638. private _activeMeshesEvaluationTime;
  53639. private _captureRenderTargetsRenderTime;
  53640. private _renderTargetsRenderTime;
  53641. private _captureFrameTime;
  53642. private _frameTime;
  53643. private _captureRenderTime;
  53644. private _renderTime;
  53645. private _captureInterFrameTime;
  53646. private _interFrameTime;
  53647. private _captureParticlesRenderTime;
  53648. private _particlesRenderTime;
  53649. private _captureSpritesRenderTime;
  53650. private _spritesRenderTime;
  53651. private _capturePhysicsTime;
  53652. private _physicsTime;
  53653. private _captureAnimationsTime;
  53654. private _animationsTime;
  53655. private _captureCameraRenderTime;
  53656. private _cameraRenderTime;
  53657. private _onBeforeActiveMeshesEvaluationObserver;
  53658. private _onAfterActiveMeshesEvaluationObserver;
  53659. private _onBeforeRenderTargetsRenderObserver;
  53660. private _onAfterRenderTargetsRenderObserver;
  53661. private _onAfterRenderObserver;
  53662. private _onBeforeDrawPhaseObserver;
  53663. private _onAfterDrawPhaseObserver;
  53664. private _onBeforeAnimationsObserver;
  53665. private _onBeforeParticlesRenderingObserver;
  53666. private _onAfterParticlesRenderingObserver;
  53667. private _onBeforeSpritesRenderingObserver;
  53668. private _onAfterSpritesRenderingObserver;
  53669. private _onBeforePhysicsObserver;
  53670. private _onAfterPhysicsObserver;
  53671. private _onAfterAnimationsObserver;
  53672. private _onBeforeCameraRenderObserver;
  53673. private _onAfterCameraRenderObserver;
  53674. /**
  53675. * Gets the perf counter used for active meshes evaluation time
  53676. */
  53677. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53678. /**
  53679. * Gets the active meshes evaluation time capture status
  53680. */
  53681. get captureActiveMeshesEvaluationTime(): boolean;
  53682. /**
  53683. * Enable or disable the active meshes evaluation time capture
  53684. */
  53685. set captureActiveMeshesEvaluationTime(value: boolean);
  53686. /**
  53687. * Gets the perf counter used for render targets render time
  53688. */
  53689. get renderTargetsRenderTimeCounter(): PerfCounter;
  53690. /**
  53691. * Gets the render targets render time capture status
  53692. */
  53693. get captureRenderTargetsRenderTime(): boolean;
  53694. /**
  53695. * Enable or disable the render targets render time capture
  53696. */
  53697. set captureRenderTargetsRenderTime(value: boolean);
  53698. /**
  53699. * Gets the perf counter used for particles render time
  53700. */
  53701. get particlesRenderTimeCounter(): PerfCounter;
  53702. /**
  53703. * Gets the particles render time capture status
  53704. */
  53705. get captureParticlesRenderTime(): boolean;
  53706. /**
  53707. * Enable or disable the particles render time capture
  53708. */
  53709. set captureParticlesRenderTime(value: boolean);
  53710. /**
  53711. * Gets the perf counter used for sprites render time
  53712. */
  53713. get spritesRenderTimeCounter(): PerfCounter;
  53714. /**
  53715. * Gets the sprites render time capture status
  53716. */
  53717. get captureSpritesRenderTime(): boolean;
  53718. /**
  53719. * Enable or disable the sprites render time capture
  53720. */
  53721. set captureSpritesRenderTime(value: boolean);
  53722. /**
  53723. * Gets the perf counter used for physics time
  53724. */
  53725. get physicsTimeCounter(): PerfCounter;
  53726. /**
  53727. * Gets the physics time capture status
  53728. */
  53729. get capturePhysicsTime(): boolean;
  53730. /**
  53731. * Enable or disable the physics time capture
  53732. */
  53733. set capturePhysicsTime(value: boolean);
  53734. /**
  53735. * Gets the perf counter used for animations time
  53736. */
  53737. get animationsTimeCounter(): PerfCounter;
  53738. /**
  53739. * Gets the animations time capture status
  53740. */
  53741. get captureAnimationsTime(): boolean;
  53742. /**
  53743. * Enable or disable the animations time capture
  53744. */
  53745. set captureAnimationsTime(value: boolean);
  53746. /**
  53747. * Gets the perf counter used for frame time capture
  53748. */
  53749. get frameTimeCounter(): PerfCounter;
  53750. /**
  53751. * Gets the frame time capture status
  53752. */
  53753. get captureFrameTime(): boolean;
  53754. /**
  53755. * Enable or disable the frame time capture
  53756. */
  53757. set captureFrameTime(value: boolean);
  53758. /**
  53759. * Gets the perf counter used for inter-frames time capture
  53760. */
  53761. get interFrameTimeCounter(): PerfCounter;
  53762. /**
  53763. * Gets the inter-frames time capture status
  53764. */
  53765. get captureInterFrameTime(): boolean;
  53766. /**
  53767. * Enable or disable the inter-frames time capture
  53768. */
  53769. set captureInterFrameTime(value: boolean);
  53770. /**
  53771. * Gets the perf counter used for render time capture
  53772. */
  53773. get renderTimeCounter(): PerfCounter;
  53774. /**
  53775. * Gets the render time capture status
  53776. */
  53777. get captureRenderTime(): boolean;
  53778. /**
  53779. * Enable or disable the render time capture
  53780. */
  53781. set captureRenderTime(value: boolean);
  53782. /**
  53783. * Gets the perf counter used for camera render time capture
  53784. */
  53785. get cameraRenderTimeCounter(): PerfCounter;
  53786. /**
  53787. * Gets the camera render time capture status
  53788. */
  53789. get captureCameraRenderTime(): boolean;
  53790. /**
  53791. * Enable or disable the camera render time capture
  53792. */
  53793. set captureCameraRenderTime(value: boolean);
  53794. /**
  53795. * Gets the perf counter used for draw calls
  53796. */
  53797. get drawCallsCounter(): PerfCounter;
  53798. /**
  53799. * Instantiates a new scene instrumentation.
  53800. * This class can be used to get instrumentation data from a Babylon engine
  53801. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53802. * @param scene Defines the scene to instrument
  53803. */
  53804. constructor(
  53805. /**
  53806. * Defines the scene to instrument
  53807. */
  53808. scene: Scene);
  53809. /**
  53810. * Dispose and release associated resources.
  53811. */
  53812. dispose(): void;
  53813. }
  53814. }
  53815. declare module "babylonjs/Instrumentation/index" {
  53816. export * from "babylonjs/Instrumentation/engineInstrumentation";
  53817. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  53818. export * from "babylonjs/Instrumentation/timeToken";
  53819. }
  53820. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  53821. /** @hidden */
  53822. export var glowMapGenerationPixelShader: {
  53823. name: string;
  53824. shader: string;
  53825. };
  53826. }
  53827. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  53828. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53829. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53830. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53831. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53832. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53833. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53834. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53835. /** @hidden */
  53836. export var glowMapGenerationVertexShader: {
  53837. name: string;
  53838. shader: string;
  53839. };
  53840. }
  53841. declare module "babylonjs/Layers/effectLayer" {
  53842. import { Observable } from "babylonjs/Misc/observable";
  53843. import { Nullable } from "babylonjs/types";
  53844. import { Camera } from "babylonjs/Cameras/camera";
  53845. import { Scene } from "babylonjs/scene";
  53846. import { ISize } from "babylonjs/Maths/math.size";
  53847. import { Color4 } from "babylonjs/Maths/math.color";
  53848. import { Engine } from "babylonjs/Engines/engine";
  53849. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53851. import { Mesh } from "babylonjs/Meshes/mesh";
  53852. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53854. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53855. import { Effect } from "babylonjs/Materials/effect";
  53856. import { Material } from "babylonjs/Materials/material";
  53857. import "babylonjs/Shaders/glowMapGeneration.fragment";
  53858. import "babylonjs/Shaders/glowMapGeneration.vertex";
  53859. /**
  53860. * Effect layer options. This helps customizing the behaviour
  53861. * of the effect layer.
  53862. */
  53863. export interface IEffectLayerOptions {
  53864. /**
  53865. * Multiplication factor apply to the canvas size to compute the render target size
  53866. * used to generated the objects (the smaller the faster).
  53867. */
  53868. mainTextureRatio: number;
  53869. /**
  53870. * Enforces a fixed size texture to ensure effect stability across devices.
  53871. */
  53872. mainTextureFixedSize?: number;
  53873. /**
  53874. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53875. */
  53876. alphaBlendingMode: number;
  53877. /**
  53878. * The camera attached to the layer.
  53879. */
  53880. camera: Nullable<Camera>;
  53881. /**
  53882. * The rendering group to draw the layer in.
  53883. */
  53884. renderingGroupId: number;
  53885. }
  53886. /**
  53887. * The effect layer Helps adding post process effect blended with the main pass.
  53888. *
  53889. * This can be for instance use to generate glow or higlight effects on the scene.
  53890. *
  53891. * The effect layer class can not be used directly and is intented to inherited from to be
  53892. * customized per effects.
  53893. */
  53894. export abstract class EffectLayer {
  53895. private _vertexBuffers;
  53896. private _indexBuffer;
  53897. private _cachedDefines;
  53898. private _effectLayerMapGenerationEffect;
  53899. private _effectLayerOptions;
  53900. private _mergeEffect;
  53901. protected _scene: Scene;
  53902. protected _engine: Engine;
  53903. protected _maxSize: number;
  53904. protected _mainTextureDesiredSize: ISize;
  53905. protected _mainTexture: RenderTargetTexture;
  53906. protected _shouldRender: boolean;
  53907. protected _postProcesses: PostProcess[];
  53908. protected _textures: BaseTexture[];
  53909. protected _emissiveTextureAndColor: {
  53910. texture: Nullable<BaseTexture>;
  53911. color: Color4;
  53912. };
  53913. /**
  53914. * The name of the layer
  53915. */
  53916. name: string;
  53917. /**
  53918. * The clear color of the texture used to generate the glow map.
  53919. */
  53920. neutralColor: Color4;
  53921. /**
  53922. * Specifies wether the highlight layer is enabled or not.
  53923. */
  53924. isEnabled: boolean;
  53925. /**
  53926. * Gets the camera attached to the layer.
  53927. */
  53928. get camera(): Nullable<Camera>;
  53929. /**
  53930. * Gets the rendering group id the layer should render in.
  53931. */
  53932. get renderingGroupId(): number;
  53933. set renderingGroupId(renderingGroupId: number);
  53934. /**
  53935. * An event triggered when the effect layer has been disposed.
  53936. */
  53937. onDisposeObservable: Observable<EffectLayer>;
  53938. /**
  53939. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53940. */
  53941. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53942. /**
  53943. * An event triggered when the generated texture is being merged in the scene.
  53944. */
  53945. onBeforeComposeObservable: Observable<EffectLayer>;
  53946. /**
  53947. * An event triggered when the mesh is rendered into the effect render target.
  53948. */
  53949. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53950. /**
  53951. * An event triggered after the mesh has been rendered into the effect render target.
  53952. */
  53953. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53954. /**
  53955. * An event triggered when the generated texture has been merged in the scene.
  53956. */
  53957. onAfterComposeObservable: Observable<EffectLayer>;
  53958. /**
  53959. * An event triggered when the efffect layer changes its size.
  53960. */
  53961. onSizeChangedObservable: Observable<EffectLayer>;
  53962. /** @hidden */
  53963. static _SceneComponentInitialization: (scene: Scene) => void;
  53964. /**
  53965. * Instantiates a new effect Layer and references it in the scene.
  53966. * @param name The name of the layer
  53967. * @param scene The scene to use the layer in
  53968. */
  53969. constructor(
  53970. /** The Friendly of the effect in the scene */
  53971. name: string, scene: Scene);
  53972. /**
  53973. * Get the effect name of the layer.
  53974. * @return The effect name
  53975. */
  53976. abstract getEffectName(): string;
  53977. /**
  53978. * Checks for the readiness of the element composing the layer.
  53979. * @param subMesh the mesh to check for
  53980. * @param useInstances specify wether or not to use instances to render the mesh
  53981. * @return true if ready otherwise, false
  53982. */
  53983. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53984. /**
  53985. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53986. * @returns true if the effect requires stencil during the main canvas render pass.
  53987. */
  53988. abstract needStencil(): boolean;
  53989. /**
  53990. * Create the merge effect. This is the shader use to blit the information back
  53991. * to the main canvas at the end of the scene rendering.
  53992. * @returns The effect containing the shader used to merge the effect on the main canvas
  53993. */
  53994. protected abstract _createMergeEffect(): Effect;
  53995. /**
  53996. * Creates the render target textures and post processes used in the effect layer.
  53997. */
  53998. protected abstract _createTextureAndPostProcesses(): void;
  53999. /**
  54000. * Implementation specific of rendering the generating effect on the main canvas.
  54001. * @param effect The effect used to render through
  54002. */
  54003. protected abstract _internalRender(effect: Effect): void;
  54004. /**
  54005. * Sets the required values for both the emissive texture and and the main color.
  54006. */
  54007. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54008. /**
  54009. * Free any resources and references associated to a mesh.
  54010. * Internal use
  54011. * @param mesh The mesh to free.
  54012. */
  54013. abstract _disposeMesh(mesh: Mesh): void;
  54014. /**
  54015. * Serializes this layer (Glow or Highlight for example)
  54016. * @returns a serialized layer object
  54017. */
  54018. abstract serialize?(): any;
  54019. /**
  54020. * Initializes the effect layer with the required options.
  54021. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54022. */
  54023. protected _init(options: Partial<IEffectLayerOptions>): void;
  54024. /**
  54025. * Generates the index buffer of the full screen quad blending to the main canvas.
  54026. */
  54027. private _generateIndexBuffer;
  54028. /**
  54029. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54030. */
  54031. private _generateVertexBuffer;
  54032. /**
  54033. * Sets the main texture desired size which is the closest power of two
  54034. * of the engine canvas size.
  54035. */
  54036. private _setMainTextureSize;
  54037. /**
  54038. * Creates the main texture for the effect layer.
  54039. */
  54040. protected _createMainTexture(): void;
  54041. /**
  54042. * Adds specific effects defines.
  54043. * @param defines The defines to add specifics to.
  54044. */
  54045. protected _addCustomEffectDefines(defines: string[]): void;
  54046. /**
  54047. * Checks for the readiness of the element composing the layer.
  54048. * @param subMesh the mesh to check for
  54049. * @param useInstances specify wether or not to use instances to render the mesh
  54050. * @param emissiveTexture the associated emissive texture used to generate the glow
  54051. * @return true if ready otherwise, false
  54052. */
  54053. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54054. /**
  54055. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54056. */
  54057. render(): void;
  54058. /**
  54059. * Determine if a given mesh will be used in the current effect.
  54060. * @param mesh mesh to test
  54061. * @returns true if the mesh will be used
  54062. */
  54063. hasMesh(mesh: AbstractMesh): boolean;
  54064. /**
  54065. * Returns true if the layer contains information to display, otherwise false.
  54066. * @returns true if the glow layer should be rendered
  54067. */
  54068. shouldRender(): boolean;
  54069. /**
  54070. * Returns true if the mesh should render, otherwise false.
  54071. * @param mesh The mesh to render
  54072. * @returns true if it should render otherwise false
  54073. */
  54074. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  54075. /**
  54076. * Returns true if the mesh can be rendered, otherwise false.
  54077. * @param mesh The mesh to render
  54078. * @param material The material used on the mesh
  54079. * @returns true if it can be rendered otherwise false
  54080. */
  54081. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54082. /**
  54083. * Returns true if the mesh should render, otherwise false.
  54084. * @param mesh The mesh to render
  54085. * @returns true if it should render otherwise false
  54086. */
  54087. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  54088. /**
  54089. * Renders the submesh passed in parameter to the generation map.
  54090. */
  54091. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  54092. /**
  54093. * Defines wether the current material of the mesh should be use to render the effect.
  54094. * @param mesh defines the current mesh to render
  54095. */
  54096. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54097. /**
  54098. * Rebuild the required buffers.
  54099. * @hidden Internal use only.
  54100. */
  54101. _rebuild(): void;
  54102. /**
  54103. * Dispose only the render target textures and post process.
  54104. */
  54105. private _disposeTextureAndPostProcesses;
  54106. /**
  54107. * Dispose the highlight layer and free resources.
  54108. */
  54109. dispose(): void;
  54110. /**
  54111. * Gets the class name of the effect layer
  54112. * @returns the string with the class name of the effect layer
  54113. */
  54114. getClassName(): string;
  54115. /**
  54116. * Creates an effect layer from parsed effect layer data
  54117. * @param parsedEffectLayer defines effect layer data
  54118. * @param scene defines the current scene
  54119. * @param rootUrl defines the root URL containing the effect layer information
  54120. * @returns a parsed effect Layer
  54121. */
  54122. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  54123. }
  54124. }
  54125. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  54126. import { Scene } from "babylonjs/scene";
  54127. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54128. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54129. import { AbstractScene } from "babylonjs/abstractScene";
  54130. module "babylonjs/abstractScene" {
  54131. interface AbstractScene {
  54132. /**
  54133. * The list of effect layers (highlights/glow) added to the scene
  54134. * @see http://doc.babylonjs.com/how_to/highlight_layer
  54135. * @see http://doc.babylonjs.com/how_to/glow_layer
  54136. */
  54137. effectLayers: Array<EffectLayer>;
  54138. /**
  54139. * Removes the given effect layer from this scene.
  54140. * @param toRemove defines the effect layer to remove
  54141. * @returns the index of the removed effect layer
  54142. */
  54143. removeEffectLayer(toRemove: EffectLayer): number;
  54144. /**
  54145. * Adds the given effect layer to this scene
  54146. * @param newEffectLayer defines the effect layer to add
  54147. */
  54148. addEffectLayer(newEffectLayer: EffectLayer): void;
  54149. }
  54150. }
  54151. /**
  54152. * Defines the layer scene component responsible to manage any effect layers
  54153. * in a given scene.
  54154. */
  54155. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  54156. /**
  54157. * The component name helpfull to identify the component in the list of scene components.
  54158. */
  54159. readonly name: string;
  54160. /**
  54161. * The scene the component belongs to.
  54162. */
  54163. scene: Scene;
  54164. private _engine;
  54165. private _renderEffects;
  54166. private _needStencil;
  54167. private _previousStencilState;
  54168. /**
  54169. * Creates a new instance of the component for the given scene
  54170. * @param scene Defines the scene to register the component in
  54171. */
  54172. constructor(scene: Scene);
  54173. /**
  54174. * Registers the component in a given scene
  54175. */
  54176. register(): void;
  54177. /**
  54178. * Rebuilds the elements related to this component in case of
  54179. * context lost for instance.
  54180. */
  54181. rebuild(): void;
  54182. /**
  54183. * Serializes the component data to the specified json object
  54184. * @param serializationObject The object to serialize to
  54185. */
  54186. serialize(serializationObject: any): void;
  54187. /**
  54188. * Adds all the elements from the container to the scene
  54189. * @param container the container holding the elements
  54190. */
  54191. addFromContainer(container: AbstractScene): void;
  54192. /**
  54193. * Removes all the elements in the container from the scene
  54194. * @param container contains the elements to remove
  54195. * @param dispose if the removed element should be disposed (default: false)
  54196. */
  54197. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54198. /**
  54199. * Disposes the component and the associated ressources.
  54200. */
  54201. dispose(): void;
  54202. private _isReadyForMesh;
  54203. private _renderMainTexture;
  54204. private _setStencil;
  54205. private _setStencilBack;
  54206. private _draw;
  54207. private _drawCamera;
  54208. private _drawRenderingGroup;
  54209. }
  54210. }
  54211. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  54212. /** @hidden */
  54213. export var glowMapMergePixelShader: {
  54214. name: string;
  54215. shader: string;
  54216. };
  54217. }
  54218. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  54219. /** @hidden */
  54220. export var glowMapMergeVertexShader: {
  54221. name: string;
  54222. shader: string;
  54223. };
  54224. }
  54225. declare module "babylonjs/Layers/glowLayer" {
  54226. import { Nullable } from "babylonjs/types";
  54227. import { Camera } from "babylonjs/Cameras/camera";
  54228. import { Scene } from "babylonjs/scene";
  54229. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54231. import { Mesh } from "babylonjs/Meshes/mesh";
  54232. import { Texture } from "babylonjs/Materials/Textures/texture";
  54233. import { Effect } from "babylonjs/Materials/effect";
  54234. import { Material } from "babylonjs/Materials/material";
  54235. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54236. import { Color4 } from "babylonjs/Maths/math.color";
  54237. import "babylonjs/Shaders/glowMapMerge.fragment";
  54238. import "babylonjs/Shaders/glowMapMerge.vertex";
  54239. import "babylonjs/Layers/effectLayerSceneComponent";
  54240. module "babylonjs/abstractScene" {
  54241. interface AbstractScene {
  54242. /**
  54243. * Return a the first highlight layer of the scene with a given name.
  54244. * @param name The name of the highlight layer to look for.
  54245. * @return The highlight layer if found otherwise null.
  54246. */
  54247. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  54248. }
  54249. }
  54250. /**
  54251. * Glow layer options. This helps customizing the behaviour
  54252. * of the glow layer.
  54253. */
  54254. export interface IGlowLayerOptions {
  54255. /**
  54256. * Multiplication factor apply to the canvas size to compute the render target size
  54257. * used to generated the glowing objects (the smaller the faster).
  54258. */
  54259. mainTextureRatio: number;
  54260. /**
  54261. * Enforces a fixed size texture to ensure resize independant blur.
  54262. */
  54263. mainTextureFixedSize?: number;
  54264. /**
  54265. * How big is the kernel of the blur texture.
  54266. */
  54267. blurKernelSize: number;
  54268. /**
  54269. * The camera attached to the layer.
  54270. */
  54271. camera: Nullable<Camera>;
  54272. /**
  54273. * Enable MSAA by chosing the number of samples.
  54274. */
  54275. mainTextureSamples?: number;
  54276. /**
  54277. * The rendering group to draw the layer in.
  54278. */
  54279. renderingGroupId: number;
  54280. }
  54281. /**
  54282. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  54283. *
  54284. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  54285. *
  54286. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  54287. */
  54288. export class GlowLayer extends EffectLayer {
  54289. /**
  54290. * Effect Name of the layer.
  54291. */
  54292. static readonly EffectName: string;
  54293. /**
  54294. * The default blur kernel size used for the glow.
  54295. */
  54296. static DefaultBlurKernelSize: number;
  54297. /**
  54298. * The default texture size ratio used for the glow.
  54299. */
  54300. static DefaultTextureRatio: number;
  54301. /**
  54302. * Sets the kernel size of the blur.
  54303. */
  54304. set blurKernelSize(value: number);
  54305. /**
  54306. * Gets the kernel size of the blur.
  54307. */
  54308. get blurKernelSize(): number;
  54309. /**
  54310. * Sets the glow intensity.
  54311. */
  54312. set intensity(value: number);
  54313. /**
  54314. * Gets the glow intensity.
  54315. */
  54316. get intensity(): number;
  54317. private _options;
  54318. private _intensity;
  54319. private _horizontalBlurPostprocess1;
  54320. private _verticalBlurPostprocess1;
  54321. private _horizontalBlurPostprocess2;
  54322. private _verticalBlurPostprocess2;
  54323. private _blurTexture1;
  54324. private _blurTexture2;
  54325. private _postProcesses1;
  54326. private _postProcesses2;
  54327. private _includedOnlyMeshes;
  54328. private _excludedMeshes;
  54329. private _meshesUsingTheirOwnMaterials;
  54330. /**
  54331. * Callback used to let the user override the color selection on a per mesh basis
  54332. */
  54333. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  54334. /**
  54335. * Callback used to let the user override the texture selection on a per mesh basis
  54336. */
  54337. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  54338. /**
  54339. * Instantiates a new glow Layer and references it to the scene.
  54340. * @param name The name of the layer
  54341. * @param scene The scene to use the layer in
  54342. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  54343. */
  54344. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  54345. /**
  54346. * Get the effect name of the layer.
  54347. * @return The effect name
  54348. */
  54349. getEffectName(): string;
  54350. /**
  54351. * Create the merge effect. This is the shader use to blit the information back
  54352. * to the main canvas at the end of the scene rendering.
  54353. */
  54354. protected _createMergeEffect(): Effect;
  54355. /**
  54356. * Creates the render target textures and post processes used in the glow layer.
  54357. */
  54358. protected _createTextureAndPostProcesses(): void;
  54359. /**
  54360. * Checks for the readiness of the element composing the layer.
  54361. * @param subMesh the mesh to check for
  54362. * @param useInstances specify wether or not to use instances to render the mesh
  54363. * @param emissiveTexture the associated emissive texture used to generate the glow
  54364. * @return true if ready otherwise, false
  54365. */
  54366. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54367. /**
  54368. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54369. */
  54370. needStencil(): boolean;
  54371. /**
  54372. * Returns true if the mesh can be rendered, otherwise false.
  54373. * @param mesh The mesh to render
  54374. * @param material The material used on the mesh
  54375. * @returns true if it can be rendered otherwise false
  54376. */
  54377. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54378. /**
  54379. * Implementation specific of rendering the generating effect on the main canvas.
  54380. * @param effect The effect used to render through
  54381. */
  54382. protected _internalRender(effect: Effect): void;
  54383. /**
  54384. * Sets the required values for both the emissive texture and and the main color.
  54385. */
  54386. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54387. /**
  54388. * Returns true if the mesh should render, otherwise false.
  54389. * @param mesh The mesh to render
  54390. * @returns true if it should render otherwise false
  54391. */
  54392. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54393. /**
  54394. * Adds specific effects defines.
  54395. * @param defines The defines to add specifics to.
  54396. */
  54397. protected _addCustomEffectDefines(defines: string[]): void;
  54398. /**
  54399. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54400. * @param mesh The mesh to exclude from the glow layer
  54401. */
  54402. addExcludedMesh(mesh: Mesh): void;
  54403. /**
  54404. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54405. * @param mesh The mesh to remove
  54406. */
  54407. removeExcludedMesh(mesh: Mesh): void;
  54408. /**
  54409. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54410. * @param mesh The mesh to include in the glow layer
  54411. */
  54412. addIncludedOnlyMesh(mesh: Mesh): void;
  54413. /**
  54414. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54415. * @param mesh The mesh to remove
  54416. */
  54417. removeIncludedOnlyMesh(mesh: Mesh): void;
  54418. /**
  54419. * Determine if a given mesh will be used in the glow layer
  54420. * @param mesh The mesh to test
  54421. * @returns true if the mesh will be highlighted by the current glow layer
  54422. */
  54423. hasMesh(mesh: AbstractMesh): boolean;
  54424. /**
  54425. * Defines wether the current material of the mesh should be use to render the effect.
  54426. * @param mesh defines the current mesh to render
  54427. */
  54428. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54429. /**
  54430. * Add a mesh to be rendered through its own material and not with emissive only.
  54431. * @param mesh The mesh for which we need to use its material
  54432. */
  54433. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54434. /**
  54435. * Remove a mesh from being rendered through its own material and not with emissive only.
  54436. * @param mesh The mesh for which we need to not use its material
  54437. */
  54438. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54439. /**
  54440. * Free any resources and references associated to a mesh.
  54441. * Internal use
  54442. * @param mesh The mesh to free.
  54443. * @hidden
  54444. */
  54445. _disposeMesh(mesh: Mesh): void;
  54446. /**
  54447. * Gets the class name of the effect layer
  54448. * @returns the string with the class name of the effect layer
  54449. */
  54450. getClassName(): string;
  54451. /**
  54452. * Serializes this glow layer
  54453. * @returns a serialized glow layer object
  54454. */
  54455. serialize(): any;
  54456. /**
  54457. * Creates a Glow Layer from parsed glow layer data
  54458. * @param parsedGlowLayer defines glow layer data
  54459. * @param scene defines the current scene
  54460. * @param rootUrl defines the root URL containing the glow layer information
  54461. * @returns a parsed Glow Layer
  54462. */
  54463. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54464. }
  54465. }
  54466. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  54467. /** @hidden */
  54468. export var glowBlurPostProcessPixelShader: {
  54469. name: string;
  54470. shader: string;
  54471. };
  54472. }
  54473. declare module "babylonjs/Layers/highlightLayer" {
  54474. import { Observable } from "babylonjs/Misc/observable";
  54475. import { Nullable } from "babylonjs/types";
  54476. import { Camera } from "babylonjs/Cameras/camera";
  54477. import { Scene } from "babylonjs/scene";
  54478. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54480. import { Mesh } from "babylonjs/Meshes/mesh";
  54481. import { Effect } from "babylonjs/Materials/effect";
  54482. import { Material } from "babylonjs/Materials/material";
  54483. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54484. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  54485. import "babylonjs/Shaders/glowMapMerge.fragment";
  54486. import "babylonjs/Shaders/glowMapMerge.vertex";
  54487. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  54488. module "babylonjs/abstractScene" {
  54489. interface AbstractScene {
  54490. /**
  54491. * Return a the first highlight layer of the scene with a given name.
  54492. * @param name The name of the highlight layer to look for.
  54493. * @return The highlight layer if found otherwise null.
  54494. */
  54495. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54496. }
  54497. }
  54498. /**
  54499. * Highlight layer options. This helps customizing the behaviour
  54500. * of the highlight layer.
  54501. */
  54502. export interface IHighlightLayerOptions {
  54503. /**
  54504. * Multiplication factor apply to the canvas size to compute the render target size
  54505. * used to generated the glowing objects (the smaller the faster).
  54506. */
  54507. mainTextureRatio: number;
  54508. /**
  54509. * Enforces a fixed size texture to ensure resize independant blur.
  54510. */
  54511. mainTextureFixedSize?: number;
  54512. /**
  54513. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54514. * of the picture to blur (the smaller the faster).
  54515. */
  54516. blurTextureSizeRatio: number;
  54517. /**
  54518. * How big in texel of the blur texture is the vertical blur.
  54519. */
  54520. blurVerticalSize: number;
  54521. /**
  54522. * How big in texel of the blur texture is the horizontal blur.
  54523. */
  54524. blurHorizontalSize: number;
  54525. /**
  54526. * Alpha blending mode used to apply the blur. Default is combine.
  54527. */
  54528. alphaBlendingMode: number;
  54529. /**
  54530. * The camera attached to the layer.
  54531. */
  54532. camera: Nullable<Camera>;
  54533. /**
  54534. * Should we display highlight as a solid stroke?
  54535. */
  54536. isStroke?: boolean;
  54537. /**
  54538. * The rendering group to draw the layer in.
  54539. */
  54540. renderingGroupId: number;
  54541. }
  54542. /**
  54543. * The highlight layer Helps adding a glow effect around a mesh.
  54544. *
  54545. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54546. * glowy meshes to your scene.
  54547. *
  54548. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54549. */
  54550. export class HighlightLayer extends EffectLayer {
  54551. name: string;
  54552. /**
  54553. * Effect Name of the highlight layer.
  54554. */
  54555. static readonly EffectName: string;
  54556. /**
  54557. * The neutral color used during the preparation of the glow effect.
  54558. * This is black by default as the blend operation is a blend operation.
  54559. */
  54560. static NeutralColor: Color4;
  54561. /**
  54562. * Stencil value used for glowing meshes.
  54563. */
  54564. static GlowingMeshStencilReference: number;
  54565. /**
  54566. * Stencil value used for the other meshes in the scene.
  54567. */
  54568. static NormalMeshStencilReference: number;
  54569. /**
  54570. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54571. */
  54572. innerGlow: boolean;
  54573. /**
  54574. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54575. */
  54576. outerGlow: boolean;
  54577. /**
  54578. * Specifies the horizontal size of the blur.
  54579. */
  54580. set blurHorizontalSize(value: number);
  54581. /**
  54582. * Specifies the vertical size of the blur.
  54583. */
  54584. set blurVerticalSize(value: number);
  54585. /**
  54586. * Gets the horizontal size of the blur.
  54587. */
  54588. get blurHorizontalSize(): number;
  54589. /**
  54590. * Gets the vertical size of the blur.
  54591. */
  54592. get blurVerticalSize(): number;
  54593. /**
  54594. * An event triggered when the highlight layer is being blurred.
  54595. */
  54596. onBeforeBlurObservable: Observable<HighlightLayer>;
  54597. /**
  54598. * An event triggered when the highlight layer has been blurred.
  54599. */
  54600. onAfterBlurObservable: Observable<HighlightLayer>;
  54601. private _instanceGlowingMeshStencilReference;
  54602. private _options;
  54603. private _downSamplePostprocess;
  54604. private _horizontalBlurPostprocess;
  54605. private _verticalBlurPostprocess;
  54606. private _blurTexture;
  54607. private _meshes;
  54608. private _excludedMeshes;
  54609. /**
  54610. * Instantiates a new highlight Layer and references it to the scene..
  54611. * @param name The name of the layer
  54612. * @param scene The scene to use the layer in
  54613. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54614. */
  54615. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54616. /**
  54617. * Get the effect name of the layer.
  54618. * @return The effect name
  54619. */
  54620. getEffectName(): string;
  54621. /**
  54622. * Create the merge effect. This is the shader use to blit the information back
  54623. * to the main canvas at the end of the scene rendering.
  54624. */
  54625. protected _createMergeEffect(): Effect;
  54626. /**
  54627. * Creates the render target textures and post processes used in the highlight layer.
  54628. */
  54629. protected _createTextureAndPostProcesses(): void;
  54630. /**
  54631. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54632. */
  54633. needStencil(): boolean;
  54634. /**
  54635. * Checks for the readiness of the element composing the layer.
  54636. * @param subMesh the mesh to check for
  54637. * @param useInstances specify wether or not to use instances to render the mesh
  54638. * @param emissiveTexture the associated emissive texture used to generate the glow
  54639. * @return true if ready otherwise, false
  54640. */
  54641. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54642. /**
  54643. * Implementation specific of rendering the generating effect on the main canvas.
  54644. * @param effect The effect used to render through
  54645. */
  54646. protected _internalRender(effect: Effect): void;
  54647. /**
  54648. * Returns true if the layer contains information to display, otherwise false.
  54649. */
  54650. shouldRender(): boolean;
  54651. /**
  54652. * Returns true if the mesh should render, otherwise false.
  54653. * @param mesh The mesh to render
  54654. * @returns true if it should render otherwise false
  54655. */
  54656. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54657. /**
  54658. * Sets the required values for both the emissive texture and and the main color.
  54659. */
  54660. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54661. /**
  54662. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54663. * @param mesh The mesh to exclude from the highlight layer
  54664. */
  54665. addExcludedMesh(mesh: Mesh): void;
  54666. /**
  54667. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54668. * @param mesh The mesh to highlight
  54669. */
  54670. removeExcludedMesh(mesh: Mesh): void;
  54671. /**
  54672. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54673. * @param mesh mesh to test
  54674. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54675. */
  54676. hasMesh(mesh: AbstractMesh): boolean;
  54677. /**
  54678. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54679. * @param mesh The mesh to highlight
  54680. * @param color The color of the highlight
  54681. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54682. */
  54683. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54684. /**
  54685. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54686. * @param mesh The mesh to highlight
  54687. */
  54688. removeMesh(mesh: Mesh): void;
  54689. /**
  54690. * Force the stencil to the normal expected value for none glowing parts
  54691. */
  54692. private _defaultStencilReference;
  54693. /**
  54694. * Free any resources and references associated to a mesh.
  54695. * Internal use
  54696. * @param mesh The mesh to free.
  54697. * @hidden
  54698. */
  54699. _disposeMesh(mesh: Mesh): void;
  54700. /**
  54701. * Dispose the highlight layer and free resources.
  54702. */
  54703. dispose(): void;
  54704. /**
  54705. * Gets the class name of the effect layer
  54706. * @returns the string with the class name of the effect layer
  54707. */
  54708. getClassName(): string;
  54709. /**
  54710. * Serializes this Highlight layer
  54711. * @returns a serialized Highlight layer object
  54712. */
  54713. serialize(): any;
  54714. /**
  54715. * Creates a Highlight layer from parsed Highlight layer data
  54716. * @param parsedHightlightLayer defines the Highlight layer data
  54717. * @param scene defines the current scene
  54718. * @param rootUrl defines the root URL containing the Highlight layer information
  54719. * @returns a parsed Highlight layer
  54720. */
  54721. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54722. }
  54723. }
  54724. declare module "babylonjs/Layers/layerSceneComponent" {
  54725. import { Scene } from "babylonjs/scene";
  54726. import { ISceneComponent } from "babylonjs/sceneComponent";
  54727. import { Layer } from "babylonjs/Layers/layer";
  54728. import { AbstractScene } from "babylonjs/abstractScene";
  54729. module "babylonjs/abstractScene" {
  54730. interface AbstractScene {
  54731. /**
  54732. * The list of layers (background and foreground) of the scene
  54733. */
  54734. layers: Array<Layer>;
  54735. }
  54736. }
  54737. /**
  54738. * Defines the layer scene component responsible to manage any layers
  54739. * in a given scene.
  54740. */
  54741. export class LayerSceneComponent implements ISceneComponent {
  54742. /**
  54743. * The component name helpfull to identify the component in the list of scene components.
  54744. */
  54745. readonly name: string;
  54746. /**
  54747. * The scene the component belongs to.
  54748. */
  54749. scene: Scene;
  54750. private _engine;
  54751. /**
  54752. * Creates a new instance of the component for the given scene
  54753. * @param scene Defines the scene to register the component in
  54754. */
  54755. constructor(scene: Scene);
  54756. /**
  54757. * Registers the component in a given scene
  54758. */
  54759. register(): void;
  54760. /**
  54761. * Rebuilds the elements related to this component in case of
  54762. * context lost for instance.
  54763. */
  54764. rebuild(): void;
  54765. /**
  54766. * Disposes the component and the associated ressources.
  54767. */
  54768. dispose(): void;
  54769. private _draw;
  54770. private _drawCameraPredicate;
  54771. private _drawCameraBackground;
  54772. private _drawCameraForeground;
  54773. private _drawRenderTargetPredicate;
  54774. private _drawRenderTargetBackground;
  54775. private _drawRenderTargetForeground;
  54776. /**
  54777. * Adds all the elements from the container to the scene
  54778. * @param container the container holding the elements
  54779. */
  54780. addFromContainer(container: AbstractScene): void;
  54781. /**
  54782. * Removes all the elements in the container from the scene
  54783. * @param container contains the elements to remove
  54784. * @param dispose if the removed element should be disposed (default: false)
  54785. */
  54786. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54787. }
  54788. }
  54789. declare module "babylonjs/Shaders/layer.fragment" {
  54790. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54791. /** @hidden */
  54792. export var layerPixelShader: {
  54793. name: string;
  54794. shader: string;
  54795. };
  54796. }
  54797. declare module "babylonjs/Shaders/layer.vertex" {
  54798. /** @hidden */
  54799. export var layerVertexShader: {
  54800. name: string;
  54801. shader: string;
  54802. };
  54803. }
  54804. declare module "babylonjs/Layers/layer" {
  54805. import { Observable } from "babylonjs/Misc/observable";
  54806. import { Nullable } from "babylonjs/types";
  54807. import { Scene } from "babylonjs/scene";
  54808. import { Vector2 } from "babylonjs/Maths/math.vector";
  54809. import { Color4 } from "babylonjs/Maths/math.color";
  54810. import { Texture } from "babylonjs/Materials/Textures/texture";
  54811. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54812. import "babylonjs/Shaders/layer.fragment";
  54813. import "babylonjs/Shaders/layer.vertex";
  54814. /**
  54815. * This represents a full screen 2d layer.
  54816. * This can be useful to display a picture in the background of your scene for instance.
  54817. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54818. */
  54819. export class Layer {
  54820. /**
  54821. * Define the name of the layer.
  54822. */
  54823. name: string;
  54824. /**
  54825. * Define the texture the layer should display.
  54826. */
  54827. texture: Nullable<Texture>;
  54828. /**
  54829. * Is the layer in background or foreground.
  54830. */
  54831. isBackground: boolean;
  54832. /**
  54833. * Define the color of the layer (instead of texture).
  54834. */
  54835. color: Color4;
  54836. /**
  54837. * Define the scale of the layer in order to zoom in out of the texture.
  54838. */
  54839. scale: Vector2;
  54840. /**
  54841. * Define an offset for the layer in order to shift the texture.
  54842. */
  54843. offset: Vector2;
  54844. /**
  54845. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54846. */
  54847. alphaBlendingMode: number;
  54848. /**
  54849. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54850. * Alpha test will not mix with the background color in case of transparency.
  54851. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54852. */
  54853. alphaTest: boolean;
  54854. /**
  54855. * Define a mask to restrict the layer to only some of the scene cameras.
  54856. */
  54857. layerMask: number;
  54858. /**
  54859. * Define the list of render target the layer is visible into.
  54860. */
  54861. renderTargetTextures: RenderTargetTexture[];
  54862. /**
  54863. * Define if the layer is only used in renderTarget or if it also
  54864. * renders in the main frame buffer of the canvas.
  54865. */
  54866. renderOnlyInRenderTargetTextures: boolean;
  54867. private _scene;
  54868. private _vertexBuffers;
  54869. private _indexBuffer;
  54870. private _effect;
  54871. private _previousDefines;
  54872. /**
  54873. * An event triggered when the layer is disposed.
  54874. */
  54875. onDisposeObservable: Observable<Layer>;
  54876. private _onDisposeObserver;
  54877. /**
  54878. * Back compatibility with callback before the onDisposeObservable existed.
  54879. * The set callback will be triggered when the layer has been disposed.
  54880. */
  54881. set onDispose(callback: () => void);
  54882. /**
  54883. * An event triggered before rendering the scene
  54884. */
  54885. onBeforeRenderObservable: Observable<Layer>;
  54886. private _onBeforeRenderObserver;
  54887. /**
  54888. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54889. * The set callback will be triggered just before rendering the layer.
  54890. */
  54891. set onBeforeRender(callback: () => void);
  54892. /**
  54893. * An event triggered after rendering the scene
  54894. */
  54895. onAfterRenderObservable: Observable<Layer>;
  54896. private _onAfterRenderObserver;
  54897. /**
  54898. * Back compatibility with callback before the onAfterRenderObservable existed.
  54899. * The set callback will be triggered just after rendering the layer.
  54900. */
  54901. set onAfterRender(callback: () => void);
  54902. /**
  54903. * Instantiates a new layer.
  54904. * This represents a full screen 2d layer.
  54905. * This can be useful to display a picture in the background of your scene for instance.
  54906. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54907. * @param name Define the name of the layer in the scene
  54908. * @param imgUrl Define the url of the texture to display in the layer
  54909. * @param scene Define the scene the layer belongs to
  54910. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54911. * @param color Defines a color for the layer
  54912. */
  54913. constructor(
  54914. /**
  54915. * Define the name of the layer.
  54916. */
  54917. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54918. private _createIndexBuffer;
  54919. /** @hidden */
  54920. _rebuild(): void;
  54921. /**
  54922. * Renders the layer in the scene.
  54923. */
  54924. render(): void;
  54925. /**
  54926. * Disposes and releases the associated ressources.
  54927. */
  54928. dispose(): void;
  54929. }
  54930. }
  54931. declare module "babylonjs/Layers/index" {
  54932. export * from "babylonjs/Layers/effectLayer";
  54933. export * from "babylonjs/Layers/effectLayerSceneComponent";
  54934. export * from "babylonjs/Layers/glowLayer";
  54935. export * from "babylonjs/Layers/highlightLayer";
  54936. export * from "babylonjs/Layers/layer";
  54937. export * from "babylonjs/Layers/layerSceneComponent";
  54938. }
  54939. declare module "babylonjs/Shaders/lensFlare.fragment" {
  54940. /** @hidden */
  54941. export var lensFlarePixelShader: {
  54942. name: string;
  54943. shader: string;
  54944. };
  54945. }
  54946. declare module "babylonjs/Shaders/lensFlare.vertex" {
  54947. /** @hidden */
  54948. export var lensFlareVertexShader: {
  54949. name: string;
  54950. shader: string;
  54951. };
  54952. }
  54953. declare module "babylonjs/LensFlares/lensFlareSystem" {
  54954. import { Scene } from "babylonjs/scene";
  54955. import { Vector3 } from "babylonjs/Maths/math.vector";
  54956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54957. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  54958. import "babylonjs/Shaders/lensFlare.fragment";
  54959. import "babylonjs/Shaders/lensFlare.vertex";
  54960. import { Viewport } from "babylonjs/Maths/math.viewport";
  54961. /**
  54962. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54963. * It is usually composed of several `lensFlare`.
  54964. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54965. */
  54966. export class LensFlareSystem {
  54967. /**
  54968. * Define the name of the lens flare system
  54969. */
  54970. name: string;
  54971. /**
  54972. * List of lens flares used in this system.
  54973. */
  54974. lensFlares: LensFlare[];
  54975. /**
  54976. * Define a limit from the border the lens flare can be visible.
  54977. */
  54978. borderLimit: number;
  54979. /**
  54980. * Define a viewport border we do not want to see the lens flare in.
  54981. */
  54982. viewportBorder: number;
  54983. /**
  54984. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54985. */
  54986. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54987. /**
  54988. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54989. */
  54990. layerMask: number;
  54991. /**
  54992. * Define the id of the lens flare system in the scene.
  54993. * (equal to name by default)
  54994. */
  54995. id: string;
  54996. private _scene;
  54997. private _emitter;
  54998. private _vertexBuffers;
  54999. private _indexBuffer;
  55000. private _effect;
  55001. private _positionX;
  55002. private _positionY;
  55003. private _isEnabled;
  55004. /** @hidden */
  55005. static _SceneComponentInitialization: (scene: Scene) => void;
  55006. /**
  55007. * Instantiates a lens flare system.
  55008. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55009. * It is usually composed of several `lensFlare`.
  55010. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55011. * @param name Define the name of the lens flare system in the scene
  55012. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55013. * @param scene Define the scene the lens flare system belongs to
  55014. */
  55015. constructor(
  55016. /**
  55017. * Define the name of the lens flare system
  55018. */
  55019. name: string, emitter: any, scene: Scene);
  55020. /**
  55021. * Define if the lens flare system is enabled.
  55022. */
  55023. get isEnabled(): boolean;
  55024. set isEnabled(value: boolean);
  55025. /**
  55026. * Get the scene the effects belongs to.
  55027. * @returns the scene holding the lens flare system
  55028. */
  55029. getScene(): Scene;
  55030. /**
  55031. * Get the emitter of the lens flare system.
  55032. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55033. * @returns the emitter of the lens flare system
  55034. */
  55035. getEmitter(): any;
  55036. /**
  55037. * Set the emitter of the lens flare system.
  55038. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55039. * @param newEmitter Define the new emitter of the system
  55040. */
  55041. setEmitter(newEmitter: any): void;
  55042. /**
  55043. * Get the lens flare system emitter position.
  55044. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55045. * @returns the position
  55046. */
  55047. getEmitterPosition(): Vector3;
  55048. /**
  55049. * @hidden
  55050. */
  55051. computeEffectivePosition(globalViewport: Viewport): boolean;
  55052. /** @hidden */
  55053. _isVisible(): boolean;
  55054. /**
  55055. * @hidden
  55056. */
  55057. render(): boolean;
  55058. /**
  55059. * Dispose and release the lens flare with its associated resources.
  55060. */
  55061. dispose(): void;
  55062. /**
  55063. * Parse a lens flare system from a JSON repressentation
  55064. * @param parsedLensFlareSystem Define the JSON to parse
  55065. * @param scene Define the scene the parsed system should be instantiated in
  55066. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55067. * @returns the parsed system
  55068. */
  55069. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  55070. /**
  55071. * Serialize the current Lens Flare System into a JSON representation.
  55072. * @returns the serialized JSON
  55073. */
  55074. serialize(): any;
  55075. }
  55076. }
  55077. declare module "babylonjs/LensFlares/lensFlare" {
  55078. import { Nullable } from "babylonjs/types";
  55079. import { Color3 } from "babylonjs/Maths/math.color";
  55080. import { Texture } from "babylonjs/Materials/Textures/texture";
  55081. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55082. /**
  55083. * This represents one of the lens effect in a `lensFlareSystem`.
  55084. * It controls one of the indiviual texture used in the effect.
  55085. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55086. */
  55087. export class LensFlare {
  55088. /**
  55089. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55090. */
  55091. size: number;
  55092. /**
  55093. * 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.
  55094. */
  55095. position: number;
  55096. /**
  55097. * Define the lens color.
  55098. */
  55099. color: Color3;
  55100. /**
  55101. * Define the lens texture.
  55102. */
  55103. texture: Nullable<Texture>;
  55104. /**
  55105. * Define the alpha mode to render this particular lens.
  55106. */
  55107. alphaMode: number;
  55108. private _system;
  55109. /**
  55110. * Creates a new Lens Flare.
  55111. * This represents one of the lens effect in a `lensFlareSystem`.
  55112. * It controls one of the indiviual texture used in the effect.
  55113. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55114. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  55115. * @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.
  55116. * @param color Define the lens color
  55117. * @param imgUrl Define the lens texture url
  55118. * @param system Define the `lensFlareSystem` this flare is part of
  55119. * @returns The newly created Lens Flare
  55120. */
  55121. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  55122. /**
  55123. * Instantiates a new Lens Flare.
  55124. * This represents one of the lens effect in a `lensFlareSystem`.
  55125. * It controls one of the indiviual texture used in the effect.
  55126. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55127. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  55128. * @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.
  55129. * @param color Define the lens color
  55130. * @param imgUrl Define the lens texture url
  55131. * @param system Define the `lensFlareSystem` this flare is part of
  55132. */
  55133. constructor(
  55134. /**
  55135. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55136. */
  55137. size: number,
  55138. /**
  55139. * 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.
  55140. */
  55141. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  55142. /**
  55143. * Dispose and release the lens flare with its associated resources.
  55144. */
  55145. dispose(): void;
  55146. }
  55147. }
  55148. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  55149. import { Nullable } from "babylonjs/types";
  55150. import { Scene } from "babylonjs/scene";
  55151. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55152. import { AbstractScene } from "babylonjs/abstractScene";
  55153. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55154. module "babylonjs/abstractScene" {
  55155. interface AbstractScene {
  55156. /**
  55157. * The list of lens flare system added to the scene
  55158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55159. */
  55160. lensFlareSystems: Array<LensFlareSystem>;
  55161. /**
  55162. * Removes the given lens flare system from this scene.
  55163. * @param toRemove The lens flare system to remove
  55164. * @returns The index of the removed lens flare system
  55165. */
  55166. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  55167. /**
  55168. * Adds the given lens flare system to this scene
  55169. * @param newLensFlareSystem The lens flare system to add
  55170. */
  55171. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  55172. /**
  55173. * Gets a lens flare system using its name
  55174. * @param name defines the name to look for
  55175. * @returns the lens flare system or null if not found
  55176. */
  55177. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  55178. /**
  55179. * Gets a lens flare system using its id
  55180. * @param id defines the id to look for
  55181. * @returns the lens flare system or null if not found
  55182. */
  55183. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  55184. }
  55185. }
  55186. /**
  55187. * Defines the lens flare scene component responsible to manage any lens flares
  55188. * in a given scene.
  55189. */
  55190. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  55191. /**
  55192. * The component name helpfull to identify the component in the list of scene components.
  55193. */
  55194. readonly name: string;
  55195. /**
  55196. * The scene the component belongs to.
  55197. */
  55198. scene: Scene;
  55199. /**
  55200. * Creates a new instance of the component for the given scene
  55201. * @param scene Defines the scene to register the component in
  55202. */
  55203. constructor(scene: Scene);
  55204. /**
  55205. * Registers the component in a given scene
  55206. */
  55207. register(): void;
  55208. /**
  55209. * Rebuilds the elements related to this component in case of
  55210. * context lost for instance.
  55211. */
  55212. rebuild(): void;
  55213. /**
  55214. * Adds all the elements from the container to the scene
  55215. * @param container the container holding the elements
  55216. */
  55217. addFromContainer(container: AbstractScene): void;
  55218. /**
  55219. * Removes all the elements in the container from the scene
  55220. * @param container contains the elements to remove
  55221. * @param dispose if the removed element should be disposed (default: false)
  55222. */
  55223. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55224. /**
  55225. * Serializes the component data to the specified json object
  55226. * @param serializationObject The object to serialize to
  55227. */
  55228. serialize(serializationObject: any): void;
  55229. /**
  55230. * Disposes the component and the associated ressources.
  55231. */
  55232. dispose(): void;
  55233. private _draw;
  55234. }
  55235. }
  55236. declare module "babylonjs/LensFlares/index" {
  55237. export * from "babylonjs/LensFlares/lensFlare";
  55238. export * from "babylonjs/LensFlares/lensFlareSystem";
  55239. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  55240. }
  55241. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  55242. import { Scene } from "babylonjs/scene";
  55243. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55244. import { AbstractScene } from "babylonjs/abstractScene";
  55245. /**
  55246. * Defines the shadow generator component responsible to manage any shadow generators
  55247. * in a given scene.
  55248. */
  55249. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55250. /**
  55251. * The component name helpfull to identify the component in the list of scene components.
  55252. */
  55253. readonly name: string;
  55254. /**
  55255. * The scene the component belongs to.
  55256. */
  55257. scene: Scene;
  55258. /**
  55259. * Creates a new instance of the component for the given scene
  55260. * @param scene Defines the scene to register the component in
  55261. */
  55262. constructor(scene: Scene);
  55263. /**
  55264. * Registers the component in a given scene
  55265. */
  55266. register(): void;
  55267. /**
  55268. * Rebuilds the elements related to this component in case of
  55269. * context lost for instance.
  55270. */
  55271. rebuild(): void;
  55272. /**
  55273. * Serializes the component data to the specified json object
  55274. * @param serializationObject The object to serialize to
  55275. */
  55276. serialize(serializationObject: any): void;
  55277. /**
  55278. * Adds all the elements from the container to the scene
  55279. * @param container the container holding the elements
  55280. */
  55281. addFromContainer(container: AbstractScene): void;
  55282. /**
  55283. * Removes all the elements in the container from the scene
  55284. * @param container contains the elements to remove
  55285. * @param dispose if the removed element should be disposed (default: false)
  55286. */
  55287. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55288. /**
  55289. * Rebuilds the elements related to this component in case of
  55290. * context lost for instance.
  55291. */
  55292. dispose(): void;
  55293. private _gatherRenderTargets;
  55294. }
  55295. }
  55296. declare module "babylonjs/Lights/Shadows/index" {
  55297. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  55298. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  55299. }
  55300. declare module "babylonjs/Lights/pointLight" {
  55301. import { Scene } from "babylonjs/scene";
  55302. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55304. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55305. import { Effect } from "babylonjs/Materials/effect";
  55306. /**
  55307. * A point light is a light defined by an unique point in world space.
  55308. * The light is emitted in every direction from this point.
  55309. * A good example of a point light is a standard light bulb.
  55310. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55311. */
  55312. export class PointLight extends ShadowLight {
  55313. private _shadowAngle;
  55314. /**
  55315. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55316. * This specifies what angle the shadow will use to be created.
  55317. *
  55318. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55319. */
  55320. get shadowAngle(): number;
  55321. /**
  55322. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55323. * This specifies what angle the shadow will use to be created.
  55324. *
  55325. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55326. */
  55327. set shadowAngle(value: number);
  55328. /**
  55329. * Gets the direction if it has been set.
  55330. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55331. */
  55332. get direction(): Vector3;
  55333. /**
  55334. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55335. */
  55336. set direction(value: Vector3);
  55337. /**
  55338. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55339. * A PointLight emits the light in every direction.
  55340. * It can cast shadows.
  55341. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55342. * ```javascript
  55343. * var pointLight = new PointLight("pl", camera.position, scene);
  55344. * ```
  55345. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55346. * @param name The light friendly name
  55347. * @param position The position of the point light in the scene
  55348. * @param scene The scene the lights belongs to
  55349. */
  55350. constructor(name: string, position: Vector3, scene: Scene);
  55351. /**
  55352. * Returns the string "PointLight"
  55353. * @returns the class name
  55354. */
  55355. getClassName(): string;
  55356. /**
  55357. * Returns the integer 0.
  55358. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55359. */
  55360. getTypeID(): number;
  55361. /**
  55362. * Specifies wether or not the shadowmap should be a cube texture.
  55363. * @returns true if the shadowmap needs to be a cube texture.
  55364. */
  55365. needCube(): boolean;
  55366. /**
  55367. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55368. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55369. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55370. */
  55371. getShadowDirection(faceIndex?: number): Vector3;
  55372. /**
  55373. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55374. * - fov = PI / 2
  55375. * - aspect ratio : 1.0
  55376. * - z-near and far equal to the active camera minZ and maxZ.
  55377. * Returns the PointLight.
  55378. */
  55379. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55380. protected _buildUniformLayout(): void;
  55381. /**
  55382. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55383. * @param effect The effect to update
  55384. * @param lightIndex The index of the light in the effect to update
  55385. * @returns The point light
  55386. */
  55387. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55388. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55389. /**
  55390. * Prepares the list of defines specific to the light type.
  55391. * @param defines the list of defines
  55392. * @param lightIndex defines the index of the light for the effect
  55393. */
  55394. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55395. }
  55396. }
  55397. declare module "babylonjs/Lights/index" {
  55398. export * from "babylonjs/Lights/light";
  55399. export * from "babylonjs/Lights/shadowLight";
  55400. export * from "babylonjs/Lights/Shadows/index";
  55401. export * from "babylonjs/Lights/directionalLight";
  55402. export * from "babylonjs/Lights/hemisphericLight";
  55403. export * from "babylonjs/Lights/pointLight";
  55404. export * from "babylonjs/Lights/spotLight";
  55405. }
  55406. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  55407. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55408. /**
  55409. * Header information of HDR texture files.
  55410. */
  55411. export interface HDRInfo {
  55412. /**
  55413. * The height of the texture in pixels.
  55414. */
  55415. height: number;
  55416. /**
  55417. * The width of the texture in pixels.
  55418. */
  55419. width: number;
  55420. /**
  55421. * The index of the beginning of the data in the binary file.
  55422. */
  55423. dataPosition: number;
  55424. }
  55425. /**
  55426. * This groups tools to convert HDR texture to native colors array.
  55427. */
  55428. export class HDRTools {
  55429. private static Ldexp;
  55430. private static Rgbe2float;
  55431. private static readStringLine;
  55432. /**
  55433. * Reads header information from an RGBE texture stored in a native array.
  55434. * More information on this format are available here:
  55435. * https://en.wikipedia.org/wiki/RGBE_image_format
  55436. *
  55437. * @param uint8array The binary file stored in native array.
  55438. * @return The header information.
  55439. */
  55440. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55441. /**
  55442. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55443. * This RGBE texture needs to store the information as a panorama.
  55444. *
  55445. * More information on this format are available here:
  55446. * https://en.wikipedia.org/wiki/RGBE_image_format
  55447. *
  55448. * @param buffer The binary file stored in an array buffer.
  55449. * @param size The expected size of the extracted cubemap.
  55450. * @return The Cube Map information.
  55451. */
  55452. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55453. /**
  55454. * Returns the pixels data extracted from an RGBE texture.
  55455. * This pixels will be stored left to right up to down in the R G B order in one array.
  55456. *
  55457. * More information on this format are available here:
  55458. * https://en.wikipedia.org/wiki/RGBE_image_format
  55459. *
  55460. * @param uint8array The binary file stored in an array buffer.
  55461. * @param hdrInfo The header information of the file.
  55462. * @return The pixels data in RGB right to left up to down order.
  55463. */
  55464. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55465. private static RGBE_ReadPixels_RLE;
  55466. }
  55467. }
  55468. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  55469. import { Nullable } from "babylonjs/types";
  55470. import { Scene } from "babylonjs/scene";
  55471. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55473. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55474. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  55475. /**
  55476. * This represents a texture coming from an HDR input.
  55477. *
  55478. * The only supported format is currently panorama picture stored in RGBE format.
  55479. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55480. */
  55481. export class HDRCubeTexture extends BaseTexture {
  55482. private static _facesMapping;
  55483. private _generateHarmonics;
  55484. private _noMipmap;
  55485. private _textureMatrix;
  55486. private _size;
  55487. private _onLoad;
  55488. private _onError;
  55489. /**
  55490. * The texture URL.
  55491. */
  55492. url: string;
  55493. /**
  55494. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55495. */
  55496. coordinatesMode: number;
  55497. protected _isBlocking: boolean;
  55498. /**
  55499. * Sets wether or not the texture is blocking during loading.
  55500. */
  55501. set isBlocking(value: boolean);
  55502. /**
  55503. * Gets wether or not the texture is blocking during loading.
  55504. */
  55505. get isBlocking(): boolean;
  55506. protected _rotationY: number;
  55507. /**
  55508. * Sets texture matrix rotation angle around Y axis in radians.
  55509. */
  55510. set rotationY(value: number);
  55511. /**
  55512. * Gets texture matrix rotation angle around Y axis radians.
  55513. */
  55514. get rotationY(): number;
  55515. /**
  55516. * Gets or sets the center of the bounding box associated with the cube texture
  55517. * It must define where the camera used to render the texture was set
  55518. */
  55519. boundingBoxPosition: Vector3;
  55520. private _boundingBoxSize;
  55521. /**
  55522. * Gets or sets the size of the bounding box associated with the cube texture
  55523. * When defined, the cubemap will switch to local mode
  55524. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55525. * @example https://www.babylonjs-playground.com/#RNASML
  55526. */
  55527. set boundingBoxSize(value: Vector3);
  55528. get boundingBoxSize(): Vector3;
  55529. /**
  55530. * Instantiates an HDRTexture from the following parameters.
  55531. *
  55532. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55533. * @param scene The scene the texture will be used in
  55534. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55535. * @param noMipmap Forces to not generate the mipmap if true
  55536. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55537. * @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)
  55538. * @param reserved Reserved flag for internal use.
  55539. */
  55540. 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>);
  55541. /**
  55542. * Get the current class name of the texture useful for serialization or dynamic coding.
  55543. * @returns "HDRCubeTexture"
  55544. */
  55545. getClassName(): string;
  55546. /**
  55547. * Occurs when the file is raw .hdr file.
  55548. */
  55549. private loadTexture;
  55550. clone(): HDRCubeTexture;
  55551. delayLoad(): void;
  55552. /**
  55553. * Get the texture reflection matrix used to rotate/transform the reflection.
  55554. * @returns the reflection matrix
  55555. */
  55556. getReflectionTextureMatrix(): Matrix;
  55557. /**
  55558. * Set the texture reflection matrix used to rotate/transform the reflection.
  55559. * @param value Define the reflection matrix to set
  55560. */
  55561. setReflectionTextureMatrix(value: Matrix): void;
  55562. /**
  55563. * Parses a JSON representation of an HDR Texture in order to create the texture
  55564. * @param parsedTexture Define the JSON representation
  55565. * @param scene Define the scene the texture should be created in
  55566. * @param rootUrl Define the root url in case we need to load relative dependencies
  55567. * @returns the newly created texture after parsing
  55568. */
  55569. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55570. serialize(): any;
  55571. }
  55572. }
  55573. declare module "babylonjs/Physics/physicsEngine" {
  55574. import { Nullable } from "babylonjs/types";
  55575. import { Vector3 } from "babylonjs/Maths/math.vector";
  55576. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  55577. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  55578. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  55579. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55580. /**
  55581. * Class used to control physics engine
  55582. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55583. */
  55584. export class PhysicsEngine implements IPhysicsEngine {
  55585. private _physicsPlugin;
  55586. /**
  55587. * Global value used to control the smallest number supported by the simulation
  55588. */
  55589. static Epsilon: number;
  55590. private _impostors;
  55591. private _joints;
  55592. private _subTimeStep;
  55593. /**
  55594. * Gets the gravity vector used by the simulation
  55595. */
  55596. gravity: Vector3;
  55597. /**
  55598. * Factory used to create the default physics plugin.
  55599. * @returns The default physics plugin
  55600. */
  55601. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55602. /**
  55603. * Creates a new Physics Engine
  55604. * @param gravity defines the gravity vector used by the simulation
  55605. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55606. */
  55607. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55608. /**
  55609. * Sets the gravity vector used by the simulation
  55610. * @param gravity defines the gravity vector to use
  55611. */
  55612. setGravity(gravity: Vector3): void;
  55613. /**
  55614. * Set the time step of the physics engine.
  55615. * Default is 1/60.
  55616. * To slow it down, enter 1/600 for example.
  55617. * To speed it up, 1/30
  55618. * @param newTimeStep defines the new timestep to apply to this world.
  55619. */
  55620. setTimeStep(newTimeStep?: number): void;
  55621. /**
  55622. * Get the time step of the physics engine.
  55623. * @returns the current time step
  55624. */
  55625. getTimeStep(): number;
  55626. /**
  55627. * Set the sub time step of the physics engine.
  55628. * Default is 0 meaning there is no sub steps
  55629. * To increase physics resolution precision, set a small value (like 1 ms)
  55630. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55631. */
  55632. setSubTimeStep(subTimeStep?: number): void;
  55633. /**
  55634. * Get the sub time step of the physics engine.
  55635. * @returns the current sub time step
  55636. */
  55637. getSubTimeStep(): number;
  55638. /**
  55639. * Release all resources
  55640. */
  55641. dispose(): void;
  55642. /**
  55643. * Gets the name of the current physics plugin
  55644. * @returns the name of the plugin
  55645. */
  55646. getPhysicsPluginName(): string;
  55647. /**
  55648. * Adding a new impostor for the impostor tracking.
  55649. * This will be done by the impostor itself.
  55650. * @param impostor the impostor to add
  55651. */
  55652. addImpostor(impostor: PhysicsImpostor): void;
  55653. /**
  55654. * Remove an impostor from the engine.
  55655. * This impostor and its mesh will not longer be updated by the physics engine.
  55656. * @param impostor the impostor to remove
  55657. */
  55658. removeImpostor(impostor: PhysicsImpostor): void;
  55659. /**
  55660. * Add a joint to the physics engine
  55661. * @param mainImpostor defines the main impostor to which the joint is added.
  55662. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55663. * @param joint defines the joint that will connect both impostors.
  55664. */
  55665. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55666. /**
  55667. * Removes a joint from the simulation
  55668. * @param mainImpostor defines the impostor used with the joint
  55669. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55670. * @param joint defines the joint to remove
  55671. */
  55672. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55673. /**
  55674. * Called by the scene. No need to call it.
  55675. * @param delta defines the timespam between frames
  55676. */
  55677. _step(delta: number): void;
  55678. /**
  55679. * Gets the current plugin used to run the simulation
  55680. * @returns current plugin
  55681. */
  55682. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55683. /**
  55684. * Gets the list of physic impostors
  55685. * @returns an array of PhysicsImpostor
  55686. */
  55687. getImpostors(): Array<PhysicsImpostor>;
  55688. /**
  55689. * Gets the impostor for a physics enabled object
  55690. * @param object defines the object impersonated by the impostor
  55691. * @returns the PhysicsImpostor or null if not found
  55692. */
  55693. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55694. /**
  55695. * Gets the impostor for a physics body object
  55696. * @param body defines physics body used by the impostor
  55697. * @returns the PhysicsImpostor or null if not found
  55698. */
  55699. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55700. /**
  55701. * Does a raycast in the physics world
  55702. * @param from when should the ray start?
  55703. * @param to when should the ray end?
  55704. * @returns PhysicsRaycastResult
  55705. */
  55706. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55707. }
  55708. }
  55709. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  55710. import { Nullable } from "babylonjs/types";
  55711. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55713. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55714. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55715. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55716. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55717. /** @hidden */
  55718. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55719. private _useDeltaForWorldStep;
  55720. world: any;
  55721. name: string;
  55722. private _physicsMaterials;
  55723. private _fixedTimeStep;
  55724. private _cannonRaycastResult;
  55725. private _raycastResult;
  55726. private _physicsBodysToRemoveAfterStep;
  55727. BJSCANNON: any;
  55728. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55729. setGravity(gravity: Vector3): void;
  55730. setTimeStep(timeStep: number): void;
  55731. getTimeStep(): number;
  55732. executeStep(delta: number): void;
  55733. private _removeMarkedPhysicsBodiesFromWorld;
  55734. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55735. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55736. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55737. private _processChildMeshes;
  55738. removePhysicsBody(impostor: PhysicsImpostor): void;
  55739. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55740. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55741. private _addMaterial;
  55742. private _checkWithEpsilon;
  55743. private _createShape;
  55744. private _createHeightmap;
  55745. private _minus90X;
  55746. private _plus90X;
  55747. private _tmpPosition;
  55748. private _tmpDeltaPosition;
  55749. private _tmpUnityRotation;
  55750. private _updatePhysicsBodyTransformation;
  55751. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55752. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55753. isSupported(): boolean;
  55754. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55755. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55756. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55757. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55758. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55759. getBodyMass(impostor: PhysicsImpostor): number;
  55760. getBodyFriction(impostor: PhysicsImpostor): number;
  55761. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55762. getBodyRestitution(impostor: PhysicsImpostor): number;
  55763. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55764. sleepBody(impostor: PhysicsImpostor): void;
  55765. wakeUpBody(impostor: PhysicsImpostor): void;
  55766. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55767. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55768. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55769. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55770. getRadius(impostor: PhysicsImpostor): number;
  55771. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55772. dispose(): void;
  55773. private _extendNamespace;
  55774. /**
  55775. * Does a raycast in the physics world
  55776. * @param from when should the ray start?
  55777. * @param to when should the ray end?
  55778. * @returns PhysicsRaycastResult
  55779. */
  55780. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55781. }
  55782. }
  55783. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  55784. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55785. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55786. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55788. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55789. import { Nullable } from "babylonjs/types";
  55790. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55791. /** @hidden */
  55792. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55793. world: any;
  55794. name: string;
  55795. BJSOIMO: any;
  55796. private _raycastResult;
  55797. constructor(iterations?: number, oimoInjection?: any);
  55798. setGravity(gravity: Vector3): void;
  55799. setTimeStep(timeStep: number): void;
  55800. getTimeStep(): number;
  55801. private _tmpImpostorsArray;
  55802. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55803. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55804. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55805. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55806. private _tmpPositionVector;
  55807. removePhysicsBody(impostor: PhysicsImpostor): void;
  55808. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55809. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55810. isSupported(): boolean;
  55811. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55812. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55813. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55814. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55815. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55816. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55817. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55818. getBodyMass(impostor: PhysicsImpostor): number;
  55819. getBodyFriction(impostor: PhysicsImpostor): number;
  55820. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55821. getBodyRestitution(impostor: PhysicsImpostor): number;
  55822. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55823. sleepBody(impostor: PhysicsImpostor): void;
  55824. wakeUpBody(impostor: PhysicsImpostor): void;
  55825. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55826. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55827. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55828. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55829. getRadius(impostor: PhysicsImpostor): number;
  55830. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55831. dispose(): void;
  55832. /**
  55833. * Does a raycast in the physics world
  55834. * @param from when should the ray start?
  55835. * @param to when should the ray end?
  55836. * @returns PhysicsRaycastResult
  55837. */
  55838. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55839. }
  55840. }
  55841. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  55842. import { Nullable } from "babylonjs/types";
  55843. import { Scene } from "babylonjs/scene";
  55844. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  55845. import { Color4 } from "babylonjs/Maths/math.color";
  55846. import { Mesh } from "babylonjs/Meshes/mesh";
  55847. /**
  55848. * Class containing static functions to help procedurally build meshes
  55849. */
  55850. export class RibbonBuilder {
  55851. /**
  55852. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55853. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55854. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55855. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55856. * * 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
  55857. * * 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
  55858. * * 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
  55859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55861. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55862. * * 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
  55863. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55864. * * 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
  55865. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55867. * @param name defines the name of the mesh
  55868. * @param options defines the options used to create the mesh
  55869. * @param scene defines the hosting scene
  55870. * @returns the ribbon mesh
  55871. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55872. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55873. */
  55874. static CreateRibbon(name: string, options: {
  55875. pathArray: Vector3[][];
  55876. closeArray?: boolean;
  55877. closePath?: boolean;
  55878. offset?: number;
  55879. updatable?: boolean;
  55880. sideOrientation?: number;
  55881. frontUVs?: Vector4;
  55882. backUVs?: Vector4;
  55883. instance?: Mesh;
  55884. invertUV?: boolean;
  55885. uvs?: Vector2[];
  55886. colors?: Color4[];
  55887. }, scene?: Nullable<Scene>): Mesh;
  55888. }
  55889. }
  55890. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  55891. import { Nullable } from "babylonjs/types";
  55892. import { Scene } from "babylonjs/scene";
  55893. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  55894. import { Mesh } from "babylonjs/Meshes/mesh";
  55895. /**
  55896. * Class containing static functions to help procedurally build meshes
  55897. */
  55898. export class ShapeBuilder {
  55899. /**
  55900. * 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.
  55901. * * 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.
  55902. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55903. * * 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.
  55904. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55905. * * 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
  55906. * * 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
  55907. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55912. * @param name defines the name of the mesh
  55913. * @param options defines the options used to create the mesh
  55914. * @param scene defines the hosting scene
  55915. * @returns the extruded shape mesh
  55916. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55918. */
  55919. static ExtrudeShape(name: string, options: {
  55920. shape: Vector3[];
  55921. path: Vector3[];
  55922. scale?: number;
  55923. rotation?: number;
  55924. cap?: number;
  55925. updatable?: boolean;
  55926. sideOrientation?: number;
  55927. frontUVs?: Vector4;
  55928. backUVs?: Vector4;
  55929. instance?: Mesh;
  55930. invertUV?: boolean;
  55931. }, scene?: Nullable<Scene>): Mesh;
  55932. /**
  55933. * Creates an custom extruded shape mesh.
  55934. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55935. * * 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.
  55936. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55937. * * 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
  55938. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55939. * * 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
  55940. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55941. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55942. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55943. * * 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
  55944. * * 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
  55945. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55950. * @param name defines the name of the mesh
  55951. * @param options defines the options used to create the mesh
  55952. * @param scene defines the hosting scene
  55953. * @returns the custom extruded shape mesh
  55954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55955. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55957. */
  55958. static ExtrudeShapeCustom(name: string, options: {
  55959. shape: Vector3[];
  55960. path: Vector3[];
  55961. scaleFunction?: any;
  55962. rotationFunction?: any;
  55963. ribbonCloseArray?: boolean;
  55964. ribbonClosePath?: boolean;
  55965. cap?: number;
  55966. updatable?: boolean;
  55967. sideOrientation?: number;
  55968. frontUVs?: Vector4;
  55969. backUVs?: Vector4;
  55970. instance?: Mesh;
  55971. invertUV?: boolean;
  55972. }, scene?: Nullable<Scene>): Mesh;
  55973. private static _ExtrudeShapeGeneric;
  55974. }
  55975. }
  55976. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  55977. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  55978. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55979. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55980. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55981. import { Nullable } from "babylonjs/types";
  55982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55983. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55984. /**
  55985. * AmmoJS Physics plugin
  55986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55987. * @see https://github.com/kripken/ammo.js/
  55988. */
  55989. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55990. private _useDeltaForWorldStep;
  55991. /**
  55992. * Reference to the Ammo library
  55993. */
  55994. bjsAMMO: any;
  55995. /**
  55996. * Created ammoJS world which physics bodies are added to
  55997. */
  55998. world: any;
  55999. /**
  56000. * Name of the plugin
  56001. */
  56002. name: string;
  56003. private _timeStep;
  56004. private _fixedTimeStep;
  56005. private _maxSteps;
  56006. private _tmpQuaternion;
  56007. private _tmpAmmoTransform;
  56008. private _tmpAmmoQuaternion;
  56009. private _tmpAmmoConcreteContactResultCallback;
  56010. private _collisionConfiguration;
  56011. private _dispatcher;
  56012. private _overlappingPairCache;
  56013. private _solver;
  56014. private _softBodySolver;
  56015. private _tmpAmmoVectorA;
  56016. private _tmpAmmoVectorB;
  56017. private _tmpAmmoVectorC;
  56018. private _tmpAmmoVectorD;
  56019. private _tmpContactCallbackResult;
  56020. private _tmpAmmoVectorRCA;
  56021. private _tmpAmmoVectorRCB;
  56022. private _raycastResult;
  56023. private static readonly DISABLE_COLLISION_FLAG;
  56024. private static readonly KINEMATIC_FLAG;
  56025. private static readonly DISABLE_DEACTIVATION_FLAG;
  56026. /**
  56027. * Initializes the ammoJS plugin
  56028. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56029. * @param ammoInjection can be used to inject your own ammo reference
  56030. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56031. */
  56032. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56033. /**
  56034. * Sets the gravity of the physics world (m/(s^2))
  56035. * @param gravity Gravity to set
  56036. */
  56037. setGravity(gravity: Vector3): void;
  56038. /**
  56039. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56040. * @param timeStep timestep to use in seconds
  56041. */
  56042. setTimeStep(timeStep: number): void;
  56043. /**
  56044. * 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)
  56045. * @param fixedTimeStep fixedTimeStep to use in seconds
  56046. */
  56047. setFixedTimeStep(fixedTimeStep: number): void;
  56048. /**
  56049. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56050. * @param maxSteps the maximum number of steps by the physics engine per frame
  56051. */
  56052. setMaxSteps(maxSteps: number): void;
  56053. /**
  56054. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56055. * @returns the current timestep in seconds
  56056. */
  56057. getTimeStep(): number;
  56058. /**
  56059. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56060. */
  56061. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56062. private _isImpostorInContact;
  56063. private _isImpostorPairInContact;
  56064. private _stepSimulation;
  56065. /**
  56066. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56067. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56068. * After the step the babylon meshes are set to the position of the physics imposters
  56069. * @param delta amount of time to step forward
  56070. * @param impostors array of imposters to update before/after the step
  56071. */
  56072. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56073. /**
  56074. * Update babylon mesh to match physics world object
  56075. * @param impostor imposter to match
  56076. */
  56077. private _afterSoftStep;
  56078. /**
  56079. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56080. * @param impostor imposter to match
  56081. */
  56082. private _ropeStep;
  56083. /**
  56084. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56085. * @param impostor imposter to match
  56086. */
  56087. private _softbodyOrClothStep;
  56088. private _tmpVector;
  56089. private _tmpMatrix;
  56090. /**
  56091. * Applies an impulse on the imposter
  56092. * @param impostor imposter to apply impulse to
  56093. * @param force amount of force to be applied to the imposter
  56094. * @param contactPoint the location to apply the impulse on the imposter
  56095. */
  56096. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56097. /**
  56098. * Applies a force on the imposter
  56099. * @param impostor imposter to apply force
  56100. * @param force amount of force to be applied to the imposter
  56101. * @param contactPoint the location to apply the force on the imposter
  56102. */
  56103. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56104. /**
  56105. * Creates a physics body using the plugin
  56106. * @param impostor the imposter to create the physics body on
  56107. */
  56108. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56109. /**
  56110. * Removes the physics body from the imposter and disposes of the body's memory
  56111. * @param impostor imposter to remove the physics body from
  56112. */
  56113. removePhysicsBody(impostor: PhysicsImpostor): void;
  56114. /**
  56115. * Generates a joint
  56116. * @param impostorJoint the imposter joint to create the joint with
  56117. */
  56118. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56119. /**
  56120. * Removes a joint
  56121. * @param impostorJoint the imposter joint to remove the joint from
  56122. */
  56123. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56124. private _addMeshVerts;
  56125. /**
  56126. * Initialise the soft body vertices to match its object's (mesh) vertices
  56127. * Softbody vertices (nodes) are in world space and to match this
  56128. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56129. * @param impostor to create the softbody for
  56130. */
  56131. private _softVertexData;
  56132. /**
  56133. * Create an impostor's soft body
  56134. * @param impostor to create the softbody for
  56135. */
  56136. private _createSoftbody;
  56137. /**
  56138. * Create cloth for an impostor
  56139. * @param impostor to create the softbody for
  56140. */
  56141. private _createCloth;
  56142. /**
  56143. * Create rope for an impostor
  56144. * @param impostor to create the softbody for
  56145. */
  56146. private _createRope;
  56147. /**
  56148. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56149. * @param impostor to create the custom physics shape for
  56150. */
  56151. private _createCustom;
  56152. private _addHullVerts;
  56153. private _createShape;
  56154. /**
  56155. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56156. * @param impostor imposter containing the physics body and babylon object
  56157. */
  56158. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56159. /**
  56160. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56161. * @param impostor imposter containing the physics body and babylon object
  56162. * @param newPosition new position
  56163. * @param newRotation new rotation
  56164. */
  56165. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56166. /**
  56167. * If this plugin is supported
  56168. * @returns true if its supported
  56169. */
  56170. isSupported(): boolean;
  56171. /**
  56172. * Sets the linear velocity of the physics body
  56173. * @param impostor imposter to set the velocity on
  56174. * @param velocity velocity to set
  56175. */
  56176. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56177. /**
  56178. * Sets the angular velocity of the physics body
  56179. * @param impostor imposter to set the velocity on
  56180. * @param velocity velocity to set
  56181. */
  56182. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56183. /**
  56184. * gets the linear velocity
  56185. * @param impostor imposter to get linear velocity from
  56186. * @returns linear velocity
  56187. */
  56188. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56189. /**
  56190. * gets the angular velocity
  56191. * @param impostor imposter to get angular velocity from
  56192. * @returns angular velocity
  56193. */
  56194. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56195. /**
  56196. * Sets the mass of physics body
  56197. * @param impostor imposter to set the mass on
  56198. * @param mass mass to set
  56199. */
  56200. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56201. /**
  56202. * Gets the mass of the physics body
  56203. * @param impostor imposter to get the mass from
  56204. * @returns mass
  56205. */
  56206. getBodyMass(impostor: PhysicsImpostor): number;
  56207. /**
  56208. * Gets friction of the impostor
  56209. * @param impostor impostor to get friction from
  56210. * @returns friction value
  56211. */
  56212. getBodyFriction(impostor: PhysicsImpostor): number;
  56213. /**
  56214. * Sets friction of the impostor
  56215. * @param impostor impostor to set friction on
  56216. * @param friction friction value
  56217. */
  56218. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56219. /**
  56220. * Gets restitution of the impostor
  56221. * @param impostor impostor to get restitution from
  56222. * @returns restitution value
  56223. */
  56224. getBodyRestitution(impostor: PhysicsImpostor): number;
  56225. /**
  56226. * Sets resitution of the impostor
  56227. * @param impostor impostor to set resitution on
  56228. * @param restitution resitution value
  56229. */
  56230. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56231. /**
  56232. * Gets pressure inside the impostor
  56233. * @param impostor impostor to get pressure from
  56234. * @returns pressure value
  56235. */
  56236. getBodyPressure(impostor: PhysicsImpostor): number;
  56237. /**
  56238. * Sets pressure inside a soft body impostor
  56239. * Cloth and rope must remain 0 pressure
  56240. * @param impostor impostor to set pressure on
  56241. * @param pressure pressure value
  56242. */
  56243. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56244. /**
  56245. * Gets stiffness of the impostor
  56246. * @param impostor impostor to get stiffness from
  56247. * @returns pressure value
  56248. */
  56249. getBodyStiffness(impostor: PhysicsImpostor): number;
  56250. /**
  56251. * Sets stiffness of the impostor
  56252. * @param impostor impostor to set stiffness on
  56253. * @param stiffness stiffness value from 0 to 1
  56254. */
  56255. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56256. /**
  56257. * Gets velocityIterations of the impostor
  56258. * @param impostor impostor to get velocity iterations from
  56259. * @returns velocityIterations value
  56260. */
  56261. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56262. /**
  56263. * Sets velocityIterations of the impostor
  56264. * @param impostor impostor to set velocity iterations on
  56265. * @param velocityIterations velocityIterations value
  56266. */
  56267. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56268. /**
  56269. * Gets positionIterations of the impostor
  56270. * @param impostor impostor to get position iterations from
  56271. * @returns positionIterations value
  56272. */
  56273. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56274. /**
  56275. * Sets positionIterations of the impostor
  56276. * @param impostor impostor to set position on
  56277. * @param positionIterations positionIterations value
  56278. */
  56279. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56280. /**
  56281. * Append an anchor to a cloth object
  56282. * @param impostor is the cloth impostor to add anchor to
  56283. * @param otherImpostor is the rigid impostor to anchor to
  56284. * @param width ratio across width from 0 to 1
  56285. * @param height ratio up height from 0 to 1
  56286. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56287. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56288. */
  56289. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56290. /**
  56291. * Append an hook to a rope object
  56292. * @param impostor is the rope impostor to add hook to
  56293. * @param otherImpostor is the rigid impostor to hook to
  56294. * @param length ratio along the rope from 0 to 1
  56295. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56296. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56297. */
  56298. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56299. /**
  56300. * Sleeps the physics body and stops it from being active
  56301. * @param impostor impostor to sleep
  56302. */
  56303. sleepBody(impostor: PhysicsImpostor): void;
  56304. /**
  56305. * Activates the physics body
  56306. * @param impostor impostor to activate
  56307. */
  56308. wakeUpBody(impostor: PhysicsImpostor): void;
  56309. /**
  56310. * Updates the distance parameters of the joint
  56311. * @param joint joint to update
  56312. * @param maxDistance maximum distance of the joint
  56313. * @param minDistance minimum distance of the joint
  56314. */
  56315. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56316. /**
  56317. * Sets a motor on the joint
  56318. * @param joint joint to set motor on
  56319. * @param speed speed of the motor
  56320. * @param maxForce maximum force of the motor
  56321. * @param motorIndex index of the motor
  56322. */
  56323. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56324. /**
  56325. * Sets the motors limit
  56326. * @param joint joint to set limit on
  56327. * @param upperLimit upper limit
  56328. * @param lowerLimit lower limit
  56329. */
  56330. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56331. /**
  56332. * Syncs the position and rotation of a mesh with the impostor
  56333. * @param mesh mesh to sync
  56334. * @param impostor impostor to update the mesh with
  56335. */
  56336. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56337. /**
  56338. * Gets the radius of the impostor
  56339. * @param impostor impostor to get radius from
  56340. * @returns the radius
  56341. */
  56342. getRadius(impostor: PhysicsImpostor): number;
  56343. /**
  56344. * Gets the box size of the impostor
  56345. * @param impostor impostor to get box size from
  56346. * @param result the resulting box size
  56347. */
  56348. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56349. /**
  56350. * Disposes of the impostor
  56351. */
  56352. dispose(): void;
  56353. /**
  56354. * Does a raycast in the physics world
  56355. * @param from when should the ray start?
  56356. * @param to when should the ray end?
  56357. * @returns PhysicsRaycastResult
  56358. */
  56359. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56360. }
  56361. }
  56362. declare module "babylonjs/Probes/reflectionProbe" {
  56363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56364. import { Vector3 } from "babylonjs/Maths/math.vector";
  56365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56366. import { Nullable } from "babylonjs/types";
  56367. import { Scene } from "babylonjs/scene";
  56368. module "babylonjs/abstractScene" {
  56369. interface AbstractScene {
  56370. /**
  56371. * The list of reflection probes added to the scene
  56372. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56373. */
  56374. reflectionProbes: Array<ReflectionProbe>;
  56375. /**
  56376. * Removes the given reflection probe from this scene.
  56377. * @param toRemove The reflection probe to remove
  56378. * @returns The index of the removed reflection probe
  56379. */
  56380. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56381. /**
  56382. * Adds the given reflection probe to this scene.
  56383. * @param newReflectionProbe The reflection probe to add
  56384. */
  56385. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56386. }
  56387. }
  56388. /**
  56389. * Class used to generate realtime reflection / refraction cube textures
  56390. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56391. */
  56392. export class ReflectionProbe {
  56393. /** defines the name of the probe */
  56394. name: string;
  56395. private _scene;
  56396. private _renderTargetTexture;
  56397. private _projectionMatrix;
  56398. private _viewMatrix;
  56399. private _target;
  56400. private _add;
  56401. private _attachedMesh;
  56402. private _invertYAxis;
  56403. /** Gets or sets probe position (center of the cube map) */
  56404. position: Vector3;
  56405. /**
  56406. * Creates a new reflection probe
  56407. * @param name defines the name of the probe
  56408. * @param size defines the texture resolution (for each face)
  56409. * @param scene defines the hosting scene
  56410. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56411. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56412. */
  56413. constructor(
  56414. /** defines the name of the probe */
  56415. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56416. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56417. get samples(): number;
  56418. set samples(value: number);
  56419. /** Gets or sets the refresh rate to use (on every frame by default) */
  56420. get refreshRate(): number;
  56421. set refreshRate(value: number);
  56422. /**
  56423. * Gets the hosting scene
  56424. * @returns a Scene
  56425. */
  56426. getScene(): Scene;
  56427. /** Gets the internal CubeTexture used to render to */
  56428. get cubeTexture(): RenderTargetTexture;
  56429. /** Gets the list of meshes to render */
  56430. get renderList(): Nullable<AbstractMesh[]>;
  56431. /**
  56432. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56433. * @param mesh defines the mesh to attach to
  56434. */
  56435. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56436. /**
  56437. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56438. * @param renderingGroupId The rendering group id corresponding to its index
  56439. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56440. */
  56441. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56442. /**
  56443. * Clean all associated resources
  56444. */
  56445. dispose(): void;
  56446. /**
  56447. * Converts the reflection probe information to a readable string for debug purpose.
  56448. * @param fullDetails Supports for multiple levels of logging within scene loading
  56449. * @returns the human readable reflection probe info
  56450. */
  56451. toString(fullDetails?: boolean): string;
  56452. /**
  56453. * Get the class name of the relfection probe.
  56454. * @returns "ReflectionProbe"
  56455. */
  56456. getClassName(): string;
  56457. /**
  56458. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56459. * @returns The JSON representation of the texture
  56460. */
  56461. serialize(): any;
  56462. /**
  56463. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56464. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56465. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56466. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56467. * @returns The parsed reflection probe if successful
  56468. */
  56469. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56470. }
  56471. }
  56472. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  56473. /** @hidden */
  56474. export var _BabylonLoaderRegistered: boolean;
  56475. /**
  56476. * Helps setting up some configuration for the babylon file loader.
  56477. */
  56478. export class BabylonFileLoaderConfiguration {
  56479. /**
  56480. * The loader does not allow injecting custom physix engine into the plugins.
  56481. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56482. * So you could set this variable to your engine import to make it work.
  56483. */
  56484. static LoaderInjectedPhysicsEngine: any;
  56485. }
  56486. }
  56487. declare module "babylonjs/Loading/Plugins/index" {
  56488. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  56489. }
  56490. declare module "babylonjs/Loading/index" {
  56491. export * from "babylonjs/Loading/loadingScreen";
  56492. export * from "babylonjs/Loading/Plugins/index";
  56493. export * from "babylonjs/Loading/sceneLoader";
  56494. export * from "babylonjs/Loading/sceneLoaderFlags";
  56495. }
  56496. declare module "babylonjs/Materials/Background/index" {
  56497. export * from "babylonjs/Materials/Background/backgroundMaterial";
  56498. }
  56499. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  56500. import { Scene } from "babylonjs/scene";
  56501. import { Color3 } from "babylonjs/Maths/math.color";
  56502. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56504. /**
  56505. * The Physically based simple base material of BJS.
  56506. *
  56507. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56508. * It is used as the base class for both the specGloss and metalRough conventions.
  56509. */
  56510. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56511. /**
  56512. * Number of Simultaneous lights allowed on the material.
  56513. */
  56514. maxSimultaneousLights: number;
  56515. /**
  56516. * If sets to true, disables all the lights affecting the material.
  56517. */
  56518. disableLighting: boolean;
  56519. /**
  56520. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56521. */
  56522. environmentTexture: BaseTexture;
  56523. /**
  56524. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56525. */
  56526. invertNormalMapX: boolean;
  56527. /**
  56528. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56529. */
  56530. invertNormalMapY: boolean;
  56531. /**
  56532. * Normal map used in the model.
  56533. */
  56534. normalTexture: BaseTexture;
  56535. /**
  56536. * Emissivie color used to self-illuminate the model.
  56537. */
  56538. emissiveColor: Color3;
  56539. /**
  56540. * Emissivie texture used to self-illuminate the model.
  56541. */
  56542. emissiveTexture: BaseTexture;
  56543. /**
  56544. * Occlusion Channel Strenght.
  56545. */
  56546. occlusionStrength: number;
  56547. /**
  56548. * Occlusion Texture of the material (adding extra occlusion effects).
  56549. */
  56550. occlusionTexture: BaseTexture;
  56551. /**
  56552. * Defines the alpha limits in alpha test mode.
  56553. */
  56554. alphaCutOff: number;
  56555. /**
  56556. * Gets the current double sided mode.
  56557. */
  56558. get doubleSided(): boolean;
  56559. /**
  56560. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56561. */
  56562. set doubleSided(value: boolean);
  56563. /**
  56564. * Stores the pre-calculated light information of a mesh in a texture.
  56565. */
  56566. lightmapTexture: BaseTexture;
  56567. /**
  56568. * If true, the light map contains occlusion information instead of lighting info.
  56569. */
  56570. useLightmapAsShadowmap: boolean;
  56571. /**
  56572. * Instantiates a new PBRMaterial instance.
  56573. *
  56574. * @param name The material name
  56575. * @param scene The scene the material will be use in.
  56576. */
  56577. constructor(name: string, scene: Scene);
  56578. getClassName(): string;
  56579. }
  56580. }
  56581. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  56582. import { Scene } from "babylonjs/scene";
  56583. import { Color3 } from "babylonjs/Maths/math.color";
  56584. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56585. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56586. /**
  56587. * The PBR material of BJS following the metal roughness convention.
  56588. *
  56589. * This fits to the PBR convention in the GLTF definition:
  56590. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56591. */
  56592. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56593. /**
  56594. * The base color has two different interpretations depending on the value of metalness.
  56595. * When the material is a metal, the base color is the specific measured reflectance value
  56596. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56597. * of the material.
  56598. */
  56599. baseColor: Color3;
  56600. /**
  56601. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56602. * well as opacity information in the alpha channel.
  56603. */
  56604. baseTexture: BaseTexture;
  56605. /**
  56606. * Specifies the metallic scalar value of the material.
  56607. * Can also be used to scale the metalness values of the metallic texture.
  56608. */
  56609. metallic: number;
  56610. /**
  56611. * Specifies the roughness scalar value of the material.
  56612. * Can also be used to scale the roughness values of the metallic texture.
  56613. */
  56614. roughness: number;
  56615. /**
  56616. * Texture containing both the metallic value in the B channel and the
  56617. * roughness value in the G channel to keep better precision.
  56618. */
  56619. metallicRoughnessTexture: BaseTexture;
  56620. /**
  56621. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56622. *
  56623. * @param name The material name
  56624. * @param scene The scene the material will be use in.
  56625. */
  56626. constructor(name: string, scene: Scene);
  56627. /**
  56628. * Return the currrent class name of the material.
  56629. */
  56630. getClassName(): string;
  56631. /**
  56632. * Makes a duplicate of the current material.
  56633. * @param name - name to use for the new material.
  56634. */
  56635. clone(name: string): PBRMetallicRoughnessMaterial;
  56636. /**
  56637. * Serialize the material to a parsable JSON object.
  56638. */
  56639. serialize(): any;
  56640. /**
  56641. * Parses a JSON object correponding to the serialize function.
  56642. */
  56643. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56644. }
  56645. }
  56646. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  56647. import { Scene } from "babylonjs/scene";
  56648. import { Color3 } from "babylonjs/Maths/math.color";
  56649. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56650. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56651. /**
  56652. * The PBR material of BJS following the specular glossiness convention.
  56653. *
  56654. * This fits to the PBR convention in the GLTF definition:
  56655. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56656. */
  56657. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56658. /**
  56659. * Specifies the diffuse color of the material.
  56660. */
  56661. diffuseColor: Color3;
  56662. /**
  56663. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56664. * channel.
  56665. */
  56666. diffuseTexture: BaseTexture;
  56667. /**
  56668. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56669. */
  56670. specularColor: Color3;
  56671. /**
  56672. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56673. */
  56674. glossiness: number;
  56675. /**
  56676. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56677. */
  56678. specularGlossinessTexture: BaseTexture;
  56679. /**
  56680. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56681. *
  56682. * @param name The material name
  56683. * @param scene The scene the material will be use in.
  56684. */
  56685. constructor(name: string, scene: Scene);
  56686. /**
  56687. * Return the currrent class name of the material.
  56688. */
  56689. getClassName(): string;
  56690. /**
  56691. * Makes a duplicate of the current material.
  56692. * @param name - name to use for the new material.
  56693. */
  56694. clone(name: string): PBRSpecularGlossinessMaterial;
  56695. /**
  56696. * Serialize the material to a parsable JSON object.
  56697. */
  56698. serialize(): any;
  56699. /**
  56700. * Parses a JSON object correponding to the serialize function.
  56701. */
  56702. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56703. }
  56704. }
  56705. declare module "babylonjs/Materials/PBR/index" {
  56706. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56707. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56708. export * from "babylonjs/Materials/PBR/pbrMaterial";
  56709. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  56710. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  56711. }
  56712. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  56713. import { Nullable } from "babylonjs/types";
  56714. import { Scene } from "babylonjs/scene";
  56715. import { Matrix } from "babylonjs/Maths/math.vector";
  56716. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56717. /**
  56718. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56719. * It can help converting any input color in a desired output one. This can then be used to create effects
  56720. * from sepia, black and white to sixties or futuristic rendering...
  56721. *
  56722. * The only supported format is currently 3dl.
  56723. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56724. */
  56725. export class ColorGradingTexture extends BaseTexture {
  56726. /**
  56727. * The current texture matrix. (will always be identity in color grading texture)
  56728. */
  56729. private _textureMatrix;
  56730. /**
  56731. * The texture URL.
  56732. */
  56733. url: string;
  56734. /**
  56735. * Empty line regex stored for GC.
  56736. */
  56737. private static _noneEmptyLineRegex;
  56738. private _engine;
  56739. /**
  56740. * Instantiates a ColorGradingTexture from the following parameters.
  56741. *
  56742. * @param url The location of the color gradind data (currently only supporting 3dl)
  56743. * @param scene The scene the texture will be used in
  56744. */
  56745. constructor(url: string, scene: Scene);
  56746. /**
  56747. * Returns the texture matrix used in most of the material.
  56748. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56749. */
  56750. getTextureMatrix(): Matrix;
  56751. /**
  56752. * Occurs when the file being loaded is a .3dl LUT file.
  56753. */
  56754. private load3dlTexture;
  56755. /**
  56756. * Starts the loading process of the texture.
  56757. */
  56758. private loadTexture;
  56759. /**
  56760. * Clones the color gradind texture.
  56761. */
  56762. clone(): ColorGradingTexture;
  56763. /**
  56764. * Called during delayed load for textures.
  56765. */
  56766. delayLoad(): void;
  56767. /**
  56768. * Parses a color grading texture serialized by Babylon.
  56769. * @param parsedTexture The texture information being parsedTexture
  56770. * @param scene The scene to load the texture in
  56771. * @param rootUrl The root url of the data assets to load
  56772. * @return A color gradind texture
  56773. */
  56774. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56775. /**
  56776. * Serializes the LUT texture to json format.
  56777. */
  56778. serialize(): any;
  56779. }
  56780. }
  56781. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  56782. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56783. import { Scene } from "babylonjs/scene";
  56784. import { Nullable } from "babylonjs/types";
  56785. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56786. /**
  56787. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56788. */
  56789. export class EquiRectangularCubeTexture extends BaseTexture {
  56790. /** The six faces of the cube. */
  56791. private static _FacesMapping;
  56792. private _noMipmap;
  56793. private _onLoad;
  56794. private _onError;
  56795. /** The size of the cubemap. */
  56796. private _size;
  56797. /** The buffer of the image. */
  56798. private _buffer;
  56799. /** The width of the input image. */
  56800. private _width;
  56801. /** The height of the input image. */
  56802. private _height;
  56803. /** The URL to the image. */
  56804. url: string;
  56805. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56806. coordinatesMode: number;
  56807. /**
  56808. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56809. * @param url The location of the image
  56810. * @param scene The scene the texture will be used in
  56811. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56812. * @param noMipmap Forces to not generate the mipmap if true
  56813. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56814. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56815. * @param onLoad — defines a callback called when texture is loaded
  56816. * @param onError — defines a callback called if there is an error
  56817. */
  56818. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56819. /**
  56820. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56821. */
  56822. private loadImage;
  56823. /**
  56824. * Convert the image buffer into a cubemap and create a CubeTexture.
  56825. */
  56826. private loadTexture;
  56827. /**
  56828. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56829. * @param buffer The ArrayBuffer that should be converted.
  56830. * @returns The buffer as Float32Array.
  56831. */
  56832. private getFloat32ArrayFromArrayBuffer;
  56833. /**
  56834. * Get the current class name of the texture useful for serialization or dynamic coding.
  56835. * @returns "EquiRectangularCubeTexture"
  56836. */
  56837. getClassName(): string;
  56838. /**
  56839. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56840. * @returns A clone of the current EquiRectangularCubeTexture.
  56841. */
  56842. clone(): EquiRectangularCubeTexture;
  56843. }
  56844. }
  56845. declare module "babylonjs/Misc/tga" {
  56846. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56847. /**
  56848. * Based on jsTGALoader - Javascript loader for TGA file
  56849. * By Vincent Thibault
  56850. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56851. */
  56852. export class TGATools {
  56853. private static _TYPE_INDEXED;
  56854. private static _TYPE_RGB;
  56855. private static _TYPE_GREY;
  56856. private static _TYPE_RLE_INDEXED;
  56857. private static _TYPE_RLE_RGB;
  56858. private static _TYPE_RLE_GREY;
  56859. private static _ORIGIN_MASK;
  56860. private static _ORIGIN_SHIFT;
  56861. private static _ORIGIN_BL;
  56862. private static _ORIGIN_BR;
  56863. private static _ORIGIN_UL;
  56864. private static _ORIGIN_UR;
  56865. /**
  56866. * Gets the header of a TGA file
  56867. * @param data defines the TGA data
  56868. * @returns the header
  56869. */
  56870. static GetTGAHeader(data: Uint8Array): any;
  56871. /**
  56872. * Uploads TGA content to a Babylon Texture
  56873. * @hidden
  56874. */
  56875. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56876. /** @hidden */
  56877. 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;
  56878. /** @hidden */
  56879. 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;
  56880. /** @hidden */
  56881. 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;
  56882. /** @hidden */
  56883. 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;
  56884. /** @hidden */
  56885. 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;
  56886. /** @hidden */
  56887. 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;
  56888. }
  56889. }
  56890. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  56891. import { Nullable } from "babylonjs/types";
  56892. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56893. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  56894. /**
  56895. * Implementation of the TGA Texture Loader.
  56896. * @hidden
  56897. */
  56898. export class _TGATextureLoader implements IInternalTextureLoader {
  56899. /**
  56900. * Defines wether the loader supports cascade loading the different faces.
  56901. */
  56902. readonly supportCascades: boolean;
  56903. /**
  56904. * This returns if the loader support the current file information.
  56905. * @param extension defines the file extension of the file being loaded
  56906. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56907. * @param fallback defines the fallback internal texture if any
  56908. * @param isBase64 defines whether the texture is encoded as a base64
  56909. * @param isBuffer defines whether the texture data are stored as a buffer
  56910. * @returns true if the loader can load the specified file
  56911. */
  56912. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56913. /**
  56914. * Transform the url before loading if required.
  56915. * @param rootUrl the url of the texture
  56916. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56917. * @returns the transformed texture
  56918. */
  56919. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56920. /**
  56921. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56922. * @param rootUrl the url of the texture
  56923. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56924. * @returns the fallback texture
  56925. */
  56926. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56927. /**
  56928. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56929. * @param data contains the texture data
  56930. * @param texture defines the BabylonJS internal texture
  56931. * @param createPolynomials will be true if polynomials have been requested
  56932. * @param onLoad defines the callback to trigger once the texture is ready
  56933. * @param onError defines the callback to trigger in case of error
  56934. */
  56935. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56936. /**
  56937. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56938. * @param data contains the texture data
  56939. * @param texture defines the BabylonJS internal texture
  56940. * @param callback defines the method to call once ready to upload
  56941. */
  56942. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56943. }
  56944. }
  56945. declare module "babylonjs/Misc/basis" {
  56946. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56947. /**
  56948. * Info about the .basis files
  56949. */
  56950. class BasisFileInfo {
  56951. /**
  56952. * If the file has alpha
  56953. */
  56954. hasAlpha: boolean;
  56955. /**
  56956. * Info about each image of the basis file
  56957. */
  56958. images: Array<{
  56959. levels: Array<{
  56960. width: number;
  56961. height: number;
  56962. transcodedPixels: ArrayBufferView;
  56963. }>;
  56964. }>;
  56965. }
  56966. /**
  56967. * Result of transcoding a basis file
  56968. */
  56969. class TranscodeResult {
  56970. /**
  56971. * Info about the .basis file
  56972. */
  56973. fileInfo: BasisFileInfo;
  56974. /**
  56975. * Format to use when loading the file
  56976. */
  56977. format: number;
  56978. }
  56979. /**
  56980. * Configuration options for the Basis transcoder
  56981. */
  56982. export class BasisTranscodeConfiguration {
  56983. /**
  56984. * Supported compression formats used to determine the supported output format of the transcoder
  56985. */
  56986. supportedCompressionFormats?: {
  56987. /**
  56988. * etc1 compression format
  56989. */
  56990. etc1?: boolean;
  56991. /**
  56992. * s3tc compression format
  56993. */
  56994. s3tc?: boolean;
  56995. /**
  56996. * pvrtc compression format
  56997. */
  56998. pvrtc?: boolean;
  56999. /**
  57000. * etc2 compression format
  57001. */
  57002. etc2?: boolean;
  57003. };
  57004. /**
  57005. * If mipmap levels should be loaded for transcoded images (Default: true)
  57006. */
  57007. loadMipmapLevels?: boolean;
  57008. /**
  57009. * Index of a single image to load (Default: all images)
  57010. */
  57011. loadSingleImage?: number;
  57012. }
  57013. /**
  57014. * Used to load .Basis files
  57015. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57016. */
  57017. export class BasisTools {
  57018. private static _IgnoreSupportedFormats;
  57019. /**
  57020. * URL to use when loading the basis transcoder
  57021. */
  57022. static JSModuleURL: string;
  57023. /**
  57024. * URL to use when loading the wasm module for the transcoder
  57025. */
  57026. static WasmModuleURL: string;
  57027. /**
  57028. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57029. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57030. * @returns internal format corresponding to the Basis format
  57031. */
  57032. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57033. private static _WorkerPromise;
  57034. private static _Worker;
  57035. private static _actionId;
  57036. private static _CreateWorkerAsync;
  57037. /**
  57038. * Transcodes a loaded image file to compressed pixel data
  57039. * @param imageData image data to transcode
  57040. * @param config configuration options for the transcoding
  57041. * @returns a promise resulting in the transcoded image
  57042. */
  57043. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57044. /**
  57045. * Loads a texture from the transcode result
  57046. * @param texture texture load to
  57047. * @param transcodeResult the result of transcoding the basis file to load from
  57048. */
  57049. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57050. }
  57051. }
  57052. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  57053. import { Nullable } from "babylonjs/types";
  57054. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57055. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57056. /**
  57057. * Loader for .basis file format
  57058. */
  57059. export class _BasisTextureLoader implements IInternalTextureLoader {
  57060. /**
  57061. * Defines whether the loader supports cascade loading the different faces.
  57062. */
  57063. readonly supportCascades: boolean;
  57064. /**
  57065. * This returns if the loader support the current file information.
  57066. * @param extension defines the file extension of the file being loaded
  57067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57068. * @param fallback defines the fallback internal texture if any
  57069. * @param isBase64 defines whether the texture is encoded as a base64
  57070. * @param isBuffer defines whether the texture data are stored as a buffer
  57071. * @returns true if the loader can load the specified file
  57072. */
  57073. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57074. /**
  57075. * Transform the url before loading if required.
  57076. * @param rootUrl the url of the texture
  57077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57078. * @returns the transformed texture
  57079. */
  57080. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57081. /**
  57082. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57083. * @param rootUrl the url of the texture
  57084. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57085. * @returns the fallback texture
  57086. */
  57087. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57088. /**
  57089. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  57090. * @param data contains the texture data
  57091. * @param texture defines the BabylonJS internal texture
  57092. * @param createPolynomials will be true if polynomials have been requested
  57093. * @param onLoad defines the callback to trigger once the texture is ready
  57094. * @param onError defines the callback to trigger in case of error
  57095. */
  57096. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57097. /**
  57098. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57099. * @param data contains the texture data
  57100. * @param texture defines the BabylonJS internal texture
  57101. * @param callback defines the method to call once ready to upload
  57102. */
  57103. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57104. }
  57105. }
  57106. declare module "babylonjs/Materials/Textures/Loaders/index" {
  57107. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  57108. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  57109. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  57110. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  57111. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  57112. }
  57113. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  57114. import { Scene } from "babylonjs/scene";
  57115. import { Texture } from "babylonjs/Materials/Textures/texture";
  57116. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57117. /**
  57118. * 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.
  57119. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57120. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57121. */
  57122. export class CustomProceduralTexture extends ProceduralTexture {
  57123. private _animate;
  57124. private _time;
  57125. private _config;
  57126. private _texturePath;
  57127. /**
  57128. * Instantiates a new Custom Procedural Texture.
  57129. * 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.
  57130. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57131. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57132. * @param name Define the name of the texture
  57133. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57134. * @param size Define the size of the texture to create
  57135. * @param scene Define the scene the texture belongs to
  57136. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57137. * @param generateMipMaps Define if the texture should creates mip maps or not
  57138. */
  57139. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57140. private _loadJson;
  57141. /**
  57142. * Is the texture ready to be used ? (rendered at least once)
  57143. * @returns true if ready, otherwise, false.
  57144. */
  57145. isReady(): boolean;
  57146. /**
  57147. * Render the texture to its associated render target.
  57148. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57149. */
  57150. render(useCameraPostProcess?: boolean): void;
  57151. /**
  57152. * Update the list of dependant textures samplers in the shader.
  57153. */
  57154. updateTextures(): void;
  57155. /**
  57156. * Update the uniform values of the procedural texture in the shader.
  57157. */
  57158. updateShaderUniforms(): void;
  57159. /**
  57160. * Define if the texture animates or not.
  57161. */
  57162. get animate(): boolean;
  57163. set animate(value: boolean);
  57164. }
  57165. }
  57166. declare module "babylonjs/Shaders/noise.fragment" {
  57167. /** @hidden */
  57168. export var noisePixelShader: {
  57169. name: string;
  57170. shader: string;
  57171. };
  57172. }
  57173. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  57174. import { Nullable } from "babylonjs/types";
  57175. import { Scene } from "babylonjs/scene";
  57176. import { Texture } from "babylonjs/Materials/Textures/texture";
  57177. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57178. import "babylonjs/Shaders/noise.fragment";
  57179. /**
  57180. * Class used to generate noise procedural textures
  57181. */
  57182. export class NoiseProceduralTexture extends ProceduralTexture {
  57183. private _time;
  57184. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57185. brightness: number;
  57186. /** Defines the number of octaves to process */
  57187. octaves: number;
  57188. /** Defines the level of persistence (0.8 by default) */
  57189. persistence: number;
  57190. /** Gets or sets animation speed factor (default is 1) */
  57191. animationSpeedFactor: number;
  57192. /**
  57193. * Creates a new NoiseProceduralTexture
  57194. * @param name defines the name fo the texture
  57195. * @param size defines the size of the texture (default is 256)
  57196. * @param scene defines the hosting scene
  57197. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57198. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57199. */
  57200. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57201. private _updateShaderUniforms;
  57202. protected _getDefines(): string;
  57203. /** Generate the current state of the procedural texture */
  57204. render(useCameraPostProcess?: boolean): void;
  57205. /**
  57206. * Serializes this noise procedural texture
  57207. * @returns a serialized noise procedural texture object
  57208. */
  57209. serialize(): any;
  57210. /**
  57211. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57212. * @param parsedTexture defines parsed texture data
  57213. * @param scene defines the current scene
  57214. * @param rootUrl defines the root URL containing noise procedural texture information
  57215. * @returns a parsed NoiseProceduralTexture
  57216. */
  57217. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57218. }
  57219. }
  57220. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  57221. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  57222. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  57223. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57224. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  57225. }
  57226. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  57227. import { Nullable } from "babylonjs/types";
  57228. import { Scene } from "babylonjs/scene";
  57229. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57230. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57231. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57232. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57233. /**
  57234. * Raw cube texture where the raw buffers are passed in
  57235. */
  57236. export class RawCubeTexture extends CubeTexture {
  57237. /**
  57238. * Creates a cube texture where the raw buffers are passed in.
  57239. * @param scene defines the scene the texture is attached to
  57240. * @param data defines the array of data to use to create each face
  57241. * @param size defines the size of the textures
  57242. * @param format defines the format of the data
  57243. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57244. * @param generateMipMaps defines if the engine should generate the mip levels
  57245. * @param invertY defines if data must be stored with Y axis inverted
  57246. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57247. * @param compression defines the compression used (null by default)
  57248. */
  57249. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57250. /**
  57251. * Updates the raw cube texture.
  57252. * @param data defines the data to store
  57253. * @param format defines the data format
  57254. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57255. * @param invertY defines if data must be stored with Y axis inverted
  57256. * @param compression defines the compression used (null by default)
  57257. * @param level defines which level of the texture to update
  57258. */
  57259. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57260. /**
  57261. * Updates a raw cube texture with RGBD encoded data.
  57262. * @param data defines the array of data [mipmap][face] to use to create each face
  57263. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57264. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57265. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57266. * @returns a promsie that resolves when the operation is complete
  57267. */
  57268. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57269. /**
  57270. * Clones the raw cube texture.
  57271. * @return a new cube texture
  57272. */
  57273. clone(): CubeTexture;
  57274. /** @hidden */
  57275. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57276. }
  57277. }
  57278. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  57279. import { Scene } from "babylonjs/scene";
  57280. import { Texture } from "babylonjs/Materials/Textures/texture";
  57281. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57282. /**
  57283. * Class used to store 3D textures containing user data
  57284. */
  57285. export class RawTexture3D extends Texture {
  57286. /** Gets or sets the texture format to use */
  57287. format: number;
  57288. private _engine;
  57289. /**
  57290. * Create a new RawTexture3D
  57291. * @param data defines the data of the texture
  57292. * @param width defines the width of the texture
  57293. * @param height defines the height of the texture
  57294. * @param depth defines the depth of the texture
  57295. * @param format defines the texture format to use
  57296. * @param scene defines the hosting scene
  57297. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57298. * @param invertY defines if texture must be stored with Y axis inverted
  57299. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57300. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57301. */
  57302. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57303. /** Gets or sets the texture format to use */
  57304. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57305. /**
  57306. * Update the texture with new data
  57307. * @param data defines the data to store in the texture
  57308. */
  57309. update(data: ArrayBufferView): void;
  57310. }
  57311. }
  57312. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  57313. import { Scene } from "babylonjs/scene";
  57314. import { Texture } from "babylonjs/Materials/Textures/texture";
  57315. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57316. /**
  57317. * Class used to store 2D array textures containing user data
  57318. */
  57319. export class RawTexture2DArray extends Texture {
  57320. /** Gets or sets the texture format to use */
  57321. format: number;
  57322. private _engine;
  57323. /**
  57324. * Create a new RawTexture2DArray
  57325. * @param data defines the data of the texture
  57326. * @param width defines the width of the texture
  57327. * @param height defines the height of the texture
  57328. * @param depth defines the number of layers of the texture
  57329. * @param format defines the texture format to use
  57330. * @param scene defines the hosting scene
  57331. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57332. * @param invertY defines if texture must be stored with Y axis inverted
  57333. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57334. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57335. */
  57336. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57337. /** Gets or sets the texture format to use */
  57338. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57339. /**
  57340. * Update the texture with new data
  57341. * @param data defines the data to store in the texture
  57342. */
  57343. update(data: ArrayBufferView): void;
  57344. }
  57345. }
  57346. declare module "babylonjs/Materials/Textures/refractionTexture" {
  57347. import { Scene } from "babylonjs/scene";
  57348. import { Plane } from "babylonjs/Maths/math.plane";
  57349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57350. /**
  57351. * Creates a refraction texture used by refraction channel of the standard material.
  57352. * It is like a mirror but to see through a material.
  57353. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57354. */
  57355. export class RefractionTexture extends RenderTargetTexture {
  57356. /**
  57357. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57358. * 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.
  57359. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57360. */
  57361. refractionPlane: Plane;
  57362. /**
  57363. * Define how deep under the surface we should see.
  57364. */
  57365. depth: number;
  57366. /**
  57367. * Creates a refraction texture used by refraction channel of the standard material.
  57368. * It is like a mirror but to see through a material.
  57369. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57370. * @param name Define the texture name
  57371. * @param size Define the size of the underlying texture
  57372. * @param scene Define the scene the refraction belongs to
  57373. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57374. */
  57375. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57376. /**
  57377. * Clone the refraction texture.
  57378. * @returns the cloned texture
  57379. */
  57380. clone(): RefractionTexture;
  57381. /**
  57382. * Serialize the texture to a JSON representation you could use in Parse later on
  57383. * @returns the serialized JSON representation
  57384. */
  57385. serialize(): any;
  57386. }
  57387. }
  57388. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  57389. import { Nullable } from "babylonjs/types";
  57390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57391. import { Matrix } from "babylonjs/Maths/math.vector";
  57392. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57393. import "babylonjs/Engines/Extensions/engine.videoTexture";
  57394. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  57395. import { Scene } from "babylonjs/scene";
  57396. /**
  57397. * Defines the options related to the creation of an HtmlElementTexture
  57398. */
  57399. export interface IHtmlElementTextureOptions {
  57400. /**
  57401. * Defines wether mip maps should be created or not.
  57402. */
  57403. generateMipMaps?: boolean;
  57404. /**
  57405. * Defines the sampling mode of the texture.
  57406. */
  57407. samplingMode?: number;
  57408. /**
  57409. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57410. */
  57411. engine: Nullable<ThinEngine>;
  57412. /**
  57413. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57414. */
  57415. scene: Nullable<Scene>;
  57416. }
  57417. /**
  57418. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57419. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57420. * is automatically managed.
  57421. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57422. * in your application.
  57423. *
  57424. * As the update is not automatic, you need to call them manually.
  57425. */
  57426. export class HtmlElementTexture extends BaseTexture {
  57427. /**
  57428. * The texture URL.
  57429. */
  57430. element: HTMLVideoElement | HTMLCanvasElement;
  57431. private static readonly DefaultOptions;
  57432. private _textureMatrix;
  57433. private _engine;
  57434. private _isVideo;
  57435. private _generateMipMaps;
  57436. private _samplingMode;
  57437. /**
  57438. * Instantiates a HtmlElementTexture from the following parameters.
  57439. *
  57440. * @param name Defines the name of the texture
  57441. * @param element Defines the video or canvas the texture is filled with
  57442. * @param options Defines the other none mandatory texture creation options
  57443. */
  57444. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57445. private _createInternalTexture;
  57446. /**
  57447. * Returns the texture matrix used in most of the material.
  57448. */
  57449. getTextureMatrix(): Matrix;
  57450. /**
  57451. * Updates the content of the texture.
  57452. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57453. */
  57454. update(invertY?: Nullable<boolean>): void;
  57455. }
  57456. }
  57457. declare module "babylonjs/Materials/Textures/index" {
  57458. export * from "babylonjs/Materials/Textures/baseTexture";
  57459. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  57460. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  57461. export * from "babylonjs/Materials/Textures/cubeTexture";
  57462. export * from "babylonjs/Materials/Textures/dynamicTexture";
  57463. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57464. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  57465. export * from "babylonjs/Materials/Textures/internalTexture";
  57466. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  57467. export * from "babylonjs/Materials/Textures/Loaders/index";
  57468. export * from "babylonjs/Materials/Textures/mirrorTexture";
  57469. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  57470. export * from "babylonjs/Materials/Textures/Procedurals/index";
  57471. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  57472. export * from "babylonjs/Materials/Textures/rawTexture";
  57473. export * from "babylonjs/Materials/Textures/rawTexture3D";
  57474. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  57475. export * from "babylonjs/Materials/Textures/refractionTexture";
  57476. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  57477. export * from "babylonjs/Materials/Textures/texture";
  57478. export * from "babylonjs/Materials/Textures/videoTexture";
  57479. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  57480. }
  57481. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  57482. /**
  57483. * Enum used to define the target of a block
  57484. */
  57485. export enum NodeMaterialBlockTargets {
  57486. /** Vertex shader */
  57487. Vertex = 1,
  57488. /** Fragment shader */
  57489. Fragment = 2,
  57490. /** Neutral */
  57491. Neutral = 4,
  57492. /** Vertex and Fragment */
  57493. VertexAndFragment = 3
  57494. }
  57495. }
  57496. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  57497. /**
  57498. * Defines the kind of connection point for node based material
  57499. */
  57500. export enum NodeMaterialBlockConnectionPointTypes {
  57501. /** Float */
  57502. Float = 1,
  57503. /** Int */
  57504. Int = 2,
  57505. /** Vector2 */
  57506. Vector2 = 4,
  57507. /** Vector3 */
  57508. Vector3 = 8,
  57509. /** Vector4 */
  57510. Vector4 = 16,
  57511. /** Color3 */
  57512. Color3 = 32,
  57513. /** Color4 */
  57514. Color4 = 64,
  57515. /** Matrix */
  57516. Matrix = 128,
  57517. /** Detect type based on connection */
  57518. AutoDetect = 1024,
  57519. /** Output type that will be defined by input type */
  57520. BasedOnInput = 2048
  57521. }
  57522. }
  57523. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  57524. /**
  57525. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57526. */
  57527. export enum NodeMaterialBlockConnectionPointMode {
  57528. /** Value is an uniform */
  57529. Uniform = 0,
  57530. /** Value is a mesh attribute */
  57531. Attribute = 1,
  57532. /** Value is a varying between vertex and fragment shaders */
  57533. Varying = 2,
  57534. /** Mode is undefined */
  57535. Undefined = 3
  57536. }
  57537. }
  57538. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  57539. /**
  57540. * Enum used to define system values e.g. values automatically provided by the system
  57541. */
  57542. export enum NodeMaterialSystemValues {
  57543. /** World */
  57544. World = 1,
  57545. /** View */
  57546. View = 2,
  57547. /** Projection */
  57548. Projection = 3,
  57549. /** ViewProjection */
  57550. ViewProjection = 4,
  57551. /** WorldView */
  57552. WorldView = 5,
  57553. /** WorldViewProjection */
  57554. WorldViewProjection = 6,
  57555. /** CameraPosition */
  57556. CameraPosition = 7,
  57557. /** Fog Color */
  57558. FogColor = 8,
  57559. /** Delta time */
  57560. DeltaTime = 9
  57561. }
  57562. }
  57563. declare module "babylonjs/Materials/Node/Enums/index" {
  57564. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57565. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57566. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  57567. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57568. }
  57569. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  57570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57571. /**
  57572. * Root class for all node material optimizers
  57573. */
  57574. export class NodeMaterialOptimizer {
  57575. /**
  57576. * Function used to optimize a NodeMaterial graph
  57577. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57578. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57579. */
  57580. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57581. }
  57582. }
  57583. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  57584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57587. import { Scene } from "babylonjs/scene";
  57588. /**
  57589. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57590. */
  57591. export class TransformBlock extends NodeMaterialBlock {
  57592. /**
  57593. * Defines the value to use to complement W value to transform it to a Vector4
  57594. */
  57595. complementW: number;
  57596. /**
  57597. * Defines the value to use to complement z value to transform it to a Vector4
  57598. */
  57599. complementZ: number;
  57600. /**
  57601. * Creates a new TransformBlock
  57602. * @param name defines the block name
  57603. */
  57604. constructor(name: string);
  57605. /**
  57606. * Gets the current class name
  57607. * @returns the class name
  57608. */
  57609. getClassName(): string;
  57610. /**
  57611. * Gets the vector input
  57612. */
  57613. get vector(): NodeMaterialConnectionPoint;
  57614. /**
  57615. * Gets the output component
  57616. */
  57617. get output(): NodeMaterialConnectionPoint;
  57618. /**
  57619. * Gets the matrix transform input
  57620. */
  57621. get transform(): NodeMaterialConnectionPoint;
  57622. protected _buildBlock(state: NodeMaterialBuildState): this;
  57623. serialize(): any;
  57624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57625. protected _dumpPropertiesCode(): string;
  57626. }
  57627. }
  57628. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  57629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57632. /**
  57633. * Block used to output the vertex position
  57634. */
  57635. export class VertexOutputBlock extends NodeMaterialBlock {
  57636. /**
  57637. * Creates a new VertexOutputBlock
  57638. * @param name defines the block name
  57639. */
  57640. constructor(name: string);
  57641. /**
  57642. * Gets the current class name
  57643. * @returns the class name
  57644. */
  57645. getClassName(): string;
  57646. /**
  57647. * Gets the vector input component
  57648. */
  57649. get vector(): NodeMaterialConnectionPoint;
  57650. protected _buildBlock(state: NodeMaterialBuildState): this;
  57651. }
  57652. }
  57653. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  57654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57657. /**
  57658. * Block used to output the final color
  57659. */
  57660. export class FragmentOutputBlock extends NodeMaterialBlock {
  57661. /**
  57662. * Create a new FragmentOutputBlock
  57663. * @param name defines the block name
  57664. */
  57665. constructor(name: string);
  57666. /**
  57667. * Gets the current class name
  57668. * @returns the class name
  57669. */
  57670. getClassName(): string;
  57671. /**
  57672. * Gets the rgba input component
  57673. */
  57674. get rgba(): NodeMaterialConnectionPoint;
  57675. /**
  57676. * Gets the rgb input component
  57677. */
  57678. get rgb(): NodeMaterialConnectionPoint;
  57679. /**
  57680. * Gets the a input component
  57681. */
  57682. get a(): NodeMaterialConnectionPoint;
  57683. protected _buildBlock(state: NodeMaterialBuildState): this;
  57684. }
  57685. }
  57686. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  57687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57690. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57692. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57693. import { Effect } from "babylonjs/Materials/effect";
  57694. import { Mesh } from "babylonjs/Meshes/mesh";
  57695. import { Nullable } from "babylonjs/types";
  57696. import { Scene } from "babylonjs/scene";
  57697. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57698. /**
  57699. * Block used to read a reflection texture from a sampler
  57700. */
  57701. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57702. private _define3DName;
  57703. private _defineCubicName;
  57704. private _defineExplicitName;
  57705. private _defineProjectionName;
  57706. private _defineLocalCubicName;
  57707. private _defineSphericalName;
  57708. private _definePlanarName;
  57709. private _defineEquirectangularName;
  57710. private _defineMirroredEquirectangularFixedName;
  57711. private _defineEquirectangularFixedName;
  57712. private _defineSkyboxName;
  57713. private _cubeSamplerName;
  57714. private _2DSamplerName;
  57715. private _positionUVWName;
  57716. private _directionWName;
  57717. private _reflectionCoordsName;
  57718. private _reflection2DCoordsName;
  57719. private _reflectionColorName;
  57720. private _reflectionMatrixName;
  57721. /**
  57722. * Gets or sets the texture associated with the node
  57723. */
  57724. texture: Nullable<BaseTexture>;
  57725. /**
  57726. * Create a new TextureBlock
  57727. * @param name defines the block name
  57728. */
  57729. constructor(name: string);
  57730. /**
  57731. * Gets the current class name
  57732. * @returns the class name
  57733. */
  57734. getClassName(): string;
  57735. /**
  57736. * Gets the world position input component
  57737. */
  57738. get position(): NodeMaterialConnectionPoint;
  57739. /**
  57740. * Gets the world position input component
  57741. */
  57742. get worldPosition(): NodeMaterialConnectionPoint;
  57743. /**
  57744. * Gets the world normal input component
  57745. */
  57746. get worldNormal(): NodeMaterialConnectionPoint;
  57747. /**
  57748. * Gets the world input component
  57749. */
  57750. get world(): NodeMaterialConnectionPoint;
  57751. /**
  57752. * Gets the camera (or eye) position component
  57753. */
  57754. get cameraPosition(): NodeMaterialConnectionPoint;
  57755. /**
  57756. * Gets the view input component
  57757. */
  57758. get view(): NodeMaterialConnectionPoint;
  57759. /**
  57760. * Gets the rgb output component
  57761. */
  57762. get rgb(): NodeMaterialConnectionPoint;
  57763. /**
  57764. * Gets the r output component
  57765. */
  57766. get r(): NodeMaterialConnectionPoint;
  57767. /**
  57768. * Gets the g output component
  57769. */
  57770. get g(): NodeMaterialConnectionPoint;
  57771. /**
  57772. * Gets the b output component
  57773. */
  57774. get b(): NodeMaterialConnectionPoint;
  57775. autoConfigure(material: NodeMaterial): void;
  57776. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57777. isReady(): boolean;
  57778. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57779. private _injectVertexCode;
  57780. private _writeOutput;
  57781. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57782. protected _dumpPropertiesCode(): string;
  57783. serialize(): any;
  57784. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57785. }
  57786. }
  57787. declare module "babylonjs/Materials/Node/nodeMaterial" {
  57788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57789. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57790. import { Scene } from "babylonjs/scene";
  57791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57792. import { Matrix } from "babylonjs/Maths/math.vector";
  57793. import { Mesh } from "babylonjs/Meshes/mesh";
  57794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57795. import { Observable } from "babylonjs/Misc/observable";
  57796. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57797. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57798. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57799. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57800. import { Nullable } from "babylonjs/types";
  57801. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57802. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57803. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57804. /**
  57805. * Interface used to configure the node material editor
  57806. */
  57807. export interface INodeMaterialEditorOptions {
  57808. /** Define the URl to load node editor script */
  57809. editorURL?: string;
  57810. }
  57811. /** @hidden */
  57812. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57813. /** BONES */
  57814. NUM_BONE_INFLUENCERS: number;
  57815. BonesPerMesh: number;
  57816. BONETEXTURE: boolean;
  57817. /** MORPH TARGETS */
  57818. MORPHTARGETS: boolean;
  57819. MORPHTARGETS_NORMAL: boolean;
  57820. MORPHTARGETS_TANGENT: boolean;
  57821. MORPHTARGETS_UV: boolean;
  57822. NUM_MORPH_INFLUENCERS: number;
  57823. /** IMAGE PROCESSING */
  57824. IMAGEPROCESSING: boolean;
  57825. VIGNETTE: boolean;
  57826. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57827. VIGNETTEBLENDMODEOPAQUE: boolean;
  57828. TONEMAPPING: boolean;
  57829. TONEMAPPING_ACES: boolean;
  57830. CONTRAST: boolean;
  57831. EXPOSURE: boolean;
  57832. COLORCURVES: boolean;
  57833. COLORGRADING: boolean;
  57834. COLORGRADING3D: boolean;
  57835. SAMPLER3DGREENDEPTH: boolean;
  57836. SAMPLER3DBGRMAP: boolean;
  57837. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57838. /** MISC. */
  57839. BUMPDIRECTUV: number;
  57840. constructor();
  57841. setValue(name: string, value: boolean): void;
  57842. }
  57843. /**
  57844. * Class used to configure NodeMaterial
  57845. */
  57846. export interface INodeMaterialOptions {
  57847. /**
  57848. * Defines if blocks should emit comments
  57849. */
  57850. emitComments: boolean;
  57851. }
  57852. /**
  57853. * Class used to create a node based material built by assembling shader blocks
  57854. */
  57855. export class NodeMaterial extends PushMaterial {
  57856. private static _BuildIdGenerator;
  57857. private _options;
  57858. private _vertexCompilationState;
  57859. private _fragmentCompilationState;
  57860. private _sharedData;
  57861. private _buildId;
  57862. private _buildWasSuccessful;
  57863. private _cachedWorldViewMatrix;
  57864. private _cachedWorldViewProjectionMatrix;
  57865. private _optimizers;
  57866. private _animationFrame;
  57867. /** Define the URl to load node editor script */
  57868. static EditorURL: string;
  57869. private BJSNODEMATERIALEDITOR;
  57870. /** Get the inspector from bundle or global */
  57871. private _getGlobalNodeMaterialEditor;
  57872. /**
  57873. * Gets or sets data used by visual editor
  57874. * @see https://nme.babylonjs.com
  57875. */
  57876. editorData: any;
  57877. /**
  57878. * 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)
  57879. */
  57880. ignoreAlpha: boolean;
  57881. /**
  57882. * Defines the maximum number of lights that can be used in the material
  57883. */
  57884. maxSimultaneousLights: number;
  57885. /**
  57886. * Observable raised when the material is built
  57887. */
  57888. onBuildObservable: Observable<NodeMaterial>;
  57889. /**
  57890. * Gets or sets the root nodes of the material vertex shader
  57891. */
  57892. _vertexOutputNodes: NodeMaterialBlock[];
  57893. /**
  57894. * Gets or sets the root nodes of the material fragment (pixel) shader
  57895. */
  57896. _fragmentOutputNodes: NodeMaterialBlock[];
  57897. /** Gets or sets options to control the node material overall behavior */
  57898. get options(): INodeMaterialOptions;
  57899. set options(options: INodeMaterialOptions);
  57900. /**
  57901. * Default configuration related to image processing available in the standard Material.
  57902. */
  57903. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57904. /**
  57905. * Gets the image processing configuration used either in this material.
  57906. */
  57907. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57908. /**
  57909. * Sets the Default image processing configuration used either in the this material.
  57910. *
  57911. * If sets to null, the scene one is in use.
  57912. */
  57913. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57914. /**
  57915. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57916. */
  57917. attachedBlocks: NodeMaterialBlock[];
  57918. /**
  57919. * Create a new node based material
  57920. * @param name defines the material name
  57921. * @param scene defines the hosting scene
  57922. * @param options defines creation option
  57923. */
  57924. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57925. /**
  57926. * Gets the current class name of the material e.g. "NodeMaterial"
  57927. * @returns the class name
  57928. */
  57929. getClassName(): string;
  57930. /**
  57931. * Keep track of the image processing observer to allow dispose and replace.
  57932. */
  57933. private _imageProcessingObserver;
  57934. /**
  57935. * Attaches a new image processing configuration to the Standard Material.
  57936. * @param configuration
  57937. */
  57938. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57939. /**
  57940. * Get a block by its name
  57941. * @param name defines the name of the block to retrieve
  57942. * @returns the required block or null if not found
  57943. */
  57944. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57945. /**
  57946. * Get a block by its name
  57947. * @param predicate defines the predicate used to find the good candidate
  57948. * @returns the required block or null if not found
  57949. */
  57950. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57951. /**
  57952. * Get an input block by its name
  57953. * @param predicate defines the predicate used to find the good candidate
  57954. * @returns the required input block or null if not found
  57955. */
  57956. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57957. /**
  57958. * Gets the list of input blocks attached to this material
  57959. * @returns an array of InputBlocks
  57960. */
  57961. getInputBlocks(): InputBlock[];
  57962. /**
  57963. * Adds a new optimizer to the list of optimizers
  57964. * @param optimizer defines the optimizers to add
  57965. * @returns the current material
  57966. */
  57967. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57968. /**
  57969. * Remove an optimizer from the list of optimizers
  57970. * @param optimizer defines the optimizers to remove
  57971. * @returns the current material
  57972. */
  57973. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57974. /**
  57975. * Add a new block to the list of output nodes
  57976. * @param node defines the node to add
  57977. * @returns the current material
  57978. */
  57979. addOutputNode(node: NodeMaterialBlock): this;
  57980. /**
  57981. * Remove a block from the list of root nodes
  57982. * @param node defines the node to remove
  57983. * @returns the current material
  57984. */
  57985. removeOutputNode(node: NodeMaterialBlock): this;
  57986. private _addVertexOutputNode;
  57987. private _removeVertexOutputNode;
  57988. private _addFragmentOutputNode;
  57989. private _removeFragmentOutputNode;
  57990. /**
  57991. * Specifies if the material will require alpha blending
  57992. * @returns a boolean specifying if alpha blending is needed
  57993. */
  57994. needAlphaBlending(): boolean;
  57995. /**
  57996. * Specifies if this material should be rendered in alpha test mode
  57997. * @returns a boolean specifying if an alpha test is needed.
  57998. */
  57999. needAlphaTesting(): boolean;
  58000. private _initializeBlock;
  58001. private _resetDualBlocks;
  58002. /**
  58003. * Remove a block from the current node material
  58004. * @param block defines the block to remove
  58005. */
  58006. removeBlock(block: NodeMaterialBlock): void;
  58007. /**
  58008. * Build the material and generates the inner effect
  58009. * @param verbose defines if the build should log activity
  58010. */
  58011. build(verbose?: boolean): void;
  58012. /**
  58013. * Runs an otpimization phase to try to improve the shader code
  58014. */
  58015. optimize(): void;
  58016. private _prepareDefinesForAttributes;
  58017. /**
  58018. * Get if the submesh is ready to be used and all its information available.
  58019. * Child classes can use it to update shaders
  58020. * @param mesh defines the mesh to check
  58021. * @param subMesh defines which submesh to check
  58022. * @param useInstances specifies that instances should be used
  58023. * @returns a boolean indicating that the submesh is ready or not
  58024. */
  58025. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58026. /**
  58027. * Get a string representing the shaders built by the current node graph
  58028. */
  58029. get compiledShaders(): string;
  58030. /**
  58031. * Binds the world matrix to the material
  58032. * @param world defines the world transformation matrix
  58033. */
  58034. bindOnlyWorldMatrix(world: Matrix): void;
  58035. /**
  58036. * Binds the submesh to this material by preparing the effect and shader to draw
  58037. * @param world defines the world transformation matrix
  58038. * @param mesh defines the mesh containing the submesh
  58039. * @param subMesh defines the submesh to bind the material to
  58040. */
  58041. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58042. /**
  58043. * Gets the active textures from the material
  58044. * @returns an array of textures
  58045. */
  58046. getActiveTextures(): BaseTexture[];
  58047. /**
  58048. * Gets the list of texture blocks
  58049. * @returns an array of texture blocks
  58050. */
  58051. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  58052. /**
  58053. * Specifies if the material uses a texture
  58054. * @param texture defines the texture to check against the material
  58055. * @returns a boolean specifying if the material uses the texture
  58056. */
  58057. hasTexture(texture: BaseTexture): boolean;
  58058. /**
  58059. * Disposes the material
  58060. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58061. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58062. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58063. */
  58064. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58065. /** Creates the node editor window. */
  58066. private _createNodeEditor;
  58067. /**
  58068. * Launch the node material editor
  58069. * @param config Define the configuration of the editor
  58070. * @return a promise fulfilled when the node editor is visible
  58071. */
  58072. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58073. /**
  58074. * Clear the current material
  58075. */
  58076. clear(): void;
  58077. /**
  58078. * Clear the current material and set it to a default state
  58079. */
  58080. setToDefault(): void;
  58081. /**
  58082. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58083. * @param url defines the url to load from
  58084. * @returns a promise that will fullfil when the material is fully loaded
  58085. */
  58086. loadAsync(url: string): Promise<void>;
  58087. private _gatherBlocks;
  58088. /**
  58089. * Generate a string containing the code declaration required to create an equivalent of this material
  58090. * @returns a string
  58091. */
  58092. generateCode(): string;
  58093. /**
  58094. * Serializes this material in a JSON representation
  58095. * @returns the serialized material object
  58096. */
  58097. serialize(): any;
  58098. private _restoreConnections;
  58099. /**
  58100. * Clear the current graph and load a new one from a serialization object
  58101. * @param source defines the JSON representation of the material
  58102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58103. */
  58104. loadFromSerialization(source: any, rootUrl?: string): void;
  58105. /**
  58106. * Creates a node material from parsed material data
  58107. * @param source defines the JSON representation of the material
  58108. * @param scene defines the hosting scene
  58109. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58110. * @returns a new node material
  58111. */
  58112. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58113. /**
  58114. * Creates a new node material set to default basic configuration
  58115. * @param name defines the name of the material
  58116. * @param scene defines the hosting scene
  58117. * @returns a new NodeMaterial
  58118. */
  58119. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58120. }
  58121. }
  58122. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  58123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58125. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58126. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58128. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58129. import { Effect } from "babylonjs/Materials/effect";
  58130. import { Mesh } from "babylonjs/Meshes/mesh";
  58131. import { Nullable } from "babylonjs/types";
  58132. import { Texture } from "babylonjs/Materials/Textures/texture";
  58133. import { Scene } from "babylonjs/scene";
  58134. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58135. /**
  58136. * Block used to read a texture from a sampler
  58137. */
  58138. export class TextureBlock extends NodeMaterialBlock {
  58139. private _defineName;
  58140. private _linearDefineName;
  58141. private _tempTextureRead;
  58142. private _samplerName;
  58143. private _transformedUVName;
  58144. private _textureTransformName;
  58145. private _textureInfoName;
  58146. private _mainUVName;
  58147. private _mainUVDefineName;
  58148. /**
  58149. * Gets or sets the texture associated with the node
  58150. */
  58151. texture: Nullable<Texture>;
  58152. /**
  58153. * Create a new TextureBlock
  58154. * @param name defines the block name
  58155. */
  58156. constructor(name: string);
  58157. /**
  58158. * Gets the current class name
  58159. * @returns the class name
  58160. */
  58161. getClassName(): string;
  58162. /**
  58163. * Gets the uv input component
  58164. */
  58165. get uv(): NodeMaterialConnectionPoint;
  58166. /**
  58167. * Gets the rgba output component
  58168. */
  58169. get rgba(): NodeMaterialConnectionPoint;
  58170. /**
  58171. * Gets the rgb output component
  58172. */
  58173. get rgb(): NodeMaterialConnectionPoint;
  58174. /**
  58175. * Gets the r output component
  58176. */
  58177. get r(): NodeMaterialConnectionPoint;
  58178. /**
  58179. * Gets the g output component
  58180. */
  58181. get g(): NodeMaterialConnectionPoint;
  58182. /**
  58183. * Gets the b output component
  58184. */
  58185. get b(): NodeMaterialConnectionPoint;
  58186. /**
  58187. * Gets the a output component
  58188. */
  58189. get a(): NodeMaterialConnectionPoint;
  58190. get target(): NodeMaterialBlockTargets;
  58191. autoConfigure(material: NodeMaterial): void;
  58192. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58193. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58194. private _getTextureBase;
  58195. isReady(): boolean;
  58196. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58197. private get _isMixed();
  58198. private _injectVertexCode;
  58199. private _writeTextureRead;
  58200. private _writeOutput;
  58201. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58202. protected _dumpPropertiesCode(): string;
  58203. serialize(): any;
  58204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58205. }
  58206. }
  58207. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  58208. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58210. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58211. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58212. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58213. import { Scene } from "babylonjs/scene";
  58214. /**
  58215. * Class used to store shared data between 2 NodeMaterialBuildState
  58216. */
  58217. export class NodeMaterialBuildStateSharedData {
  58218. /**
  58219. * Gets the list of emitted varyings
  58220. */
  58221. temps: string[];
  58222. /**
  58223. * Gets the list of emitted varyings
  58224. */
  58225. varyings: string[];
  58226. /**
  58227. * Gets the varying declaration string
  58228. */
  58229. varyingDeclaration: string;
  58230. /**
  58231. * Input blocks
  58232. */
  58233. inputBlocks: InputBlock[];
  58234. /**
  58235. * Input blocks
  58236. */
  58237. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58238. /**
  58239. * Bindable blocks (Blocks that need to set data to the effect)
  58240. */
  58241. bindableBlocks: NodeMaterialBlock[];
  58242. /**
  58243. * List of blocks that can provide a compilation fallback
  58244. */
  58245. blocksWithFallbacks: NodeMaterialBlock[];
  58246. /**
  58247. * List of blocks that can provide a define update
  58248. */
  58249. blocksWithDefines: NodeMaterialBlock[];
  58250. /**
  58251. * List of blocks that can provide a repeatable content
  58252. */
  58253. repeatableContentBlocks: NodeMaterialBlock[];
  58254. /**
  58255. * List of blocks that can provide a dynamic list of uniforms
  58256. */
  58257. dynamicUniformBlocks: NodeMaterialBlock[];
  58258. /**
  58259. * List of blocks that can block the isReady function for the material
  58260. */
  58261. blockingBlocks: NodeMaterialBlock[];
  58262. /**
  58263. * Gets the list of animated inputs
  58264. */
  58265. animatedInputs: InputBlock[];
  58266. /**
  58267. * Build Id used to avoid multiple recompilations
  58268. */
  58269. buildId: number;
  58270. /** List of emitted variables */
  58271. variableNames: {
  58272. [key: string]: number;
  58273. };
  58274. /** List of emitted defines */
  58275. defineNames: {
  58276. [key: string]: number;
  58277. };
  58278. /** Should emit comments? */
  58279. emitComments: boolean;
  58280. /** Emit build activity */
  58281. verbose: boolean;
  58282. /** Gets or sets the hosting scene */
  58283. scene: Scene;
  58284. /**
  58285. * Gets the compilation hints emitted at compilation time
  58286. */
  58287. hints: {
  58288. needWorldViewMatrix: boolean;
  58289. needWorldViewProjectionMatrix: boolean;
  58290. needAlphaBlending: boolean;
  58291. needAlphaTesting: boolean;
  58292. };
  58293. /**
  58294. * List of compilation checks
  58295. */
  58296. checks: {
  58297. emitVertex: boolean;
  58298. emitFragment: boolean;
  58299. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58300. };
  58301. /** Creates a new shared data */
  58302. constructor();
  58303. /**
  58304. * Emits console errors and exceptions if there is a failing check
  58305. */
  58306. emitErrors(): void;
  58307. }
  58308. }
  58309. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  58310. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58311. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58312. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  58313. /**
  58314. * Class used to store node based material build state
  58315. */
  58316. export class NodeMaterialBuildState {
  58317. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58318. supportUniformBuffers: boolean;
  58319. /**
  58320. * Gets the list of emitted attributes
  58321. */
  58322. attributes: string[];
  58323. /**
  58324. * Gets the list of emitted uniforms
  58325. */
  58326. uniforms: string[];
  58327. /**
  58328. * Gets the list of emitted constants
  58329. */
  58330. constants: string[];
  58331. /**
  58332. * Gets the list of emitted samplers
  58333. */
  58334. samplers: string[];
  58335. /**
  58336. * Gets the list of emitted functions
  58337. */
  58338. functions: {
  58339. [key: string]: string;
  58340. };
  58341. /**
  58342. * Gets the list of emitted extensions
  58343. */
  58344. extensions: {
  58345. [key: string]: string;
  58346. };
  58347. /**
  58348. * Gets the target of the compilation state
  58349. */
  58350. target: NodeMaterialBlockTargets;
  58351. /**
  58352. * Gets the list of emitted counters
  58353. */
  58354. counters: {
  58355. [key: string]: number;
  58356. };
  58357. /**
  58358. * Shared data between multiple NodeMaterialBuildState instances
  58359. */
  58360. sharedData: NodeMaterialBuildStateSharedData;
  58361. /** @hidden */
  58362. _vertexState: NodeMaterialBuildState;
  58363. /** @hidden */
  58364. _attributeDeclaration: string;
  58365. /** @hidden */
  58366. _uniformDeclaration: string;
  58367. /** @hidden */
  58368. _constantDeclaration: string;
  58369. /** @hidden */
  58370. _samplerDeclaration: string;
  58371. /** @hidden */
  58372. _varyingTransfer: string;
  58373. private _repeatableContentAnchorIndex;
  58374. /** @hidden */
  58375. _builtCompilationString: string;
  58376. /**
  58377. * Gets the emitted compilation strings
  58378. */
  58379. compilationString: string;
  58380. /**
  58381. * Finalize the compilation strings
  58382. * @param state defines the current compilation state
  58383. */
  58384. finalize(state: NodeMaterialBuildState): void;
  58385. /** @hidden */
  58386. get _repeatableContentAnchor(): string;
  58387. /** @hidden */
  58388. _getFreeVariableName(prefix: string): string;
  58389. /** @hidden */
  58390. _getFreeDefineName(prefix: string): string;
  58391. /** @hidden */
  58392. _excludeVariableName(name: string): void;
  58393. /** @hidden */
  58394. _emit2DSampler(name: string): void;
  58395. /** @hidden */
  58396. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58397. /** @hidden */
  58398. _emitExtension(name: string, extension: string): void;
  58399. /** @hidden */
  58400. _emitFunction(name: string, code: string, comments: string): void;
  58401. /** @hidden */
  58402. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58403. replaceStrings?: {
  58404. search: RegExp;
  58405. replace: string;
  58406. }[];
  58407. repeatKey?: string;
  58408. }): string;
  58409. /** @hidden */
  58410. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58411. repeatKey?: string;
  58412. removeAttributes?: boolean;
  58413. removeUniforms?: boolean;
  58414. removeVaryings?: boolean;
  58415. removeIfDef?: boolean;
  58416. replaceStrings?: {
  58417. search: RegExp;
  58418. replace: string;
  58419. }[];
  58420. }, storeKey?: string): void;
  58421. /** @hidden */
  58422. _registerTempVariable(name: string): boolean;
  58423. /** @hidden */
  58424. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58425. /** @hidden */
  58426. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58427. /** @hidden */
  58428. _emitFloat(value: number): string;
  58429. }
  58430. }
  58431. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  58432. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58433. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58434. import { Nullable } from "babylonjs/types";
  58435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58436. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58437. import { Effect } from "babylonjs/Materials/effect";
  58438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58439. import { Mesh } from "babylonjs/Meshes/mesh";
  58440. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58441. import { Scene } from "babylonjs/scene";
  58442. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58443. /**
  58444. * Defines a block that can be used inside a node based material
  58445. */
  58446. export class NodeMaterialBlock {
  58447. private _buildId;
  58448. private _buildTarget;
  58449. private _target;
  58450. private _isFinalMerger;
  58451. private _isInput;
  58452. protected _isUnique: boolean;
  58453. /** @hidden */
  58454. _codeVariableName: string;
  58455. /** @hidden */
  58456. _inputs: NodeMaterialConnectionPoint[];
  58457. /** @hidden */
  58458. _outputs: NodeMaterialConnectionPoint[];
  58459. /** @hidden */
  58460. _preparationId: number;
  58461. /**
  58462. * Gets or sets the name of the block
  58463. */
  58464. name: string;
  58465. /**
  58466. * Gets or sets the unique id of the node
  58467. */
  58468. uniqueId: number;
  58469. /**
  58470. * Gets or sets the comments associated with this block
  58471. */
  58472. comments: string;
  58473. /**
  58474. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58475. */
  58476. get isUnique(): boolean;
  58477. /**
  58478. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58479. */
  58480. get isFinalMerger(): boolean;
  58481. /**
  58482. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58483. */
  58484. get isInput(): boolean;
  58485. /**
  58486. * Gets or sets the build Id
  58487. */
  58488. get buildId(): number;
  58489. set buildId(value: number);
  58490. /**
  58491. * Gets or sets the target of the block
  58492. */
  58493. get target(): NodeMaterialBlockTargets;
  58494. set target(value: NodeMaterialBlockTargets);
  58495. /**
  58496. * Gets the list of input points
  58497. */
  58498. get inputs(): NodeMaterialConnectionPoint[];
  58499. /** Gets the list of output points */
  58500. get outputs(): NodeMaterialConnectionPoint[];
  58501. /**
  58502. * Find an input by its name
  58503. * @param name defines the name of the input to look for
  58504. * @returns the input or null if not found
  58505. */
  58506. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58507. /**
  58508. * Find an output by its name
  58509. * @param name defines the name of the outputto look for
  58510. * @returns the output or null if not found
  58511. */
  58512. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58513. /**
  58514. * Creates a new NodeMaterialBlock
  58515. * @param name defines the block name
  58516. * @param target defines the target of that block (Vertex by default)
  58517. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58518. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58519. */
  58520. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58521. /**
  58522. * Initialize the block and prepare the context for build
  58523. * @param state defines the state that will be used for the build
  58524. */
  58525. initialize(state: NodeMaterialBuildState): void;
  58526. /**
  58527. * Bind data to effect. Will only be called for blocks with isBindable === true
  58528. * @param effect defines the effect to bind data to
  58529. * @param nodeMaterial defines the hosting NodeMaterial
  58530. * @param mesh defines the mesh that will be rendered
  58531. */
  58532. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58533. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58534. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58535. protected _writeFloat(value: number): string;
  58536. /**
  58537. * Gets the current class name e.g. "NodeMaterialBlock"
  58538. * @returns the class name
  58539. */
  58540. getClassName(): string;
  58541. /**
  58542. * Register a new input. Must be called inside a block constructor
  58543. * @param name defines the connection point name
  58544. * @param type defines the connection point type
  58545. * @param isOptional defines a boolean indicating that this input can be omitted
  58546. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58547. * @returns the current block
  58548. */
  58549. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58550. /**
  58551. * Register a new output. Must be called inside a block constructor
  58552. * @param name defines the connection point name
  58553. * @param type defines the connection point type
  58554. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58555. * @returns the current block
  58556. */
  58557. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58558. /**
  58559. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58560. * @param forOutput defines an optional connection point to check compatibility with
  58561. * @returns the first available input or null
  58562. */
  58563. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58564. /**
  58565. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58566. * @param forBlock defines an optional block to check compatibility with
  58567. * @returns the first available input or null
  58568. */
  58569. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58570. /**
  58571. * Gets the sibling of the given output
  58572. * @param current defines the current output
  58573. * @returns the next output in the list or null
  58574. */
  58575. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58576. /**
  58577. * Connect current block with another block
  58578. * @param other defines the block to connect with
  58579. * @param options define the various options to help pick the right connections
  58580. * @returns the current block
  58581. */
  58582. connectTo(other: NodeMaterialBlock, options?: {
  58583. input?: string;
  58584. output?: string;
  58585. outputSwizzle?: string;
  58586. }): this | undefined;
  58587. protected _buildBlock(state: NodeMaterialBuildState): void;
  58588. /**
  58589. * Add uniforms, samplers and uniform buffers at compilation time
  58590. * @param state defines the state to update
  58591. * @param nodeMaterial defines the node material requesting the update
  58592. * @param defines defines the material defines to update
  58593. * @param uniformBuffers defines the list of uniform buffer names
  58594. */
  58595. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58596. /**
  58597. * Add potential fallbacks if shader compilation fails
  58598. * @param mesh defines the mesh to be rendered
  58599. * @param fallbacks defines the current prioritized list of fallbacks
  58600. */
  58601. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58602. /**
  58603. * Initialize defines for shader compilation
  58604. * @param mesh defines the mesh to be rendered
  58605. * @param nodeMaterial defines the node material requesting the update
  58606. * @param defines defines the material defines to update
  58607. * @param useInstances specifies that instances should be used
  58608. */
  58609. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58610. /**
  58611. * Update defines for shader compilation
  58612. * @param mesh defines the mesh to be rendered
  58613. * @param nodeMaterial defines the node material requesting the update
  58614. * @param defines defines the material defines to update
  58615. * @param useInstances specifies that instances should be used
  58616. */
  58617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58618. /**
  58619. * Lets the block try to connect some inputs automatically
  58620. * @param material defines the hosting NodeMaterial
  58621. */
  58622. autoConfigure(material: NodeMaterial): void;
  58623. /**
  58624. * Function called when a block is declared as repeatable content generator
  58625. * @param vertexShaderState defines the current compilation state for the vertex shader
  58626. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58627. * @param mesh defines the mesh to be rendered
  58628. * @param defines defines the material defines to update
  58629. */
  58630. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58631. /**
  58632. * Checks if the block is ready
  58633. * @param mesh defines the mesh to be rendered
  58634. * @param nodeMaterial defines the node material requesting the update
  58635. * @param defines defines the material defines to update
  58636. * @param useInstances specifies that instances should be used
  58637. * @returns true if the block is ready
  58638. */
  58639. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58640. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58641. private _processBuild;
  58642. /**
  58643. * Compile the current node and generate the shader code
  58644. * @param state defines the current compilation state (uniforms, samplers, current string)
  58645. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58646. * @returns true if already built
  58647. */
  58648. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58649. protected _inputRename(name: string): string;
  58650. protected _outputRename(name: string): string;
  58651. protected _dumpPropertiesCode(): string;
  58652. /** @hidden */
  58653. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58654. /** @hidden */
  58655. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58656. /**
  58657. * Clone the current block to a new identical block
  58658. * @param scene defines the hosting scene
  58659. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58660. * @returns a copy of the current block
  58661. */
  58662. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58663. /**
  58664. * Serializes this block in a JSON representation
  58665. * @returns the serialized block object
  58666. */
  58667. serialize(): any;
  58668. /** @hidden */
  58669. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58670. /**
  58671. * Release resources
  58672. */
  58673. dispose(): void;
  58674. }
  58675. }
  58676. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  58677. /**
  58678. * Enum defining the type of animations supported by InputBlock
  58679. */
  58680. export enum AnimatedInputBlockTypes {
  58681. /** No animation */
  58682. None = 0,
  58683. /** Time based animation. Will only work for floats */
  58684. Time = 1
  58685. }
  58686. }
  58687. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  58688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58689. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58690. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58691. import { Nullable } from "babylonjs/types";
  58692. import { Effect } from "babylonjs/Materials/effect";
  58693. import { Matrix } from "babylonjs/Maths/math.vector";
  58694. import { Scene } from "babylonjs/scene";
  58695. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58697. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58698. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58699. /**
  58700. * Block used to expose an input value
  58701. */
  58702. export class InputBlock extends NodeMaterialBlock {
  58703. private _mode;
  58704. private _associatedVariableName;
  58705. private _storedValue;
  58706. private _valueCallback;
  58707. private _type;
  58708. private _animationType;
  58709. /** Gets or set a value used to limit the range of float values */
  58710. min: number;
  58711. /** Gets or set a value used to limit the range of float values */
  58712. max: number;
  58713. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58714. matrixMode: number;
  58715. /** @hidden */
  58716. _systemValue: Nullable<NodeMaterialSystemValues>;
  58717. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58718. visibleInInspector: boolean;
  58719. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58720. isConstant: boolean;
  58721. /** Gets or sets the group to use to display this block in the Inspector */
  58722. groupInInspector: string;
  58723. /**
  58724. * Gets or sets the connection point type (default is float)
  58725. */
  58726. get type(): NodeMaterialBlockConnectionPointTypes;
  58727. /**
  58728. * Creates a new InputBlock
  58729. * @param name defines the block name
  58730. * @param target defines the target of that block (Vertex by default)
  58731. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58732. */
  58733. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58734. /**
  58735. * Gets the output component
  58736. */
  58737. get output(): NodeMaterialConnectionPoint;
  58738. /**
  58739. * Set the source of this connection point to a vertex attribute
  58740. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58741. * @returns the current connection point
  58742. */
  58743. setAsAttribute(attributeName?: string): InputBlock;
  58744. /**
  58745. * Set the source of this connection point to a system value
  58746. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58747. * @returns the current connection point
  58748. */
  58749. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58750. /**
  58751. * Gets or sets the value of that point.
  58752. * Please note that this value will be ignored if valueCallback is defined
  58753. */
  58754. get value(): any;
  58755. set value(value: any);
  58756. /**
  58757. * Gets or sets a callback used to get the value of that point.
  58758. * Please note that setting this value will force the connection point to ignore the value property
  58759. */
  58760. get valueCallback(): () => any;
  58761. set valueCallback(value: () => any);
  58762. /**
  58763. * Gets or sets the associated variable name in the shader
  58764. */
  58765. get associatedVariableName(): string;
  58766. set associatedVariableName(value: string);
  58767. /** Gets or sets the type of animation applied to the input */
  58768. get animationType(): AnimatedInputBlockTypes;
  58769. set animationType(value: AnimatedInputBlockTypes);
  58770. /**
  58771. * Gets a boolean indicating that this connection point not defined yet
  58772. */
  58773. get isUndefined(): boolean;
  58774. /**
  58775. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58776. * In this case the connection point name must be the name of the uniform to use.
  58777. * Can only be set on inputs
  58778. */
  58779. get isUniform(): boolean;
  58780. set isUniform(value: boolean);
  58781. /**
  58782. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58783. * In this case the connection point name must be the name of the attribute to use
  58784. * Can only be set on inputs
  58785. */
  58786. get isAttribute(): boolean;
  58787. set isAttribute(value: boolean);
  58788. /**
  58789. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58790. * Can only be set on exit points
  58791. */
  58792. get isVarying(): boolean;
  58793. set isVarying(value: boolean);
  58794. /**
  58795. * Gets a boolean indicating that the current connection point is a system value
  58796. */
  58797. get isSystemValue(): boolean;
  58798. /**
  58799. * Gets or sets the current well known value or null if not defined as a system value
  58800. */
  58801. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58802. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58803. /**
  58804. * Gets the current class name
  58805. * @returns the class name
  58806. */
  58807. getClassName(): string;
  58808. /**
  58809. * Animate the input if animationType !== None
  58810. * @param scene defines the rendering scene
  58811. */
  58812. animate(scene: Scene): void;
  58813. private _emitDefine;
  58814. initialize(state: NodeMaterialBuildState): void;
  58815. /**
  58816. * Set the input block to its default value (based on its type)
  58817. */
  58818. setDefaultValue(): void;
  58819. private _emitConstant;
  58820. private _emit;
  58821. /** @hidden */
  58822. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58823. /** @hidden */
  58824. _transmit(effect: Effect, scene: Scene): void;
  58825. protected _buildBlock(state: NodeMaterialBuildState): void;
  58826. protected _dumpPropertiesCode(): string;
  58827. serialize(): any;
  58828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58829. }
  58830. }
  58831. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  58832. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58833. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58834. import { Nullable } from "babylonjs/types";
  58835. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58836. import { Observable } from "babylonjs/Misc/observable";
  58837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58838. /**
  58839. * Enum used to define the compatibility state between two connection points
  58840. */
  58841. export enum NodeMaterialConnectionPointCompatibilityStates {
  58842. /** Points are compatibles */
  58843. Compatible = 0,
  58844. /** Points are incompatible because of their types */
  58845. TypeIncompatible = 1,
  58846. /** Points are incompatible because of their targets (vertex vs fragment) */
  58847. TargetIncompatible = 2
  58848. }
  58849. /**
  58850. * Defines the direction of a connection point
  58851. */
  58852. export enum NodeMaterialConnectionPointDirection {
  58853. /** Input */
  58854. Input = 0,
  58855. /** Output */
  58856. Output = 1
  58857. }
  58858. /**
  58859. * Defines a connection point for a block
  58860. */
  58861. export class NodeMaterialConnectionPoint {
  58862. /** @hidden */
  58863. _ownerBlock: NodeMaterialBlock;
  58864. /** @hidden */
  58865. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58866. private _endpoints;
  58867. private _associatedVariableName;
  58868. private _direction;
  58869. /** @hidden */
  58870. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58871. /** @hidden */
  58872. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58873. private _type;
  58874. /** @hidden */
  58875. _enforceAssociatedVariableName: boolean;
  58876. /** Gets the direction of the point */
  58877. get direction(): NodeMaterialConnectionPointDirection;
  58878. /**
  58879. * Gets or sets the additional types supported by this connection point
  58880. */
  58881. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58882. /**
  58883. * Gets or sets the additional types excluded by this connection point
  58884. */
  58885. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58886. /**
  58887. * Observable triggered when this point is connected
  58888. */
  58889. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58890. /**
  58891. * Gets or sets the associated variable name in the shader
  58892. */
  58893. get associatedVariableName(): string;
  58894. set associatedVariableName(value: string);
  58895. /**
  58896. * Gets or sets the connection point type (default is float)
  58897. */
  58898. get type(): NodeMaterialBlockConnectionPointTypes;
  58899. set type(value: NodeMaterialBlockConnectionPointTypes);
  58900. /**
  58901. * Gets or sets the connection point name
  58902. */
  58903. name: string;
  58904. /**
  58905. * Gets or sets a boolean indicating that this connection point can be omitted
  58906. */
  58907. isOptional: boolean;
  58908. /**
  58909. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58910. */
  58911. define: string;
  58912. /** @hidden */
  58913. _prioritizeVertex: boolean;
  58914. private _target;
  58915. /** Gets or sets the target of that connection point */
  58916. get target(): NodeMaterialBlockTargets;
  58917. set target(value: NodeMaterialBlockTargets);
  58918. /**
  58919. * Gets a boolean indicating that the current point is connected
  58920. */
  58921. get isConnected(): boolean;
  58922. /**
  58923. * Gets a boolean indicating that the current point is connected to an input block
  58924. */
  58925. get isConnectedToInputBlock(): boolean;
  58926. /**
  58927. * Gets a the connected input block (if any)
  58928. */
  58929. get connectInputBlock(): Nullable<InputBlock>;
  58930. /** Get the other side of the connection (if any) */
  58931. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58932. /** Get the block that owns this connection point */
  58933. get ownerBlock(): NodeMaterialBlock;
  58934. /** Get the block connected on the other side of this connection (if any) */
  58935. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58936. /** Get the block connected on the endpoints of this connection (if any) */
  58937. get connectedBlocks(): Array<NodeMaterialBlock>;
  58938. /** Gets the list of connected endpoints */
  58939. get endpoints(): NodeMaterialConnectionPoint[];
  58940. /** Gets a boolean indicating if that output point is connected to at least one input */
  58941. get hasEndpoints(): boolean;
  58942. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58943. get isConnectedInVertexShader(): boolean;
  58944. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58945. get isConnectedInFragmentShader(): boolean;
  58946. /**
  58947. * Creates a new connection point
  58948. * @param name defines the connection point name
  58949. * @param ownerBlock defines the block hosting this connection point
  58950. * @param direction defines the direction of the connection point
  58951. */
  58952. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58953. /**
  58954. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58955. * @returns the class name
  58956. */
  58957. getClassName(): string;
  58958. /**
  58959. * Gets a boolean indicating if the current point can be connected to another point
  58960. * @param connectionPoint defines the other connection point
  58961. * @returns a boolean
  58962. */
  58963. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58964. /**
  58965. * Gets a number indicating if the current point can be connected to another point
  58966. * @param connectionPoint defines the other connection point
  58967. * @returns a number defining the compatibility state
  58968. */
  58969. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58970. /**
  58971. * Connect this point to another connection point
  58972. * @param connectionPoint defines the other connection point
  58973. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58974. * @returns the current connection point
  58975. */
  58976. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58977. /**
  58978. * Disconnect this point from one of his endpoint
  58979. * @param endpoint defines the other connection point
  58980. * @returns the current connection point
  58981. */
  58982. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58983. /**
  58984. * Serializes this point in a JSON representation
  58985. * @returns the serialized point object
  58986. */
  58987. serialize(): any;
  58988. /**
  58989. * Release resources
  58990. */
  58991. dispose(): void;
  58992. }
  58993. }
  58994. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  58995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58998. import { Mesh } from "babylonjs/Meshes/mesh";
  58999. import { Effect } from "babylonjs/Materials/effect";
  59000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59001. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59002. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59003. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59004. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59005. /**
  59006. * Block used to add support for vertex skinning (bones)
  59007. */
  59008. export class BonesBlock extends NodeMaterialBlock {
  59009. /**
  59010. * Creates a new BonesBlock
  59011. * @param name defines the block name
  59012. */
  59013. constructor(name: string);
  59014. /**
  59015. * Initialize the block and prepare the context for build
  59016. * @param state defines the state that will be used for the build
  59017. */
  59018. initialize(state: NodeMaterialBuildState): void;
  59019. /**
  59020. * Gets the current class name
  59021. * @returns the class name
  59022. */
  59023. getClassName(): string;
  59024. /**
  59025. * Gets the matrix indices input component
  59026. */
  59027. get matricesIndices(): NodeMaterialConnectionPoint;
  59028. /**
  59029. * Gets the matrix weights input component
  59030. */
  59031. get matricesWeights(): NodeMaterialConnectionPoint;
  59032. /**
  59033. * Gets the extra matrix indices input component
  59034. */
  59035. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59036. /**
  59037. * Gets the extra matrix weights input component
  59038. */
  59039. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59040. /**
  59041. * Gets the world input component
  59042. */
  59043. get world(): NodeMaterialConnectionPoint;
  59044. /**
  59045. * Gets the output component
  59046. */
  59047. get output(): NodeMaterialConnectionPoint;
  59048. autoConfigure(material: NodeMaterial): void;
  59049. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59050. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59052. protected _buildBlock(state: NodeMaterialBuildState): this;
  59053. }
  59054. }
  59055. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  59056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59060. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59061. /**
  59062. * Block used to add support for instances
  59063. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59064. */
  59065. export class InstancesBlock extends NodeMaterialBlock {
  59066. /**
  59067. * Creates a new InstancesBlock
  59068. * @param name defines the block name
  59069. */
  59070. constructor(name: string);
  59071. /**
  59072. * Gets the current class name
  59073. * @returns the class name
  59074. */
  59075. getClassName(): string;
  59076. /**
  59077. * Gets the first world row input component
  59078. */
  59079. get world0(): NodeMaterialConnectionPoint;
  59080. /**
  59081. * Gets the second world row input component
  59082. */
  59083. get world1(): NodeMaterialConnectionPoint;
  59084. /**
  59085. * Gets the third world row input component
  59086. */
  59087. get world2(): NodeMaterialConnectionPoint;
  59088. /**
  59089. * Gets the forth world row input component
  59090. */
  59091. get world3(): NodeMaterialConnectionPoint;
  59092. /**
  59093. * Gets the world input component
  59094. */
  59095. get world(): NodeMaterialConnectionPoint;
  59096. /**
  59097. * Gets the output component
  59098. */
  59099. get output(): NodeMaterialConnectionPoint;
  59100. autoConfigure(material: NodeMaterial): void;
  59101. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59102. protected _buildBlock(state: NodeMaterialBuildState): this;
  59103. }
  59104. }
  59105. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  59106. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59107. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59110. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59111. import { Effect } from "babylonjs/Materials/effect";
  59112. import { Mesh } from "babylonjs/Meshes/mesh";
  59113. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59114. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59115. /**
  59116. * Block used to add morph targets support to vertex shader
  59117. */
  59118. export class MorphTargetsBlock extends NodeMaterialBlock {
  59119. private _repeatableContentAnchor;
  59120. private _repeatebleContentGenerated;
  59121. /**
  59122. * Create a new MorphTargetsBlock
  59123. * @param name defines the block name
  59124. */
  59125. constructor(name: string);
  59126. /**
  59127. * Gets the current class name
  59128. * @returns the class name
  59129. */
  59130. getClassName(): string;
  59131. /**
  59132. * Gets the position input component
  59133. */
  59134. get position(): NodeMaterialConnectionPoint;
  59135. /**
  59136. * Gets the normal input component
  59137. */
  59138. get normal(): NodeMaterialConnectionPoint;
  59139. /**
  59140. * Gets the tangent input component
  59141. */
  59142. get tangent(): NodeMaterialConnectionPoint;
  59143. /**
  59144. * Gets the tangent input component
  59145. */
  59146. get uv(): NodeMaterialConnectionPoint;
  59147. /**
  59148. * Gets the position output component
  59149. */
  59150. get positionOutput(): NodeMaterialConnectionPoint;
  59151. /**
  59152. * Gets the normal output component
  59153. */
  59154. get normalOutput(): NodeMaterialConnectionPoint;
  59155. /**
  59156. * Gets the tangent output component
  59157. */
  59158. get tangentOutput(): NodeMaterialConnectionPoint;
  59159. /**
  59160. * Gets the tangent output component
  59161. */
  59162. get uvOutput(): NodeMaterialConnectionPoint;
  59163. initialize(state: NodeMaterialBuildState): void;
  59164. autoConfigure(material: NodeMaterial): void;
  59165. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59166. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59167. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59168. protected _buildBlock(state: NodeMaterialBuildState): this;
  59169. }
  59170. }
  59171. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  59172. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59173. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59174. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59175. import { Nullable } from "babylonjs/types";
  59176. import { Scene } from "babylonjs/scene";
  59177. import { Effect } from "babylonjs/Materials/effect";
  59178. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59179. import { Mesh } from "babylonjs/Meshes/mesh";
  59180. import { Light } from "babylonjs/Lights/light";
  59181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59182. /**
  59183. * Block used to get data information from a light
  59184. */
  59185. export class LightInformationBlock extends NodeMaterialBlock {
  59186. private _lightDataUniformName;
  59187. private _lightColorUniformName;
  59188. private _lightTypeDefineName;
  59189. /**
  59190. * Gets or sets the light associated with this block
  59191. */
  59192. light: Nullable<Light>;
  59193. /**
  59194. * Creates a new LightInformationBlock
  59195. * @param name defines the block name
  59196. */
  59197. constructor(name: string);
  59198. /**
  59199. * Gets the current class name
  59200. * @returns the class name
  59201. */
  59202. getClassName(): string;
  59203. /**
  59204. * Gets the world position input component
  59205. */
  59206. get worldPosition(): NodeMaterialConnectionPoint;
  59207. /**
  59208. * Gets the direction output component
  59209. */
  59210. get direction(): NodeMaterialConnectionPoint;
  59211. /**
  59212. * Gets the direction output component
  59213. */
  59214. get color(): NodeMaterialConnectionPoint;
  59215. /**
  59216. * Gets the direction output component
  59217. */
  59218. get intensity(): NodeMaterialConnectionPoint;
  59219. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59220. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59221. protected _buildBlock(state: NodeMaterialBuildState): this;
  59222. serialize(): any;
  59223. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59224. }
  59225. }
  59226. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  59227. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  59228. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  59229. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  59230. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  59231. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  59232. }
  59233. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  59234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59238. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59239. import { Effect } from "babylonjs/Materials/effect";
  59240. import { Mesh } from "babylonjs/Meshes/mesh";
  59241. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59242. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59243. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59244. /**
  59245. * Block used to add image processing support to fragment shader
  59246. */
  59247. export class ImageProcessingBlock extends NodeMaterialBlock {
  59248. /**
  59249. * Create a new ImageProcessingBlock
  59250. * @param name defines the block name
  59251. */
  59252. constructor(name: string);
  59253. /**
  59254. * Gets the current class name
  59255. * @returns the class name
  59256. */
  59257. getClassName(): string;
  59258. /**
  59259. * Gets the color input component
  59260. */
  59261. get color(): NodeMaterialConnectionPoint;
  59262. /**
  59263. * Gets the output component
  59264. */
  59265. get output(): NodeMaterialConnectionPoint;
  59266. /**
  59267. * Initialize the block and prepare the context for build
  59268. * @param state defines the state that will be used for the build
  59269. */
  59270. initialize(state: NodeMaterialBuildState): void;
  59271. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59272. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59273. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59274. protected _buildBlock(state: NodeMaterialBuildState): this;
  59275. }
  59276. }
  59277. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  59278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59281. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59283. import { Effect } from "babylonjs/Materials/effect";
  59284. import { Mesh } from "babylonjs/Meshes/mesh";
  59285. import { Scene } from "babylonjs/scene";
  59286. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  59287. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59288. /**
  59289. * Block used to pertub normals based on a normal map
  59290. */
  59291. export class PerturbNormalBlock extends NodeMaterialBlock {
  59292. private _tangentSpaceParameterName;
  59293. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59294. invertX: boolean;
  59295. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59296. invertY: boolean;
  59297. /**
  59298. * Create a new PerturbNormalBlock
  59299. * @param name defines the block name
  59300. */
  59301. constructor(name: string);
  59302. /**
  59303. * Gets the current class name
  59304. * @returns the class name
  59305. */
  59306. getClassName(): string;
  59307. /**
  59308. * Gets the world position input component
  59309. */
  59310. get worldPosition(): NodeMaterialConnectionPoint;
  59311. /**
  59312. * Gets the world normal input component
  59313. */
  59314. get worldNormal(): NodeMaterialConnectionPoint;
  59315. /**
  59316. * Gets the uv input component
  59317. */
  59318. get uv(): NodeMaterialConnectionPoint;
  59319. /**
  59320. * Gets the normal map color input component
  59321. */
  59322. get normalMapColor(): NodeMaterialConnectionPoint;
  59323. /**
  59324. * Gets the strength input component
  59325. */
  59326. get strength(): NodeMaterialConnectionPoint;
  59327. /**
  59328. * Gets the output component
  59329. */
  59330. get output(): NodeMaterialConnectionPoint;
  59331. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59332. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59333. autoConfigure(material: NodeMaterial): void;
  59334. protected _buildBlock(state: NodeMaterialBuildState): this;
  59335. protected _dumpPropertiesCode(): string;
  59336. serialize(): any;
  59337. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59338. }
  59339. }
  59340. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  59341. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59342. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59343. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59344. /**
  59345. * Block used to discard a pixel if a value is smaller than a cutoff
  59346. */
  59347. export class DiscardBlock extends NodeMaterialBlock {
  59348. /**
  59349. * Create a new DiscardBlock
  59350. * @param name defines the block name
  59351. */
  59352. constructor(name: string);
  59353. /**
  59354. * Gets the current class name
  59355. * @returns the class name
  59356. */
  59357. getClassName(): string;
  59358. /**
  59359. * Gets the color input component
  59360. */
  59361. get value(): NodeMaterialConnectionPoint;
  59362. /**
  59363. * Gets the cutoff input component
  59364. */
  59365. get cutoff(): NodeMaterialConnectionPoint;
  59366. protected _buildBlock(state: NodeMaterialBuildState): this;
  59367. }
  59368. }
  59369. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  59370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59371. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59372. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59373. /**
  59374. * Block used to test if the fragment shader is front facing
  59375. */
  59376. export class FrontFacingBlock extends NodeMaterialBlock {
  59377. /**
  59378. * Creates a new FrontFacingBlock
  59379. * @param name defines the block name
  59380. */
  59381. constructor(name: string);
  59382. /**
  59383. * Gets the current class name
  59384. * @returns the class name
  59385. */
  59386. getClassName(): string;
  59387. /**
  59388. * Gets the output component
  59389. */
  59390. get output(): NodeMaterialConnectionPoint;
  59391. protected _buildBlock(state: NodeMaterialBuildState): this;
  59392. }
  59393. }
  59394. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  59395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59396. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59398. /**
  59399. * Block used to get the derivative value on x and y of a given input
  59400. */
  59401. export class DerivativeBlock extends NodeMaterialBlock {
  59402. /**
  59403. * Create a new DerivativeBlock
  59404. * @param name defines the block name
  59405. */
  59406. constructor(name: string);
  59407. /**
  59408. * Gets the current class name
  59409. * @returns the class name
  59410. */
  59411. getClassName(): string;
  59412. /**
  59413. * Gets the input component
  59414. */
  59415. get input(): NodeMaterialConnectionPoint;
  59416. /**
  59417. * Gets the derivative output on x
  59418. */
  59419. get dx(): NodeMaterialConnectionPoint;
  59420. /**
  59421. * Gets the derivative output on y
  59422. */
  59423. get dy(): NodeMaterialConnectionPoint;
  59424. protected _buildBlock(state: NodeMaterialBuildState): this;
  59425. }
  59426. }
  59427. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  59428. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  59429. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  59430. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  59431. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  59432. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  59433. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  59434. }
  59435. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  59436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59438. import { Mesh } from "babylonjs/Meshes/mesh";
  59439. import { Effect } from "babylonjs/Materials/effect";
  59440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59442. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59443. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59444. /**
  59445. * Block used to add support for scene fog
  59446. */
  59447. export class FogBlock extends NodeMaterialBlock {
  59448. private _fogDistanceName;
  59449. private _fogParameters;
  59450. /**
  59451. * Create a new FogBlock
  59452. * @param name defines the block name
  59453. */
  59454. constructor(name: string);
  59455. /**
  59456. * Gets the current class name
  59457. * @returns the class name
  59458. */
  59459. getClassName(): string;
  59460. /**
  59461. * Gets the world position input component
  59462. */
  59463. get worldPosition(): NodeMaterialConnectionPoint;
  59464. /**
  59465. * Gets the view input component
  59466. */
  59467. get view(): NodeMaterialConnectionPoint;
  59468. /**
  59469. * Gets the color input component
  59470. */
  59471. get input(): NodeMaterialConnectionPoint;
  59472. /**
  59473. * Gets the fog color input component
  59474. */
  59475. get fogColor(): NodeMaterialConnectionPoint;
  59476. /**
  59477. * Gets the output component
  59478. */
  59479. get output(): NodeMaterialConnectionPoint;
  59480. autoConfigure(material: NodeMaterial): void;
  59481. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59482. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59483. protected _buildBlock(state: NodeMaterialBuildState): this;
  59484. }
  59485. }
  59486. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  59487. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59488. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59489. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59491. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59492. import { Effect } from "babylonjs/Materials/effect";
  59493. import { Mesh } from "babylonjs/Meshes/mesh";
  59494. import { Light } from "babylonjs/Lights/light";
  59495. import { Nullable } from "babylonjs/types";
  59496. import { Scene } from "babylonjs/scene";
  59497. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59498. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59499. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59500. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59501. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59502. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59503. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59504. /**
  59505. * Block used to add light in the fragment shader
  59506. */
  59507. export class LightBlock extends NodeMaterialBlock {
  59508. private _lightId;
  59509. /**
  59510. * Gets or sets the light associated with this block
  59511. */
  59512. light: Nullable<Light>;
  59513. /**
  59514. * Create a new LightBlock
  59515. * @param name defines the block name
  59516. */
  59517. constructor(name: string);
  59518. /**
  59519. * Gets the current class name
  59520. * @returns the class name
  59521. */
  59522. getClassName(): string;
  59523. /**
  59524. * Gets the world position input component
  59525. */
  59526. get worldPosition(): NodeMaterialConnectionPoint;
  59527. /**
  59528. * Gets the world normal input component
  59529. */
  59530. get worldNormal(): NodeMaterialConnectionPoint;
  59531. /**
  59532. * Gets the camera (or eye) position component
  59533. */
  59534. get cameraPosition(): NodeMaterialConnectionPoint;
  59535. /**
  59536. * Gets the glossiness component
  59537. */
  59538. get glossiness(): NodeMaterialConnectionPoint;
  59539. /**
  59540. * Gets the glossinness power component
  59541. */
  59542. get glossPower(): NodeMaterialConnectionPoint;
  59543. /**
  59544. * Gets the diffuse color component
  59545. */
  59546. get diffuseColor(): NodeMaterialConnectionPoint;
  59547. /**
  59548. * Gets the specular color component
  59549. */
  59550. get specularColor(): NodeMaterialConnectionPoint;
  59551. /**
  59552. * Gets the diffuse output component
  59553. */
  59554. get diffuseOutput(): NodeMaterialConnectionPoint;
  59555. /**
  59556. * Gets the specular output component
  59557. */
  59558. get specularOutput(): NodeMaterialConnectionPoint;
  59559. autoConfigure(material: NodeMaterial): void;
  59560. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59561. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59563. private _injectVertexCode;
  59564. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59565. serialize(): any;
  59566. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59567. }
  59568. }
  59569. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  59570. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  59571. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  59572. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59573. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59574. }
  59575. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  59576. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59577. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59578. }
  59579. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  59580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59581. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59583. /**
  59584. * Block used to multiply 2 values
  59585. */
  59586. export class MultiplyBlock extends NodeMaterialBlock {
  59587. /**
  59588. * Creates a new MultiplyBlock
  59589. * @param name defines the block name
  59590. */
  59591. constructor(name: string);
  59592. /**
  59593. * Gets the current class name
  59594. * @returns the class name
  59595. */
  59596. getClassName(): string;
  59597. /**
  59598. * Gets the left operand input component
  59599. */
  59600. get left(): NodeMaterialConnectionPoint;
  59601. /**
  59602. * Gets the right operand input component
  59603. */
  59604. get right(): NodeMaterialConnectionPoint;
  59605. /**
  59606. * Gets the output component
  59607. */
  59608. get output(): NodeMaterialConnectionPoint;
  59609. protected _buildBlock(state: NodeMaterialBuildState): this;
  59610. }
  59611. }
  59612. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  59613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59614. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59615. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59616. /**
  59617. * Block used to add 2 vectors
  59618. */
  59619. export class AddBlock extends NodeMaterialBlock {
  59620. /**
  59621. * Creates a new AddBlock
  59622. * @param name defines the block name
  59623. */
  59624. constructor(name: string);
  59625. /**
  59626. * Gets the current class name
  59627. * @returns the class name
  59628. */
  59629. getClassName(): string;
  59630. /**
  59631. * Gets the left operand input component
  59632. */
  59633. get left(): NodeMaterialConnectionPoint;
  59634. /**
  59635. * Gets the right operand input component
  59636. */
  59637. get right(): NodeMaterialConnectionPoint;
  59638. /**
  59639. * Gets the output component
  59640. */
  59641. get output(): NodeMaterialConnectionPoint;
  59642. protected _buildBlock(state: NodeMaterialBuildState): this;
  59643. }
  59644. }
  59645. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  59646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59649. /**
  59650. * Block used to scale a vector by a float
  59651. */
  59652. export class ScaleBlock extends NodeMaterialBlock {
  59653. /**
  59654. * Creates a new ScaleBlock
  59655. * @param name defines the block name
  59656. */
  59657. constructor(name: string);
  59658. /**
  59659. * Gets the current class name
  59660. * @returns the class name
  59661. */
  59662. getClassName(): string;
  59663. /**
  59664. * Gets the input component
  59665. */
  59666. get input(): NodeMaterialConnectionPoint;
  59667. /**
  59668. * Gets the factor input component
  59669. */
  59670. get factor(): NodeMaterialConnectionPoint;
  59671. /**
  59672. * Gets the output component
  59673. */
  59674. get output(): NodeMaterialConnectionPoint;
  59675. protected _buildBlock(state: NodeMaterialBuildState): this;
  59676. }
  59677. }
  59678. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  59679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59682. import { Scene } from "babylonjs/scene";
  59683. /**
  59684. * Block used to clamp a float
  59685. */
  59686. export class ClampBlock extends NodeMaterialBlock {
  59687. /** Gets or sets the minimum range */
  59688. minimum: number;
  59689. /** Gets or sets the maximum range */
  59690. maximum: number;
  59691. /**
  59692. * Creates a new ClampBlock
  59693. * @param name defines the block name
  59694. */
  59695. constructor(name: string);
  59696. /**
  59697. * Gets the current class name
  59698. * @returns the class name
  59699. */
  59700. getClassName(): string;
  59701. /**
  59702. * Gets the value input component
  59703. */
  59704. get value(): NodeMaterialConnectionPoint;
  59705. /**
  59706. * Gets the output component
  59707. */
  59708. get output(): NodeMaterialConnectionPoint;
  59709. protected _buildBlock(state: NodeMaterialBuildState): this;
  59710. protected _dumpPropertiesCode(): string;
  59711. serialize(): any;
  59712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59713. }
  59714. }
  59715. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  59716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59717. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59718. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59719. /**
  59720. * Block used to apply a cross product between 2 vectors
  59721. */
  59722. export class CrossBlock extends NodeMaterialBlock {
  59723. /**
  59724. * Creates a new CrossBlock
  59725. * @param name defines the block name
  59726. */
  59727. constructor(name: string);
  59728. /**
  59729. * Gets the current class name
  59730. * @returns the class name
  59731. */
  59732. getClassName(): string;
  59733. /**
  59734. * Gets the left operand input component
  59735. */
  59736. get left(): NodeMaterialConnectionPoint;
  59737. /**
  59738. * Gets the right operand input component
  59739. */
  59740. get right(): NodeMaterialConnectionPoint;
  59741. /**
  59742. * Gets the output component
  59743. */
  59744. get output(): NodeMaterialConnectionPoint;
  59745. protected _buildBlock(state: NodeMaterialBuildState): this;
  59746. }
  59747. }
  59748. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  59749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59750. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59751. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59752. /**
  59753. * Block used to apply a dot product between 2 vectors
  59754. */
  59755. export class DotBlock extends NodeMaterialBlock {
  59756. /**
  59757. * Creates a new DotBlock
  59758. * @param name defines the block name
  59759. */
  59760. constructor(name: string);
  59761. /**
  59762. * Gets the current class name
  59763. * @returns the class name
  59764. */
  59765. getClassName(): string;
  59766. /**
  59767. * Gets the left operand input component
  59768. */
  59769. get left(): NodeMaterialConnectionPoint;
  59770. /**
  59771. * Gets the right operand input component
  59772. */
  59773. get right(): NodeMaterialConnectionPoint;
  59774. /**
  59775. * Gets the output component
  59776. */
  59777. get output(): NodeMaterialConnectionPoint;
  59778. protected _buildBlock(state: NodeMaterialBuildState): this;
  59779. }
  59780. }
  59781. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  59782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59785. import { Vector2 } from "babylonjs/Maths/math.vector";
  59786. import { Scene } from "babylonjs/scene";
  59787. /**
  59788. * Block used to remap a float from a range to a new one
  59789. */
  59790. export class RemapBlock extends NodeMaterialBlock {
  59791. /**
  59792. * Gets or sets the source range
  59793. */
  59794. sourceRange: Vector2;
  59795. /**
  59796. * Gets or sets the target range
  59797. */
  59798. targetRange: Vector2;
  59799. /**
  59800. * Creates a new RemapBlock
  59801. * @param name defines the block name
  59802. */
  59803. constructor(name: string);
  59804. /**
  59805. * Gets the current class name
  59806. * @returns the class name
  59807. */
  59808. getClassName(): string;
  59809. /**
  59810. * Gets the input component
  59811. */
  59812. get input(): NodeMaterialConnectionPoint;
  59813. /**
  59814. * Gets the source min input component
  59815. */
  59816. get sourceMin(): NodeMaterialConnectionPoint;
  59817. /**
  59818. * Gets the source max input component
  59819. */
  59820. get sourceMax(): NodeMaterialConnectionPoint;
  59821. /**
  59822. * Gets the target min input component
  59823. */
  59824. get targetMin(): NodeMaterialConnectionPoint;
  59825. /**
  59826. * Gets the target max input component
  59827. */
  59828. get targetMax(): NodeMaterialConnectionPoint;
  59829. /**
  59830. * Gets the output component
  59831. */
  59832. get output(): NodeMaterialConnectionPoint;
  59833. protected _buildBlock(state: NodeMaterialBuildState): this;
  59834. protected _dumpPropertiesCode(): string;
  59835. serialize(): any;
  59836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59837. }
  59838. }
  59839. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  59840. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59841. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59842. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59843. /**
  59844. * Block used to normalize a vector
  59845. */
  59846. export class NormalizeBlock extends NodeMaterialBlock {
  59847. /**
  59848. * Creates a new NormalizeBlock
  59849. * @param name defines the block name
  59850. */
  59851. constructor(name: string);
  59852. /**
  59853. * Gets the current class name
  59854. * @returns the class name
  59855. */
  59856. getClassName(): string;
  59857. /**
  59858. * Gets the input component
  59859. */
  59860. get input(): NodeMaterialConnectionPoint;
  59861. /**
  59862. * Gets the output component
  59863. */
  59864. get output(): NodeMaterialConnectionPoint;
  59865. protected _buildBlock(state: NodeMaterialBuildState): this;
  59866. }
  59867. }
  59868. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  59869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59872. import { Scene } from "babylonjs/scene";
  59873. /**
  59874. * Operations supported by the Trigonometry block
  59875. */
  59876. export enum TrigonometryBlockOperations {
  59877. /** Cos */
  59878. Cos = 0,
  59879. /** Sin */
  59880. Sin = 1,
  59881. /** Abs */
  59882. Abs = 2,
  59883. /** Exp */
  59884. Exp = 3,
  59885. /** Exp2 */
  59886. Exp2 = 4,
  59887. /** Round */
  59888. Round = 5,
  59889. /** Floor */
  59890. Floor = 6,
  59891. /** Ceiling */
  59892. Ceiling = 7,
  59893. /** Square root */
  59894. Sqrt = 8,
  59895. /** Log */
  59896. Log = 9,
  59897. /** Tangent */
  59898. Tan = 10,
  59899. /** Arc tangent */
  59900. ArcTan = 11,
  59901. /** Arc cosinus */
  59902. ArcCos = 12,
  59903. /** Arc sinus */
  59904. ArcSin = 13,
  59905. /** Fraction */
  59906. Fract = 14,
  59907. /** Sign */
  59908. Sign = 15,
  59909. /** To radians (from degrees) */
  59910. Radians = 16,
  59911. /** To degrees (from radians) */
  59912. Degrees = 17
  59913. }
  59914. /**
  59915. * Block used to apply trigonometry operation to floats
  59916. */
  59917. export class TrigonometryBlock extends NodeMaterialBlock {
  59918. /**
  59919. * Gets or sets the operation applied by the block
  59920. */
  59921. operation: TrigonometryBlockOperations;
  59922. /**
  59923. * Creates a new TrigonometryBlock
  59924. * @param name defines the block name
  59925. */
  59926. constructor(name: string);
  59927. /**
  59928. * Gets the current class name
  59929. * @returns the class name
  59930. */
  59931. getClassName(): string;
  59932. /**
  59933. * Gets the input component
  59934. */
  59935. get input(): NodeMaterialConnectionPoint;
  59936. /**
  59937. * Gets the output component
  59938. */
  59939. get output(): NodeMaterialConnectionPoint;
  59940. protected _buildBlock(state: NodeMaterialBuildState): this;
  59941. serialize(): any;
  59942. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59943. protected _dumpPropertiesCode(): string;
  59944. }
  59945. }
  59946. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  59947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59950. /**
  59951. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59952. */
  59953. export class ColorMergerBlock extends NodeMaterialBlock {
  59954. /**
  59955. * Create a new ColorMergerBlock
  59956. * @param name defines the block name
  59957. */
  59958. constructor(name: string);
  59959. /**
  59960. * Gets the current class name
  59961. * @returns the class name
  59962. */
  59963. getClassName(): string;
  59964. /**
  59965. * Gets the rgb component (input)
  59966. */
  59967. get rgbIn(): NodeMaterialConnectionPoint;
  59968. /**
  59969. * Gets the r component (input)
  59970. */
  59971. get r(): NodeMaterialConnectionPoint;
  59972. /**
  59973. * Gets the g component (input)
  59974. */
  59975. get g(): NodeMaterialConnectionPoint;
  59976. /**
  59977. * Gets the b component (input)
  59978. */
  59979. get b(): NodeMaterialConnectionPoint;
  59980. /**
  59981. * Gets the a component (input)
  59982. */
  59983. get a(): NodeMaterialConnectionPoint;
  59984. /**
  59985. * Gets the rgba component (output)
  59986. */
  59987. get rgba(): NodeMaterialConnectionPoint;
  59988. /**
  59989. * Gets the rgb component (output)
  59990. */
  59991. get rgbOut(): NodeMaterialConnectionPoint;
  59992. /**
  59993. * Gets the rgb component (output)
  59994. * @deprecated Please use rgbOut instead.
  59995. */
  59996. get rgb(): NodeMaterialConnectionPoint;
  59997. protected _buildBlock(state: NodeMaterialBuildState): this;
  59998. }
  59999. }
  60000. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60004. /**
  60005. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60006. */
  60007. export class VectorMergerBlock extends NodeMaterialBlock {
  60008. /**
  60009. * Create a new VectorMergerBlock
  60010. * @param name defines the block name
  60011. */
  60012. constructor(name: string);
  60013. /**
  60014. * Gets the current class name
  60015. * @returns the class name
  60016. */
  60017. getClassName(): string;
  60018. /**
  60019. * Gets the xyz component (input)
  60020. */
  60021. get xyzIn(): NodeMaterialConnectionPoint;
  60022. /**
  60023. * Gets the xy component (input)
  60024. */
  60025. get xyIn(): NodeMaterialConnectionPoint;
  60026. /**
  60027. * Gets the x component (input)
  60028. */
  60029. get x(): NodeMaterialConnectionPoint;
  60030. /**
  60031. * Gets the y component (input)
  60032. */
  60033. get y(): NodeMaterialConnectionPoint;
  60034. /**
  60035. * Gets the z component (input)
  60036. */
  60037. get z(): NodeMaterialConnectionPoint;
  60038. /**
  60039. * Gets the w component (input)
  60040. */
  60041. get w(): NodeMaterialConnectionPoint;
  60042. /**
  60043. * Gets the xyzw component (output)
  60044. */
  60045. get xyzw(): NodeMaterialConnectionPoint;
  60046. /**
  60047. * Gets the xyz component (output)
  60048. */
  60049. get xyzOut(): NodeMaterialConnectionPoint;
  60050. /**
  60051. * Gets the xy component (output)
  60052. */
  60053. get xyOut(): NodeMaterialConnectionPoint;
  60054. /**
  60055. * Gets the xy component (output)
  60056. * @deprecated Please use xyOut instead.
  60057. */
  60058. get xy(): NodeMaterialConnectionPoint;
  60059. /**
  60060. * Gets the xyz component (output)
  60061. * @deprecated Please use xyzOut instead.
  60062. */
  60063. get xyz(): NodeMaterialConnectionPoint;
  60064. protected _buildBlock(state: NodeMaterialBuildState): this;
  60065. }
  60066. }
  60067. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  60068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60071. /**
  60072. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60073. */
  60074. export class ColorSplitterBlock extends NodeMaterialBlock {
  60075. /**
  60076. * Create a new ColorSplitterBlock
  60077. * @param name defines the block name
  60078. */
  60079. constructor(name: string);
  60080. /**
  60081. * Gets the current class name
  60082. * @returns the class name
  60083. */
  60084. getClassName(): string;
  60085. /**
  60086. * Gets the rgba component (input)
  60087. */
  60088. get rgba(): NodeMaterialConnectionPoint;
  60089. /**
  60090. * Gets the rgb component (input)
  60091. */
  60092. get rgbIn(): NodeMaterialConnectionPoint;
  60093. /**
  60094. * Gets the rgb component (output)
  60095. */
  60096. get rgbOut(): NodeMaterialConnectionPoint;
  60097. /**
  60098. * Gets the r component (output)
  60099. */
  60100. get r(): NodeMaterialConnectionPoint;
  60101. /**
  60102. * Gets the g component (output)
  60103. */
  60104. get g(): NodeMaterialConnectionPoint;
  60105. /**
  60106. * Gets the b component (output)
  60107. */
  60108. get b(): NodeMaterialConnectionPoint;
  60109. /**
  60110. * Gets the a component (output)
  60111. */
  60112. get a(): NodeMaterialConnectionPoint;
  60113. protected _inputRename(name: string): string;
  60114. protected _outputRename(name: string): string;
  60115. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60116. }
  60117. }
  60118. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  60119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60122. /**
  60123. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60124. */
  60125. export class VectorSplitterBlock extends NodeMaterialBlock {
  60126. /**
  60127. * Create a new VectorSplitterBlock
  60128. * @param name defines the block name
  60129. */
  60130. constructor(name: string);
  60131. /**
  60132. * Gets the current class name
  60133. * @returns the class name
  60134. */
  60135. getClassName(): string;
  60136. /**
  60137. * Gets the xyzw component (input)
  60138. */
  60139. get xyzw(): NodeMaterialConnectionPoint;
  60140. /**
  60141. * Gets the xyz component (input)
  60142. */
  60143. get xyzIn(): NodeMaterialConnectionPoint;
  60144. /**
  60145. * Gets the xy component (input)
  60146. */
  60147. get xyIn(): NodeMaterialConnectionPoint;
  60148. /**
  60149. * Gets the xyz component (output)
  60150. */
  60151. get xyzOut(): NodeMaterialConnectionPoint;
  60152. /**
  60153. * Gets the xy component (output)
  60154. */
  60155. get xyOut(): NodeMaterialConnectionPoint;
  60156. /**
  60157. * Gets the x component (output)
  60158. */
  60159. get x(): NodeMaterialConnectionPoint;
  60160. /**
  60161. * Gets the y component (output)
  60162. */
  60163. get y(): NodeMaterialConnectionPoint;
  60164. /**
  60165. * Gets the z component (output)
  60166. */
  60167. get z(): NodeMaterialConnectionPoint;
  60168. /**
  60169. * Gets the w component (output)
  60170. */
  60171. get w(): NodeMaterialConnectionPoint;
  60172. protected _inputRename(name: string): string;
  60173. protected _outputRename(name: string): string;
  60174. protected _buildBlock(state: NodeMaterialBuildState): this;
  60175. }
  60176. }
  60177. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  60178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60181. /**
  60182. * Block used to lerp between 2 values
  60183. */
  60184. export class LerpBlock extends NodeMaterialBlock {
  60185. /**
  60186. * Creates a new LerpBlock
  60187. * @param name defines the block name
  60188. */
  60189. constructor(name: string);
  60190. /**
  60191. * Gets the current class name
  60192. * @returns the class name
  60193. */
  60194. getClassName(): string;
  60195. /**
  60196. * Gets the left operand input component
  60197. */
  60198. get left(): NodeMaterialConnectionPoint;
  60199. /**
  60200. * Gets the right operand input component
  60201. */
  60202. get right(): NodeMaterialConnectionPoint;
  60203. /**
  60204. * Gets the gradient operand input component
  60205. */
  60206. get gradient(): NodeMaterialConnectionPoint;
  60207. /**
  60208. * Gets the output component
  60209. */
  60210. get output(): NodeMaterialConnectionPoint;
  60211. protected _buildBlock(state: NodeMaterialBuildState): this;
  60212. }
  60213. }
  60214. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  60215. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60216. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60217. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60218. /**
  60219. * Block used to divide 2 vectors
  60220. */
  60221. export class DivideBlock extends NodeMaterialBlock {
  60222. /**
  60223. * Creates a new DivideBlock
  60224. * @param name defines the block name
  60225. */
  60226. constructor(name: string);
  60227. /**
  60228. * Gets the current class name
  60229. * @returns the class name
  60230. */
  60231. getClassName(): string;
  60232. /**
  60233. * Gets the left operand input component
  60234. */
  60235. get left(): NodeMaterialConnectionPoint;
  60236. /**
  60237. * Gets the right operand input component
  60238. */
  60239. get right(): NodeMaterialConnectionPoint;
  60240. /**
  60241. * Gets the output component
  60242. */
  60243. get output(): NodeMaterialConnectionPoint;
  60244. protected _buildBlock(state: NodeMaterialBuildState): this;
  60245. }
  60246. }
  60247. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  60248. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60249. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60250. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60251. /**
  60252. * Block used to subtract 2 vectors
  60253. */
  60254. export class SubtractBlock extends NodeMaterialBlock {
  60255. /**
  60256. * Creates a new SubtractBlock
  60257. * @param name defines the block name
  60258. */
  60259. constructor(name: string);
  60260. /**
  60261. * Gets the current class name
  60262. * @returns the class name
  60263. */
  60264. getClassName(): string;
  60265. /**
  60266. * Gets the left operand input component
  60267. */
  60268. get left(): NodeMaterialConnectionPoint;
  60269. /**
  60270. * Gets the right operand input component
  60271. */
  60272. get right(): NodeMaterialConnectionPoint;
  60273. /**
  60274. * Gets the output component
  60275. */
  60276. get output(): NodeMaterialConnectionPoint;
  60277. protected _buildBlock(state: NodeMaterialBuildState): this;
  60278. }
  60279. }
  60280. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  60281. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60282. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60284. /**
  60285. * Block used to step a value
  60286. */
  60287. export class StepBlock extends NodeMaterialBlock {
  60288. /**
  60289. * Creates a new StepBlock
  60290. * @param name defines the block name
  60291. */
  60292. constructor(name: string);
  60293. /**
  60294. * Gets the current class name
  60295. * @returns the class name
  60296. */
  60297. getClassName(): string;
  60298. /**
  60299. * Gets the value operand input component
  60300. */
  60301. get value(): NodeMaterialConnectionPoint;
  60302. /**
  60303. * Gets the edge operand input component
  60304. */
  60305. get edge(): NodeMaterialConnectionPoint;
  60306. /**
  60307. * Gets the output component
  60308. */
  60309. get output(): NodeMaterialConnectionPoint;
  60310. protected _buildBlock(state: NodeMaterialBuildState): this;
  60311. }
  60312. }
  60313. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  60314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60317. /**
  60318. * Block used to get the opposite (1 - x) of a value
  60319. */
  60320. export class OneMinusBlock extends NodeMaterialBlock {
  60321. /**
  60322. * Creates a new OneMinusBlock
  60323. * @param name defines the block name
  60324. */
  60325. constructor(name: string);
  60326. /**
  60327. * Gets the current class name
  60328. * @returns the class name
  60329. */
  60330. getClassName(): string;
  60331. /**
  60332. * Gets the input component
  60333. */
  60334. get input(): NodeMaterialConnectionPoint;
  60335. /**
  60336. * Gets the output component
  60337. */
  60338. get output(): NodeMaterialConnectionPoint;
  60339. protected _buildBlock(state: NodeMaterialBuildState): this;
  60340. }
  60341. }
  60342. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  60343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60346. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60347. /**
  60348. * Block used to get the view direction
  60349. */
  60350. export class ViewDirectionBlock extends NodeMaterialBlock {
  60351. /**
  60352. * Creates a new ViewDirectionBlock
  60353. * @param name defines the block name
  60354. */
  60355. constructor(name: string);
  60356. /**
  60357. * Gets the current class name
  60358. * @returns the class name
  60359. */
  60360. getClassName(): string;
  60361. /**
  60362. * Gets the world position component
  60363. */
  60364. get worldPosition(): NodeMaterialConnectionPoint;
  60365. /**
  60366. * Gets the camera position component
  60367. */
  60368. get cameraPosition(): NodeMaterialConnectionPoint;
  60369. /**
  60370. * Gets the output component
  60371. */
  60372. get output(): NodeMaterialConnectionPoint;
  60373. autoConfigure(material: NodeMaterial): void;
  60374. protected _buildBlock(state: NodeMaterialBuildState): this;
  60375. }
  60376. }
  60377. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  60378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60381. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60382. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  60383. /**
  60384. * Block used to compute fresnel value
  60385. */
  60386. export class FresnelBlock extends NodeMaterialBlock {
  60387. /**
  60388. * Create a new FresnelBlock
  60389. * @param name defines the block name
  60390. */
  60391. constructor(name: string);
  60392. /**
  60393. * Gets the current class name
  60394. * @returns the class name
  60395. */
  60396. getClassName(): string;
  60397. /**
  60398. * Gets the world normal input component
  60399. */
  60400. get worldNormal(): NodeMaterialConnectionPoint;
  60401. /**
  60402. * Gets the view direction input component
  60403. */
  60404. get viewDirection(): NodeMaterialConnectionPoint;
  60405. /**
  60406. * Gets the bias input component
  60407. */
  60408. get bias(): NodeMaterialConnectionPoint;
  60409. /**
  60410. * Gets the camera (or eye) position component
  60411. */
  60412. get power(): NodeMaterialConnectionPoint;
  60413. /**
  60414. * Gets the fresnel output component
  60415. */
  60416. get fresnel(): NodeMaterialConnectionPoint;
  60417. autoConfigure(material: NodeMaterial): void;
  60418. protected _buildBlock(state: NodeMaterialBuildState): this;
  60419. }
  60420. }
  60421. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  60422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60425. /**
  60426. * Block used to get the max of 2 values
  60427. */
  60428. export class MaxBlock extends NodeMaterialBlock {
  60429. /**
  60430. * Creates a new MaxBlock
  60431. * @param name defines the block name
  60432. */
  60433. constructor(name: string);
  60434. /**
  60435. * Gets the current class name
  60436. * @returns the class name
  60437. */
  60438. getClassName(): string;
  60439. /**
  60440. * Gets the left operand input component
  60441. */
  60442. get left(): NodeMaterialConnectionPoint;
  60443. /**
  60444. * Gets the right operand input component
  60445. */
  60446. get right(): NodeMaterialConnectionPoint;
  60447. /**
  60448. * Gets the output component
  60449. */
  60450. get output(): NodeMaterialConnectionPoint;
  60451. protected _buildBlock(state: NodeMaterialBuildState): this;
  60452. }
  60453. }
  60454. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  60455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60458. /**
  60459. * Block used to get the min of 2 values
  60460. */
  60461. export class MinBlock extends NodeMaterialBlock {
  60462. /**
  60463. * Creates a new MinBlock
  60464. * @param name defines the block name
  60465. */
  60466. constructor(name: string);
  60467. /**
  60468. * Gets the current class name
  60469. * @returns the class name
  60470. */
  60471. getClassName(): string;
  60472. /**
  60473. * Gets the left operand input component
  60474. */
  60475. get left(): NodeMaterialConnectionPoint;
  60476. /**
  60477. * Gets the right operand input component
  60478. */
  60479. get right(): NodeMaterialConnectionPoint;
  60480. /**
  60481. * Gets the output component
  60482. */
  60483. get output(): NodeMaterialConnectionPoint;
  60484. protected _buildBlock(state: NodeMaterialBuildState): this;
  60485. }
  60486. }
  60487. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  60488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60491. /**
  60492. * Block used to get the distance between 2 values
  60493. */
  60494. export class DistanceBlock extends NodeMaterialBlock {
  60495. /**
  60496. * Creates a new DistanceBlock
  60497. * @param name defines the block name
  60498. */
  60499. constructor(name: string);
  60500. /**
  60501. * Gets the current class name
  60502. * @returns the class name
  60503. */
  60504. getClassName(): string;
  60505. /**
  60506. * Gets the left operand input component
  60507. */
  60508. get left(): NodeMaterialConnectionPoint;
  60509. /**
  60510. * Gets the right operand input component
  60511. */
  60512. get right(): NodeMaterialConnectionPoint;
  60513. /**
  60514. * Gets the output component
  60515. */
  60516. get output(): NodeMaterialConnectionPoint;
  60517. protected _buildBlock(state: NodeMaterialBuildState): this;
  60518. }
  60519. }
  60520. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  60521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60524. /**
  60525. * Block used to get the length of a vector
  60526. */
  60527. export class LengthBlock extends NodeMaterialBlock {
  60528. /**
  60529. * Creates a new LengthBlock
  60530. * @param name defines the block name
  60531. */
  60532. constructor(name: string);
  60533. /**
  60534. * Gets the current class name
  60535. * @returns the class name
  60536. */
  60537. getClassName(): string;
  60538. /**
  60539. * Gets the value input component
  60540. */
  60541. get value(): NodeMaterialConnectionPoint;
  60542. /**
  60543. * Gets the output component
  60544. */
  60545. get output(): NodeMaterialConnectionPoint;
  60546. protected _buildBlock(state: NodeMaterialBuildState): this;
  60547. }
  60548. }
  60549. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  60550. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60551. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60552. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60553. /**
  60554. * Block used to get negative version of a value (i.e. x * -1)
  60555. */
  60556. export class NegateBlock extends NodeMaterialBlock {
  60557. /**
  60558. * Creates a new NegateBlock
  60559. * @param name defines the block name
  60560. */
  60561. constructor(name: string);
  60562. /**
  60563. * Gets the current class name
  60564. * @returns the class name
  60565. */
  60566. getClassName(): string;
  60567. /**
  60568. * Gets the value input component
  60569. */
  60570. get value(): NodeMaterialConnectionPoint;
  60571. /**
  60572. * Gets the output component
  60573. */
  60574. get output(): NodeMaterialConnectionPoint;
  60575. protected _buildBlock(state: NodeMaterialBuildState): this;
  60576. }
  60577. }
  60578. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  60579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60582. /**
  60583. * Block used to get the value of the first parameter raised to the power of the second
  60584. */
  60585. export class PowBlock extends NodeMaterialBlock {
  60586. /**
  60587. * Creates a new PowBlock
  60588. * @param name defines the block name
  60589. */
  60590. constructor(name: string);
  60591. /**
  60592. * Gets the current class name
  60593. * @returns the class name
  60594. */
  60595. getClassName(): string;
  60596. /**
  60597. * Gets the value operand input component
  60598. */
  60599. get value(): NodeMaterialConnectionPoint;
  60600. /**
  60601. * Gets the power operand input component
  60602. */
  60603. get power(): NodeMaterialConnectionPoint;
  60604. /**
  60605. * Gets the output component
  60606. */
  60607. get output(): NodeMaterialConnectionPoint;
  60608. protected _buildBlock(state: NodeMaterialBuildState): this;
  60609. }
  60610. }
  60611. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  60612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60615. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60616. /**
  60617. * Block used to get a random number
  60618. */
  60619. export class RandomNumberBlock extends NodeMaterialBlock {
  60620. /**
  60621. * Creates a new RandomNumberBlock
  60622. * @param name defines the block name
  60623. */
  60624. constructor(name: string);
  60625. /**
  60626. * Gets the current class name
  60627. * @returns the class name
  60628. */
  60629. getClassName(): string;
  60630. /**
  60631. * Gets the seed input component
  60632. */
  60633. get seed(): NodeMaterialConnectionPoint;
  60634. /**
  60635. * Gets the output component
  60636. */
  60637. get output(): NodeMaterialConnectionPoint;
  60638. protected _buildBlock(state: NodeMaterialBuildState): this;
  60639. }
  60640. }
  60641. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  60642. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60643. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60644. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60645. /**
  60646. * Block used to compute arc tangent of 2 values
  60647. */
  60648. export class ArcTan2Block extends NodeMaterialBlock {
  60649. /**
  60650. * Creates a new ArcTan2Block
  60651. * @param name defines the block name
  60652. */
  60653. constructor(name: string);
  60654. /**
  60655. * Gets the current class name
  60656. * @returns the class name
  60657. */
  60658. getClassName(): string;
  60659. /**
  60660. * Gets the x operand input component
  60661. */
  60662. get x(): NodeMaterialConnectionPoint;
  60663. /**
  60664. * Gets the y operand input component
  60665. */
  60666. get y(): NodeMaterialConnectionPoint;
  60667. /**
  60668. * Gets the output component
  60669. */
  60670. get output(): NodeMaterialConnectionPoint;
  60671. protected _buildBlock(state: NodeMaterialBuildState): this;
  60672. }
  60673. }
  60674. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  60675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60676. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60677. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60678. /**
  60679. * Block used to smooth step a value
  60680. */
  60681. export class SmoothStepBlock extends NodeMaterialBlock {
  60682. /**
  60683. * Creates a new SmoothStepBlock
  60684. * @param name defines the block name
  60685. */
  60686. constructor(name: string);
  60687. /**
  60688. * Gets the current class name
  60689. * @returns the class name
  60690. */
  60691. getClassName(): string;
  60692. /**
  60693. * Gets the value operand input component
  60694. */
  60695. get value(): NodeMaterialConnectionPoint;
  60696. /**
  60697. * Gets the first edge operand input component
  60698. */
  60699. get edge0(): NodeMaterialConnectionPoint;
  60700. /**
  60701. * Gets the second edge operand input component
  60702. */
  60703. get edge1(): NodeMaterialConnectionPoint;
  60704. /**
  60705. * Gets the output component
  60706. */
  60707. get output(): NodeMaterialConnectionPoint;
  60708. protected _buildBlock(state: NodeMaterialBuildState): this;
  60709. }
  60710. }
  60711. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  60712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60715. /**
  60716. * Block used to get the reciprocal (1 / x) of a value
  60717. */
  60718. export class ReciprocalBlock extends NodeMaterialBlock {
  60719. /**
  60720. * Creates a new ReciprocalBlock
  60721. * @param name defines the block name
  60722. */
  60723. constructor(name: string);
  60724. /**
  60725. * Gets the current class name
  60726. * @returns the class name
  60727. */
  60728. getClassName(): string;
  60729. /**
  60730. * Gets the input component
  60731. */
  60732. get input(): NodeMaterialConnectionPoint;
  60733. /**
  60734. * Gets the output component
  60735. */
  60736. get output(): NodeMaterialConnectionPoint;
  60737. protected _buildBlock(state: NodeMaterialBuildState): this;
  60738. }
  60739. }
  60740. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  60741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60742. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60743. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60744. /**
  60745. * Block used to replace a color by another one
  60746. */
  60747. export class ReplaceColorBlock extends NodeMaterialBlock {
  60748. /**
  60749. * Creates a new ReplaceColorBlock
  60750. * @param name defines the block name
  60751. */
  60752. constructor(name: string);
  60753. /**
  60754. * Gets the current class name
  60755. * @returns the class name
  60756. */
  60757. getClassName(): string;
  60758. /**
  60759. * Gets the value input component
  60760. */
  60761. get value(): NodeMaterialConnectionPoint;
  60762. /**
  60763. * Gets the reference input component
  60764. */
  60765. get reference(): NodeMaterialConnectionPoint;
  60766. /**
  60767. * Gets the distance input component
  60768. */
  60769. get distance(): NodeMaterialConnectionPoint;
  60770. /**
  60771. * Gets the replacement input component
  60772. */
  60773. get replacement(): NodeMaterialConnectionPoint;
  60774. /**
  60775. * Gets the output component
  60776. */
  60777. get output(): NodeMaterialConnectionPoint;
  60778. protected _buildBlock(state: NodeMaterialBuildState): this;
  60779. }
  60780. }
  60781. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  60782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60785. /**
  60786. * Block used to posterize a value
  60787. * @see https://en.wikipedia.org/wiki/Posterization
  60788. */
  60789. export class PosterizeBlock extends NodeMaterialBlock {
  60790. /**
  60791. * Creates a new PosterizeBlock
  60792. * @param name defines the block name
  60793. */
  60794. constructor(name: string);
  60795. /**
  60796. * Gets the current class name
  60797. * @returns the class name
  60798. */
  60799. getClassName(): string;
  60800. /**
  60801. * Gets the value input component
  60802. */
  60803. get value(): NodeMaterialConnectionPoint;
  60804. /**
  60805. * Gets the steps input component
  60806. */
  60807. get steps(): NodeMaterialConnectionPoint;
  60808. /**
  60809. * Gets the output component
  60810. */
  60811. get output(): NodeMaterialConnectionPoint;
  60812. protected _buildBlock(state: NodeMaterialBuildState): this;
  60813. }
  60814. }
  60815. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  60816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60819. import { Scene } from "babylonjs/scene";
  60820. /**
  60821. * Operations supported by the Wave block
  60822. */
  60823. export enum WaveBlockKind {
  60824. /** SawTooth */
  60825. SawTooth = 0,
  60826. /** Square */
  60827. Square = 1,
  60828. /** Triangle */
  60829. Triangle = 2
  60830. }
  60831. /**
  60832. * Block used to apply wave operation to floats
  60833. */
  60834. export class WaveBlock extends NodeMaterialBlock {
  60835. /**
  60836. * Gets or sets the kibnd of wave to be applied by the block
  60837. */
  60838. kind: WaveBlockKind;
  60839. /**
  60840. * Creates a new WaveBlock
  60841. * @param name defines the block name
  60842. */
  60843. constructor(name: string);
  60844. /**
  60845. * Gets the current class name
  60846. * @returns the class name
  60847. */
  60848. getClassName(): string;
  60849. /**
  60850. * Gets the input component
  60851. */
  60852. get input(): NodeMaterialConnectionPoint;
  60853. /**
  60854. * Gets the output component
  60855. */
  60856. get output(): NodeMaterialConnectionPoint;
  60857. protected _buildBlock(state: NodeMaterialBuildState): this;
  60858. serialize(): any;
  60859. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60860. }
  60861. }
  60862. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  60863. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60866. import { Color3 } from "babylonjs/Maths/math.color";
  60867. import { Scene } from "babylonjs/scene";
  60868. /**
  60869. * Class used to store a color step for the GradientBlock
  60870. */
  60871. export class GradientBlockColorStep {
  60872. /**
  60873. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60874. */
  60875. step: number;
  60876. /**
  60877. * Gets or sets the color associated with this step
  60878. */
  60879. color: Color3;
  60880. /**
  60881. * Creates a new GradientBlockColorStep
  60882. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60883. * @param color defines the color associated with this step
  60884. */
  60885. constructor(
  60886. /**
  60887. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60888. */
  60889. step: number,
  60890. /**
  60891. * Gets or sets the color associated with this step
  60892. */
  60893. color: Color3);
  60894. }
  60895. /**
  60896. * Block used to return a color from a gradient based on an input value between 0 and 1
  60897. */
  60898. export class GradientBlock extends NodeMaterialBlock {
  60899. /**
  60900. * Gets or sets the list of color steps
  60901. */
  60902. colorSteps: GradientBlockColorStep[];
  60903. /**
  60904. * Creates a new GradientBlock
  60905. * @param name defines the block name
  60906. */
  60907. constructor(name: string);
  60908. /**
  60909. * Gets the current class name
  60910. * @returns the class name
  60911. */
  60912. getClassName(): string;
  60913. /**
  60914. * Gets the gradient input component
  60915. */
  60916. get gradient(): NodeMaterialConnectionPoint;
  60917. /**
  60918. * Gets the output component
  60919. */
  60920. get output(): NodeMaterialConnectionPoint;
  60921. private _writeColorConstant;
  60922. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60923. serialize(): any;
  60924. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60925. protected _dumpPropertiesCode(): string;
  60926. }
  60927. }
  60928. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  60929. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60930. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60932. /**
  60933. * Block used to normalize lerp between 2 values
  60934. */
  60935. export class NLerpBlock extends NodeMaterialBlock {
  60936. /**
  60937. * Creates a new NLerpBlock
  60938. * @param name defines the block name
  60939. */
  60940. constructor(name: string);
  60941. /**
  60942. * Gets the current class name
  60943. * @returns the class name
  60944. */
  60945. getClassName(): string;
  60946. /**
  60947. * Gets the left operand input component
  60948. */
  60949. get left(): NodeMaterialConnectionPoint;
  60950. /**
  60951. * Gets the right operand input component
  60952. */
  60953. get right(): NodeMaterialConnectionPoint;
  60954. /**
  60955. * Gets the gradient operand input component
  60956. */
  60957. get gradient(): NodeMaterialConnectionPoint;
  60958. /**
  60959. * Gets the output component
  60960. */
  60961. get output(): NodeMaterialConnectionPoint;
  60962. protected _buildBlock(state: NodeMaterialBuildState): this;
  60963. }
  60964. }
  60965. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  60966. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60967. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60969. import { Scene } from "babylonjs/scene";
  60970. /**
  60971. * block used to Generate a Worley Noise 3D Noise Pattern
  60972. */
  60973. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60974. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60975. manhattanDistance: boolean;
  60976. /**
  60977. * Creates a new WorleyNoise3DBlock
  60978. * @param name defines the block name
  60979. */
  60980. constructor(name: string);
  60981. /**
  60982. * Gets the current class name
  60983. * @returns the class name
  60984. */
  60985. getClassName(): string;
  60986. /**
  60987. * Gets the seed input component
  60988. */
  60989. get seed(): NodeMaterialConnectionPoint;
  60990. /**
  60991. * Gets the jitter input component
  60992. */
  60993. get jitter(): NodeMaterialConnectionPoint;
  60994. /**
  60995. * Gets the output component
  60996. */
  60997. get output(): NodeMaterialConnectionPoint;
  60998. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60999. /**
  61000. * Exposes the properties to the UI?
  61001. */
  61002. protected _dumpPropertiesCode(): string;
  61003. /**
  61004. * Exposes the properties to the Seralize?
  61005. */
  61006. serialize(): any;
  61007. /**
  61008. * Exposes the properties to the deseralize?
  61009. */
  61010. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61011. }
  61012. }
  61013. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  61014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61017. /**
  61018. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61019. */
  61020. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61021. /**
  61022. * Creates a new SimplexPerlin3DBlock
  61023. * @param name defines the block name
  61024. */
  61025. constructor(name: string);
  61026. /**
  61027. * Gets the current class name
  61028. * @returns the class name
  61029. */
  61030. getClassName(): string;
  61031. /**
  61032. * Gets the seed operand input component
  61033. */
  61034. get seed(): NodeMaterialConnectionPoint;
  61035. /**
  61036. * Gets the output component
  61037. */
  61038. get output(): NodeMaterialConnectionPoint;
  61039. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61040. }
  61041. }
  61042. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  61043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61046. /**
  61047. * Block used to blend normals
  61048. */
  61049. export class NormalBlendBlock extends NodeMaterialBlock {
  61050. /**
  61051. * Creates a new NormalBlendBlock
  61052. * @param name defines the block name
  61053. */
  61054. constructor(name: string);
  61055. /**
  61056. * Gets the current class name
  61057. * @returns the class name
  61058. */
  61059. getClassName(): string;
  61060. /**
  61061. * Gets the first input component
  61062. */
  61063. get normalMap0(): NodeMaterialConnectionPoint;
  61064. /**
  61065. * Gets the second input component
  61066. */
  61067. get normalMap1(): NodeMaterialConnectionPoint;
  61068. /**
  61069. * Gets the output component
  61070. */
  61071. get output(): NodeMaterialConnectionPoint;
  61072. protected _buildBlock(state: NodeMaterialBuildState): this;
  61073. }
  61074. }
  61075. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  61076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61079. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61080. /**
  61081. * Block used to rotate a 2d vector by a given angle
  61082. */
  61083. export class Rotate2dBlock extends NodeMaterialBlock {
  61084. /**
  61085. * Creates a new Rotate2dBlock
  61086. * @param name defines the block name
  61087. */
  61088. constructor(name: string);
  61089. /**
  61090. * Gets the current class name
  61091. * @returns the class name
  61092. */
  61093. getClassName(): string;
  61094. /**
  61095. * Gets the input vector
  61096. */
  61097. get input(): NodeMaterialConnectionPoint;
  61098. /**
  61099. * Gets the input angle
  61100. */
  61101. get angle(): NodeMaterialConnectionPoint;
  61102. /**
  61103. * Gets the output component
  61104. */
  61105. get output(): NodeMaterialConnectionPoint;
  61106. autoConfigure(material: NodeMaterial): void;
  61107. protected _buildBlock(state: NodeMaterialBuildState): this;
  61108. }
  61109. }
  61110. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  61111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61114. /**
  61115. * Block used to get the reflected vector from a direction and a normal
  61116. */
  61117. export class ReflectBlock extends NodeMaterialBlock {
  61118. /**
  61119. * Creates a new ReflectBlock
  61120. * @param name defines the block name
  61121. */
  61122. constructor(name: string);
  61123. /**
  61124. * Gets the current class name
  61125. * @returns the class name
  61126. */
  61127. getClassName(): string;
  61128. /**
  61129. * Gets the incident component
  61130. */
  61131. get incident(): NodeMaterialConnectionPoint;
  61132. /**
  61133. * Gets the normal component
  61134. */
  61135. get normal(): NodeMaterialConnectionPoint;
  61136. /**
  61137. * Gets the output component
  61138. */
  61139. get output(): NodeMaterialConnectionPoint;
  61140. protected _buildBlock(state: NodeMaterialBuildState): this;
  61141. }
  61142. }
  61143. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  61144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61147. /**
  61148. * Block used to get the refracted vector from a direction and a normal
  61149. */
  61150. export class RefractBlock extends NodeMaterialBlock {
  61151. /**
  61152. * Creates a new RefractBlock
  61153. * @param name defines the block name
  61154. */
  61155. constructor(name: string);
  61156. /**
  61157. * Gets the current class name
  61158. * @returns the class name
  61159. */
  61160. getClassName(): string;
  61161. /**
  61162. * Gets the incident component
  61163. */
  61164. get incident(): NodeMaterialConnectionPoint;
  61165. /**
  61166. * Gets the normal component
  61167. */
  61168. get normal(): NodeMaterialConnectionPoint;
  61169. /**
  61170. * Gets the index of refraction component
  61171. */
  61172. get ior(): NodeMaterialConnectionPoint;
  61173. /**
  61174. * Gets the output component
  61175. */
  61176. get output(): NodeMaterialConnectionPoint;
  61177. protected _buildBlock(state: NodeMaterialBuildState): this;
  61178. }
  61179. }
  61180. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  61181. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61182. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61183. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61184. /**
  61185. * Block used to desaturate a color
  61186. */
  61187. export class DesaturateBlock extends NodeMaterialBlock {
  61188. /**
  61189. * Creates a new DesaturateBlock
  61190. * @param name defines the block name
  61191. */
  61192. constructor(name: string);
  61193. /**
  61194. * Gets the current class name
  61195. * @returns the class name
  61196. */
  61197. getClassName(): string;
  61198. /**
  61199. * Gets the color operand input component
  61200. */
  61201. get color(): NodeMaterialConnectionPoint;
  61202. /**
  61203. * Gets the level operand input component
  61204. */
  61205. get level(): NodeMaterialConnectionPoint;
  61206. /**
  61207. * Gets the output component
  61208. */
  61209. get output(): NodeMaterialConnectionPoint;
  61210. protected _buildBlock(state: NodeMaterialBuildState): this;
  61211. }
  61212. }
  61213. declare module "babylonjs/Materials/Node/Blocks/index" {
  61214. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  61215. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  61216. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  61217. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  61218. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  61219. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  61220. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  61221. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  61222. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  61223. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  61224. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  61225. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  61226. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  61227. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  61228. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  61229. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  61230. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  61231. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  61232. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  61233. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  61234. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  61235. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  61236. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  61237. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  61238. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  61239. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  61240. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  61241. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  61242. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  61243. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  61244. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  61245. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  61246. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  61247. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  61248. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  61249. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  61250. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  61251. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  61252. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  61253. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  61254. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  61255. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  61256. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  61257. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  61258. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  61259. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  61260. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  61261. }
  61262. declare module "babylonjs/Materials/Node/Optimizers/index" {
  61263. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61264. }
  61265. declare module "babylonjs/Materials/Node/index" {
  61266. export * from "babylonjs/Materials/Node/Enums/index";
  61267. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61268. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  61269. export * from "babylonjs/Materials/Node/nodeMaterial";
  61270. export * from "babylonjs/Materials/Node/Blocks/index";
  61271. export * from "babylonjs/Materials/Node/Optimizers/index";
  61272. }
  61273. declare module "babylonjs/Materials/effectRenderer" {
  61274. import { Nullable } from "babylonjs/types";
  61275. import { Texture } from "babylonjs/Materials/Textures/texture";
  61276. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61277. import { Viewport } from "babylonjs/Maths/math.viewport";
  61278. import { Observable } from "babylonjs/Misc/observable";
  61279. import { Effect } from "babylonjs/Materials/effect";
  61280. import "babylonjs/Engines/Extensions/engine.renderTarget";
  61281. import "babylonjs/Shaders/postprocess.vertex";
  61282. /**
  61283. * Effect Render Options
  61284. */
  61285. export interface IEffectRendererOptions {
  61286. /**
  61287. * Defines the vertices positions.
  61288. */
  61289. positions?: number[];
  61290. /**
  61291. * Defines the indices.
  61292. */
  61293. indices?: number[];
  61294. }
  61295. /**
  61296. * Helper class to render one or more effects
  61297. */
  61298. export class EffectRenderer {
  61299. private engine;
  61300. private static _DefaultOptions;
  61301. private _vertexBuffers;
  61302. private _indexBuffer;
  61303. private _ringBufferIndex;
  61304. private _ringScreenBuffer;
  61305. private _fullscreenViewport;
  61306. private _getNextFrameBuffer;
  61307. /**
  61308. * Creates an effect renderer
  61309. * @param engine the engine to use for rendering
  61310. * @param options defines the options of the effect renderer
  61311. */
  61312. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61313. /**
  61314. * Sets the current viewport in normalized coordinates 0-1
  61315. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61316. */
  61317. setViewport(viewport?: Viewport): void;
  61318. /**
  61319. * Binds the embedded attributes buffer to the effect.
  61320. * @param effect Defines the effect to bind the attributes for
  61321. */
  61322. bindBuffers(effect: Effect): void;
  61323. /**
  61324. * Sets the current effect wrapper to use during draw.
  61325. * The effect needs to be ready before calling this api.
  61326. * This also sets the default full screen position attribute.
  61327. * @param effectWrapper Defines the effect to draw with
  61328. */
  61329. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61330. /**
  61331. * Draws a full screen quad.
  61332. */
  61333. draw(): void;
  61334. /**
  61335. * renders one or more effects to a specified texture
  61336. * @param effectWrappers list of effects to renderer
  61337. * @param outputTexture texture to draw to, if null it will render to the screen
  61338. */
  61339. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  61340. /**
  61341. * Disposes of the effect renderer
  61342. */
  61343. dispose(): void;
  61344. }
  61345. /**
  61346. * Options to create an EffectWrapper
  61347. */
  61348. interface EffectWrapperCreationOptions {
  61349. /**
  61350. * Engine to use to create the effect
  61351. */
  61352. engine: ThinEngine;
  61353. /**
  61354. * Fragment shader for the effect
  61355. */
  61356. fragmentShader: string;
  61357. /**
  61358. * Vertex shader for the effect
  61359. */
  61360. vertexShader?: string;
  61361. /**
  61362. * Attributes to use in the shader
  61363. */
  61364. attributeNames?: Array<string>;
  61365. /**
  61366. * Uniforms to use in the shader
  61367. */
  61368. uniformNames?: Array<string>;
  61369. /**
  61370. * Texture sampler names to use in the shader
  61371. */
  61372. samplerNames?: Array<string>;
  61373. /**
  61374. * The friendly name of the effect displayed in Spector.
  61375. */
  61376. name?: string;
  61377. }
  61378. /**
  61379. * Wraps an effect to be used for rendering
  61380. */
  61381. export class EffectWrapper {
  61382. /**
  61383. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61384. */
  61385. onApplyObservable: Observable<{}>;
  61386. /**
  61387. * The underlying effect
  61388. */
  61389. effect: Effect;
  61390. /**
  61391. * Creates an effect to be renderer
  61392. * @param creationOptions options to create the effect
  61393. */
  61394. constructor(creationOptions: EffectWrapperCreationOptions);
  61395. /**
  61396. * Disposes of the effect wrapper
  61397. */
  61398. dispose(): void;
  61399. }
  61400. }
  61401. declare module "babylonjs/Materials/index" {
  61402. export * from "babylonjs/Materials/Background/index";
  61403. export * from "babylonjs/Materials/colorCurves";
  61404. export * from "babylonjs/Materials/iEffectFallbacks";
  61405. export * from "babylonjs/Materials/effectFallbacks";
  61406. export * from "babylonjs/Materials/effect";
  61407. export * from "babylonjs/Materials/fresnelParameters";
  61408. export * from "babylonjs/Materials/imageProcessingConfiguration";
  61409. export * from "babylonjs/Materials/material";
  61410. export * from "babylonjs/Materials/materialDefines";
  61411. export * from "babylonjs/Materials/materialHelper";
  61412. export * from "babylonjs/Materials/multiMaterial";
  61413. export * from "babylonjs/Materials/PBR/index";
  61414. export * from "babylonjs/Materials/pushMaterial";
  61415. export * from "babylonjs/Materials/shaderMaterial";
  61416. export * from "babylonjs/Materials/standardMaterial";
  61417. export * from "babylonjs/Materials/Textures/index";
  61418. export * from "babylonjs/Materials/uniformBuffer";
  61419. export * from "babylonjs/Materials/materialFlags";
  61420. export * from "babylonjs/Materials/Node/index";
  61421. export * from "babylonjs/Materials/effectRenderer";
  61422. }
  61423. declare module "babylonjs/Maths/index" {
  61424. export * from "babylonjs/Maths/math.scalar";
  61425. export * from "babylonjs/Maths/math";
  61426. export * from "babylonjs/Maths/sphericalPolynomial";
  61427. }
  61428. declare module "babylonjs/Misc/workerPool" {
  61429. import { IDisposable } from "babylonjs/scene";
  61430. /**
  61431. * Helper class to push actions to a pool of workers.
  61432. */
  61433. export class WorkerPool implements IDisposable {
  61434. private _workerInfos;
  61435. private _pendingActions;
  61436. /**
  61437. * Constructor
  61438. * @param workers Array of workers to use for actions
  61439. */
  61440. constructor(workers: Array<Worker>);
  61441. /**
  61442. * Terminates all workers and clears any pending actions.
  61443. */
  61444. dispose(): void;
  61445. /**
  61446. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61447. * pended until a worker has completed its action.
  61448. * @param action The action to perform. Call onComplete when the action is complete.
  61449. */
  61450. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61451. private _execute;
  61452. }
  61453. }
  61454. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  61455. import { IDisposable } from "babylonjs/scene";
  61456. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61457. /**
  61458. * Configuration for Draco compression
  61459. */
  61460. export interface IDracoCompressionConfiguration {
  61461. /**
  61462. * Configuration for the decoder.
  61463. */
  61464. decoder: {
  61465. /**
  61466. * The url to the WebAssembly module.
  61467. */
  61468. wasmUrl?: string;
  61469. /**
  61470. * The url to the WebAssembly binary.
  61471. */
  61472. wasmBinaryUrl?: string;
  61473. /**
  61474. * The url to the fallback JavaScript module.
  61475. */
  61476. fallbackUrl?: string;
  61477. };
  61478. }
  61479. /**
  61480. * Draco compression (https://google.github.io/draco/)
  61481. *
  61482. * This class wraps the Draco module.
  61483. *
  61484. * **Encoder**
  61485. *
  61486. * The encoder is not currently implemented.
  61487. *
  61488. * **Decoder**
  61489. *
  61490. * 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.
  61491. *
  61492. * To update the configuration, use the following code:
  61493. * ```javascript
  61494. * DracoCompression.Configuration = {
  61495. * decoder: {
  61496. * wasmUrl: "<url to the WebAssembly library>",
  61497. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61498. * fallbackUrl: "<url to the fallback JavaScript library>",
  61499. * }
  61500. * };
  61501. * ```
  61502. *
  61503. * 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.
  61504. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61505. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61506. *
  61507. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61508. * ```javascript
  61509. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61510. * ```
  61511. *
  61512. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61513. */
  61514. export class DracoCompression implements IDisposable {
  61515. private _workerPoolPromise?;
  61516. private _decoderModulePromise?;
  61517. /**
  61518. * The configuration. Defaults to the following urls:
  61519. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61520. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61521. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61522. */
  61523. static Configuration: IDracoCompressionConfiguration;
  61524. /**
  61525. * Returns true if the decoder configuration is available.
  61526. */
  61527. static get DecoderAvailable(): boolean;
  61528. /**
  61529. * Default number of workers to create when creating the draco compression object.
  61530. */
  61531. static DefaultNumWorkers: number;
  61532. private static GetDefaultNumWorkers;
  61533. private static _Default;
  61534. /**
  61535. * Default instance for the draco compression object.
  61536. */
  61537. static get Default(): DracoCompression;
  61538. /**
  61539. * Constructor
  61540. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61541. */
  61542. constructor(numWorkers?: number);
  61543. /**
  61544. * Stop all async operations and release resources.
  61545. */
  61546. dispose(): void;
  61547. /**
  61548. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61549. * @returns a promise that resolves when ready
  61550. */
  61551. whenReadyAsync(): Promise<void>;
  61552. /**
  61553. * Decode Draco compressed mesh data to vertex data.
  61554. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61555. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61556. * @returns A promise that resolves with the decoded vertex data
  61557. */
  61558. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61559. [kind: string]: number;
  61560. }): Promise<VertexData>;
  61561. }
  61562. }
  61563. declare module "babylonjs/Meshes/Compression/index" {
  61564. export * from "babylonjs/Meshes/Compression/dracoCompression";
  61565. }
  61566. declare module "babylonjs/Meshes/csg" {
  61567. import { Nullable } from "babylonjs/types";
  61568. import { Scene } from "babylonjs/scene";
  61569. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61570. import { Mesh } from "babylonjs/Meshes/mesh";
  61571. import { Material } from "babylonjs/Materials/material";
  61572. /**
  61573. * Class for building Constructive Solid Geometry
  61574. */
  61575. export class CSG {
  61576. private polygons;
  61577. /**
  61578. * The world matrix
  61579. */
  61580. matrix: Matrix;
  61581. /**
  61582. * Stores the position
  61583. */
  61584. position: Vector3;
  61585. /**
  61586. * Stores the rotation
  61587. */
  61588. rotation: Vector3;
  61589. /**
  61590. * Stores the rotation quaternion
  61591. */
  61592. rotationQuaternion: Nullable<Quaternion>;
  61593. /**
  61594. * Stores the scaling vector
  61595. */
  61596. scaling: Vector3;
  61597. /**
  61598. * Convert the Mesh to CSG
  61599. * @param mesh The Mesh to convert to CSG
  61600. * @returns A new CSG from the Mesh
  61601. */
  61602. static FromMesh(mesh: Mesh): CSG;
  61603. /**
  61604. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61605. * @param polygons Polygons used to construct a CSG solid
  61606. */
  61607. private static FromPolygons;
  61608. /**
  61609. * Clones, or makes a deep copy, of the CSG
  61610. * @returns A new CSG
  61611. */
  61612. clone(): CSG;
  61613. /**
  61614. * Unions this CSG with another CSG
  61615. * @param csg The CSG to union against this CSG
  61616. * @returns The unioned CSG
  61617. */
  61618. union(csg: CSG): CSG;
  61619. /**
  61620. * Unions this CSG with another CSG in place
  61621. * @param csg The CSG to union against this CSG
  61622. */
  61623. unionInPlace(csg: CSG): void;
  61624. /**
  61625. * Subtracts this CSG with another CSG
  61626. * @param csg The CSG to subtract against this CSG
  61627. * @returns A new CSG
  61628. */
  61629. subtract(csg: CSG): CSG;
  61630. /**
  61631. * Subtracts this CSG with another CSG in place
  61632. * @param csg The CSG to subtact against this CSG
  61633. */
  61634. subtractInPlace(csg: CSG): void;
  61635. /**
  61636. * Intersect this CSG with another CSG
  61637. * @param csg The CSG to intersect against this CSG
  61638. * @returns A new CSG
  61639. */
  61640. intersect(csg: CSG): CSG;
  61641. /**
  61642. * Intersects this CSG with another CSG in place
  61643. * @param csg The CSG to intersect against this CSG
  61644. */
  61645. intersectInPlace(csg: CSG): void;
  61646. /**
  61647. * Return a new CSG solid with solid and empty space switched. This solid is
  61648. * not modified.
  61649. * @returns A new CSG solid with solid and empty space switched
  61650. */
  61651. inverse(): CSG;
  61652. /**
  61653. * Inverses the CSG in place
  61654. */
  61655. inverseInPlace(): void;
  61656. /**
  61657. * This is used to keep meshes transformations so they can be restored
  61658. * when we build back a Babylon Mesh
  61659. * NB : All CSG operations are performed in world coordinates
  61660. * @param csg The CSG to copy the transform attributes from
  61661. * @returns This CSG
  61662. */
  61663. copyTransformAttributes(csg: CSG): CSG;
  61664. /**
  61665. * Build Raw mesh from CSG
  61666. * Coordinates here are in world space
  61667. * @param name The name of the mesh geometry
  61668. * @param scene The Scene
  61669. * @param keepSubMeshes Specifies if the submeshes should be kept
  61670. * @returns A new Mesh
  61671. */
  61672. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61673. /**
  61674. * Build Mesh from CSG taking material and transforms into account
  61675. * @param name The name of the Mesh
  61676. * @param material The material of the Mesh
  61677. * @param scene The Scene
  61678. * @param keepSubMeshes Specifies if submeshes should be kept
  61679. * @returns The new Mesh
  61680. */
  61681. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61682. }
  61683. }
  61684. declare module "babylonjs/Meshes/trailMesh" {
  61685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61686. import { Mesh } from "babylonjs/Meshes/mesh";
  61687. import { Scene } from "babylonjs/scene";
  61688. /**
  61689. * Class used to create a trail following a mesh
  61690. */
  61691. export class TrailMesh extends Mesh {
  61692. private _generator;
  61693. private _autoStart;
  61694. private _running;
  61695. private _diameter;
  61696. private _length;
  61697. private _sectionPolygonPointsCount;
  61698. private _sectionVectors;
  61699. private _sectionNormalVectors;
  61700. private _beforeRenderObserver;
  61701. /**
  61702. * @constructor
  61703. * @param name The value used by scene.getMeshByName() to do a lookup.
  61704. * @param generator The mesh to generate a trail.
  61705. * @param scene The scene to add this mesh to.
  61706. * @param diameter Diameter of trailing mesh. Default is 1.
  61707. * @param length Length of trailing mesh. Default is 60.
  61708. * @param autoStart Automatically start trailing mesh. Default true.
  61709. */
  61710. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61711. /**
  61712. * "TrailMesh"
  61713. * @returns "TrailMesh"
  61714. */
  61715. getClassName(): string;
  61716. private _createMesh;
  61717. /**
  61718. * Start trailing mesh.
  61719. */
  61720. start(): void;
  61721. /**
  61722. * Stop trailing mesh.
  61723. */
  61724. stop(): void;
  61725. /**
  61726. * Update trailing mesh geometry.
  61727. */
  61728. update(): void;
  61729. /**
  61730. * Returns a new TrailMesh object.
  61731. * @param name is a string, the name given to the new mesh
  61732. * @param newGenerator use new generator object for cloned trail mesh
  61733. * @returns a new mesh
  61734. */
  61735. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  61736. /**
  61737. * Serializes this trail mesh
  61738. * @param serializationObject object to write serialization to
  61739. */
  61740. serialize(serializationObject: any): void;
  61741. /**
  61742. * Parses a serialized trail mesh
  61743. * @param parsedMesh the serialized mesh
  61744. * @param scene the scene to create the trail mesh in
  61745. * @returns the created trail mesh
  61746. */
  61747. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61748. }
  61749. }
  61750. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  61751. import { Nullable } from "babylonjs/types";
  61752. import { Scene } from "babylonjs/scene";
  61753. import { Vector4 } from "babylonjs/Maths/math.vector";
  61754. import { Color4 } from "babylonjs/Maths/math.color";
  61755. import { Mesh } from "babylonjs/Meshes/mesh";
  61756. /**
  61757. * Class containing static functions to help procedurally build meshes
  61758. */
  61759. export class TiledBoxBuilder {
  61760. /**
  61761. * Creates a box mesh
  61762. * 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)
  61763. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61767. * @param name defines the name of the mesh
  61768. * @param options defines the options used to create the mesh
  61769. * @param scene defines the hosting scene
  61770. * @returns the box mesh
  61771. */
  61772. static CreateTiledBox(name: string, options: {
  61773. pattern?: number;
  61774. width?: number;
  61775. height?: number;
  61776. depth?: number;
  61777. tileSize?: number;
  61778. tileWidth?: number;
  61779. tileHeight?: number;
  61780. alignHorizontal?: number;
  61781. alignVertical?: number;
  61782. faceUV?: Vector4[];
  61783. faceColors?: Color4[];
  61784. sideOrientation?: number;
  61785. updatable?: boolean;
  61786. }, scene?: Nullable<Scene>): Mesh;
  61787. }
  61788. }
  61789. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  61790. import { Vector4 } from "babylonjs/Maths/math.vector";
  61791. import { Mesh } from "babylonjs/Meshes/mesh";
  61792. /**
  61793. * Class containing static functions to help procedurally build meshes
  61794. */
  61795. export class TorusKnotBuilder {
  61796. /**
  61797. * Creates a torus knot mesh
  61798. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61799. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61800. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61801. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61805. * @param name defines the name of the mesh
  61806. * @param options defines the options used to create the mesh
  61807. * @param scene defines the hosting scene
  61808. * @returns the torus knot mesh
  61809. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61810. */
  61811. static CreateTorusKnot(name: string, options: {
  61812. radius?: number;
  61813. tube?: number;
  61814. radialSegments?: number;
  61815. tubularSegments?: number;
  61816. p?: number;
  61817. q?: number;
  61818. updatable?: boolean;
  61819. sideOrientation?: number;
  61820. frontUVs?: Vector4;
  61821. backUVs?: Vector4;
  61822. }, scene: any): Mesh;
  61823. }
  61824. }
  61825. declare module "babylonjs/Meshes/polygonMesh" {
  61826. import { Scene } from "babylonjs/scene";
  61827. import { Vector2 } from "babylonjs/Maths/math.vector";
  61828. import { Mesh } from "babylonjs/Meshes/mesh";
  61829. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61830. import { Path2 } from "babylonjs/Maths/math.path";
  61831. /**
  61832. * Polygon
  61833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61834. */
  61835. export class Polygon {
  61836. /**
  61837. * Creates a rectangle
  61838. * @param xmin bottom X coord
  61839. * @param ymin bottom Y coord
  61840. * @param xmax top X coord
  61841. * @param ymax top Y coord
  61842. * @returns points that make the resulting rectation
  61843. */
  61844. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61845. /**
  61846. * Creates a circle
  61847. * @param radius radius of circle
  61848. * @param cx scale in x
  61849. * @param cy scale in y
  61850. * @param numberOfSides number of sides that make up the circle
  61851. * @returns points that make the resulting circle
  61852. */
  61853. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61854. /**
  61855. * Creates a polygon from input string
  61856. * @param input Input polygon data
  61857. * @returns the parsed points
  61858. */
  61859. static Parse(input: string): Vector2[];
  61860. /**
  61861. * Starts building a polygon from x and y coordinates
  61862. * @param x x coordinate
  61863. * @param y y coordinate
  61864. * @returns the started path2
  61865. */
  61866. static StartingAt(x: number, y: number): Path2;
  61867. }
  61868. /**
  61869. * Builds a polygon
  61870. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61871. */
  61872. export class PolygonMeshBuilder {
  61873. private _points;
  61874. private _outlinepoints;
  61875. private _holes;
  61876. private _name;
  61877. private _scene;
  61878. private _epoints;
  61879. private _eholes;
  61880. private _addToepoint;
  61881. /**
  61882. * Babylon reference to the earcut plugin.
  61883. */
  61884. bjsEarcut: any;
  61885. /**
  61886. * Creates a PolygonMeshBuilder
  61887. * @param name name of the builder
  61888. * @param contours Path of the polygon
  61889. * @param scene scene to add to when creating the mesh
  61890. * @param earcutInjection can be used to inject your own earcut reference
  61891. */
  61892. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61893. /**
  61894. * Adds a whole within the polygon
  61895. * @param hole Array of points defining the hole
  61896. * @returns this
  61897. */
  61898. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61899. /**
  61900. * Creates the polygon
  61901. * @param updatable If the mesh should be updatable
  61902. * @param depth The depth of the mesh created
  61903. * @returns the created mesh
  61904. */
  61905. build(updatable?: boolean, depth?: number): Mesh;
  61906. /**
  61907. * Creates the polygon
  61908. * @param depth The depth of the mesh created
  61909. * @returns the created VertexData
  61910. */
  61911. buildVertexData(depth?: number): VertexData;
  61912. /**
  61913. * Adds a side to the polygon
  61914. * @param positions points that make the polygon
  61915. * @param normals normals of the polygon
  61916. * @param uvs uvs of the polygon
  61917. * @param indices indices of the polygon
  61918. * @param bounds bounds of the polygon
  61919. * @param points points of the polygon
  61920. * @param depth depth of the polygon
  61921. * @param flip flip of the polygon
  61922. */
  61923. private addSide;
  61924. }
  61925. }
  61926. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  61927. import { Scene } from "babylonjs/scene";
  61928. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61929. import { Color4 } from "babylonjs/Maths/math.color";
  61930. import { Mesh } from "babylonjs/Meshes/mesh";
  61931. import { Nullable } from "babylonjs/types";
  61932. /**
  61933. * Class containing static functions to help procedurally build meshes
  61934. */
  61935. export class PolygonBuilder {
  61936. /**
  61937. * Creates a polygon mesh
  61938. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61939. * * 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
  61940. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61943. * * Remember you can only change the shape positions, not their number when updating a polygon
  61944. * @param name defines the name of the mesh
  61945. * @param options defines the options used to create the mesh
  61946. * @param scene defines the hosting scene
  61947. * @param earcutInjection can be used to inject your own earcut reference
  61948. * @returns the polygon mesh
  61949. */
  61950. static CreatePolygon(name: string, options: {
  61951. shape: Vector3[];
  61952. holes?: Vector3[][];
  61953. depth?: number;
  61954. faceUV?: Vector4[];
  61955. faceColors?: Color4[];
  61956. updatable?: boolean;
  61957. sideOrientation?: number;
  61958. frontUVs?: Vector4;
  61959. backUVs?: Vector4;
  61960. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61961. /**
  61962. * Creates an extruded polygon mesh, with depth in the Y direction.
  61963. * * 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)
  61964. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61965. * @param name defines the name of the mesh
  61966. * @param options defines the options used to create the mesh
  61967. * @param scene defines the hosting scene
  61968. * @param earcutInjection can be used to inject your own earcut reference
  61969. * @returns the polygon mesh
  61970. */
  61971. static ExtrudePolygon(name: string, options: {
  61972. shape: Vector3[];
  61973. holes?: Vector3[][];
  61974. depth?: number;
  61975. faceUV?: Vector4[];
  61976. faceColors?: Color4[];
  61977. updatable?: boolean;
  61978. sideOrientation?: number;
  61979. frontUVs?: Vector4;
  61980. backUVs?: Vector4;
  61981. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61982. }
  61983. }
  61984. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  61985. import { Scene } from "babylonjs/scene";
  61986. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61987. import { Mesh } from "babylonjs/Meshes/mesh";
  61988. import { Nullable } from "babylonjs/types";
  61989. /**
  61990. * Class containing static functions to help procedurally build meshes
  61991. */
  61992. export class LatheBuilder {
  61993. /**
  61994. * Creates lathe mesh.
  61995. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61996. * * 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
  61997. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61998. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61999. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62000. * * 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
  62001. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62002. * * 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
  62003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62005. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62007. * @param name defines the name of the mesh
  62008. * @param options defines the options used to create the mesh
  62009. * @param scene defines the hosting scene
  62010. * @returns the lathe mesh
  62011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62012. */
  62013. static CreateLathe(name: string, options: {
  62014. shape: Vector3[];
  62015. radius?: number;
  62016. tessellation?: number;
  62017. clip?: number;
  62018. arc?: number;
  62019. closed?: boolean;
  62020. updatable?: boolean;
  62021. sideOrientation?: number;
  62022. frontUVs?: Vector4;
  62023. backUVs?: Vector4;
  62024. cap?: number;
  62025. invertUV?: boolean;
  62026. }, scene?: Nullable<Scene>): Mesh;
  62027. }
  62028. }
  62029. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  62030. import { Nullable } from "babylonjs/types";
  62031. import { Scene } from "babylonjs/scene";
  62032. import { Vector4 } from "babylonjs/Maths/math.vector";
  62033. import { Mesh } from "babylonjs/Meshes/mesh";
  62034. /**
  62035. * Class containing static functions to help procedurally build meshes
  62036. */
  62037. export class TiledPlaneBuilder {
  62038. /**
  62039. * Creates a tiled plane mesh
  62040. * * The parameter `pattern` will, depending on value, do nothing or
  62041. * * * flip (reflect about central vertical) alternate tiles across and up
  62042. * * * flip every tile on alternate rows
  62043. * * * rotate (180 degs) alternate tiles across and up
  62044. * * * rotate every tile on alternate rows
  62045. * * * flip and rotate alternate tiles across and up
  62046. * * * flip and rotate every tile on alternate rows
  62047. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62048. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62050. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62051. * * 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)
  62052. * * 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)
  62053. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62054. * @param name defines the name of the mesh
  62055. * @param options defines the options used to create the mesh
  62056. * @param scene defines the hosting scene
  62057. * @returns the box mesh
  62058. */
  62059. static CreateTiledPlane(name: string, options: {
  62060. pattern?: number;
  62061. tileSize?: number;
  62062. tileWidth?: number;
  62063. tileHeight?: number;
  62064. size?: number;
  62065. width?: number;
  62066. height?: number;
  62067. alignHorizontal?: number;
  62068. alignVertical?: number;
  62069. sideOrientation?: number;
  62070. frontUVs?: Vector4;
  62071. backUVs?: Vector4;
  62072. updatable?: boolean;
  62073. }, scene?: Nullable<Scene>): Mesh;
  62074. }
  62075. }
  62076. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  62077. import { Nullable } from "babylonjs/types";
  62078. import { Scene } from "babylonjs/scene";
  62079. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62080. import { Mesh } from "babylonjs/Meshes/mesh";
  62081. /**
  62082. * Class containing static functions to help procedurally build meshes
  62083. */
  62084. export class TubeBuilder {
  62085. /**
  62086. * Creates a tube mesh.
  62087. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62088. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62089. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62090. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62091. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62092. * * 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)
  62093. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62094. * * 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
  62095. * * 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
  62096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62100. * @param name defines the name of the mesh
  62101. * @param options defines the options used to create the mesh
  62102. * @param scene defines the hosting scene
  62103. * @returns the tube mesh
  62104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62105. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62106. */
  62107. static CreateTube(name: string, options: {
  62108. path: Vector3[];
  62109. radius?: number;
  62110. tessellation?: number;
  62111. radiusFunction?: {
  62112. (i: number, distance: number): number;
  62113. };
  62114. cap?: number;
  62115. arc?: number;
  62116. updatable?: boolean;
  62117. sideOrientation?: number;
  62118. frontUVs?: Vector4;
  62119. backUVs?: Vector4;
  62120. instance?: Mesh;
  62121. invertUV?: boolean;
  62122. }, scene?: Nullable<Scene>): Mesh;
  62123. }
  62124. }
  62125. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  62126. import { Scene } from "babylonjs/scene";
  62127. import { Vector4 } from "babylonjs/Maths/math.vector";
  62128. import { Mesh } from "babylonjs/Meshes/mesh";
  62129. import { Nullable } from "babylonjs/types";
  62130. /**
  62131. * Class containing static functions to help procedurally build meshes
  62132. */
  62133. export class IcoSphereBuilder {
  62134. /**
  62135. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62136. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62137. * * 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`)
  62138. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62139. * * 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
  62140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62143. * @param name defines the name of the mesh
  62144. * @param options defines the options used to create the mesh
  62145. * @param scene defines the hosting scene
  62146. * @returns the icosahedron mesh
  62147. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62148. */
  62149. static CreateIcoSphere(name: string, options: {
  62150. radius?: number;
  62151. radiusX?: number;
  62152. radiusY?: number;
  62153. radiusZ?: number;
  62154. flat?: boolean;
  62155. subdivisions?: number;
  62156. sideOrientation?: number;
  62157. frontUVs?: Vector4;
  62158. backUVs?: Vector4;
  62159. updatable?: boolean;
  62160. }, scene?: Nullable<Scene>): Mesh;
  62161. }
  62162. }
  62163. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  62164. import { Vector3 } from "babylonjs/Maths/math.vector";
  62165. import { Mesh } from "babylonjs/Meshes/mesh";
  62166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62167. /**
  62168. * Class containing static functions to help procedurally build meshes
  62169. */
  62170. export class DecalBuilder {
  62171. /**
  62172. * Creates a decal mesh.
  62173. * 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
  62174. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62175. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62176. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62177. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62178. * @param name defines the name of the mesh
  62179. * @param sourceMesh defines the mesh where the decal must be applied
  62180. * @param options defines the options used to create the mesh
  62181. * @param scene defines the hosting scene
  62182. * @returns the decal mesh
  62183. * @see https://doc.babylonjs.com/how_to/decals
  62184. */
  62185. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62186. position?: Vector3;
  62187. normal?: Vector3;
  62188. size?: Vector3;
  62189. angle?: number;
  62190. }): Mesh;
  62191. }
  62192. }
  62193. declare module "babylonjs/Meshes/meshBuilder" {
  62194. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  62195. import { Nullable } from "babylonjs/types";
  62196. import { Scene } from "babylonjs/scene";
  62197. import { Mesh } from "babylonjs/Meshes/mesh";
  62198. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  62199. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  62200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62201. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62202. import { Plane } from "babylonjs/Maths/math.plane";
  62203. /**
  62204. * Class containing static functions to help procedurally build meshes
  62205. */
  62206. export class MeshBuilder {
  62207. /**
  62208. * Creates a box mesh
  62209. * * The parameter `size` sets the size (float) of each box side (default 1)
  62210. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  62211. * * 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)
  62212. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62216. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62217. * @param name defines the name of the mesh
  62218. * @param options defines the options used to create the mesh
  62219. * @param scene defines the hosting scene
  62220. * @returns the box mesh
  62221. */
  62222. static CreateBox(name: string, options: {
  62223. size?: number;
  62224. width?: number;
  62225. height?: number;
  62226. depth?: number;
  62227. faceUV?: Vector4[];
  62228. faceColors?: Color4[];
  62229. sideOrientation?: number;
  62230. frontUVs?: Vector4;
  62231. backUVs?: Vector4;
  62232. updatable?: boolean;
  62233. }, scene?: Nullable<Scene>): Mesh;
  62234. /**
  62235. * Creates a tiled box mesh
  62236. * * faceTiles sets the pattern, tile size and number of tiles for a face
  62237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62238. * @param name defines the name of the mesh
  62239. * @param options defines the options used to create the mesh
  62240. * @param scene defines the hosting scene
  62241. * @returns the tiled box mesh
  62242. */
  62243. static CreateTiledBox(name: string, options: {
  62244. pattern?: number;
  62245. size?: number;
  62246. width?: number;
  62247. height?: number;
  62248. depth: number;
  62249. tileSize?: number;
  62250. tileWidth?: number;
  62251. tileHeight?: number;
  62252. faceUV?: Vector4[];
  62253. faceColors?: Color4[];
  62254. alignHorizontal?: number;
  62255. alignVertical?: number;
  62256. sideOrientation?: number;
  62257. updatable?: boolean;
  62258. }, scene?: Nullable<Scene>): Mesh;
  62259. /**
  62260. * Creates a sphere mesh
  62261. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  62262. * * 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`)
  62263. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  62264. * * 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
  62265. * * 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)
  62266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62269. * @param name defines the name of the mesh
  62270. * @param options defines the options used to create the mesh
  62271. * @param scene defines the hosting scene
  62272. * @returns the sphere mesh
  62273. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  62274. */
  62275. static CreateSphere(name: string, options: {
  62276. segments?: number;
  62277. diameter?: number;
  62278. diameterX?: number;
  62279. diameterY?: number;
  62280. diameterZ?: number;
  62281. arc?: number;
  62282. slice?: number;
  62283. sideOrientation?: number;
  62284. frontUVs?: Vector4;
  62285. backUVs?: Vector4;
  62286. updatable?: boolean;
  62287. }, scene?: Nullable<Scene>): Mesh;
  62288. /**
  62289. * Creates a plane polygonal mesh. By default, this is a disc
  62290. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  62291. * * 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
  62292. * * 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
  62293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62296. * @param name defines the name of the mesh
  62297. * @param options defines the options used to create the mesh
  62298. * @param scene defines the hosting scene
  62299. * @returns the plane polygonal mesh
  62300. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  62301. */
  62302. static CreateDisc(name: string, options: {
  62303. radius?: number;
  62304. tessellation?: number;
  62305. arc?: number;
  62306. updatable?: boolean;
  62307. sideOrientation?: number;
  62308. frontUVs?: Vector4;
  62309. backUVs?: Vector4;
  62310. }, scene?: Nullable<Scene>): Mesh;
  62311. /**
  62312. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62313. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62314. * * 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`)
  62315. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62316. * * 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
  62317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62320. * @param name defines the name of the mesh
  62321. * @param options defines the options used to create the mesh
  62322. * @param scene defines the hosting scene
  62323. * @returns the icosahedron mesh
  62324. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62325. */
  62326. static CreateIcoSphere(name: string, options: {
  62327. radius?: number;
  62328. radiusX?: number;
  62329. radiusY?: number;
  62330. radiusZ?: number;
  62331. flat?: boolean;
  62332. subdivisions?: number;
  62333. sideOrientation?: number;
  62334. frontUVs?: Vector4;
  62335. backUVs?: Vector4;
  62336. updatable?: boolean;
  62337. }, scene?: Nullable<Scene>): Mesh;
  62338. /**
  62339. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62340. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62341. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62342. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62343. * * 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
  62344. * * 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
  62345. * * 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
  62346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62348. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62349. * * 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
  62350. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62351. * * 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
  62352. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62354. * @param name defines the name of the mesh
  62355. * @param options defines the options used to create the mesh
  62356. * @param scene defines the hosting scene
  62357. * @returns the ribbon mesh
  62358. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62359. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62360. */
  62361. static CreateRibbon(name: string, options: {
  62362. pathArray: Vector3[][];
  62363. closeArray?: boolean;
  62364. closePath?: boolean;
  62365. offset?: number;
  62366. updatable?: boolean;
  62367. sideOrientation?: number;
  62368. frontUVs?: Vector4;
  62369. backUVs?: Vector4;
  62370. instance?: Mesh;
  62371. invertUV?: boolean;
  62372. uvs?: Vector2[];
  62373. colors?: Color4[];
  62374. }, scene?: Nullable<Scene>): Mesh;
  62375. /**
  62376. * Creates a cylinder or a cone mesh
  62377. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  62378. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  62379. * * 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.
  62380. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  62381. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  62382. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  62383. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  62384. * * 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).
  62385. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  62386. * * 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).
  62387. * * 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
  62388. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  62389. * * 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
  62390. * * 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.
  62391. * * If `enclose` is false, a ring surface is one element.
  62392. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  62393. * * 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
  62394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62397. * @param name defines the name of the mesh
  62398. * @param options defines the options used to create the mesh
  62399. * @param scene defines the hosting scene
  62400. * @returns the cylinder mesh
  62401. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  62402. */
  62403. static CreateCylinder(name: string, options: {
  62404. height?: number;
  62405. diameterTop?: number;
  62406. diameterBottom?: number;
  62407. diameter?: number;
  62408. tessellation?: number;
  62409. subdivisions?: number;
  62410. arc?: number;
  62411. faceColors?: Color4[];
  62412. faceUV?: Vector4[];
  62413. updatable?: boolean;
  62414. hasRings?: boolean;
  62415. enclose?: boolean;
  62416. cap?: number;
  62417. sideOrientation?: number;
  62418. frontUVs?: Vector4;
  62419. backUVs?: Vector4;
  62420. }, scene?: Nullable<Scene>): Mesh;
  62421. /**
  62422. * Creates a torus mesh
  62423. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  62424. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  62425. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  62426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62429. * @param name defines the name of the mesh
  62430. * @param options defines the options used to create the mesh
  62431. * @param scene defines the hosting scene
  62432. * @returns the torus mesh
  62433. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  62434. */
  62435. static CreateTorus(name: string, options: {
  62436. diameter?: number;
  62437. thickness?: number;
  62438. tessellation?: number;
  62439. updatable?: boolean;
  62440. sideOrientation?: number;
  62441. frontUVs?: Vector4;
  62442. backUVs?: Vector4;
  62443. }, scene?: Nullable<Scene>): Mesh;
  62444. /**
  62445. * Creates a torus knot mesh
  62446. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62447. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62448. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62449. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62453. * @param name defines the name of the mesh
  62454. * @param options defines the options used to create the mesh
  62455. * @param scene defines the hosting scene
  62456. * @returns the torus knot mesh
  62457. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62458. */
  62459. static CreateTorusKnot(name: string, options: {
  62460. radius?: number;
  62461. tube?: number;
  62462. radialSegments?: number;
  62463. tubularSegments?: number;
  62464. p?: number;
  62465. q?: number;
  62466. updatable?: boolean;
  62467. sideOrientation?: number;
  62468. frontUVs?: Vector4;
  62469. backUVs?: Vector4;
  62470. }, scene?: Nullable<Scene>): Mesh;
  62471. /**
  62472. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  62473. * * 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
  62474. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  62475. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62476. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62477. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62478. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62479. * * 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
  62480. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62482. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62483. * @param name defines the name of the new line system
  62484. * @param options defines the options used to create the line system
  62485. * @param scene defines the hosting scene
  62486. * @returns a new line system mesh
  62487. */
  62488. static CreateLineSystem(name: string, options: {
  62489. lines: Vector3[][];
  62490. updatable?: boolean;
  62491. instance?: Nullable<LinesMesh>;
  62492. colors?: Nullable<Color4[][]>;
  62493. useVertexAlpha?: boolean;
  62494. }, scene: Nullable<Scene>): LinesMesh;
  62495. /**
  62496. * Creates a line mesh
  62497. * 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
  62498. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62499. * * The parameter `points` is an array successive Vector3
  62500. * * 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
  62501. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62502. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62503. * * When updating an instance, remember that only point positions can change, not the number of points
  62504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62506. * @param name defines the name of the new line system
  62507. * @param options defines the options used to create the line system
  62508. * @param scene defines the hosting scene
  62509. * @returns a new line mesh
  62510. */
  62511. static CreateLines(name: string, options: {
  62512. points: Vector3[];
  62513. updatable?: boolean;
  62514. instance?: Nullable<LinesMesh>;
  62515. colors?: Color4[];
  62516. useVertexAlpha?: boolean;
  62517. }, scene?: Nullable<Scene>): LinesMesh;
  62518. /**
  62519. * Creates a dashed line mesh
  62520. * * 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
  62521. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62522. * * The parameter `points` is an array successive Vector3
  62523. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62524. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62525. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62526. * * 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
  62527. * * When updating an instance, remember that only point positions can change, not the number of points
  62528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62529. * @param name defines the name of the mesh
  62530. * @param options defines the options used to create the mesh
  62531. * @param scene defines the hosting scene
  62532. * @returns the dashed line mesh
  62533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62534. */
  62535. static CreateDashedLines(name: string, options: {
  62536. points: Vector3[];
  62537. dashSize?: number;
  62538. gapSize?: number;
  62539. dashNb?: number;
  62540. updatable?: boolean;
  62541. instance?: LinesMesh;
  62542. }, scene?: Nullable<Scene>): LinesMesh;
  62543. /**
  62544. * 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.
  62545. * * 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.
  62546. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62547. * * 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.
  62548. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62549. * * 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
  62550. * * 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
  62551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62556. * @param name defines the name of the mesh
  62557. * @param options defines the options used to create the mesh
  62558. * @param scene defines the hosting scene
  62559. * @returns the extruded shape mesh
  62560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62562. */
  62563. static ExtrudeShape(name: string, options: {
  62564. shape: Vector3[];
  62565. path: Vector3[];
  62566. scale?: number;
  62567. rotation?: number;
  62568. cap?: number;
  62569. updatable?: boolean;
  62570. sideOrientation?: number;
  62571. frontUVs?: Vector4;
  62572. backUVs?: Vector4;
  62573. instance?: Mesh;
  62574. invertUV?: boolean;
  62575. }, scene?: Nullable<Scene>): Mesh;
  62576. /**
  62577. * Creates an custom extruded shape mesh.
  62578. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62579. * * 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.
  62580. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62581. * * 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
  62582. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62583. * * 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
  62584. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62585. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62586. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62587. * * 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
  62588. * * 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
  62589. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62592. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62594. * @param name defines the name of the mesh
  62595. * @param options defines the options used to create the mesh
  62596. * @param scene defines the hosting scene
  62597. * @returns the custom extruded shape mesh
  62598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62599. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62601. */
  62602. static ExtrudeShapeCustom(name: string, options: {
  62603. shape: Vector3[];
  62604. path: Vector3[];
  62605. scaleFunction?: any;
  62606. rotationFunction?: any;
  62607. ribbonCloseArray?: boolean;
  62608. ribbonClosePath?: boolean;
  62609. cap?: number;
  62610. updatable?: boolean;
  62611. sideOrientation?: number;
  62612. frontUVs?: Vector4;
  62613. backUVs?: Vector4;
  62614. instance?: Mesh;
  62615. invertUV?: boolean;
  62616. }, scene?: Nullable<Scene>): Mesh;
  62617. /**
  62618. * Creates lathe mesh.
  62619. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62620. * * 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
  62621. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62622. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62623. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62624. * * 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
  62625. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62626. * * 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
  62627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62631. * @param name defines the name of the mesh
  62632. * @param options defines the options used to create the mesh
  62633. * @param scene defines the hosting scene
  62634. * @returns the lathe mesh
  62635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62636. */
  62637. static CreateLathe(name: string, options: {
  62638. shape: Vector3[];
  62639. radius?: number;
  62640. tessellation?: number;
  62641. clip?: number;
  62642. arc?: number;
  62643. closed?: boolean;
  62644. updatable?: boolean;
  62645. sideOrientation?: number;
  62646. frontUVs?: Vector4;
  62647. backUVs?: Vector4;
  62648. cap?: number;
  62649. invertUV?: boolean;
  62650. }, scene?: Nullable<Scene>): Mesh;
  62651. /**
  62652. * Creates a tiled plane mesh
  62653. * * You can set a limited pattern arrangement with the tiles
  62654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62657. * @param name defines the name of the mesh
  62658. * @param options defines the options used to create the mesh
  62659. * @param scene defines the hosting scene
  62660. * @returns the plane mesh
  62661. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62662. */
  62663. static CreateTiledPlane(name: string, options: {
  62664. pattern?: number;
  62665. tileSize?: number;
  62666. tileWidth?: number;
  62667. tileHeight?: number;
  62668. size?: number;
  62669. width?: number;
  62670. height?: number;
  62671. alignHorizontal?: number;
  62672. alignVertical?: number;
  62673. sideOrientation?: number;
  62674. frontUVs?: Vector4;
  62675. backUVs?: Vector4;
  62676. updatable?: boolean;
  62677. }, scene?: Nullable<Scene>): Mesh;
  62678. /**
  62679. * Creates a plane mesh
  62680. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62681. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62682. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62686. * @param name defines the name of the mesh
  62687. * @param options defines the options used to create the mesh
  62688. * @param scene defines the hosting scene
  62689. * @returns the plane mesh
  62690. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62691. */
  62692. static CreatePlane(name: string, options: {
  62693. size?: number;
  62694. width?: number;
  62695. height?: number;
  62696. sideOrientation?: number;
  62697. frontUVs?: Vector4;
  62698. backUVs?: Vector4;
  62699. updatable?: boolean;
  62700. sourcePlane?: Plane;
  62701. }, scene?: Nullable<Scene>): Mesh;
  62702. /**
  62703. * Creates a ground mesh
  62704. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62705. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62707. * @param name defines the name of the mesh
  62708. * @param options defines the options used to create the mesh
  62709. * @param scene defines the hosting scene
  62710. * @returns the ground mesh
  62711. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62712. */
  62713. static CreateGround(name: string, options: {
  62714. width?: number;
  62715. height?: number;
  62716. subdivisions?: number;
  62717. subdivisionsX?: number;
  62718. subdivisionsY?: number;
  62719. updatable?: boolean;
  62720. }, scene?: Nullable<Scene>): Mesh;
  62721. /**
  62722. * Creates a tiled ground mesh
  62723. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62724. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62725. * * 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
  62726. * * 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
  62727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62728. * @param name defines the name of the mesh
  62729. * @param options defines the options used to create the mesh
  62730. * @param scene defines the hosting scene
  62731. * @returns the tiled ground mesh
  62732. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62733. */
  62734. static CreateTiledGround(name: string, options: {
  62735. xmin: number;
  62736. zmin: number;
  62737. xmax: number;
  62738. zmax: number;
  62739. subdivisions?: {
  62740. w: number;
  62741. h: number;
  62742. };
  62743. precision?: {
  62744. w: number;
  62745. h: number;
  62746. };
  62747. updatable?: boolean;
  62748. }, scene?: Nullable<Scene>): Mesh;
  62749. /**
  62750. * Creates a ground mesh from a height map
  62751. * * The parameter `url` sets the URL of the height map image resource.
  62752. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62753. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62754. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62755. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62756. * * 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.
  62757. * * 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).
  62758. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62760. * @param name defines the name of the mesh
  62761. * @param url defines the url to the height map
  62762. * @param options defines the options used to create the mesh
  62763. * @param scene defines the hosting scene
  62764. * @returns the ground mesh
  62765. * @see https://doc.babylonjs.com/babylon101/height_map
  62766. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62767. */
  62768. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62769. width?: number;
  62770. height?: number;
  62771. subdivisions?: number;
  62772. minHeight?: number;
  62773. maxHeight?: number;
  62774. colorFilter?: Color3;
  62775. alphaFilter?: number;
  62776. updatable?: boolean;
  62777. onReady?: (mesh: GroundMesh) => void;
  62778. }, scene?: Nullable<Scene>): GroundMesh;
  62779. /**
  62780. * Creates a polygon mesh
  62781. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62782. * * 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
  62783. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62786. * * Remember you can only change the shape positions, not their number when updating a polygon
  62787. * @param name defines the name of the mesh
  62788. * @param options defines the options used to create the mesh
  62789. * @param scene defines the hosting scene
  62790. * @param earcutInjection can be used to inject your own earcut reference
  62791. * @returns the polygon mesh
  62792. */
  62793. static CreatePolygon(name: string, options: {
  62794. shape: Vector3[];
  62795. holes?: Vector3[][];
  62796. depth?: number;
  62797. faceUV?: Vector4[];
  62798. faceColors?: Color4[];
  62799. updatable?: boolean;
  62800. sideOrientation?: number;
  62801. frontUVs?: Vector4;
  62802. backUVs?: Vector4;
  62803. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62804. /**
  62805. * Creates an extruded polygon mesh, with depth in the Y direction.
  62806. * * 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)
  62807. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62808. * @param name defines the name of the mesh
  62809. * @param options defines the options used to create the mesh
  62810. * @param scene defines the hosting scene
  62811. * @param earcutInjection can be used to inject your own earcut reference
  62812. * @returns the polygon mesh
  62813. */
  62814. static ExtrudePolygon(name: string, options: {
  62815. shape: Vector3[];
  62816. holes?: Vector3[][];
  62817. depth?: number;
  62818. faceUV?: Vector4[];
  62819. faceColors?: Color4[];
  62820. updatable?: boolean;
  62821. sideOrientation?: number;
  62822. frontUVs?: Vector4;
  62823. backUVs?: Vector4;
  62824. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62825. /**
  62826. * Creates a tube mesh.
  62827. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62828. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62829. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62830. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62831. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62832. * * 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)
  62833. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62834. * * 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
  62835. * * 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
  62836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62838. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62840. * @param name defines the name of the mesh
  62841. * @param options defines the options used to create the mesh
  62842. * @param scene defines the hosting scene
  62843. * @returns the tube mesh
  62844. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62845. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62846. */
  62847. static CreateTube(name: string, options: {
  62848. path: Vector3[];
  62849. radius?: number;
  62850. tessellation?: number;
  62851. radiusFunction?: {
  62852. (i: number, distance: number): number;
  62853. };
  62854. cap?: number;
  62855. arc?: number;
  62856. updatable?: boolean;
  62857. sideOrientation?: number;
  62858. frontUVs?: Vector4;
  62859. backUVs?: Vector4;
  62860. instance?: Mesh;
  62861. invertUV?: boolean;
  62862. }, scene?: Nullable<Scene>): Mesh;
  62863. /**
  62864. * Creates a polyhedron mesh
  62865. * * 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
  62866. * * The parameter `size` (positive float, default 1) sets the polygon size
  62867. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62868. * * 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`
  62869. * * 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
  62870. * * 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)`)
  62871. * * 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
  62872. * * 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
  62873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62876. * @param name defines the name of the mesh
  62877. * @param options defines the options used to create the mesh
  62878. * @param scene defines the hosting scene
  62879. * @returns the polyhedron mesh
  62880. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62881. */
  62882. static CreatePolyhedron(name: string, options: {
  62883. type?: number;
  62884. size?: number;
  62885. sizeX?: number;
  62886. sizeY?: number;
  62887. sizeZ?: number;
  62888. custom?: any;
  62889. faceUV?: Vector4[];
  62890. faceColors?: Color4[];
  62891. flat?: boolean;
  62892. updatable?: boolean;
  62893. sideOrientation?: number;
  62894. frontUVs?: Vector4;
  62895. backUVs?: Vector4;
  62896. }, scene?: Nullable<Scene>): Mesh;
  62897. /**
  62898. * Creates a decal mesh.
  62899. * 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
  62900. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62901. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62902. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62903. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62904. * @param name defines the name of the mesh
  62905. * @param sourceMesh defines the mesh where the decal must be applied
  62906. * @param options defines the options used to create the mesh
  62907. * @param scene defines the hosting scene
  62908. * @returns the decal mesh
  62909. * @see https://doc.babylonjs.com/how_to/decals
  62910. */
  62911. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62912. position?: Vector3;
  62913. normal?: Vector3;
  62914. size?: Vector3;
  62915. angle?: number;
  62916. }): Mesh;
  62917. }
  62918. }
  62919. declare module "babylonjs/Meshes/meshSimplification" {
  62920. import { Mesh } from "babylonjs/Meshes/mesh";
  62921. /**
  62922. * A simplifier interface for future simplification implementations
  62923. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62924. */
  62925. export interface ISimplifier {
  62926. /**
  62927. * Simplification of a given mesh according to the given settings.
  62928. * Since this requires computation, it is assumed that the function runs async.
  62929. * @param settings The settings of the simplification, including quality and distance
  62930. * @param successCallback A callback that will be called after the mesh was simplified.
  62931. * @param errorCallback in case of an error, this callback will be called. optional.
  62932. */
  62933. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62934. }
  62935. /**
  62936. * Expected simplification settings.
  62937. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62938. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62939. */
  62940. export interface ISimplificationSettings {
  62941. /**
  62942. * Gets or sets the expected quality
  62943. */
  62944. quality: number;
  62945. /**
  62946. * Gets or sets the distance when this optimized version should be used
  62947. */
  62948. distance: number;
  62949. /**
  62950. * Gets an already optimized mesh
  62951. */
  62952. optimizeMesh?: boolean;
  62953. }
  62954. /**
  62955. * Class used to specify simplification options
  62956. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62957. */
  62958. export class SimplificationSettings implements ISimplificationSettings {
  62959. /** expected quality */
  62960. quality: number;
  62961. /** distance when this optimized version should be used */
  62962. distance: number;
  62963. /** already optimized mesh */
  62964. optimizeMesh?: boolean | undefined;
  62965. /**
  62966. * Creates a SimplificationSettings
  62967. * @param quality expected quality
  62968. * @param distance distance when this optimized version should be used
  62969. * @param optimizeMesh already optimized mesh
  62970. */
  62971. constructor(
  62972. /** expected quality */
  62973. quality: number,
  62974. /** distance when this optimized version should be used */
  62975. distance: number,
  62976. /** already optimized mesh */
  62977. optimizeMesh?: boolean | undefined);
  62978. }
  62979. /**
  62980. * Interface used to define a simplification task
  62981. */
  62982. export interface ISimplificationTask {
  62983. /**
  62984. * Array of settings
  62985. */
  62986. settings: Array<ISimplificationSettings>;
  62987. /**
  62988. * Simplification type
  62989. */
  62990. simplificationType: SimplificationType;
  62991. /**
  62992. * Mesh to simplify
  62993. */
  62994. mesh: Mesh;
  62995. /**
  62996. * Callback called on success
  62997. */
  62998. successCallback?: () => void;
  62999. /**
  63000. * Defines if parallel processing can be used
  63001. */
  63002. parallelProcessing: boolean;
  63003. }
  63004. /**
  63005. * Queue used to order the simplification tasks
  63006. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63007. */
  63008. export class SimplificationQueue {
  63009. private _simplificationArray;
  63010. /**
  63011. * Gets a boolean indicating that the process is still running
  63012. */
  63013. running: boolean;
  63014. /**
  63015. * Creates a new queue
  63016. */
  63017. constructor();
  63018. /**
  63019. * Adds a new simplification task
  63020. * @param task defines a task to add
  63021. */
  63022. addTask(task: ISimplificationTask): void;
  63023. /**
  63024. * Execute next task
  63025. */
  63026. executeNext(): void;
  63027. /**
  63028. * Execute a simplification task
  63029. * @param task defines the task to run
  63030. */
  63031. runSimplification(task: ISimplificationTask): void;
  63032. private getSimplifier;
  63033. }
  63034. /**
  63035. * The implemented types of simplification
  63036. * At the moment only Quadratic Error Decimation is implemented
  63037. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63038. */
  63039. export enum SimplificationType {
  63040. /** Quadratic error decimation */
  63041. QUADRATIC = 0
  63042. }
  63043. }
  63044. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  63045. import { Scene } from "babylonjs/scene";
  63046. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  63047. import { ISceneComponent } from "babylonjs/sceneComponent";
  63048. module "babylonjs/scene" {
  63049. interface Scene {
  63050. /** @hidden (Backing field) */
  63051. _simplificationQueue: SimplificationQueue;
  63052. /**
  63053. * Gets or sets the simplification queue attached to the scene
  63054. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63055. */
  63056. simplificationQueue: SimplificationQueue;
  63057. }
  63058. }
  63059. module "babylonjs/Meshes/mesh" {
  63060. interface Mesh {
  63061. /**
  63062. * Simplify the mesh according to the given array of settings.
  63063. * Function will return immediately and will simplify async
  63064. * @param settings a collection of simplification settings
  63065. * @param parallelProcessing should all levels calculate parallel or one after the other
  63066. * @param simplificationType the type of simplification to run
  63067. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63068. * @returns the current mesh
  63069. */
  63070. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63071. }
  63072. }
  63073. /**
  63074. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63075. * created in a scene
  63076. */
  63077. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63078. /**
  63079. * The component name helpfull to identify the component in the list of scene components.
  63080. */
  63081. readonly name: string;
  63082. /**
  63083. * The scene the component belongs to.
  63084. */
  63085. scene: Scene;
  63086. /**
  63087. * Creates a new instance of the component for the given scene
  63088. * @param scene Defines the scene to register the component in
  63089. */
  63090. constructor(scene: Scene);
  63091. /**
  63092. * Registers the component in a given scene
  63093. */
  63094. register(): void;
  63095. /**
  63096. * Rebuilds the elements related to this component in case of
  63097. * context lost for instance.
  63098. */
  63099. rebuild(): void;
  63100. /**
  63101. * Disposes the component and the associated ressources
  63102. */
  63103. dispose(): void;
  63104. private _beforeCameraUpdate;
  63105. }
  63106. }
  63107. declare module "babylonjs/Meshes/Builders/index" {
  63108. export * from "babylonjs/Meshes/Builders/boxBuilder";
  63109. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  63110. export * from "babylonjs/Meshes/Builders/discBuilder";
  63111. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  63112. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  63113. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  63114. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  63115. export * from "babylonjs/Meshes/Builders/torusBuilder";
  63116. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  63117. export * from "babylonjs/Meshes/Builders/linesBuilder";
  63118. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  63119. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  63120. export * from "babylonjs/Meshes/Builders/latheBuilder";
  63121. export * from "babylonjs/Meshes/Builders/planeBuilder";
  63122. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  63123. export * from "babylonjs/Meshes/Builders/groundBuilder";
  63124. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  63125. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  63126. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  63127. export * from "babylonjs/Meshes/Builders/decalBuilder";
  63128. }
  63129. declare module "babylonjs/Meshes/index" {
  63130. export * from "babylonjs/Meshes/abstractMesh";
  63131. export * from "babylonjs/Meshes/buffer";
  63132. export * from "babylonjs/Meshes/Compression/index";
  63133. export * from "babylonjs/Meshes/csg";
  63134. export * from "babylonjs/Meshes/geometry";
  63135. export * from "babylonjs/Meshes/groundMesh";
  63136. export * from "babylonjs/Meshes/trailMesh";
  63137. export * from "babylonjs/Meshes/instancedMesh";
  63138. export * from "babylonjs/Meshes/linesMesh";
  63139. export * from "babylonjs/Meshes/mesh";
  63140. export * from "babylonjs/Meshes/mesh.vertexData";
  63141. export * from "babylonjs/Meshes/meshBuilder";
  63142. export * from "babylonjs/Meshes/meshSimplification";
  63143. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  63144. export * from "babylonjs/Meshes/polygonMesh";
  63145. export * from "babylonjs/Meshes/subMesh";
  63146. export * from "babylonjs/Meshes/meshLODLevel";
  63147. export * from "babylonjs/Meshes/transformNode";
  63148. export * from "babylonjs/Meshes/Builders/index";
  63149. export * from "babylonjs/Meshes/dataBuffer";
  63150. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  63151. }
  63152. declare module "babylonjs/Morph/index" {
  63153. export * from "babylonjs/Morph/morphTarget";
  63154. export * from "babylonjs/Morph/morphTargetManager";
  63155. }
  63156. declare module "babylonjs/Navigation/INavigationEngine" {
  63157. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63158. import { Vector3 } from "babylonjs/Maths/math";
  63159. import { Mesh } from "babylonjs/Meshes/mesh";
  63160. import { Scene } from "babylonjs/scene";
  63161. /**
  63162. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63163. */
  63164. export interface INavigationEnginePlugin {
  63165. /**
  63166. * plugin name
  63167. */
  63168. name: string;
  63169. /**
  63170. * Creates a navigation mesh
  63171. * @param meshes array of all the geometry used to compute the navigatio mesh
  63172. * @param parameters bunch of parameters used to filter geometry
  63173. */
  63174. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63175. /**
  63176. * Create a navigation mesh debug mesh
  63177. * @param scene is where the mesh will be added
  63178. * @returns debug display mesh
  63179. */
  63180. createDebugNavMesh(scene: Scene): Mesh;
  63181. /**
  63182. * Get a navigation mesh constrained position, closest to the parameter position
  63183. * @param position world position
  63184. * @returns the closest point to position constrained by the navigation mesh
  63185. */
  63186. getClosestPoint(position: Vector3): Vector3;
  63187. /**
  63188. * Get a navigation mesh constrained position, within a particular radius
  63189. * @param position world position
  63190. * @param maxRadius the maximum distance to the constrained world position
  63191. * @returns the closest point to position constrained by the navigation mesh
  63192. */
  63193. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63194. /**
  63195. * Compute the final position from a segment made of destination-position
  63196. * @param position world position
  63197. * @param destination world position
  63198. * @returns the resulting point along the navmesh
  63199. */
  63200. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63201. /**
  63202. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63203. * @param start world position
  63204. * @param end world position
  63205. * @returns array containing world position composing the path
  63206. */
  63207. computePath(start: Vector3, end: Vector3): Vector3[];
  63208. /**
  63209. * If this plugin is supported
  63210. * @returns true if plugin is supported
  63211. */
  63212. isSupported(): boolean;
  63213. /**
  63214. * Create a new Crowd so you can add agents
  63215. * @param maxAgents the maximum agent count in the crowd
  63216. * @param maxAgentRadius the maximum radius an agent can have
  63217. * @param scene to attach the crowd to
  63218. * @returns the crowd you can add agents to
  63219. */
  63220. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63221. /**
  63222. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63223. * The queries will try to find a solution within those bounds
  63224. * default is (1,1,1)
  63225. * @param extent x,y,z value that define the extent around the queries point of reference
  63226. */
  63227. setDefaultQueryExtent(extent: Vector3): void;
  63228. /**
  63229. * Get the Bounding box extent specified by setDefaultQueryExtent
  63230. * @returns the box extent values
  63231. */
  63232. getDefaultQueryExtent(): Vector3;
  63233. /**
  63234. * Release all resources
  63235. */
  63236. dispose(): void;
  63237. }
  63238. /**
  63239. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  63240. */
  63241. export interface ICrowd {
  63242. /**
  63243. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63244. * You can attach anything to that node. The node position is updated in the scene update tick.
  63245. * @param pos world position that will be constrained by the navigation mesh
  63246. * @param parameters agent parameters
  63247. * @param transform hooked to the agent that will be update by the scene
  63248. * @returns agent index
  63249. */
  63250. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63251. /**
  63252. * Returns the agent position in world space
  63253. * @param index agent index returned by addAgent
  63254. * @returns world space position
  63255. */
  63256. getAgentPosition(index: number): Vector3;
  63257. /**
  63258. * Gets the agent velocity in world space
  63259. * @param index agent index returned by addAgent
  63260. * @returns world space velocity
  63261. */
  63262. getAgentVelocity(index: number): Vector3;
  63263. /**
  63264. * remove a particular agent previously created
  63265. * @param index agent index returned by addAgent
  63266. */
  63267. removeAgent(index: number): void;
  63268. /**
  63269. * get the list of all agents attached to this crowd
  63270. * @returns list of agent indices
  63271. */
  63272. getAgents(): number[];
  63273. /**
  63274. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63275. * @param deltaTime in seconds
  63276. */
  63277. update(deltaTime: number): void;
  63278. /**
  63279. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63280. * @param index agent index returned by addAgent
  63281. * @param destination targeted world position
  63282. */
  63283. agentGoto(index: number, destination: Vector3): void;
  63284. /**
  63285. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63286. * The queries will try to find a solution within those bounds
  63287. * default is (1,1,1)
  63288. * @param extent x,y,z value that define the extent around the queries point of reference
  63289. */
  63290. setDefaultQueryExtent(extent: Vector3): void;
  63291. /**
  63292. * Get the Bounding box extent specified by setDefaultQueryExtent
  63293. * @returns the box extent values
  63294. */
  63295. getDefaultQueryExtent(): Vector3;
  63296. /**
  63297. * Release all resources
  63298. */
  63299. dispose(): void;
  63300. }
  63301. /**
  63302. * Configures an agent
  63303. */
  63304. export interface IAgentParameters {
  63305. /**
  63306. * Agent radius. [Limit: >= 0]
  63307. */
  63308. radius: number;
  63309. /**
  63310. * Agent height. [Limit: > 0]
  63311. */
  63312. height: number;
  63313. /**
  63314. * Maximum allowed acceleration. [Limit: >= 0]
  63315. */
  63316. maxAcceleration: number;
  63317. /**
  63318. * Maximum allowed speed. [Limit: >= 0]
  63319. */
  63320. maxSpeed: number;
  63321. /**
  63322. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  63323. */
  63324. collisionQueryRange: number;
  63325. /**
  63326. * The path visibility optimization range. [Limit: > 0]
  63327. */
  63328. pathOptimizationRange: number;
  63329. /**
  63330. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  63331. */
  63332. separationWeight: number;
  63333. }
  63334. /**
  63335. * Configures the navigation mesh creation
  63336. */
  63337. export interface INavMeshParameters {
  63338. /**
  63339. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  63340. */
  63341. cs: number;
  63342. /**
  63343. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  63344. */
  63345. ch: number;
  63346. /**
  63347. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  63348. */
  63349. walkableSlopeAngle: number;
  63350. /**
  63351. * Minimum floor to 'ceiling' height that will still allow the floor area to
  63352. * be considered walkable. [Limit: >= 3] [Units: vx]
  63353. */
  63354. walkableHeight: number;
  63355. /**
  63356. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  63357. */
  63358. walkableClimb: number;
  63359. /**
  63360. * The distance to erode/shrink the walkable area of the heightfield away from
  63361. * obstructions. [Limit: >=0] [Units: vx]
  63362. */
  63363. walkableRadius: number;
  63364. /**
  63365. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  63366. */
  63367. maxEdgeLen: number;
  63368. /**
  63369. * The maximum distance a simplfied contour's border edges should deviate
  63370. * the original raw contour. [Limit: >=0] [Units: vx]
  63371. */
  63372. maxSimplificationError: number;
  63373. /**
  63374. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  63375. */
  63376. minRegionArea: number;
  63377. /**
  63378. * Any regions with a span count smaller than this value will, if possible,
  63379. * be merged with larger regions. [Limit: >=0] [Units: vx]
  63380. */
  63381. mergeRegionArea: number;
  63382. /**
  63383. * The maximum number of vertices allowed for polygons generated during the
  63384. * contour to polygon conversion process. [Limit: >= 3]
  63385. */
  63386. maxVertsPerPoly: number;
  63387. /**
  63388. * Sets the sampling distance to use when generating the detail mesh.
  63389. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  63390. */
  63391. detailSampleDist: number;
  63392. /**
  63393. * The maximum distance the detail mesh surface should deviate from heightfield
  63394. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  63395. */
  63396. detailSampleMaxError: number;
  63397. }
  63398. }
  63399. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  63400. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  63401. import { Mesh } from "babylonjs/Meshes/mesh";
  63402. import { Scene } from "babylonjs/scene";
  63403. import { Vector3 } from "babylonjs/Maths/math";
  63404. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63405. /**
  63406. * RecastJS navigation plugin
  63407. */
  63408. export class RecastJSPlugin implements INavigationEnginePlugin {
  63409. /**
  63410. * Reference to the Recast library
  63411. */
  63412. bjsRECAST: any;
  63413. /**
  63414. * plugin name
  63415. */
  63416. name: string;
  63417. /**
  63418. * the first navmesh created. We might extend this to support multiple navmeshes
  63419. */
  63420. navMesh: any;
  63421. /**
  63422. * Initializes the recastJS plugin
  63423. * @param recastInjection can be used to inject your own recast reference
  63424. */
  63425. constructor(recastInjection?: any);
  63426. /**
  63427. * Creates a navigation mesh
  63428. * @param meshes array of all the geometry used to compute the navigatio mesh
  63429. * @param parameters bunch of parameters used to filter geometry
  63430. */
  63431. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63432. /**
  63433. * Create a navigation mesh debug mesh
  63434. * @param scene is where the mesh will be added
  63435. * @returns debug display mesh
  63436. */
  63437. createDebugNavMesh(scene: Scene): Mesh;
  63438. /**
  63439. * Get a navigation mesh constrained position, closest to the parameter position
  63440. * @param position world position
  63441. * @returns the closest point to position constrained by the navigation mesh
  63442. */
  63443. getClosestPoint(position: Vector3): Vector3;
  63444. /**
  63445. * Get a navigation mesh constrained position, within a particular radius
  63446. * @param position world position
  63447. * @param maxRadius the maximum distance to the constrained world position
  63448. * @returns the closest point to position constrained by the navigation mesh
  63449. */
  63450. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63451. /**
  63452. * Compute the final position from a segment made of destination-position
  63453. * @param position world position
  63454. * @param destination world position
  63455. * @returns the resulting point along the navmesh
  63456. */
  63457. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63458. /**
  63459. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63460. * @param start world position
  63461. * @param end world position
  63462. * @returns array containing world position composing the path
  63463. */
  63464. computePath(start: Vector3, end: Vector3): Vector3[];
  63465. /**
  63466. * Create a new Crowd so you can add agents
  63467. * @param maxAgents the maximum agent count in the crowd
  63468. * @param maxAgentRadius the maximum radius an agent can have
  63469. * @param scene to attach the crowd to
  63470. * @returns the crowd you can add agents to
  63471. */
  63472. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63473. /**
  63474. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63475. * The queries will try to find a solution within those bounds
  63476. * default is (1,1,1)
  63477. * @param extent x,y,z value that define the extent around the queries point of reference
  63478. */
  63479. setDefaultQueryExtent(extent: Vector3): void;
  63480. /**
  63481. * Get the Bounding box extent specified by setDefaultQueryExtent
  63482. * @returns the box extent values
  63483. */
  63484. getDefaultQueryExtent(): Vector3;
  63485. /**
  63486. * Disposes
  63487. */
  63488. dispose(): void;
  63489. /**
  63490. * If this plugin is supported
  63491. * @returns true if plugin is supported
  63492. */
  63493. isSupported(): boolean;
  63494. }
  63495. /**
  63496. * Recast detour crowd implementation
  63497. */
  63498. export class RecastJSCrowd implements ICrowd {
  63499. /**
  63500. * Recast/detour plugin
  63501. */
  63502. bjsRECASTPlugin: RecastJSPlugin;
  63503. /**
  63504. * Link to the detour crowd
  63505. */
  63506. recastCrowd: any;
  63507. /**
  63508. * One transform per agent
  63509. */
  63510. transforms: TransformNode[];
  63511. /**
  63512. * All agents created
  63513. */
  63514. agents: number[];
  63515. /**
  63516. * Link to the scene is kept to unregister the crowd from the scene
  63517. */
  63518. private _scene;
  63519. /**
  63520. * Observer for crowd updates
  63521. */
  63522. private _onBeforeAnimationsObserver;
  63523. /**
  63524. * Constructor
  63525. * @param plugin recastJS plugin
  63526. * @param maxAgents the maximum agent count in the crowd
  63527. * @param maxAgentRadius the maximum radius an agent can have
  63528. * @param scene to attach the crowd to
  63529. * @returns the crowd you can add agents to
  63530. */
  63531. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63532. /**
  63533. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63534. * You can attach anything to that node. The node position is updated in the scene update tick.
  63535. * @param pos world position that will be constrained by the navigation mesh
  63536. * @param parameters agent parameters
  63537. * @param transform hooked to the agent that will be update by the scene
  63538. * @returns agent index
  63539. */
  63540. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63541. /**
  63542. * Returns the agent position in world space
  63543. * @param index agent index returned by addAgent
  63544. * @returns world space position
  63545. */
  63546. getAgentPosition(index: number): Vector3;
  63547. /**
  63548. * Returns the agent velocity in world space
  63549. * @param index agent index returned by addAgent
  63550. * @returns world space velocity
  63551. */
  63552. getAgentVelocity(index: number): Vector3;
  63553. /**
  63554. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63555. * @param index agent index returned by addAgent
  63556. * @param destination targeted world position
  63557. */
  63558. agentGoto(index: number, destination: Vector3): void;
  63559. /**
  63560. * remove a particular agent previously created
  63561. * @param index agent index returned by addAgent
  63562. */
  63563. removeAgent(index: number): void;
  63564. /**
  63565. * get the list of all agents attached to this crowd
  63566. * @returns list of agent indices
  63567. */
  63568. getAgents(): number[];
  63569. /**
  63570. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63571. * @param deltaTime in seconds
  63572. */
  63573. update(deltaTime: number): void;
  63574. /**
  63575. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63576. * The queries will try to find a solution within those bounds
  63577. * default is (1,1,1)
  63578. * @param extent x,y,z value that define the extent around the queries point of reference
  63579. */
  63580. setDefaultQueryExtent(extent: Vector3): void;
  63581. /**
  63582. * Get the Bounding box extent specified by setDefaultQueryExtent
  63583. * @returns the box extent values
  63584. */
  63585. getDefaultQueryExtent(): Vector3;
  63586. /**
  63587. * Release all resources
  63588. */
  63589. dispose(): void;
  63590. }
  63591. }
  63592. declare module "babylonjs/Navigation/Plugins/index" {
  63593. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  63594. }
  63595. declare module "babylonjs/Navigation/index" {
  63596. export * from "babylonjs/Navigation/INavigationEngine";
  63597. export * from "babylonjs/Navigation/Plugins/index";
  63598. }
  63599. declare module "babylonjs/Offline/database" {
  63600. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  63601. /**
  63602. * Class used to enable access to IndexedDB
  63603. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63604. */
  63605. export class Database implements IOfflineProvider {
  63606. private _callbackManifestChecked;
  63607. private _currentSceneUrl;
  63608. private _db;
  63609. private _enableSceneOffline;
  63610. private _enableTexturesOffline;
  63611. private _manifestVersionFound;
  63612. private _mustUpdateRessources;
  63613. private _hasReachedQuota;
  63614. private _isSupported;
  63615. private _idbFactory;
  63616. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63617. private static IsUASupportingBlobStorage;
  63618. /**
  63619. * Gets a boolean indicating if Database storate is enabled (off by default)
  63620. */
  63621. static IDBStorageEnabled: boolean;
  63622. /**
  63623. * Gets a boolean indicating if scene must be saved in the database
  63624. */
  63625. get enableSceneOffline(): boolean;
  63626. /**
  63627. * Gets a boolean indicating if textures must be saved in the database
  63628. */
  63629. get enableTexturesOffline(): boolean;
  63630. /**
  63631. * Creates a new Database
  63632. * @param urlToScene defines the url to load the scene
  63633. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63634. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63635. */
  63636. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63637. private static _ParseURL;
  63638. private static _ReturnFullUrlLocation;
  63639. private _checkManifestFile;
  63640. /**
  63641. * Open the database and make it available
  63642. * @param successCallback defines the callback to call on success
  63643. * @param errorCallback defines the callback to call on error
  63644. */
  63645. open(successCallback: () => void, errorCallback: () => void): void;
  63646. /**
  63647. * Loads an image from the database
  63648. * @param url defines the url to load from
  63649. * @param image defines the target DOM image
  63650. */
  63651. loadImage(url: string, image: HTMLImageElement): void;
  63652. private _loadImageFromDBAsync;
  63653. private _saveImageIntoDBAsync;
  63654. private _checkVersionFromDB;
  63655. private _loadVersionFromDBAsync;
  63656. private _saveVersionIntoDBAsync;
  63657. /**
  63658. * Loads a file from database
  63659. * @param url defines the URL to load from
  63660. * @param sceneLoaded defines a callback to call on success
  63661. * @param progressCallBack defines a callback to call when progress changed
  63662. * @param errorCallback defines a callback to call on error
  63663. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63664. */
  63665. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63666. private _loadFileAsync;
  63667. private _saveFileAsync;
  63668. /**
  63669. * Validates if xhr data is correct
  63670. * @param xhr defines the request to validate
  63671. * @param dataType defines the expected data type
  63672. * @returns true if data is correct
  63673. */
  63674. private static _ValidateXHRData;
  63675. }
  63676. }
  63677. declare module "babylonjs/Offline/index" {
  63678. export * from "babylonjs/Offline/database";
  63679. export * from "babylonjs/Offline/IOfflineProvider";
  63680. }
  63681. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  63682. /** @hidden */
  63683. export var gpuUpdateParticlesPixelShader: {
  63684. name: string;
  63685. shader: string;
  63686. };
  63687. }
  63688. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  63689. /** @hidden */
  63690. export var gpuUpdateParticlesVertexShader: {
  63691. name: string;
  63692. shader: string;
  63693. };
  63694. }
  63695. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  63696. /** @hidden */
  63697. export var clipPlaneFragmentDeclaration2: {
  63698. name: string;
  63699. shader: string;
  63700. };
  63701. }
  63702. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  63703. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  63704. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63705. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63706. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63707. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63708. /** @hidden */
  63709. export var gpuRenderParticlesPixelShader: {
  63710. name: string;
  63711. shader: string;
  63712. };
  63713. }
  63714. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  63715. /** @hidden */
  63716. export var clipPlaneVertexDeclaration2: {
  63717. name: string;
  63718. shader: string;
  63719. };
  63720. }
  63721. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  63722. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  63723. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63724. /** @hidden */
  63725. export var gpuRenderParticlesVertexShader: {
  63726. name: string;
  63727. shader: string;
  63728. };
  63729. }
  63730. declare module "babylonjs/Particles/gpuParticleSystem" {
  63731. import { Nullable } from "babylonjs/types";
  63732. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  63733. import { Observable } from "babylonjs/Misc/observable";
  63734. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63735. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63736. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  63737. import { Scene, IDisposable } from "babylonjs/scene";
  63738. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  63739. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63740. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  63741. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  63742. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  63743. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  63744. /**
  63745. * This represents a GPU particle system in Babylon
  63746. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63747. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63748. */
  63749. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63750. /**
  63751. * The layer mask we are rendering the particles through.
  63752. */
  63753. layerMask: number;
  63754. private _capacity;
  63755. private _activeCount;
  63756. private _currentActiveCount;
  63757. private _accumulatedCount;
  63758. private _renderEffect;
  63759. private _updateEffect;
  63760. private _buffer0;
  63761. private _buffer1;
  63762. private _spriteBuffer;
  63763. private _updateVAO;
  63764. private _renderVAO;
  63765. private _targetIndex;
  63766. private _sourceBuffer;
  63767. private _targetBuffer;
  63768. private _engine;
  63769. private _currentRenderId;
  63770. private _started;
  63771. private _stopped;
  63772. private _timeDelta;
  63773. private _randomTexture;
  63774. private _randomTexture2;
  63775. private _attributesStrideSize;
  63776. private _updateEffectOptions;
  63777. private _randomTextureSize;
  63778. private _actualFrame;
  63779. private readonly _rawTextureWidth;
  63780. /**
  63781. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63782. */
  63783. static get IsSupported(): boolean;
  63784. /**
  63785. * An event triggered when the system is disposed.
  63786. */
  63787. onDisposeObservable: Observable<GPUParticleSystem>;
  63788. /**
  63789. * Gets the maximum number of particles active at the same time.
  63790. * @returns The max number of active particles.
  63791. */
  63792. getCapacity(): number;
  63793. /**
  63794. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63795. * to override the particles.
  63796. */
  63797. forceDepthWrite: boolean;
  63798. /**
  63799. * Gets or set the number of active particles
  63800. */
  63801. get activeParticleCount(): number;
  63802. set activeParticleCount(value: number);
  63803. private _preWarmDone;
  63804. /**
  63805. * Is this system ready to be used/rendered
  63806. * @return true if the system is ready
  63807. */
  63808. isReady(): boolean;
  63809. /**
  63810. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63811. * @returns True if it has been started, otherwise false.
  63812. */
  63813. isStarted(): boolean;
  63814. /**
  63815. * Starts the particle system and begins to emit
  63816. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63817. */
  63818. start(delay?: number): void;
  63819. /**
  63820. * Stops the particle system.
  63821. */
  63822. stop(): void;
  63823. /**
  63824. * Remove all active particles
  63825. */
  63826. reset(): void;
  63827. /**
  63828. * Returns the string "GPUParticleSystem"
  63829. * @returns a string containing the class name
  63830. */
  63831. getClassName(): string;
  63832. private _colorGradientsTexture;
  63833. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63834. /**
  63835. * Adds a new color gradient
  63836. * @param gradient defines the gradient to use (between 0 and 1)
  63837. * @param color1 defines the color to affect to the specified gradient
  63838. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63839. * @returns the current particle system
  63840. */
  63841. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63842. /**
  63843. * Remove a specific color gradient
  63844. * @param gradient defines the gradient to remove
  63845. * @returns the current particle system
  63846. */
  63847. removeColorGradient(gradient: number): GPUParticleSystem;
  63848. private _angularSpeedGradientsTexture;
  63849. private _sizeGradientsTexture;
  63850. private _velocityGradientsTexture;
  63851. private _limitVelocityGradientsTexture;
  63852. private _dragGradientsTexture;
  63853. private _addFactorGradient;
  63854. /**
  63855. * Adds a new size gradient
  63856. * @param gradient defines the gradient to use (between 0 and 1)
  63857. * @param factor defines the size factor to affect to the specified gradient
  63858. * @returns the current particle system
  63859. */
  63860. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63861. /**
  63862. * Remove a specific size gradient
  63863. * @param gradient defines the gradient to remove
  63864. * @returns the current particle system
  63865. */
  63866. removeSizeGradient(gradient: number): GPUParticleSystem;
  63867. /**
  63868. * Adds a new angular speed gradient
  63869. * @param gradient defines the gradient to use (between 0 and 1)
  63870. * @param factor defines the angular speed to affect to the specified gradient
  63871. * @returns the current particle system
  63872. */
  63873. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63874. /**
  63875. * Remove a specific angular speed gradient
  63876. * @param gradient defines the gradient to remove
  63877. * @returns the current particle system
  63878. */
  63879. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63880. /**
  63881. * Adds a new velocity gradient
  63882. * @param gradient defines the gradient to use (between 0 and 1)
  63883. * @param factor defines the velocity to affect to the specified gradient
  63884. * @returns the current particle system
  63885. */
  63886. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63887. /**
  63888. * Remove a specific velocity gradient
  63889. * @param gradient defines the gradient to remove
  63890. * @returns the current particle system
  63891. */
  63892. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63893. /**
  63894. * Adds a new limit velocity gradient
  63895. * @param gradient defines the gradient to use (between 0 and 1)
  63896. * @param factor defines the limit velocity value to affect to the specified gradient
  63897. * @returns the current particle system
  63898. */
  63899. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63900. /**
  63901. * Remove a specific limit velocity gradient
  63902. * @param gradient defines the gradient to remove
  63903. * @returns the current particle system
  63904. */
  63905. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63906. /**
  63907. * Adds a new drag gradient
  63908. * @param gradient defines the gradient to use (between 0 and 1)
  63909. * @param factor defines the drag value to affect to the specified gradient
  63910. * @returns the current particle system
  63911. */
  63912. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63913. /**
  63914. * Remove a specific drag gradient
  63915. * @param gradient defines the gradient to remove
  63916. * @returns the current particle system
  63917. */
  63918. removeDragGradient(gradient: number): GPUParticleSystem;
  63919. /**
  63920. * Not supported by GPUParticleSystem
  63921. * @param gradient defines the gradient to use (between 0 and 1)
  63922. * @param factor defines the emit rate value to affect to the specified gradient
  63923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63924. * @returns the current particle system
  63925. */
  63926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63927. /**
  63928. * Not supported by GPUParticleSystem
  63929. * @param gradient defines the gradient to remove
  63930. * @returns the current particle system
  63931. */
  63932. removeEmitRateGradient(gradient: number): IParticleSystem;
  63933. /**
  63934. * Not supported by GPUParticleSystem
  63935. * @param gradient defines the gradient to use (between 0 and 1)
  63936. * @param factor defines the start size value to affect to the specified gradient
  63937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63938. * @returns the current particle system
  63939. */
  63940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63941. /**
  63942. * Not supported by GPUParticleSystem
  63943. * @param gradient defines the gradient to remove
  63944. * @returns the current particle system
  63945. */
  63946. removeStartSizeGradient(gradient: number): IParticleSystem;
  63947. /**
  63948. * Not supported by GPUParticleSystem
  63949. * @param gradient defines the gradient to use (between 0 and 1)
  63950. * @param min defines the color remap minimal range
  63951. * @param max defines the color remap maximal range
  63952. * @returns the current particle system
  63953. */
  63954. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63955. /**
  63956. * Not supported by GPUParticleSystem
  63957. * @param gradient defines the gradient to remove
  63958. * @returns the current particle system
  63959. */
  63960. removeColorRemapGradient(): IParticleSystem;
  63961. /**
  63962. * Not supported by GPUParticleSystem
  63963. * @param gradient defines the gradient to use (between 0 and 1)
  63964. * @param min defines the alpha remap minimal range
  63965. * @param max defines the alpha remap maximal range
  63966. * @returns the current particle system
  63967. */
  63968. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63969. /**
  63970. * Not supported by GPUParticleSystem
  63971. * @param gradient defines the gradient to remove
  63972. * @returns the current particle system
  63973. */
  63974. removeAlphaRemapGradient(): IParticleSystem;
  63975. /**
  63976. * Not supported by GPUParticleSystem
  63977. * @param gradient defines the gradient to use (between 0 and 1)
  63978. * @param color defines the color to affect to the specified gradient
  63979. * @returns the current particle system
  63980. */
  63981. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63982. /**
  63983. * Not supported by GPUParticleSystem
  63984. * @param gradient defines the gradient to remove
  63985. * @returns the current particle system
  63986. */
  63987. removeRampGradient(): IParticleSystem;
  63988. /**
  63989. * Not supported by GPUParticleSystem
  63990. * @returns the list of ramp gradients
  63991. */
  63992. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63993. /**
  63994. * Not supported by GPUParticleSystem
  63995. * Gets or sets a boolean indicating that ramp gradients must be used
  63996. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63997. */
  63998. get useRampGradients(): boolean;
  63999. set useRampGradients(value: boolean);
  64000. /**
  64001. * Not supported by GPUParticleSystem
  64002. * @param gradient defines the gradient to use (between 0 and 1)
  64003. * @param factor defines the life time factor to affect to the specified gradient
  64004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64005. * @returns the current particle system
  64006. */
  64007. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64008. /**
  64009. * Not supported by GPUParticleSystem
  64010. * @param gradient defines the gradient to remove
  64011. * @returns the current particle system
  64012. */
  64013. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64014. /**
  64015. * Instantiates a GPU particle system.
  64016. * 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.
  64017. * @param name The name of the particle system
  64018. * @param options The options used to create the system
  64019. * @param scene The scene the particle system belongs to
  64020. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64021. */
  64022. constructor(name: string, options: Partial<{
  64023. capacity: number;
  64024. randomTextureSize: number;
  64025. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64026. protected _reset(): void;
  64027. private _createUpdateVAO;
  64028. private _createRenderVAO;
  64029. private _initialize;
  64030. /** @hidden */
  64031. _recreateUpdateEffect(): void;
  64032. /** @hidden */
  64033. _recreateRenderEffect(): void;
  64034. /**
  64035. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64036. * @param preWarm defines if we are in the pre-warmimg phase
  64037. */
  64038. animate(preWarm?: boolean): void;
  64039. private _createFactorGradientTexture;
  64040. private _createSizeGradientTexture;
  64041. private _createAngularSpeedGradientTexture;
  64042. private _createVelocityGradientTexture;
  64043. private _createLimitVelocityGradientTexture;
  64044. private _createDragGradientTexture;
  64045. private _createColorGradientTexture;
  64046. /**
  64047. * Renders the particle system in its current state
  64048. * @param preWarm defines if the system should only update the particles but not render them
  64049. * @returns the current number of particles
  64050. */
  64051. render(preWarm?: boolean): number;
  64052. /**
  64053. * Rebuilds the particle system
  64054. */
  64055. rebuild(): void;
  64056. private _releaseBuffers;
  64057. private _releaseVAOs;
  64058. /**
  64059. * Disposes the particle system and free the associated resources
  64060. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64061. */
  64062. dispose(disposeTexture?: boolean): void;
  64063. /**
  64064. * Clones the particle system.
  64065. * @param name The name of the cloned object
  64066. * @param newEmitter The new emitter to use
  64067. * @returns the cloned particle system
  64068. */
  64069. clone(name: string, newEmitter: any): GPUParticleSystem;
  64070. /**
  64071. * Serializes the particle system to a JSON object.
  64072. * @returns the JSON object
  64073. */
  64074. serialize(): any;
  64075. /**
  64076. * Parses a JSON object to create a GPU particle system.
  64077. * @param parsedParticleSystem The JSON object to parse
  64078. * @param scene The scene to create the particle system in
  64079. * @param rootUrl The root url to use to load external dependencies like texture
  64080. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64081. * @returns the parsed GPU particle system
  64082. */
  64083. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64084. }
  64085. }
  64086. declare module "babylonjs/Particles/particleSystemSet" {
  64087. import { Nullable } from "babylonjs/types";
  64088. import { Color3 } from "babylonjs/Maths/math.color";
  64089. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64091. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64092. import { Scene, IDisposable } from "babylonjs/scene";
  64093. /**
  64094. * Represents a set of particle systems working together to create a specific effect
  64095. */
  64096. export class ParticleSystemSet implements IDisposable {
  64097. /**
  64098. * Gets or sets base Assets URL
  64099. */
  64100. static BaseAssetsUrl: string;
  64101. private _emitterCreationOptions;
  64102. private _emitterNode;
  64103. /**
  64104. * Gets the particle system list
  64105. */
  64106. systems: IParticleSystem[];
  64107. /**
  64108. * Gets the emitter node used with this set
  64109. */
  64110. get emitterNode(): Nullable<TransformNode>;
  64111. /**
  64112. * Creates a new emitter mesh as a sphere
  64113. * @param options defines the options used to create the sphere
  64114. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64115. * @param scene defines the hosting scene
  64116. */
  64117. setEmitterAsSphere(options: {
  64118. diameter: number;
  64119. segments: number;
  64120. color: Color3;
  64121. }, renderingGroupId: number, scene: Scene): void;
  64122. /**
  64123. * Starts all particle systems of the set
  64124. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64125. */
  64126. start(emitter?: AbstractMesh): void;
  64127. /**
  64128. * Release all associated resources
  64129. */
  64130. dispose(): void;
  64131. /**
  64132. * Serialize the set into a JSON compatible object
  64133. * @returns a JSON compatible representation of the set
  64134. */
  64135. serialize(): any;
  64136. /**
  64137. * Parse a new ParticleSystemSet from a serialized source
  64138. * @param data defines a JSON compatible representation of the set
  64139. * @param scene defines the hosting scene
  64140. * @param gpu defines if we want GPU particles or CPU particles
  64141. * @returns a new ParticleSystemSet
  64142. */
  64143. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64144. }
  64145. }
  64146. declare module "babylonjs/Particles/particleHelper" {
  64147. import { Nullable } from "babylonjs/types";
  64148. import { Scene } from "babylonjs/scene";
  64149. import { Vector3 } from "babylonjs/Maths/math.vector";
  64150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64151. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64152. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  64153. /**
  64154. * This class is made for on one-liner static method to help creating particle system set.
  64155. */
  64156. export class ParticleHelper {
  64157. /**
  64158. * Gets or sets base Assets URL
  64159. */
  64160. static BaseAssetsUrl: string;
  64161. /**
  64162. * Create a default particle system that you can tweak
  64163. * @param emitter defines the emitter to use
  64164. * @param capacity defines the system capacity (default is 500 particles)
  64165. * @param scene defines the hosting scene
  64166. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64167. * @returns the new Particle system
  64168. */
  64169. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64170. /**
  64171. * This is the main static method (one-liner) of this helper to create different particle systems
  64172. * @param type This string represents the type to the particle system to create
  64173. * @param scene The scene where the particle system should live
  64174. * @param gpu If the system will use gpu
  64175. * @returns the ParticleSystemSet created
  64176. */
  64177. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64178. /**
  64179. * Static function used to export a particle system to a ParticleSystemSet variable.
  64180. * Please note that the emitter shape is not exported
  64181. * @param systems defines the particle systems to export
  64182. * @returns the created particle system set
  64183. */
  64184. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64185. }
  64186. }
  64187. declare module "babylonjs/Particles/particleSystemComponent" {
  64188. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64189. import { Effect } from "babylonjs/Materials/effect";
  64190. import "babylonjs/Shaders/particles.vertex";
  64191. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64192. module "babylonjs/Engines/engine" {
  64193. interface Engine {
  64194. /**
  64195. * Create an effect to use with particle systems.
  64196. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  64197. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  64198. * @param uniformsNames defines a list of attribute names
  64199. * @param samplers defines an array of string used to represent textures
  64200. * @param defines defines the string containing the defines to use to compile the shaders
  64201. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  64202. * @param onCompiled defines a function to call when the effect creation is successful
  64203. * @param onError defines a function to call when the effect creation has failed
  64204. * @returns the new Effect
  64205. */
  64206. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  64207. }
  64208. }
  64209. module "babylonjs/Meshes/mesh" {
  64210. interface Mesh {
  64211. /**
  64212. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  64213. * @returns an array of IParticleSystem
  64214. */
  64215. getEmittedParticleSystems(): IParticleSystem[];
  64216. /**
  64217. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  64218. * @returns an array of IParticleSystem
  64219. */
  64220. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  64221. }
  64222. }
  64223. /**
  64224. * @hidden
  64225. */
  64226. export var _IDoNeedToBeInTheBuild: number;
  64227. }
  64228. declare module "babylonjs/Particles/pointsCloudSystem" {
  64229. import { Color4 } from "babylonjs/Maths/math";
  64230. import { Mesh } from "babylonjs/Meshes/mesh";
  64231. import { Scene, IDisposable } from "babylonjs/scene";
  64232. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  64233. /** Defines the 4 color options */
  64234. export enum PointColor {
  64235. /** color value */
  64236. Color = 2,
  64237. /** uv value */
  64238. UV = 1,
  64239. /** random value */
  64240. Random = 0,
  64241. /** stated value */
  64242. Stated = 3
  64243. }
  64244. /**
  64245. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  64246. * 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.
  64247. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  64248. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  64249. *
  64250. * Full documentation here : TO BE ENTERED
  64251. */
  64252. export class PointsCloudSystem implements IDisposable {
  64253. /**
  64254. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  64255. * Example : var p = SPS.particles[i];
  64256. */
  64257. particles: CloudPoint[];
  64258. /**
  64259. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  64260. */
  64261. nbParticles: number;
  64262. /**
  64263. * This a counter for your own usage. It's not set by any SPS functions.
  64264. */
  64265. counter: number;
  64266. /**
  64267. * The PCS name. This name is also given to the underlying mesh.
  64268. */
  64269. name: string;
  64270. /**
  64271. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  64272. */
  64273. mesh: Mesh;
  64274. /**
  64275. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  64276. * Please read :
  64277. */
  64278. vars: any;
  64279. /**
  64280. * @hidden
  64281. */
  64282. _size: number;
  64283. private _scene;
  64284. private _promises;
  64285. private _positions;
  64286. private _indices;
  64287. private _normals;
  64288. private _colors;
  64289. private _uvs;
  64290. private _indices32;
  64291. private _positions32;
  64292. private _colors32;
  64293. private _uvs32;
  64294. private _updatable;
  64295. private _isVisibilityBoxLocked;
  64296. private _alwaysVisible;
  64297. private _groups;
  64298. private _groupCounter;
  64299. private _computeParticleColor;
  64300. private _computeParticleTexture;
  64301. private _computeParticleRotation;
  64302. private _computeBoundingBox;
  64303. private _isReady;
  64304. /**
  64305. * Creates a PCS (Points Cloud System) object
  64306. * @param name (String) is the PCS name, this will be the underlying mesh name
  64307. * @param pointSize (number) is the size for each point
  64308. * @param scene (Scene) is the scene in which the PCS is added
  64309. * @param options defines the options of the PCS e.g.
  64310. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  64311. */
  64312. constructor(name: string, pointSize: number, scene: Scene, options?: {
  64313. updatable?: boolean;
  64314. });
  64315. /**
  64316. * Builds the PCS underlying mesh. Returns a standard Mesh.
  64317. * If no points were added to the PCS, the returned mesh is just a single point.
  64318. * @returns a promise for the created mesh
  64319. */
  64320. buildMeshAsync(): Promise<Mesh>;
  64321. /**
  64322. * @hidden
  64323. */
  64324. private _buildMesh;
  64325. private _addParticle;
  64326. private _randomUnitVector;
  64327. private _getColorIndicesForCoord;
  64328. private _setPointsColorOrUV;
  64329. private _colorFromTexture;
  64330. private _calculateDensity;
  64331. /**
  64332. * Adds points to the PCS in random positions within a unit sphere
  64333. * @param nb (positive integer) the number of particles to be created from this model
  64334. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  64335. * @returns the number of groups in the system
  64336. */
  64337. addPoints(nb: number, pointFunction?: any): number;
  64338. /**
  64339. * Adds points to the PCS from the surface of the model shape
  64340. * @param mesh is any Mesh object that will be used as a surface model for the points
  64341. * @param nb (positive integer) the number of particles to be created from this model
  64342. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64343. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64344. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64345. * @returns the number of groups in the system
  64346. */
  64347. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64348. /**
  64349. * Adds points to the PCS inside the model shape
  64350. * @param mesh is any Mesh object that will be used as a surface model for the points
  64351. * @param nb (positive integer) the number of particles to be created from this model
  64352. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64353. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64354. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64355. * @returns the number of groups in the system
  64356. */
  64357. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64358. /**
  64359. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  64360. * This method calls `updateParticle()` for each particle of the SPS.
  64361. * For an animated SPS, it is usually called within the render loop.
  64362. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  64363. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  64364. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  64365. * @returns the PCS.
  64366. */
  64367. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  64368. /**
  64369. * Disposes the PCS.
  64370. */
  64371. dispose(): void;
  64372. /**
  64373. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  64374. * doc :
  64375. * @returns the PCS.
  64376. */
  64377. refreshVisibleSize(): PointsCloudSystem;
  64378. /**
  64379. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64380. * @param size the size (float) of the visibility box
  64381. * note : this doesn't lock the PCS mesh bounding box.
  64382. * doc :
  64383. */
  64384. setVisibilityBox(size: number): void;
  64385. /**
  64386. * Gets whether the PCS is always visible or not
  64387. * doc :
  64388. */
  64389. get isAlwaysVisible(): boolean;
  64390. /**
  64391. * Sets the PCS as always visible or not
  64392. * doc :
  64393. */
  64394. set isAlwaysVisible(val: boolean);
  64395. /**
  64396. * Tells to `setParticles()` to compute the particle rotations or not
  64397. * Default value : false. The PCS is faster when it's set to false
  64398. * Note : particle rotations are only applied to parent particles
  64399. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64400. */
  64401. set computeParticleRotation(val: boolean);
  64402. /**
  64403. * Tells to `setParticles()` to compute the particle colors or not.
  64404. * Default value : true. The PCS is faster when it's set to false.
  64405. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64406. */
  64407. set computeParticleColor(val: boolean);
  64408. set computeParticleTexture(val: boolean);
  64409. /**
  64410. * Gets if `setParticles()` computes the particle colors or not.
  64411. * Default value : false. The PCS is faster when it's set to false.
  64412. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64413. */
  64414. get computeParticleColor(): boolean;
  64415. /**
  64416. * Gets if `setParticles()` computes the particle textures or not.
  64417. * Default value : false. The PCS is faster when it's set to false.
  64418. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64419. */
  64420. get computeParticleTexture(): boolean;
  64421. /**
  64422. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64423. */
  64424. set computeBoundingBox(val: boolean);
  64425. /**
  64426. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64427. */
  64428. get computeBoundingBox(): boolean;
  64429. /**
  64430. * This function does nothing. It may be overwritten to set all the particle first values.
  64431. * The PCS doesn't call this function, you may have to call it by your own.
  64432. * doc :
  64433. */
  64434. initParticles(): void;
  64435. /**
  64436. * This function does nothing. It may be overwritten to recycle a particle
  64437. * The PCS doesn't call this function, you can to call it
  64438. * doc :
  64439. * @param particle The particle to recycle
  64440. * @returns the recycled particle
  64441. */
  64442. recycleParticle(particle: CloudPoint): CloudPoint;
  64443. /**
  64444. * Updates a particle : this function should be overwritten by the user.
  64445. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64446. * doc :
  64447. * @example : just set a particle position or velocity and recycle conditions
  64448. * @param particle The particle to update
  64449. * @returns the updated particle
  64450. */
  64451. updateParticle(particle: CloudPoint): CloudPoint;
  64452. /**
  64453. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64454. * This does nothing and may be overwritten by the user.
  64455. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64456. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64457. * @param update the boolean update value actually passed to setParticles()
  64458. */
  64459. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64460. /**
  64461. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64462. * This will be passed three parameters.
  64463. * This does nothing and may be overwritten by the user.
  64464. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64465. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64466. * @param update the boolean update value actually passed to setParticles()
  64467. */
  64468. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64469. }
  64470. }
  64471. declare module "babylonjs/Particles/cloudPoint" {
  64472. import { Nullable } from "babylonjs/types";
  64473. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  64474. import { Mesh } from "babylonjs/Meshes/mesh";
  64475. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64476. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  64477. /**
  64478. * Represents one particle of a points cloud system.
  64479. */
  64480. export class CloudPoint {
  64481. /**
  64482. * particle global index
  64483. */
  64484. idx: number;
  64485. /**
  64486. * The color of the particle
  64487. */
  64488. color: Nullable<Color4>;
  64489. /**
  64490. * The world space position of the particle.
  64491. */
  64492. position: Vector3;
  64493. /**
  64494. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64495. */
  64496. rotation: Vector3;
  64497. /**
  64498. * The world space rotation quaternion of the particle.
  64499. */
  64500. rotationQuaternion: Nullable<Quaternion>;
  64501. /**
  64502. * The uv of the particle.
  64503. */
  64504. uv: Nullable<Vector2>;
  64505. /**
  64506. * The current speed of the particle.
  64507. */
  64508. velocity: Vector3;
  64509. /**
  64510. * The pivot point in the particle local space.
  64511. */
  64512. pivot: Vector3;
  64513. /**
  64514. * Must the particle be translated from its pivot point in its local space ?
  64515. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64516. * Default : false
  64517. */
  64518. translateFromPivot: boolean;
  64519. /**
  64520. * Index of this particle in the global "positions" array (Internal use)
  64521. * @hidden
  64522. */
  64523. _pos: number;
  64524. /**
  64525. * @hidden Index of this particle in the global "indices" array (Internal use)
  64526. */
  64527. _ind: number;
  64528. /**
  64529. * Group this particle belongs to
  64530. */
  64531. _group: PointsGroup;
  64532. /**
  64533. * Group id of this particle
  64534. */
  64535. groupId: number;
  64536. /**
  64537. * Index of the particle in its group id (Internal use)
  64538. */
  64539. idxInGroup: number;
  64540. /**
  64541. * @hidden Particle BoundingInfo object (Internal use)
  64542. */
  64543. _boundingInfo: BoundingInfo;
  64544. /**
  64545. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64546. */
  64547. _pcs: PointsCloudSystem;
  64548. /**
  64549. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64550. */
  64551. _stillInvisible: boolean;
  64552. /**
  64553. * @hidden Last computed particle rotation matrix
  64554. */
  64555. _rotationMatrix: number[];
  64556. /**
  64557. * Parent particle Id, if any.
  64558. * Default null.
  64559. */
  64560. parentId: Nullable<number>;
  64561. /**
  64562. * @hidden Internal global position in the PCS.
  64563. */
  64564. _globalPosition: Vector3;
  64565. /**
  64566. * Creates a Point Cloud object.
  64567. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64568. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64569. * @param group (PointsGroup) is the group the particle belongs to
  64570. * @param groupId (integer) is the group identifier in the PCS.
  64571. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64572. * @param pcs defines the PCS it is associated to
  64573. */
  64574. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64575. /**
  64576. * get point size
  64577. */
  64578. get size(): Vector3;
  64579. /**
  64580. * Set point size
  64581. */
  64582. set size(scale: Vector3);
  64583. /**
  64584. * Legacy support, changed quaternion to rotationQuaternion
  64585. */
  64586. get quaternion(): Nullable<Quaternion>;
  64587. /**
  64588. * Legacy support, changed quaternion to rotationQuaternion
  64589. */
  64590. set quaternion(q: Nullable<Quaternion>);
  64591. /**
  64592. * Returns a boolean. True if the particle intersects a mesh, else false
  64593. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64594. * @param target is the object (point or mesh) what the intersection is computed against
  64595. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64596. * @returns true if it intersects
  64597. */
  64598. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64599. /**
  64600. * get the rotation matrix of the particle
  64601. * @hidden
  64602. */
  64603. getRotationMatrix(m: Matrix): void;
  64604. }
  64605. /**
  64606. * Represents a group of points in a points cloud system
  64607. * * PCS internal tool, don't use it manually.
  64608. */
  64609. export class PointsGroup {
  64610. /**
  64611. * The group id
  64612. * @hidden
  64613. */
  64614. groupID: number;
  64615. /**
  64616. * image data for group (internal use)
  64617. * @hidden
  64618. */
  64619. _groupImageData: Nullable<ArrayBufferView>;
  64620. /**
  64621. * Image Width (internal use)
  64622. * @hidden
  64623. */
  64624. _groupImgWidth: number;
  64625. /**
  64626. * Image Height (internal use)
  64627. * @hidden
  64628. */
  64629. _groupImgHeight: number;
  64630. /**
  64631. * Custom position function (internal use)
  64632. * @hidden
  64633. */
  64634. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64635. /**
  64636. * density per facet for surface points
  64637. * @hidden
  64638. */
  64639. _groupDensity: number[];
  64640. /**
  64641. * Only when points are colored by texture carries pointer to texture list array
  64642. * @hidden
  64643. */
  64644. _textureNb: number;
  64645. /**
  64646. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64647. * PCS internal tool, don't use it manually.
  64648. * @hidden
  64649. */
  64650. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64651. }
  64652. }
  64653. declare module "babylonjs/Particles/index" {
  64654. export * from "babylonjs/Particles/baseParticleSystem";
  64655. export * from "babylonjs/Particles/EmitterTypes/index";
  64656. export * from "babylonjs/Particles/gpuParticleSystem";
  64657. export * from "babylonjs/Particles/IParticleSystem";
  64658. export * from "babylonjs/Particles/particle";
  64659. export * from "babylonjs/Particles/particleHelper";
  64660. export * from "babylonjs/Particles/particleSystem";
  64661. export * from "babylonjs/Particles/particleSystemComponent";
  64662. export * from "babylonjs/Particles/particleSystemSet";
  64663. export * from "babylonjs/Particles/solidParticle";
  64664. export * from "babylonjs/Particles/solidParticleSystem";
  64665. export * from "babylonjs/Particles/cloudPoint";
  64666. export * from "babylonjs/Particles/pointsCloudSystem";
  64667. export * from "babylonjs/Particles/subEmitter";
  64668. }
  64669. declare module "babylonjs/Physics/physicsEngineComponent" {
  64670. import { Nullable } from "babylonjs/types";
  64671. import { Observable, Observer } from "babylonjs/Misc/observable";
  64672. import { Vector3 } from "babylonjs/Maths/math.vector";
  64673. import { Mesh } from "babylonjs/Meshes/mesh";
  64674. import { ISceneComponent } from "babylonjs/sceneComponent";
  64675. import { Scene } from "babylonjs/scene";
  64676. import { Node } from "babylonjs/node";
  64677. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64678. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64679. module "babylonjs/scene" {
  64680. interface Scene {
  64681. /** @hidden (Backing field) */
  64682. _physicsEngine: Nullable<IPhysicsEngine>;
  64683. /** @hidden */
  64684. _physicsTimeAccumulator: number;
  64685. /**
  64686. * Gets the current physics engine
  64687. * @returns a IPhysicsEngine or null if none attached
  64688. */
  64689. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64690. /**
  64691. * Enables physics to the current scene
  64692. * @param gravity defines the scene's gravity for the physics engine
  64693. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64694. * @return a boolean indicating if the physics engine was initialized
  64695. */
  64696. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64697. /**
  64698. * Disables and disposes the physics engine associated with the scene
  64699. */
  64700. disablePhysicsEngine(): void;
  64701. /**
  64702. * Gets a boolean indicating if there is an active physics engine
  64703. * @returns a boolean indicating if there is an active physics engine
  64704. */
  64705. isPhysicsEnabled(): boolean;
  64706. /**
  64707. * Deletes a physics compound impostor
  64708. * @param compound defines the compound to delete
  64709. */
  64710. deleteCompoundImpostor(compound: any): void;
  64711. /**
  64712. * An event triggered when physic simulation is about to be run
  64713. */
  64714. onBeforePhysicsObservable: Observable<Scene>;
  64715. /**
  64716. * An event triggered when physic simulation has been done
  64717. */
  64718. onAfterPhysicsObservable: Observable<Scene>;
  64719. }
  64720. }
  64721. module "babylonjs/Meshes/abstractMesh" {
  64722. interface AbstractMesh {
  64723. /** @hidden */
  64724. _physicsImpostor: Nullable<PhysicsImpostor>;
  64725. /**
  64726. * Gets or sets impostor used for physic simulation
  64727. * @see http://doc.babylonjs.com/features/physics_engine
  64728. */
  64729. physicsImpostor: Nullable<PhysicsImpostor>;
  64730. /**
  64731. * Gets the current physics impostor
  64732. * @see http://doc.babylonjs.com/features/physics_engine
  64733. * @returns a physics impostor or null
  64734. */
  64735. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64736. /** Apply a physic impulse to the mesh
  64737. * @param force defines the force to apply
  64738. * @param contactPoint defines where to apply the force
  64739. * @returns the current mesh
  64740. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64741. */
  64742. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64743. /**
  64744. * Creates a physic joint between two meshes
  64745. * @param otherMesh defines the other mesh to use
  64746. * @param pivot1 defines the pivot to use on this mesh
  64747. * @param pivot2 defines the pivot to use on the other mesh
  64748. * @param options defines additional options (can be plugin dependent)
  64749. * @returns the current mesh
  64750. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64751. */
  64752. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64753. /** @hidden */
  64754. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64755. }
  64756. }
  64757. /**
  64758. * Defines the physics engine scene component responsible to manage a physics engine
  64759. */
  64760. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64761. /**
  64762. * The component name helpful to identify the component in the list of scene components.
  64763. */
  64764. readonly name: string;
  64765. /**
  64766. * The scene the component belongs to.
  64767. */
  64768. scene: Scene;
  64769. /**
  64770. * Creates a new instance of the component for the given scene
  64771. * @param scene Defines the scene to register the component in
  64772. */
  64773. constructor(scene: Scene);
  64774. /**
  64775. * Registers the component in a given scene
  64776. */
  64777. register(): void;
  64778. /**
  64779. * Rebuilds the elements related to this component in case of
  64780. * context lost for instance.
  64781. */
  64782. rebuild(): void;
  64783. /**
  64784. * Disposes the component and the associated ressources
  64785. */
  64786. dispose(): void;
  64787. }
  64788. }
  64789. declare module "babylonjs/Physics/physicsHelper" {
  64790. import { Nullable } from "babylonjs/types";
  64791. import { Vector3 } from "babylonjs/Maths/math.vector";
  64792. import { Mesh } from "babylonjs/Meshes/mesh";
  64793. import { Scene } from "babylonjs/scene";
  64794. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64795. /**
  64796. * A helper for physics simulations
  64797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64798. */
  64799. export class PhysicsHelper {
  64800. private _scene;
  64801. private _physicsEngine;
  64802. /**
  64803. * Initializes the Physics helper
  64804. * @param scene Babylon.js scene
  64805. */
  64806. constructor(scene: Scene);
  64807. /**
  64808. * Applies a radial explosion impulse
  64809. * @param origin the origin of the explosion
  64810. * @param radiusOrEventOptions the radius or the options of radial explosion
  64811. * @param strength the explosion strength
  64812. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64813. * @returns A physics radial explosion event, or null
  64814. */
  64815. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64816. /**
  64817. * Applies a radial explosion force
  64818. * @param origin the origin of the explosion
  64819. * @param radiusOrEventOptions the radius or the options of radial explosion
  64820. * @param strength the explosion strength
  64821. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64822. * @returns A physics radial explosion event, or null
  64823. */
  64824. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64825. /**
  64826. * Creates a gravitational field
  64827. * @param origin the origin of the explosion
  64828. * @param radiusOrEventOptions the radius or the options of radial explosion
  64829. * @param strength the explosion strength
  64830. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64831. * @returns A physics gravitational field event, or null
  64832. */
  64833. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64834. /**
  64835. * Creates a physics updraft event
  64836. * @param origin the origin of the updraft
  64837. * @param radiusOrEventOptions the radius or the options of the updraft
  64838. * @param strength the strength of the updraft
  64839. * @param height the height of the updraft
  64840. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64841. * @returns A physics updraft event, or null
  64842. */
  64843. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64844. /**
  64845. * Creates a physics vortex event
  64846. * @param origin the of the vortex
  64847. * @param radiusOrEventOptions the radius or the options of the vortex
  64848. * @param strength the strength of the vortex
  64849. * @param height the height of the vortex
  64850. * @returns a Physics vortex event, or null
  64851. * A physics vortex event or null
  64852. */
  64853. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64854. }
  64855. /**
  64856. * Represents a physics radial explosion event
  64857. */
  64858. class PhysicsRadialExplosionEvent {
  64859. private _scene;
  64860. private _options;
  64861. private _sphere;
  64862. private _dataFetched;
  64863. /**
  64864. * Initializes a radial explosioin event
  64865. * @param _scene BabylonJS scene
  64866. * @param _options The options for the vortex event
  64867. */
  64868. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64869. /**
  64870. * Returns the data related to the radial explosion event (sphere).
  64871. * @returns The radial explosion event data
  64872. */
  64873. getData(): PhysicsRadialExplosionEventData;
  64874. /**
  64875. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64876. * @param impostor A physics imposter
  64877. * @param origin the origin of the explosion
  64878. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64879. */
  64880. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64881. /**
  64882. * Triggers affecterd impostors callbacks
  64883. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64884. */
  64885. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64886. /**
  64887. * Disposes the sphere.
  64888. * @param force Specifies if the sphere should be disposed by force
  64889. */
  64890. dispose(force?: boolean): void;
  64891. /*** Helpers ***/
  64892. private _prepareSphere;
  64893. private _intersectsWithSphere;
  64894. }
  64895. /**
  64896. * Represents a gravitational field event
  64897. */
  64898. class PhysicsGravitationalFieldEvent {
  64899. private _physicsHelper;
  64900. private _scene;
  64901. private _origin;
  64902. private _options;
  64903. private _tickCallback;
  64904. private _sphere;
  64905. private _dataFetched;
  64906. /**
  64907. * Initializes the physics gravitational field event
  64908. * @param _physicsHelper A physics helper
  64909. * @param _scene BabylonJS scene
  64910. * @param _origin The origin position of the gravitational field event
  64911. * @param _options The options for the vortex event
  64912. */
  64913. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64914. /**
  64915. * Returns the data related to the gravitational field event (sphere).
  64916. * @returns A gravitational field event
  64917. */
  64918. getData(): PhysicsGravitationalFieldEventData;
  64919. /**
  64920. * Enables the gravitational field.
  64921. */
  64922. enable(): void;
  64923. /**
  64924. * Disables the gravitational field.
  64925. */
  64926. disable(): void;
  64927. /**
  64928. * Disposes the sphere.
  64929. * @param force The force to dispose from the gravitational field event
  64930. */
  64931. dispose(force?: boolean): void;
  64932. private _tick;
  64933. }
  64934. /**
  64935. * Represents a physics updraft event
  64936. */
  64937. class PhysicsUpdraftEvent {
  64938. private _scene;
  64939. private _origin;
  64940. private _options;
  64941. private _physicsEngine;
  64942. private _originTop;
  64943. private _originDirection;
  64944. private _tickCallback;
  64945. private _cylinder;
  64946. private _cylinderPosition;
  64947. private _dataFetched;
  64948. /**
  64949. * Initializes the physics updraft event
  64950. * @param _scene BabylonJS scene
  64951. * @param _origin The origin position of the updraft
  64952. * @param _options The options for the updraft event
  64953. */
  64954. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64955. /**
  64956. * Returns the data related to the updraft event (cylinder).
  64957. * @returns A physics updraft event
  64958. */
  64959. getData(): PhysicsUpdraftEventData;
  64960. /**
  64961. * Enables the updraft.
  64962. */
  64963. enable(): void;
  64964. /**
  64965. * Disables the updraft.
  64966. */
  64967. disable(): void;
  64968. /**
  64969. * Disposes the cylinder.
  64970. * @param force Specifies if the updraft should be disposed by force
  64971. */
  64972. dispose(force?: boolean): void;
  64973. private getImpostorHitData;
  64974. private _tick;
  64975. /*** Helpers ***/
  64976. private _prepareCylinder;
  64977. private _intersectsWithCylinder;
  64978. }
  64979. /**
  64980. * Represents a physics vortex event
  64981. */
  64982. class PhysicsVortexEvent {
  64983. private _scene;
  64984. private _origin;
  64985. private _options;
  64986. private _physicsEngine;
  64987. private _originTop;
  64988. private _tickCallback;
  64989. private _cylinder;
  64990. private _cylinderPosition;
  64991. private _dataFetched;
  64992. /**
  64993. * Initializes the physics vortex event
  64994. * @param _scene The BabylonJS scene
  64995. * @param _origin The origin position of the vortex
  64996. * @param _options The options for the vortex event
  64997. */
  64998. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64999. /**
  65000. * Returns the data related to the vortex event (cylinder).
  65001. * @returns The physics vortex event data
  65002. */
  65003. getData(): PhysicsVortexEventData;
  65004. /**
  65005. * Enables the vortex.
  65006. */
  65007. enable(): void;
  65008. /**
  65009. * Disables the cortex.
  65010. */
  65011. disable(): void;
  65012. /**
  65013. * Disposes the sphere.
  65014. * @param force
  65015. */
  65016. dispose(force?: boolean): void;
  65017. private getImpostorHitData;
  65018. private _tick;
  65019. /*** Helpers ***/
  65020. private _prepareCylinder;
  65021. private _intersectsWithCylinder;
  65022. }
  65023. /**
  65024. * Options fot the radial explosion event
  65025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65026. */
  65027. export class PhysicsRadialExplosionEventOptions {
  65028. /**
  65029. * The radius of the sphere for the radial explosion.
  65030. */
  65031. radius: number;
  65032. /**
  65033. * The strenth of the explosion.
  65034. */
  65035. strength: number;
  65036. /**
  65037. * The strenght of the force in correspondence to the distance of the affected object
  65038. */
  65039. falloff: PhysicsRadialImpulseFalloff;
  65040. /**
  65041. * Sphere options for the radial explosion.
  65042. */
  65043. sphere: {
  65044. segments: number;
  65045. diameter: number;
  65046. };
  65047. /**
  65048. * Sphere options for the radial explosion.
  65049. */
  65050. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65051. }
  65052. /**
  65053. * Options fot the updraft event
  65054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65055. */
  65056. export class PhysicsUpdraftEventOptions {
  65057. /**
  65058. * The radius of the cylinder for the vortex
  65059. */
  65060. radius: number;
  65061. /**
  65062. * The strenth of the updraft.
  65063. */
  65064. strength: number;
  65065. /**
  65066. * The height of the cylinder for the updraft.
  65067. */
  65068. height: number;
  65069. /**
  65070. * The mode for the the updraft.
  65071. */
  65072. updraftMode: PhysicsUpdraftMode;
  65073. }
  65074. /**
  65075. * Options fot the vortex event
  65076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65077. */
  65078. export class PhysicsVortexEventOptions {
  65079. /**
  65080. * The radius of the cylinder for the vortex
  65081. */
  65082. radius: number;
  65083. /**
  65084. * The strenth of the vortex.
  65085. */
  65086. strength: number;
  65087. /**
  65088. * The height of the cylinder for the vortex.
  65089. */
  65090. height: number;
  65091. /**
  65092. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65093. */
  65094. centripetalForceThreshold: number;
  65095. /**
  65096. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65097. */
  65098. centripetalForceMultiplier: number;
  65099. /**
  65100. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65101. */
  65102. centrifugalForceMultiplier: number;
  65103. /**
  65104. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65105. */
  65106. updraftForceMultiplier: number;
  65107. }
  65108. /**
  65109. * The strenght of the force in correspondence to the distance of the affected object
  65110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65111. */
  65112. export enum PhysicsRadialImpulseFalloff {
  65113. /** Defines that impulse is constant in strength across it's whole radius */
  65114. Constant = 0,
  65115. /** Defines that impulse gets weaker if it's further from the origin */
  65116. Linear = 1
  65117. }
  65118. /**
  65119. * The strength of the force in correspondence to the distance of the affected object
  65120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65121. */
  65122. export enum PhysicsUpdraftMode {
  65123. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65124. Center = 0,
  65125. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65126. Perpendicular = 1
  65127. }
  65128. /**
  65129. * Interface for a physics hit data
  65130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65131. */
  65132. export interface PhysicsHitData {
  65133. /**
  65134. * The force applied at the contact point
  65135. */
  65136. force: Vector3;
  65137. /**
  65138. * The contact point
  65139. */
  65140. contactPoint: Vector3;
  65141. /**
  65142. * The distance from the origin to the contact point
  65143. */
  65144. distanceFromOrigin: number;
  65145. }
  65146. /**
  65147. * Interface for radial explosion event data
  65148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65149. */
  65150. export interface PhysicsRadialExplosionEventData {
  65151. /**
  65152. * A sphere used for the radial explosion event
  65153. */
  65154. sphere: Mesh;
  65155. }
  65156. /**
  65157. * Interface for gravitational field event data
  65158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65159. */
  65160. export interface PhysicsGravitationalFieldEventData {
  65161. /**
  65162. * A sphere mesh used for the gravitational field event
  65163. */
  65164. sphere: Mesh;
  65165. }
  65166. /**
  65167. * Interface for updraft event data
  65168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65169. */
  65170. export interface PhysicsUpdraftEventData {
  65171. /**
  65172. * A cylinder used for the updraft event
  65173. */
  65174. cylinder: Mesh;
  65175. }
  65176. /**
  65177. * Interface for vortex event data
  65178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65179. */
  65180. export interface PhysicsVortexEventData {
  65181. /**
  65182. * A cylinder used for the vortex event
  65183. */
  65184. cylinder: Mesh;
  65185. }
  65186. /**
  65187. * Interface for an affected physics impostor
  65188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65189. */
  65190. export interface PhysicsAffectedImpostorWithData {
  65191. /**
  65192. * The impostor affected by the effect
  65193. */
  65194. impostor: PhysicsImpostor;
  65195. /**
  65196. * The data about the hit/horce from the explosion
  65197. */
  65198. hitData: PhysicsHitData;
  65199. }
  65200. }
  65201. declare module "babylonjs/Physics/Plugins/index" {
  65202. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  65203. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  65204. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  65205. }
  65206. declare module "babylonjs/Physics/index" {
  65207. export * from "babylonjs/Physics/IPhysicsEngine";
  65208. export * from "babylonjs/Physics/physicsEngine";
  65209. export * from "babylonjs/Physics/physicsEngineComponent";
  65210. export * from "babylonjs/Physics/physicsHelper";
  65211. export * from "babylonjs/Physics/physicsImpostor";
  65212. export * from "babylonjs/Physics/physicsJoint";
  65213. export * from "babylonjs/Physics/Plugins/index";
  65214. }
  65215. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  65216. /** @hidden */
  65217. export var blackAndWhitePixelShader: {
  65218. name: string;
  65219. shader: string;
  65220. };
  65221. }
  65222. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  65223. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65224. import { Camera } from "babylonjs/Cameras/camera";
  65225. import { Engine } from "babylonjs/Engines/engine";
  65226. import "babylonjs/Shaders/blackAndWhite.fragment";
  65227. /**
  65228. * Post process used to render in black and white
  65229. */
  65230. export class BlackAndWhitePostProcess extends PostProcess {
  65231. /**
  65232. * Linear about to convert he result to black and white (default: 1)
  65233. */
  65234. degree: number;
  65235. /**
  65236. * Creates a black and white post process
  65237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  65238. * @param name The name of the effect.
  65239. * @param options The required width/height ratio to downsize to before computing the render pass.
  65240. * @param camera The camera to apply the render pass to.
  65241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65242. * @param engine The engine which the post process will be applied. (default: current engine)
  65243. * @param reusable If the post process can be reused on the same frame. (default: false)
  65244. */
  65245. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65246. }
  65247. }
  65248. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  65249. import { Nullable } from "babylonjs/types";
  65250. import { Camera } from "babylonjs/Cameras/camera";
  65251. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65252. import { Engine } from "babylonjs/Engines/engine";
  65253. /**
  65254. * This represents a set of one or more post processes in Babylon.
  65255. * A post process can be used to apply a shader to a texture after it is rendered.
  65256. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65257. */
  65258. export class PostProcessRenderEffect {
  65259. private _postProcesses;
  65260. private _getPostProcesses;
  65261. private _singleInstance;
  65262. private _cameras;
  65263. private _indicesForCamera;
  65264. /**
  65265. * Name of the effect
  65266. * @hidden
  65267. */
  65268. _name: string;
  65269. /**
  65270. * Instantiates a post process render effect.
  65271. * A post process can be used to apply a shader to a texture after it is rendered.
  65272. * @param engine The engine the effect is tied to
  65273. * @param name The name of the effect
  65274. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  65275. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  65276. */
  65277. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  65278. /**
  65279. * Checks if all the post processes in the effect are supported.
  65280. */
  65281. get isSupported(): boolean;
  65282. /**
  65283. * Updates the current state of the effect
  65284. * @hidden
  65285. */
  65286. _update(): void;
  65287. /**
  65288. * Attaches the effect on cameras
  65289. * @param cameras The camera to attach to.
  65290. * @hidden
  65291. */
  65292. _attachCameras(cameras: Camera): void;
  65293. /**
  65294. * Attaches the effect on cameras
  65295. * @param cameras The camera to attach to.
  65296. * @hidden
  65297. */
  65298. _attachCameras(cameras: Camera[]): void;
  65299. /**
  65300. * Detaches the effect on cameras
  65301. * @param cameras The camera to detatch from.
  65302. * @hidden
  65303. */
  65304. _detachCameras(cameras: Camera): void;
  65305. /**
  65306. * Detatches the effect on cameras
  65307. * @param cameras The camera to detatch from.
  65308. * @hidden
  65309. */
  65310. _detachCameras(cameras: Camera[]): void;
  65311. /**
  65312. * Enables the effect on given cameras
  65313. * @param cameras The camera to enable.
  65314. * @hidden
  65315. */
  65316. _enable(cameras: Camera): void;
  65317. /**
  65318. * Enables the effect on given cameras
  65319. * @param cameras The camera to enable.
  65320. * @hidden
  65321. */
  65322. _enable(cameras: Nullable<Camera[]>): void;
  65323. /**
  65324. * Disables the effect on the given cameras
  65325. * @param cameras The camera to disable.
  65326. * @hidden
  65327. */
  65328. _disable(cameras: Camera): void;
  65329. /**
  65330. * Disables the effect on the given cameras
  65331. * @param cameras The camera to disable.
  65332. * @hidden
  65333. */
  65334. _disable(cameras: Nullable<Camera[]>): void;
  65335. /**
  65336. * Gets a list of the post processes contained in the effect.
  65337. * @param camera The camera to get the post processes on.
  65338. * @returns The list of the post processes in the effect.
  65339. */
  65340. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  65341. }
  65342. }
  65343. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  65344. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65345. /** @hidden */
  65346. export var extractHighlightsPixelShader: {
  65347. name: string;
  65348. shader: string;
  65349. };
  65350. }
  65351. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  65352. import { Nullable } from "babylonjs/types";
  65353. import { Camera } from "babylonjs/Cameras/camera";
  65354. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65355. import { Engine } from "babylonjs/Engines/engine";
  65356. import "babylonjs/Shaders/extractHighlights.fragment";
  65357. /**
  65358. * 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.
  65359. */
  65360. export class ExtractHighlightsPostProcess extends PostProcess {
  65361. /**
  65362. * The luminance threshold, pixels below this value will be set to black.
  65363. */
  65364. threshold: number;
  65365. /** @hidden */
  65366. _exposure: number;
  65367. /**
  65368. * Post process which has the input texture to be used when performing highlight extraction
  65369. * @hidden
  65370. */
  65371. _inputPostProcess: Nullable<PostProcess>;
  65372. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65373. }
  65374. }
  65375. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  65376. /** @hidden */
  65377. export var bloomMergePixelShader: {
  65378. name: string;
  65379. shader: string;
  65380. };
  65381. }
  65382. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  65383. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65384. import { Nullable } from "babylonjs/types";
  65385. import { Engine } from "babylonjs/Engines/engine";
  65386. import { Camera } from "babylonjs/Cameras/camera";
  65387. import "babylonjs/Shaders/bloomMerge.fragment";
  65388. /**
  65389. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65390. */
  65391. export class BloomMergePostProcess extends PostProcess {
  65392. /** Weight of the bloom to be added to the original input. */
  65393. weight: number;
  65394. /**
  65395. * Creates a new instance of @see BloomMergePostProcess
  65396. * @param name The name of the effect.
  65397. * @param originalFromInput Post process which's input will be used for the merge.
  65398. * @param blurred Blurred highlights post process which's output will be used.
  65399. * @param weight Weight of the bloom to be added to the original input.
  65400. * @param options The required width/height ratio to downsize to before computing the render pass.
  65401. * @param camera The camera to apply the render pass to.
  65402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65403. * @param engine The engine which the post process will be applied. (default: current engine)
  65404. * @param reusable If the post process can be reused on the same frame. (default: false)
  65405. * @param textureType Type of textures used when performing the post process. (default: 0)
  65406. * @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)
  65407. */
  65408. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  65409. /** Weight of the bloom to be added to the original input. */
  65410. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65411. }
  65412. }
  65413. declare module "babylonjs/PostProcesses/bloomEffect" {
  65414. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65415. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65416. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65417. import { Camera } from "babylonjs/Cameras/camera";
  65418. import { Scene } from "babylonjs/scene";
  65419. /**
  65420. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  65421. */
  65422. export class BloomEffect extends PostProcessRenderEffect {
  65423. private bloomScale;
  65424. /**
  65425. * @hidden Internal
  65426. */
  65427. _effects: Array<PostProcess>;
  65428. /**
  65429. * @hidden Internal
  65430. */
  65431. _downscale: ExtractHighlightsPostProcess;
  65432. private _blurX;
  65433. private _blurY;
  65434. private _merge;
  65435. /**
  65436. * The luminance threshold to find bright areas of the image to bloom.
  65437. */
  65438. get threshold(): number;
  65439. set threshold(value: number);
  65440. /**
  65441. * The strength of the bloom.
  65442. */
  65443. get weight(): number;
  65444. set weight(value: number);
  65445. /**
  65446. * Specifies the size of the bloom blur kernel, relative to the final output size
  65447. */
  65448. get kernel(): number;
  65449. set kernel(value: number);
  65450. /**
  65451. * Creates a new instance of @see BloomEffect
  65452. * @param scene The scene the effect belongs to.
  65453. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  65454. * @param bloomKernel The size of the kernel to be used when applying the blur.
  65455. * @param bloomWeight The the strength of bloom.
  65456. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65457. * @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)
  65458. */
  65459. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65460. /**
  65461. * Disposes each of the internal effects for a given camera.
  65462. * @param camera The camera to dispose the effect on.
  65463. */
  65464. disposeEffects(camera: Camera): void;
  65465. /**
  65466. * @hidden Internal
  65467. */
  65468. _updateEffects(): void;
  65469. /**
  65470. * Internal
  65471. * @returns if all the contained post processes are ready.
  65472. * @hidden
  65473. */
  65474. _isReady(): boolean;
  65475. }
  65476. }
  65477. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  65478. /** @hidden */
  65479. export var chromaticAberrationPixelShader: {
  65480. name: string;
  65481. shader: string;
  65482. };
  65483. }
  65484. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  65485. import { Vector2 } from "babylonjs/Maths/math.vector";
  65486. import { Nullable } from "babylonjs/types";
  65487. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65488. import { Camera } from "babylonjs/Cameras/camera";
  65489. import { Engine } from "babylonjs/Engines/engine";
  65490. import "babylonjs/Shaders/chromaticAberration.fragment";
  65491. /**
  65492. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65493. */
  65494. export class ChromaticAberrationPostProcess extends PostProcess {
  65495. /**
  65496. * The amount of seperation of rgb channels (default: 30)
  65497. */
  65498. aberrationAmount: number;
  65499. /**
  65500. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65501. */
  65502. radialIntensity: number;
  65503. /**
  65504. * 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))
  65505. */
  65506. direction: Vector2;
  65507. /**
  65508. * 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))
  65509. */
  65510. centerPosition: Vector2;
  65511. /**
  65512. * Creates a new instance ChromaticAberrationPostProcess
  65513. * @param name The name of the effect.
  65514. * @param screenWidth The width of the screen to apply the effect on.
  65515. * @param screenHeight The height of the screen to apply the effect on.
  65516. * @param options The required width/height ratio to downsize to before computing the render pass.
  65517. * @param camera The camera to apply the render pass to.
  65518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65519. * @param engine The engine which the post process will be applied. (default: current engine)
  65520. * @param reusable If the post process can be reused on the same frame. (default: false)
  65521. * @param textureType Type of textures used when performing the post process. (default: 0)
  65522. * @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)
  65523. */
  65524. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65525. }
  65526. }
  65527. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  65528. /** @hidden */
  65529. export var circleOfConfusionPixelShader: {
  65530. name: string;
  65531. shader: string;
  65532. };
  65533. }
  65534. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  65535. import { Nullable } from "babylonjs/types";
  65536. import { Engine } from "babylonjs/Engines/engine";
  65537. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65538. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65539. import { Camera } from "babylonjs/Cameras/camera";
  65540. import "babylonjs/Shaders/circleOfConfusion.fragment";
  65541. /**
  65542. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65543. */
  65544. export class CircleOfConfusionPostProcess extends PostProcess {
  65545. /**
  65546. * 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.
  65547. */
  65548. lensSize: number;
  65549. /**
  65550. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65551. */
  65552. fStop: number;
  65553. /**
  65554. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65555. */
  65556. focusDistance: number;
  65557. /**
  65558. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65559. */
  65560. focalLength: number;
  65561. private _depthTexture;
  65562. /**
  65563. * Creates a new instance CircleOfConfusionPostProcess
  65564. * @param name The name of the effect.
  65565. * @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.
  65566. * @param options The required width/height ratio to downsize to before computing the render pass.
  65567. * @param camera The camera to apply the render pass to.
  65568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65569. * @param engine The engine which the post process will be applied. (default: current engine)
  65570. * @param reusable If the post process can be reused on the same frame. (default: false)
  65571. * @param textureType Type of textures used when performing the post process. (default: 0)
  65572. * @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)
  65573. */
  65574. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65575. /**
  65576. * 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.
  65577. */
  65578. set depthTexture(value: RenderTargetTexture);
  65579. }
  65580. }
  65581. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  65582. /** @hidden */
  65583. export var colorCorrectionPixelShader: {
  65584. name: string;
  65585. shader: string;
  65586. };
  65587. }
  65588. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  65589. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65590. import { Engine } from "babylonjs/Engines/engine";
  65591. import { Camera } from "babylonjs/Cameras/camera";
  65592. import "babylonjs/Shaders/colorCorrection.fragment";
  65593. /**
  65594. *
  65595. * This post-process allows the modification of rendered colors by using
  65596. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65597. *
  65598. * The object needs to be provided an url to a texture containing the color
  65599. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65600. * Use an image editing software to tweak the LUT to match your needs.
  65601. *
  65602. * For an example of a color LUT, see here:
  65603. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65604. * For explanations on color grading, see here:
  65605. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65606. *
  65607. */
  65608. export class ColorCorrectionPostProcess extends PostProcess {
  65609. private _colorTableTexture;
  65610. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65611. }
  65612. }
  65613. declare module "babylonjs/Shaders/convolution.fragment" {
  65614. /** @hidden */
  65615. export var convolutionPixelShader: {
  65616. name: string;
  65617. shader: string;
  65618. };
  65619. }
  65620. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  65621. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65622. import { Nullable } from "babylonjs/types";
  65623. import { Camera } from "babylonjs/Cameras/camera";
  65624. import { Engine } from "babylonjs/Engines/engine";
  65625. import "babylonjs/Shaders/convolution.fragment";
  65626. /**
  65627. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65628. * input texture to perform effects such as edge detection or sharpening
  65629. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65630. */
  65631. export class ConvolutionPostProcess extends PostProcess {
  65632. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65633. kernel: number[];
  65634. /**
  65635. * Creates a new instance ConvolutionPostProcess
  65636. * @param name The name of the effect.
  65637. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65638. * @param options The required width/height ratio to downsize to before computing the render pass.
  65639. * @param camera The camera to apply the render pass to.
  65640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65641. * @param engine The engine which the post process will be applied. (default: current engine)
  65642. * @param reusable If the post process can be reused on the same frame. (default: false)
  65643. * @param textureType Type of textures used when performing the post process. (default: 0)
  65644. */
  65645. constructor(name: string,
  65646. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65647. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65648. /**
  65649. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65650. */
  65651. static EdgeDetect0Kernel: number[];
  65652. /**
  65653. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65654. */
  65655. static EdgeDetect1Kernel: number[];
  65656. /**
  65657. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65658. */
  65659. static EdgeDetect2Kernel: number[];
  65660. /**
  65661. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65662. */
  65663. static SharpenKernel: number[];
  65664. /**
  65665. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65666. */
  65667. static EmbossKernel: number[];
  65668. /**
  65669. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65670. */
  65671. static GaussianKernel: number[];
  65672. }
  65673. }
  65674. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  65675. import { Nullable } from "babylonjs/types";
  65676. import { Vector2 } from "babylonjs/Maths/math.vector";
  65677. import { Camera } from "babylonjs/Cameras/camera";
  65678. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65679. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65680. import { Engine } from "babylonjs/Engines/engine";
  65681. import { Scene } from "babylonjs/scene";
  65682. /**
  65683. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65684. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65685. * based on samples that have a large difference in distance than the center pixel.
  65686. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65687. */
  65688. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65689. direction: Vector2;
  65690. /**
  65691. * Creates a new instance CircleOfConfusionPostProcess
  65692. * @param name The name of the effect.
  65693. * @param scene The scene the effect belongs to.
  65694. * @param direction The direction the blur should be applied.
  65695. * @param kernel The size of the kernel used to blur.
  65696. * @param options The required width/height ratio to downsize to before computing the render pass.
  65697. * @param camera The camera to apply the render pass to.
  65698. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65699. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65701. * @param engine The engine which the post process will be applied. (default: current engine)
  65702. * @param reusable If the post process can be reused on the same frame. (default: false)
  65703. * @param textureType Type of textures used when performing the post process. (default: 0)
  65704. * @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)
  65705. */
  65706. 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);
  65707. }
  65708. }
  65709. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  65710. /** @hidden */
  65711. export var depthOfFieldMergePixelShader: {
  65712. name: string;
  65713. shader: string;
  65714. };
  65715. }
  65716. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  65717. import { Nullable } from "babylonjs/types";
  65718. import { Camera } from "babylonjs/Cameras/camera";
  65719. import { Effect } from "babylonjs/Materials/effect";
  65720. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65721. import { Engine } from "babylonjs/Engines/engine";
  65722. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  65723. /**
  65724. * Options to be set when merging outputs from the default pipeline.
  65725. */
  65726. export class DepthOfFieldMergePostProcessOptions {
  65727. /**
  65728. * The original image to merge on top of
  65729. */
  65730. originalFromInput: PostProcess;
  65731. /**
  65732. * Parameters to perform the merge of the depth of field effect
  65733. */
  65734. depthOfField?: {
  65735. circleOfConfusion: PostProcess;
  65736. blurSteps: Array<PostProcess>;
  65737. };
  65738. /**
  65739. * Parameters to perform the merge of bloom effect
  65740. */
  65741. bloom?: {
  65742. blurred: PostProcess;
  65743. weight: number;
  65744. };
  65745. }
  65746. /**
  65747. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65748. */
  65749. export class DepthOfFieldMergePostProcess extends PostProcess {
  65750. private blurSteps;
  65751. /**
  65752. * Creates a new instance of DepthOfFieldMergePostProcess
  65753. * @param name The name of the effect.
  65754. * @param originalFromInput Post process which's input will be used for the merge.
  65755. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65756. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65757. * @param options The required width/height ratio to downsize to before computing the render pass.
  65758. * @param camera The camera to apply the render pass to.
  65759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65760. * @param engine The engine which the post process will be applied. (default: current engine)
  65761. * @param reusable If the post process can be reused on the same frame. (default: false)
  65762. * @param textureType Type of textures used when performing the post process. (default: 0)
  65763. * @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)
  65764. */
  65765. 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);
  65766. /**
  65767. * Updates the effect with the current post process compile time values and recompiles the shader.
  65768. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65769. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65770. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65771. * @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
  65772. * @param onCompiled Called when the shader has been compiled.
  65773. * @param onError Called if there is an error when compiling a shader.
  65774. */
  65775. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65776. }
  65777. }
  65778. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  65779. import { Nullable } from "babylonjs/types";
  65780. import { Camera } from "babylonjs/Cameras/camera";
  65781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65782. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65783. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65784. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65785. import { Scene } from "babylonjs/scene";
  65786. /**
  65787. * Specifies the level of max blur that should be applied when using the depth of field effect
  65788. */
  65789. export enum DepthOfFieldEffectBlurLevel {
  65790. /**
  65791. * Subtle blur
  65792. */
  65793. Low = 0,
  65794. /**
  65795. * Medium blur
  65796. */
  65797. Medium = 1,
  65798. /**
  65799. * Large blur
  65800. */
  65801. High = 2
  65802. }
  65803. /**
  65804. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65805. */
  65806. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65807. private _circleOfConfusion;
  65808. /**
  65809. * @hidden Internal, blurs from high to low
  65810. */
  65811. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65812. private _depthOfFieldBlurY;
  65813. private _dofMerge;
  65814. /**
  65815. * @hidden Internal post processes in depth of field effect
  65816. */
  65817. _effects: Array<PostProcess>;
  65818. /**
  65819. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65820. */
  65821. set focalLength(value: number);
  65822. get focalLength(): number;
  65823. /**
  65824. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65825. */
  65826. set fStop(value: number);
  65827. get fStop(): number;
  65828. /**
  65829. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65830. */
  65831. set focusDistance(value: number);
  65832. get focusDistance(): number;
  65833. /**
  65834. * 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.
  65835. */
  65836. set lensSize(value: number);
  65837. get lensSize(): number;
  65838. /**
  65839. * Creates a new instance DepthOfFieldEffect
  65840. * @param scene The scene the effect belongs to.
  65841. * @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.
  65842. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65843. * @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)
  65844. */
  65845. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65846. /**
  65847. * Get the current class name of the current effet
  65848. * @returns "DepthOfFieldEffect"
  65849. */
  65850. getClassName(): string;
  65851. /**
  65852. * 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.
  65853. */
  65854. set depthTexture(value: RenderTargetTexture);
  65855. /**
  65856. * Disposes each of the internal effects for a given camera.
  65857. * @param camera The camera to dispose the effect on.
  65858. */
  65859. disposeEffects(camera: Camera): void;
  65860. /**
  65861. * @hidden Internal
  65862. */
  65863. _updateEffects(): void;
  65864. /**
  65865. * Internal
  65866. * @returns if all the contained post processes are ready.
  65867. * @hidden
  65868. */
  65869. _isReady(): boolean;
  65870. }
  65871. }
  65872. declare module "babylonjs/Shaders/displayPass.fragment" {
  65873. /** @hidden */
  65874. export var displayPassPixelShader: {
  65875. name: string;
  65876. shader: string;
  65877. };
  65878. }
  65879. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  65880. import { Nullable } from "babylonjs/types";
  65881. import { Camera } from "babylonjs/Cameras/camera";
  65882. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65883. import { Engine } from "babylonjs/Engines/engine";
  65884. import "babylonjs/Shaders/displayPass.fragment";
  65885. /**
  65886. * DisplayPassPostProcess which produces an output the same as it's input
  65887. */
  65888. export class DisplayPassPostProcess extends PostProcess {
  65889. /**
  65890. * Creates the DisplayPassPostProcess
  65891. * @param name The name of the effect.
  65892. * @param options The required width/height ratio to downsize to before computing the render pass.
  65893. * @param camera The camera to apply the render pass to.
  65894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65895. * @param engine The engine which the post process will be applied. (default: current engine)
  65896. * @param reusable If the post process can be reused on the same frame. (default: false)
  65897. */
  65898. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65899. }
  65900. }
  65901. declare module "babylonjs/Shaders/filter.fragment" {
  65902. /** @hidden */
  65903. export var filterPixelShader: {
  65904. name: string;
  65905. shader: string;
  65906. };
  65907. }
  65908. declare module "babylonjs/PostProcesses/filterPostProcess" {
  65909. import { Nullable } from "babylonjs/types";
  65910. import { Matrix } from "babylonjs/Maths/math.vector";
  65911. import { Camera } from "babylonjs/Cameras/camera";
  65912. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65913. import { Engine } from "babylonjs/Engines/engine";
  65914. import "babylonjs/Shaders/filter.fragment";
  65915. /**
  65916. * Applies a kernel filter to the image
  65917. */
  65918. export class FilterPostProcess extends PostProcess {
  65919. /** The matrix to be applied to the image */
  65920. kernelMatrix: Matrix;
  65921. /**
  65922. *
  65923. * @param name The name of the effect.
  65924. * @param kernelMatrix The matrix to be applied to the image
  65925. * @param options The required width/height ratio to downsize to before computing the render pass.
  65926. * @param camera The camera to apply the render pass to.
  65927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65928. * @param engine The engine which the post process will be applied. (default: current engine)
  65929. * @param reusable If the post process can be reused on the same frame. (default: false)
  65930. */
  65931. constructor(name: string,
  65932. /** The matrix to be applied to the image */
  65933. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65934. }
  65935. }
  65936. declare module "babylonjs/Shaders/fxaa.fragment" {
  65937. /** @hidden */
  65938. export var fxaaPixelShader: {
  65939. name: string;
  65940. shader: string;
  65941. };
  65942. }
  65943. declare module "babylonjs/Shaders/fxaa.vertex" {
  65944. /** @hidden */
  65945. export var fxaaVertexShader: {
  65946. name: string;
  65947. shader: string;
  65948. };
  65949. }
  65950. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  65951. import { Nullable } from "babylonjs/types";
  65952. import { Camera } from "babylonjs/Cameras/camera";
  65953. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65954. import { Engine } from "babylonjs/Engines/engine";
  65955. import "babylonjs/Shaders/fxaa.fragment";
  65956. import "babylonjs/Shaders/fxaa.vertex";
  65957. /**
  65958. * Fxaa post process
  65959. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65960. */
  65961. export class FxaaPostProcess extends PostProcess {
  65962. /** @hidden */
  65963. texelWidth: number;
  65964. /** @hidden */
  65965. texelHeight: number;
  65966. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65967. private _getDefines;
  65968. }
  65969. }
  65970. declare module "babylonjs/Shaders/grain.fragment" {
  65971. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65972. /** @hidden */
  65973. export var grainPixelShader: {
  65974. name: string;
  65975. shader: string;
  65976. };
  65977. }
  65978. declare module "babylonjs/PostProcesses/grainPostProcess" {
  65979. import { Nullable } from "babylonjs/types";
  65980. import { Camera } from "babylonjs/Cameras/camera";
  65981. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65982. import { Engine } from "babylonjs/Engines/engine";
  65983. import "babylonjs/Shaders/grain.fragment";
  65984. /**
  65985. * The GrainPostProcess adds noise to the image at mid luminance levels
  65986. */
  65987. export class GrainPostProcess extends PostProcess {
  65988. /**
  65989. * The intensity of the grain added (default: 30)
  65990. */
  65991. intensity: number;
  65992. /**
  65993. * If the grain should be randomized on every frame
  65994. */
  65995. animated: boolean;
  65996. /**
  65997. * Creates a new instance of @see GrainPostProcess
  65998. * @param name The name of the effect.
  65999. * @param options The required width/height ratio to downsize to before computing the render pass.
  66000. * @param camera The camera to apply the render pass to.
  66001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66002. * @param engine The engine which the post process will be applied. (default: current engine)
  66003. * @param reusable If the post process can be reused on the same frame. (default: false)
  66004. * @param textureType Type of textures used when performing the post process. (default: 0)
  66005. * @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)
  66006. */
  66007. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66008. }
  66009. }
  66010. declare module "babylonjs/Shaders/highlights.fragment" {
  66011. /** @hidden */
  66012. export var highlightsPixelShader: {
  66013. name: string;
  66014. shader: string;
  66015. };
  66016. }
  66017. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  66018. import { Nullable } from "babylonjs/types";
  66019. import { Camera } from "babylonjs/Cameras/camera";
  66020. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66021. import { Engine } from "babylonjs/Engines/engine";
  66022. import "babylonjs/Shaders/highlights.fragment";
  66023. /**
  66024. * Extracts highlights from the image
  66025. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66026. */
  66027. export class HighlightsPostProcess extends PostProcess {
  66028. /**
  66029. * Extracts highlights from the image
  66030. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66031. * @param name The name of the effect.
  66032. * @param options The required width/height ratio to downsize to before computing the render pass.
  66033. * @param camera The camera to apply the render pass to.
  66034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66035. * @param engine The engine which the post process will be applied. (default: current engine)
  66036. * @param reusable If the post process can be reused on the same frame. (default: false)
  66037. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66038. */
  66039. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66040. }
  66041. }
  66042. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  66043. /** @hidden */
  66044. export var mrtFragmentDeclaration: {
  66045. name: string;
  66046. shader: string;
  66047. };
  66048. }
  66049. declare module "babylonjs/Shaders/geometry.fragment" {
  66050. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  66051. /** @hidden */
  66052. export var geometryPixelShader: {
  66053. name: string;
  66054. shader: string;
  66055. };
  66056. }
  66057. declare module "babylonjs/Shaders/geometry.vertex" {
  66058. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66059. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66060. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66061. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66062. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66063. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66064. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66065. /** @hidden */
  66066. export var geometryVertexShader: {
  66067. name: string;
  66068. shader: string;
  66069. };
  66070. }
  66071. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  66072. import { Matrix } from "babylonjs/Maths/math.vector";
  66073. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66074. import { Mesh } from "babylonjs/Meshes/mesh";
  66075. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  66076. import { Effect } from "babylonjs/Materials/effect";
  66077. import { Scene } from "babylonjs/scene";
  66078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66079. import "babylonjs/Shaders/geometry.fragment";
  66080. import "babylonjs/Shaders/geometry.vertex";
  66081. /** @hidden */
  66082. interface ISavedTransformationMatrix {
  66083. world: Matrix;
  66084. viewProjection: Matrix;
  66085. }
  66086. /**
  66087. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66088. */
  66089. export class GeometryBufferRenderer {
  66090. /**
  66091. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66092. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66093. */
  66094. static readonly POSITION_TEXTURE_TYPE: number;
  66095. /**
  66096. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66097. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66098. */
  66099. static readonly VELOCITY_TEXTURE_TYPE: number;
  66100. /**
  66101. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66102. * in order to compute objects velocities when enableVelocity is set to "true"
  66103. * @hidden
  66104. */
  66105. _previousTransformationMatrices: {
  66106. [index: number]: ISavedTransformationMatrix;
  66107. };
  66108. /**
  66109. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66110. * in order to compute objects velocities when enableVelocity is set to "true"
  66111. * @hidden
  66112. */
  66113. _previousBonesTransformationMatrices: {
  66114. [index: number]: Float32Array;
  66115. };
  66116. /**
  66117. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66118. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66119. */
  66120. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66121. private _scene;
  66122. private _multiRenderTarget;
  66123. private _ratio;
  66124. private _enablePosition;
  66125. private _enableVelocity;
  66126. private _positionIndex;
  66127. private _velocityIndex;
  66128. protected _effect: Effect;
  66129. protected _cachedDefines: string;
  66130. /**
  66131. * Set the render list (meshes to be rendered) used in the G buffer.
  66132. */
  66133. set renderList(meshes: Mesh[]);
  66134. /**
  66135. * Gets wether or not G buffer are supported by the running hardware.
  66136. * This requires draw buffer supports
  66137. */
  66138. get isSupported(): boolean;
  66139. /**
  66140. * Returns the index of the given texture type in the G-Buffer textures array
  66141. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66142. * @returns the index of the given texture type in the G-Buffer textures array
  66143. */
  66144. getTextureIndex(textureType: number): number;
  66145. /**
  66146. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66147. */
  66148. get enablePosition(): boolean;
  66149. /**
  66150. * Sets whether or not objects positions are enabled for the G buffer.
  66151. */
  66152. set enablePosition(enable: boolean);
  66153. /**
  66154. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66155. */
  66156. get enableVelocity(): boolean;
  66157. /**
  66158. * Sets wether or not objects velocities are enabled for the G buffer.
  66159. */
  66160. set enableVelocity(enable: boolean);
  66161. /**
  66162. * Gets the scene associated with the buffer.
  66163. */
  66164. get scene(): Scene;
  66165. /**
  66166. * Gets the ratio used by the buffer during its creation.
  66167. * How big is the buffer related to the main canvas.
  66168. */
  66169. get ratio(): number;
  66170. /** @hidden */
  66171. static _SceneComponentInitialization: (scene: Scene) => void;
  66172. /**
  66173. * Creates a new G Buffer for the scene
  66174. * @param scene The scene the buffer belongs to
  66175. * @param ratio How big is the buffer related to the main canvas.
  66176. */
  66177. constructor(scene: Scene, ratio?: number);
  66178. /**
  66179. * Checks wether everything is ready to render a submesh to the G buffer.
  66180. * @param subMesh the submesh to check readiness for
  66181. * @param useInstances is the mesh drawn using instance or not
  66182. * @returns true if ready otherwise false
  66183. */
  66184. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66185. /**
  66186. * Gets the current underlying G Buffer.
  66187. * @returns the buffer
  66188. */
  66189. getGBuffer(): MultiRenderTarget;
  66190. /**
  66191. * Gets the number of samples used to render the buffer (anti aliasing).
  66192. */
  66193. get samples(): number;
  66194. /**
  66195. * Sets the number of samples used to render the buffer (anti aliasing).
  66196. */
  66197. set samples(value: number);
  66198. /**
  66199. * Disposes the renderer and frees up associated resources.
  66200. */
  66201. dispose(): void;
  66202. protected _createRenderTargets(): void;
  66203. private _copyBonesTransformationMatrices;
  66204. }
  66205. }
  66206. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  66207. import { Nullable } from "babylonjs/types";
  66208. import { Scene } from "babylonjs/scene";
  66209. import { ISceneComponent } from "babylonjs/sceneComponent";
  66210. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  66211. module "babylonjs/scene" {
  66212. interface Scene {
  66213. /** @hidden (Backing field) */
  66214. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66215. /**
  66216. * Gets or Sets the current geometry buffer associated to the scene.
  66217. */
  66218. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66219. /**
  66220. * Enables a GeometryBufferRender and associates it with the scene
  66221. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  66222. * @returns the GeometryBufferRenderer
  66223. */
  66224. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  66225. /**
  66226. * Disables the GeometryBufferRender associated with the scene
  66227. */
  66228. disableGeometryBufferRenderer(): void;
  66229. }
  66230. }
  66231. /**
  66232. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  66233. * in several rendering techniques.
  66234. */
  66235. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  66236. /**
  66237. * The component name helpful to identify the component in the list of scene components.
  66238. */
  66239. readonly name: string;
  66240. /**
  66241. * The scene the component belongs to.
  66242. */
  66243. scene: Scene;
  66244. /**
  66245. * Creates a new instance of the component for the given scene
  66246. * @param scene Defines the scene to register the component in
  66247. */
  66248. constructor(scene: Scene);
  66249. /**
  66250. * Registers the component in a given scene
  66251. */
  66252. register(): void;
  66253. /**
  66254. * Rebuilds the elements related to this component in case of
  66255. * context lost for instance.
  66256. */
  66257. rebuild(): void;
  66258. /**
  66259. * Disposes the component and the associated ressources
  66260. */
  66261. dispose(): void;
  66262. private _gatherRenderTargets;
  66263. }
  66264. }
  66265. declare module "babylonjs/Shaders/motionBlur.fragment" {
  66266. /** @hidden */
  66267. export var motionBlurPixelShader: {
  66268. name: string;
  66269. shader: string;
  66270. };
  66271. }
  66272. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  66273. import { Nullable } from "babylonjs/types";
  66274. import { Camera } from "babylonjs/Cameras/camera";
  66275. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66276. import { Scene } from "babylonjs/scene";
  66277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66278. import "babylonjs/Animations/animatable";
  66279. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66280. import "babylonjs/Shaders/motionBlur.fragment";
  66281. import { Engine } from "babylonjs/Engines/engine";
  66282. /**
  66283. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  66284. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  66285. * As an example, all you have to do is to create the post-process:
  66286. * var mb = new BABYLON.MotionBlurPostProcess(
  66287. * 'mb', // The name of the effect.
  66288. * scene, // The scene containing the objects to blur according to their velocity.
  66289. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  66290. * camera // The camera to apply the render pass to.
  66291. * );
  66292. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  66293. */
  66294. export class MotionBlurPostProcess extends PostProcess {
  66295. /**
  66296. * Defines how much the image is blurred by the movement. Default value is equal to 1
  66297. */
  66298. motionStrength: number;
  66299. /**
  66300. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  66301. */
  66302. get motionBlurSamples(): number;
  66303. /**
  66304. * Sets the number of iterations to be used for motion blur quality
  66305. */
  66306. set motionBlurSamples(samples: number);
  66307. private _motionBlurSamples;
  66308. private _geometryBufferRenderer;
  66309. /**
  66310. * Creates a new instance MotionBlurPostProcess
  66311. * @param name The name of the effect.
  66312. * @param scene The scene containing the objects to blur according to their velocity.
  66313. * @param options The required width/height ratio to downsize to before computing the render pass.
  66314. * @param camera The camera to apply the render pass to.
  66315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66316. * @param engine The engine which the post process will be applied. (default: current engine)
  66317. * @param reusable If the post process can be reused on the same frame. (default: false)
  66318. * @param textureType Type of textures used when performing the post process. (default: 0)
  66319. * @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)
  66320. */
  66321. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66322. /**
  66323. * Excludes the given skinned mesh from computing bones velocities.
  66324. * 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.
  66325. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  66326. */
  66327. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66328. /**
  66329. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  66330. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  66331. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  66332. */
  66333. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66334. /**
  66335. * Disposes the post process.
  66336. * @param camera The camera to dispose the post process on.
  66337. */
  66338. dispose(camera?: Camera): void;
  66339. }
  66340. }
  66341. declare module "babylonjs/Shaders/refraction.fragment" {
  66342. /** @hidden */
  66343. export var refractionPixelShader: {
  66344. name: string;
  66345. shader: string;
  66346. };
  66347. }
  66348. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  66349. import { Color3 } from "babylonjs/Maths/math.color";
  66350. import { Camera } from "babylonjs/Cameras/camera";
  66351. import { Texture } from "babylonjs/Materials/Textures/texture";
  66352. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66353. import { Engine } from "babylonjs/Engines/engine";
  66354. import "babylonjs/Shaders/refraction.fragment";
  66355. /**
  66356. * Post process which applies a refractin texture
  66357. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66358. */
  66359. export class RefractionPostProcess extends PostProcess {
  66360. /** the base color of the refraction (used to taint the rendering) */
  66361. color: Color3;
  66362. /** simulated refraction depth */
  66363. depth: number;
  66364. /** the coefficient of the base color (0 to remove base color tainting) */
  66365. colorLevel: number;
  66366. private _refTexture;
  66367. private _ownRefractionTexture;
  66368. /**
  66369. * Gets or sets the refraction texture
  66370. * Please note that you are responsible for disposing the texture if you set it manually
  66371. */
  66372. get refractionTexture(): Texture;
  66373. set refractionTexture(value: Texture);
  66374. /**
  66375. * Initializes the RefractionPostProcess
  66376. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66377. * @param name The name of the effect.
  66378. * @param refractionTextureUrl Url of the refraction texture to use
  66379. * @param color the base color of the refraction (used to taint the rendering)
  66380. * @param depth simulated refraction depth
  66381. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  66382. * @param camera The camera to apply the render pass to.
  66383. * @param options The required width/height ratio to downsize to before computing the render pass.
  66384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66385. * @param engine The engine which the post process will be applied. (default: current engine)
  66386. * @param reusable If the post process can be reused on the same frame. (default: false)
  66387. */
  66388. constructor(name: string, refractionTextureUrl: string,
  66389. /** the base color of the refraction (used to taint the rendering) */
  66390. color: Color3,
  66391. /** simulated refraction depth */
  66392. depth: number,
  66393. /** the coefficient of the base color (0 to remove base color tainting) */
  66394. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66395. /**
  66396. * Disposes of the post process
  66397. * @param camera Camera to dispose post process on
  66398. */
  66399. dispose(camera: Camera): void;
  66400. }
  66401. }
  66402. declare module "babylonjs/Shaders/sharpen.fragment" {
  66403. /** @hidden */
  66404. export var sharpenPixelShader: {
  66405. name: string;
  66406. shader: string;
  66407. };
  66408. }
  66409. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  66410. import { Nullable } from "babylonjs/types";
  66411. import { Camera } from "babylonjs/Cameras/camera";
  66412. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66413. import "babylonjs/Shaders/sharpen.fragment";
  66414. import { Engine } from "babylonjs/Engines/engine";
  66415. /**
  66416. * The SharpenPostProcess applies a sharpen kernel to every pixel
  66417. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66418. */
  66419. export class SharpenPostProcess extends PostProcess {
  66420. /**
  66421. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  66422. */
  66423. colorAmount: number;
  66424. /**
  66425. * How much sharpness should be applied (default: 0.3)
  66426. */
  66427. edgeAmount: number;
  66428. /**
  66429. * Creates a new instance ConvolutionPostProcess
  66430. * @param name The name of the effect.
  66431. * @param options The required width/height ratio to downsize to before computing the render pass.
  66432. * @param camera The camera to apply the render pass to.
  66433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66434. * @param engine The engine which the post process will be applied. (default: current engine)
  66435. * @param reusable If the post process can be reused on the same frame. (default: false)
  66436. * @param textureType Type of textures used when performing the post process. (default: 0)
  66437. * @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)
  66438. */
  66439. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66440. }
  66441. }
  66442. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  66443. import { Nullable } from "babylonjs/types";
  66444. import { Camera } from "babylonjs/Cameras/camera";
  66445. import { Engine } from "babylonjs/Engines/engine";
  66446. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66447. import { IInspectable } from "babylonjs/Misc/iInspectable";
  66448. /**
  66449. * PostProcessRenderPipeline
  66450. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66451. */
  66452. export class PostProcessRenderPipeline {
  66453. private engine;
  66454. private _renderEffects;
  66455. private _renderEffectsForIsolatedPass;
  66456. /**
  66457. * List of inspectable custom properties (used by the Inspector)
  66458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66459. */
  66460. inspectableCustomProperties: IInspectable[];
  66461. /**
  66462. * @hidden
  66463. */
  66464. protected _cameras: Camera[];
  66465. /** @hidden */
  66466. _name: string;
  66467. /**
  66468. * Gets pipeline name
  66469. */
  66470. get name(): string;
  66471. /** Gets the list of attached cameras */
  66472. get cameras(): Camera[];
  66473. /**
  66474. * Initializes a PostProcessRenderPipeline
  66475. * @param engine engine to add the pipeline to
  66476. * @param name name of the pipeline
  66477. */
  66478. constructor(engine: Engine, name: string);
  66479. /**
  66480. * Gets the class name
  66481. * @returns "PostProcessRenderPipeline"
  66482. */
  66483. getClassName(): string;
  66484. /**
  66485. * If all the render effects in the pipeline are supported
  66486. */
  66487. get isSupported(): boolean;
  66488. /**
  66489. * Adds an effect to the pipeline
  66490. * @param renderEffect the effect to add
  66491. */
  66492. addEffect(renderEffect: PostProcessRenderEffect): void;
  66493. /** @hidden */
  66494. _rebuild(): void;
  66495. /** @hidden */
  66496. _enableEffect(renderEffectName: string, cameras: Camera): void;
  66497. /** @hidden */
  66498. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  66499. /** @hidden */
  66500. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66501. /** @hidden */
  66502. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66503. /** @hidden */
  66504. _attachCameras(cameras: Camera, unique: boolean): void;
  66505. /** @hidden */
  66506. _attachCameras(cameras: Camera[], unique: boolean): void;
  66507. /** @hidden */
  66508. _detachCameras(cameras: Camera): void;
  66509. /** @hidden */
  66510. _detachCameras(cameras: Nullable<Camera[]>): void;
  66511. /** @hidden */
  66512. _update(): void;
  66513. /** @hidden */
  66514. _reset(): void;
  66515. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  66516. /**
  66517. * Disposes of the pipeline
  66518. */
  66519. dispose(): void;
  66520. }
  66521. }
  66522. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  66523. import { Camera } from "babylonjs/Cameras/camera";
  66524. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66525. /**
  66526. * PostProcessRenderPipelineManager class
  66527. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66528. */
  66529. export class PostProcessRenderPipelineManager {
  66530. private _renderPipelines;
  66531. /**
  66532. * Initializes a PostProcessRenderPipelineManager
  66533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66534. */
  66535. constructor();
  66536. /**
  66537. * Gets the list of supported render pipelines
  66538. */
  66539. get supportedPipelines(): PostProcessRenderPipeline[];
  66540. /**
  66541. * Adds a pipeline to the manager
  66542. * @param renderPipeline The pipeline to add
  66543. */
  66544. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  66545. /**
  66546. * Attaches a camera to the pipeline
  66547. * @param renderPipelineName The name of the pipeline to attach to
  66548. * @param cameras the camera to attach
  66549. * @param unique if the camera can be attached multiple times to the pipeline
  66550. */
  66551. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  66552. /**
  66553. * Detaches a camera from the pipeline
  66554. * @param renderPipelineName The name of the pipeline to detach from
  66555. * @param cameras the camera to detach
  66556. */
  66557. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66558. /**
  66559. * Enables an effect by name on a pipeline
  66560. * @param renderPipelineName the name of the pipeline to enable the effect in
  66561. * @param renderEffectName the name of the effect to enable
  66562. * @param cameras the cameras that the effect should be enabled on
  66563. */
  66564. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66565. /**
  66566. * Disables an effect by name on a pipeline
  66567. * @param renderPipelineName the name of the pipeline to disable the effect in
  66568. * @param renderEffectName the name of the effect to disable
  66569. * @param cameras the cameras that the effect should be disabled on
  66570. */
  66571. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66572. /**
  66573. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66574. */
  66575. update(): void;
  66576. /** @hidden */
  66577. _rebuild(): void;
  66578. /**
  66579. * Disposes of the manager and pipelines
  66580. */
  66581. dispose(): void;
  66582. }
  66583. }
  66584. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  66585. import { ISceneComponent } from "babylonjs/sceneComponent";
  66586. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66587. import { Scene } from "babylonjs/scene";
  66588. module "babylonjs/scene" {
  66589. interface Scene {
  66590. /** @hidden (Backing field) */
  66591. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66592. /**
  66593. * Gets the postprocess render pipeline manager
  66594. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66595. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66596. */
  66597. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66598. }
  66599. }
  66600. /**
  66601. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66602. */
  66603. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66604. /**
  66605. * The component name helpfull to identify the component in the list of scene components.
  66606. */
  66607. readonly name: string;
  66608. /**
  66609. * The scene the component belongs to.
  66610. */
  66611. scene: Scene;
  66612. /**
  66613. * Creates a new instance of the component for the given scene
  66614. * @param scene Defines the scene to register the component in
  66615. */
  66616. constructor(scene: Scene);
  66617. /**
  66618. * Registers the component in a given scene
  66619. */
  66620. register(): void;
  66621. /**
  66622. * Rebuilds the elements related to this component in case of
  66623. * context lost for instance.
  66624. */
  66625. rebuild(): void;
  66626. /**
  66627. * Disposes the component and the associated ressources
  66628. */
  66629. dispose(): void;
  66630. private _gatherRenderTargets;
  66631. }
  66632. }
  66633. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  66634. import { Nullable } from "babylonjs/types";
  66635. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66636. import { Camera } from "babylonjs/Cameras/camera";
  66637. import { IDisposable } from "babylonjs/scene";
  66638. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  66639. import { Scene } from "babylonjs/scene";
  66640. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  66641. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66642. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66643. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  66644. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66645. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66646. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  66647. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66648. import { Animation } from "babylonjs/Animations/animation";
  66649. /**
  66650. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66651. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66652. */
  66653. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66654. private _scene;
  66655. private _camerasToBeAttached;
  66656. /**
  66657. * ID of the sharpen post process,
  66658. */
  66659. private readonly SharpenPostProcessId;
  66660. /**
  66661. * @ignore
  66662. * ID of the image processing post process;
  66663. */
  66664. readonly ImageProcessingPostProcessId: string;
  66665. /**
  66666. * @ignore
  66667. * ID of the Fast Approximate Anti-Aliasing post process;
  66668. */
  66669. readonly FxaaPostProcessId: string;
  66670. /**
  66671. * ID of the chromatic aberration post process,
  66672. */
  66673. private readonly ChromaticAberrationPostProcessId;
  66674. /**
  66675. * ID of the grain post process
  66676. */
  66677. private readonly GrainPostProcessId;
  66678. /**
  66679. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66680. */
  66681. sharpen: SharpenPostProcess;
  66682. private _sharpenEffect;
  66683. private bloom;
  66684. /**
  66685. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66686. */
  66687. depthOfField: DepthOfFieldEffect;
  66688. /**
  66689. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66690. */
  66691. fxaa: FxaaPostProcess;
  66692. /**
  66693. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66694. */
  66695. imageProcessing: ImageProcessingPostProcess;
  66696. /**
  66697. * Chromatic aberration post process which will shift rgb colors in the image
  66698. */
  66699. chromaticAberration: ChromaticAberrationPostProcess;
  66700. private _chromaticAberrationEffect;
  66701. /**
  66702. * Grain post process which add noise to the image
  66703. */
  66704. grain: GrainPostProcess;
  66705. private _grainEffect;
  66706. /**
  66707. * Glow post process which adds a glow to emissive areas of the image
  66708. */
  66709. private _glowLayer;
  66710. /**
  66711. * Animations which can be used to tweak settings over a period of time
  66712. */
  66713. animations: Animation[];
  66714. private _imageProcessingConfigurationObserver;
  66715. private _sharpenEnabled;
  66716. private _bloomEnabled;
  66717. private _depthOfFieldEnabled;
  66718. private _depthOfFieldBlurLevel;
  66719. private _fxaaEnabled;
  66720. private _imageProcessingEnabled;
  66721. private _defaultPipelineTextureType;
  66722. private _bloomScale;
  66723. private _chromaticAberrationEnabled;
  66724. private _grainEnabled;
  66725. private _buildAllowed;
  66726. /**
  66727. * Gets active scene
  66728. */
  66729. get scene(): Scene;
  66730. /**
  66731. * Enable or disable the sharpen process from the pipeline
  66732. */
  66733. set sharpenEnabled(enabled: boolean);
  66734. get sharpenEnabled(): boolean;
  66735. private _resizeObserver;
  66736. private _hardwareScaleLevel;
  66737. private _bloomKernel;
  66738. /**
  66739. * Specifies the size of the bloom blur kernel, relative to the final output size
  66740. */
  66741. get bloomKernel(): number;
  66742. set bloomKernel(value: number);
  66743. /**
  66744. * Specifies the weight of the bloom in the final rendering
  66745. */
  66746. private _bloomWeight;
  66747. /**
  66748. * Specifies the luma threshold for the area that will be blurred by the bloom
  66749. */
  66750. private _bloomThreshold;
  66751. private _hdr;
  66752. /**
  66753. * The strength of the bloom.
  66754. */
  66755. set bloomWeight(value: number);
  66756. get bloomWeight(): number;
  66757. /**
  66758. * The strength of the bloom.
  66759. */
  66760. set bloomThreshold(value: number);
  66761. get bloomThreshold(): number;
  66762. /**
  66763. * The scale of the bloom, lower value will provide better performance.
  66764. */
  66765. set bloomScale(value: number);
  66766. get bloomScale(): number;
  66767. /**
  66768. * Enable or disable the bloom from the pipeline
  66769. */
  66770. set bloomEnabled(enabled: boolean);
  66771. get bloomEnabled(): boolean;
  66772. private _rebuildBloom;
  66773. /**
  66774. * If the depth of field is enabled.
  66775. */
  66776. get depthOfFieldEnabled(): boolean;
  66777. set depthOfFieldEnabled(enabled: boolean);
  66778. /**
  66779. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66780. */
  66781. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66782. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66783. /**
  66784. * If the anti aliasing is enabled.
  66785. */
  66786. set fxaaEnabled(enabled: boolean);
  66787. get fxaaEnabled(): boolean;
  66788. private _samples;
  66789. /**
  66790. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66791. */
  66792. set samples(sampleCount: number);
  66793. get samples(): number;
  66794. /**
  66795. * If image processing is enabled.
  66796. */
  66797. set imageProcessingEnabled(enabled: boolean);
  66798. get imageProcessingEnabled(): boolean;
  66799. /**
  66800. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66801. */
  66802. set glowLayerEnabled(enabled: boolean);
  66803. get glowLayerEnabled(): boolean;
  66804. /**
  66805. * Gets the glow layer (or null if not defined)
  66806. */
  66807. get glowLayer(): Nullable<GlowLayer>;
  66808. /**
  66809. * Enable or disable the chromaticAberration process from the pipeline
  66810. */
  66811. set chromaticAberrationEnabled(enabled: boolean);
  66812. get chromaticAberrationEnabled(): boolean;
  66813. /**
  66814. * Enable or disable the grain process from the pipeline
  66815. */
  66816. set grainEnabled(enabled: boolean);
  66817. get grainEnabled(): boolean;
  66818. /**
  66819. * @constructor
  66820. * @param name - The rendering pipeline name (default: "")
  66821. * @param hdr - If high dynamic range textures should be used (default: true)
  66822. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66823. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66824. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66825. */
  66826. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66827. /**
  66828. * Get the class name
  66829. * @returns "DefaultRenderingPipeline"
  66830. */
  66831. getClassName(): string;
  66832. /**
  66833. * Force the compilation of the entire pipeline.
  66834. */
  66835. prepare(): void;
  66836. private _hasCleared;
  66837. private _prevPostProcess;
  66838. private _prevPrevPostProcess;
  66839. private _setAutoClearAndTextureSharing;
  66840. private _depthOfFieldSceneObserver;
  66841. private _buildPipeline;
  66842. private _disposePostProcesses;
  66843. /**
  66844. * Adds a camera to the pipeline
  66845. * @param camera the camera to be added
  66846. */
  66847. addCamera(camera: Camera): void;
  66848. /**
  66849. * Removes a camera from the pipeline
  66850. * @param camera the camera to remove
  66851. */
  66852. removeCamera(camera: Camera): void;
  66853. /**
  66854. * Dispose of the pipeline and stop all post processes
  66855. */
  66856. dispose(): void;
  66857. /**
  66858. * Serialize the rendering pipeline (Used when exporting)
  66859. * @returns the serialized object
  66860. */
  66861. serialize(): any;
  66862. /**
  66863. * Parse the serialized pipeline
  66864. * @param source Source pipeline.
  66865. * @param scene The scene to load the pipeline to.
  66866. * @param rootUrl The URL of the serialized pipeline.
  66867. * @returns An instantiated pipeline from the serialized object.
  66868. */
  66869. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66870. }
  66871. }
  66872. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  66873. /** @hidden */
  66874. export var lensHighlightsPixelShader: {
  66875. name: string;
  66876. shader: string;
  66877. };
  66878. }
  66879. declare module "babylonjs/Shaders/depthOfField.fragment" {
  66880. /** @hidden */
  66881. export var depthOfFieldPixelShader: {
  66882. name: string;
  66883. shader: string;
  66884. };
  66885. }
  66886. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  66887. import { Camera } from "babylonjs/Cameras/camera";
  66888. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66889. import { Scene } from "babylonjs/scene";
  66890. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66891. import "babylonjs/Shaders/chromaticAberration.fragment";
  66892. import "babylonjs/Shaders/lensHighlights.fragment";
  66893. import "babylonjs/Shaders/depthOfField.fragment";
  66894. /**
  66895. * BABYLON.JS Chromatic Aberration GLSL Shader
  66896. * Author: Olivier Guyot
  66897. * Separates very slightly R, G and B colors on the edges of the screen
  66898. * Inspired by Francois Tarlier & Martins Upitis
  66899. */
  66900. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66901. /**
  66902. * @ignore
  66903. * The chromatic aberration PostProcess id in the pipeline
  66904. */
  66905. LensChromaticAberrationEffect: string;
  66906. /**
  66907. * @ignore
  66908. * The highlights enhancing PostProcess id in the pipeline
  66909. */
  66910. HighlightsEnhancingEffect: string;
  66911. /**
  66912. * @ignore
  66913. * The depth-of-field PostProcess id in the pipeline
  66914. */
  66915. LensDepthOfFieldEffect: string;
  66916. private _scene;
  66917. private _depthTexture;
  66918. private _grainTexture;
  66919. private _chromaticAberrationPostProcess;
  66920. private _highlightsPostProcess;
  66921. private _depthOfFieldPostProcess;
  66922. private _edgeBlur;
  66923. private _grainAmount;
  66924. private _chromaticAberration;
  66925. private _distortion;
  66926. private _highlightsGain;
  66927. private _highlightsThreshold;
  66928. private _dofDistance;
  66929. private _dofAperture;
  66930. private _dofDarken;
  66931. private _dofPentagon;
  66932. private _blurNoise;
  66933. /**
  66934. * @constructor
  66935. *
  66936. * Effect parameters are as follow:
  66937. * {
  66938. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66939. * edge_blur: number; // from 0 to x (1 for realism)
  66940. * distortion: number; // from 0 to x (1 for realism)
  66941. * grain_amount: number; // from 0 to 1
  66942. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66943. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66944. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66945. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66946. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66947. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66948. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66949. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66950. * }
  66951. * Note: if an effect parameter is unset, effect is disabled
  66952. *
  66953. * @param name The rendering pipeline name
  66954. * @param parameters - An object containing all parameters (see above)
  66955. * @param scene The scene linked to this pipeline
  66956. * @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)
  66957. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66958. */
  66959. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66960. /**
  66961. * Get the class name
  66962. * @returns "LensRenderingPipeline"
  66963. */
  66964. getClassName(): string;
  66965. /**
  66966. * Gets associated scene
  66967. */
  66968. get scene(): Scene;
  66969. /**
  66970. * Gets or sets the edge blur
  66971. */
  66972. get edgeBlur(): number;
  66973. set edgeBlur(value: number);
  66974. /**
  66975. * Gets or sets the grain amount
  66976. */
  66977. get grainAmount(): number;
  66978. set grainAmount(value: number);
  66979. /**
  66980. * Gets or sets the chromatic aberration amount
  66981. */
  66982. get chromaticAberration(): number;
  66983. set chromaticAberration(value: number);
  66984. /**
  66985. * Gets or sets the depth of field aperture
  66986. */
  66987. get dofAperture(): number;
  66988. set dofAperture(value: number);
  66989. /**
  66990. * Gets or sets the edge distortion
  66991. */
  66992. get edgeDistortion(): number;
  66993. set edgeDistortion(value: number);
  66994. /**
  66995. * Gets or sets the depth of field distortion
  66996. */
  66997. get dofDistortion(): number;
  66998. set dofDistortion(value: number);
  66999. /**
  67000. * Gets or sets the darken out of focus amount
  67001. */
  67002. get darkenOutOfFocus(): number;
  67003. set darkenOutOfFocus(value: number);
  67004. /**
  67005. * Gets or sets a boolean indicating if blur noise is enabled
  67006. */
  67007. get blurNoise(): boolean;
  67008. set blurNoise(value: boolean);
  67009. /**
  67010. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67011. */
  67012. get pentagonBokeh(): boolean;
  67013. set pentagonBokeh(value: boolean);
  67014. /**
  67015. * Gets or sets the highlight grain amount
  67016. */
  67017. get highlightsGain(): number;
  67018. set highlightsGain(value: number);
  67019. /**
  67020. * Gets or sets the highlight threshold
  67021. */
  67022. get highlightsThreshold(): number;
  67023. set highlightsThreshold(value: number);
  67024. /**
  67025. * Sets the amount of blur at the edges
  67026. * @param amount blur amount
  67027. */
  67028. setEdgeBlur(amount: number): void;
  67029. /**
  67030. * Sets edge blur to 0
  67031. */
  67032. disableEdgeBlur(): void;
  67033. /**
  67034. * Sets the amout of grain
  67035. * @param amount Amount of grain
  67036. */
  67037. setGrainAmount(amount: number): void;
  67038. /**
  67039. * Set grain amount to 0
  67040. */
  67041. disableGrain(): void;
  67042. /**
  67043. * Sets the chromatic aberration amount
  67044. * @param amount amount of chromatic aberration
  67045. */
  67046. setChromaticAberration(amount: number): void;
  67047. /**
  67048. * Sets chromatic aberration amount to 0
  67049. */
  67050. disableChromaticAberration(): void;
  67051. /**
  67052. * Sets the EdgeDistortion amount
  67053. * @param amount amount of EdgeDistortion
  67054. */
  67055. setEdgeDistortion(amount: number): void;
  67056. /**
  67057. * Sets edge distortion to 0
  67058. */
  67059. disableEdgeDistortion(): void;
  67060. /**
  67061. * Sets the FocusDistance amount
  67062. * @param amount amount of FocusDistance
  67063. */
  67064. setFocusDistance(amount: number): void;
  67065. /**
  67066. * Disables depth of field
  67067. */
  67068. disableDepthOfField(): void;
  67069. /**
  67070. * Sets the Aperture amount
  67071. * @param amount amount of Aperture
  67072. */
  67073. setAperture(amount: number): void;
  67074. /**
  67075. * Sets the DarkenOutOfFocus amount
  67076. * @param amount amount of DarkenOutOfFocus
  67077. */
  67078. setDarkenOutOfFocus(amount: number): void;
  67079. private _pentagonBokehIsEnabled;
  67080. /**
  67081. * Creates a pentagon bokeh effect
  67082. */
  67083. enablePentagonBokeh(): void;
  67084. /**
  67085. * Disables the pentagon bokeh effect
  67086. */
  67087. disablePentagonBokeh(): void;
  67088. /**
  67089. * Enables noise blur
  67090. */
  67091. enableNoiseBlur(): void;
  67092. /**
  67093. * Disables noise blur
  67094. */
  67095. disableNoiseBlur(): void;
  67096. /**
  67097. * Sets the HighlightsGain amount
  67098. * @param amount amount of HighlightsGain
  67099. */
  67100. setHighlightsGain(amount: number): void;
  67101. /**
  67102. * Sets the HighlightsThreshold amount
  67103. * @param amount amount of HighlightsThreshold
  67104. */
  67105. setHighlightsThreshold(amount: number): void;
  67106. /**
  67107. * Disables highlights
  67108. */
  67109. disableHighlights(): void;
  67110. /**
  67111. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67112. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67113. */
  67114. dispose(disableDepthRender?: boolean): void;
  67115. private _createChromaticAberrationPostProcess;
  67116. private _createHighlightsPostProcess;
  67117. private _createDepthOfFieldPostProcess;
  67118. private _createGrainTexture;
  67119. }
  67120. }
  67121. declare module "babylonjs/Shaders/ssao2.fragment" {
  67122. /** @hidden */
  67123. export var ssao2PixelShader: {
  67124. name: string;
  67125. shader: string;
  67126. };
  67127. }
  67128. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  67129. /** @hidden */
  67130. export var ssaoCombinePixelShader: {
  67131. name: string;
  67132. shader: string;
  67133. };
  67134. }
  67135. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  67136. import { Camera } from "babylonjs/Cameras/camera";
  67137. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67138. import { Scene } from "babylonjs/scene";
  67139. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67140. import "babylonjs/Shaders/ssao2.fragment";
  67141. import "babylonjs/Shaders/ssaoCombine.fragment";
  67142. /**
  67143. * Render pipeline to produce ssao effect
  67144. */
  67145. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67146. /**
  67147. * @ignore
  67148. * The PassPostProcess id in the pipeline that contains the original scene color
  67149. */
  67150. SSAOOriginalSceneColorEffect: string;
  67151. /**
  67152. * @ignore
  67153. * The SSAO PostProcess id in the pipeline
  67154. */
  67155. SSAORenderEffect: string;
  67156. /**
  67157. * @ignore
  67158. * The horizontal blur PostProcess id in the pipeline
  67159. */
  67160. SSAOBlurHRenderEffect: string;
  67161. /**
  67162. * @ignore
  67163. * The vertical blur PostProcess id in the pipeline
  67164. */
  67165. SSAOBlurVRenderEffect: string;
  67166. /**
  67167. * @ignore
  67168. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67169. */
  67170. SSAOCombineRenderEffect: string;
  67171. /**
  67172. * The output strength of the SSAO post-process. Default value is 1.0.
  67173. */
  67174. totalStrength: number;
  67175. /**
  67176. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67177. */
  67178. maxZ: number;
  67179. /**
  67180. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67181. */
  67182. minZAspect: number;
  67183. private _samples;
  67184. /**
  67185. * Number of samples used for the SSAO calculations. Default value is 8
  67186. */
  67187. set samples(n: number);
  67188. get samples(): number;
  67189. private _textureSamples;
  67190. /**
  67191. * Number of samples to use for antialiasing
  67192. */
  67193. set textureSamples(n: number);
  67194. get textureSamples(): number;
  67195. /**
  67196. * Ratio object used for SSAO ratio and blur ratio
  67197. */
  67198. private _ratio;
  67199. /**
  67200. * Dynamically generated sphere sampler.
  67201. */
  67202. private _sampleSphere;
  67203. /**
  67204. * Blur filter offsets
  67205. */
  67206. private _samplerOffsets;
  67207. private _expensiveBlur;
  67208. /**
  67209. * If bilateral blur should be used
  67210. */
  67211. set expensiveBlur(b: boolean);
  67212. get expensiveBlur(): boolean;
  67213. /**
  67214. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67215. */
  67216. radius: number;
  67217. /**
  67218. * The base color of the SSAO post-process
  67219. * The final result is "base + ssao" between [0, 1]
  67220. */
  67221. base: number;
  67222. /**
  67223. * Support test.
  67224. */
  67225. static get IsSupported(): boolean;
  67226. private _scene;
  67227. private _depthTexture;
  67228. private _normalTexture;
  67229. private _randomTexture;
  67230. private _originalColorPostProcess;
  67231. private _ssaoPostProcess;
  67232. private _blurHPostProcess;
  67233. private _blurVPostProcess;
  67234. private _ssaoCombinePostProcess;
  67235. /**
  67236. * Gets active scene
  67237. */
  67238. get scene(): Scene;
  67239. /**
  67240. * @constructor
  67241. * @param name The rendering pipeline name
  67242. * @param scene The scene linked to this pipeline
  67243. * @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 }
  67244. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67245. */
  67246. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67247. /**
  67248. * Get the class name
  67249. * @returns "SSAO2RenderingPipeline"
  67250. */
  67251. getClassName(): string;
  67252. /**
  67253. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67254. */
  67255. dispose(disableGeometryBufferRenderer?: boolean): void;
  67256. private _createBlurPostProcess;
  67257. /** @hidden */
  67258. _rebuild(): void;
  67259. private _bits;
  67260. private _radicalInverse_VdC;
  67261. private _hammersley;
  67262. private _hemisphereSample_uniform;
  67263. private _generateHemisphere;
  67264. private _createSSAOPostProcess;
  67265. private _createSSAOCombinePostProcess;
  67266. private _createRandomTexture;
  67267. /**
  67268. * Serialize the rendering pipeline (Used when exporting)
  67269. * @returns the serialized object
  67270. */
  67271. serialize(): any;
  67272. /**
  67273. * Parse the serialized pipeline
  67274. * @param source Source pipeline.
  67275. * @param scene The scene to load the pipeline to.
  67276. * @param rootUrl The URL of the serialized pipeline.
  67277. * @returns An instantiated pipeline from the serialized object.
  67278. */
  67279. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  67280. }
  67281. }
  67282. declare module "babylonjs/Shaders/ssao.fragment" {
  67283. /** @hidden */
  67284. export var ssaoPixelShader: {
  67285. name: string;
  67286. shader: string;
  67287. };
  67288. }
  67289. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  67290. import { Camera } from "babylonjs/Cameras/camera";
  67291. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67292. import { Scene } from "babylonjs/scene";
  67293. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67294. import "babylonjs/Shaders/ssao.fragment";
  67295. import "babylonjs/Shaders/ssaoCombine.fragment";
  67296. /**
  67297. * Render pipeline to produce ssao effect
  67298. */
  67299. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  67300. /**
  67301. * @ignore
  67302. * The PassPostProcess id in the pipeline that contains the original scene color
  67303. */
  67304. SSAOOriginalSceneColorEffect: string;
  67305. /**
  67306. * @ignore
  67307. * The SSAO PostProcess id in the pipeline
  67308. */
  67309. SSAORenderEffect: string;
  67310. /**
  67311. * @ignore
  67312. * The horizontal blur PostProcess id in the pipeline
  67313. */
  67314. SSAOBlurHRenderEffect: string;
  67315. /**
  67316. * @ignore
  67317. * The vertical blur PostProcess id in the pipeline
  67318. */
  67319. SSAOBlurVRenderEffect: string;
  67320. /**
  67321. * @ignore
  67322. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67323. */
  67324. SSAOCombineRenderEffect: string;
  67325. /**
  67326. * The output strength of the SSAO post-process. Default value is 1.0.
  67327. */
  67328. totalStrength: number;
  67329. /**
  67330. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  67331. */
  67332. radius: number;
  67333. /**
  67334. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  67335. * Must not be equal to fallOff and superior to fallOff.
  67336. * Default value is 0.0075
  67337. */
  67338. area: number;
  67339. /**
  67340. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  67341. * Must not be equal to area and inferior to area.
  67342. * Default value is 0.000001
  67343. */
  67344. fallOff: number;
  67345. /**
  67346. * The base color of the SSAO post-process
  67347. * The final result is "base + ssao" between [0, 1]
  67348. */
  67349. base: number;
  67350. private _scene;
  67351. private _depthTexture;
  67352. private _randomTexture;
  67353. private _originalColorPostProcess;
  67354. private _ssaoPostProcess;
  67355. private _blurHPostProcess;
  67356. private _blurVPostProcess;
  67357. private _ssaoCombinePostProcess;
  67358. private _firstUpdate;
  67359. /**
  67360. * Gets active scene
  67361. */
  67362. get scene(): Scene;
  67363. /**
  67364. * @constructor
  67365. * @param name - The rendering pipeline name
  67366. * @param scene - The scene linked to this pipeline
  67367. * @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 }
  67368. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  67369. */
  67370. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67371. /**
  67372. * Get the class name
  67373. * @returns "SSAORenderingPipeline"
  67374. */
  67375. getClassName(): string;
  67376. /**
  67377. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67378. */
  67379. dispose(disableDepthRender?: boolean): void;
  67380. private _createBlurPostProcess;
  67381. /** @hidden */
  67382. _rebuild(): void;
  67383. private _createSSAOPostProcess;
  67384. private _createSSAOCombinePostProcess;
  67385. private _createRandomTexture;
  67386. }
  67387. }
  67388. declare module "babylonjs/Shaders/standard.fragment" {
  67389. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  67390. /** @hidden */
  67391. export var standardPixelShader: {
  67392. name: string;
  67393. shader: string;
  67394. };
  67395. }
  67396. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  67397. import { Nullable } from "babylonjs/types";
  67398. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67399. import { Camera } from "babylonjs/Cameras/camera";
  67400. import { Texture } from "babylonjs/Materials/Textures/texture";
  67401. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67402. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67403. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67404. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  67405. import { IDisposable } from "babylonjs/scene";
  67406. import { SpotLight } from "babylonjs/Lights/spotLight";
  67407. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  67408. import { Scene } from "babylonjs/scene";
  67409. import { Animation } from "babylonjs/Animations/animation";
  67410. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67411. import "babylonjs/Shaders/standard.fragment";
  67412. /**
  67413. * Standard rendering pipeline
  67414. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67415. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  67416. */
  67417. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67418. /**
  67419. * Public members
  67420. */
  67421. /**
  67422. * Post-process which contains the original scene color before the pipeline applies all the effects
  67423. */
  67424. originalPostProcess: Nullable<PostProcess>;
  67425. /**
  67426. * Post-process used to down scale an image x4
  67427. */
  67428. downSampleX4PostProcess: Nullable<PostProcess>;
  67429. /**
  67430. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  67431. */
  67432. brightPassPostProcess: Nullable<PostProcess>;
  67433. /**
  67434. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  67435. */
  67436. blurHPostProcesses: PostProcess[];
  67437. /**
  67438. * Post-process array storing all the vertical blur post-processes used by the pipeline
  67439. */
  67440. blurVPostProcesses: PostProcess[];
  67441. /**
  67442. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  67443. */
  67444. textureAdderPostProcess: Nullable<PostProcess>;
  67445. /**
  67446. * Post-process used to create volumetric lighting effect
  67447. */
  67448. volumetricLightPostProcess: Nullable<PostProcess>;
  67449. /**
  67450. * Post-process used to smooth the previous volumetric light post-process on the X axis
  67451. */
  67452. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  67453. /**
  67454. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  67455. */
  67456. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  67457. /**
  67458. * Post-process used to merge the volumetric light effect and the real scene color
  67459. */
  67460. volumetricLightMergePostProces: Nullable<PostProcess>;
  67461. /**
  67462. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  67463. */
  67464. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  67465. /**
  67466. * Base post-process used to calculate the average luminance of the final image for HDR
  67467. */
  67468. luminancePostProcess: Nullable<PostProcess>;
  67469. /**
  67470. * Post-processes used to create down sample post-processes in order to get
  67471. * the average luminance of the final image for HDR
  67472. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  67473. */
  67474. luminanceDownSamplePostProcesses: PostProcess[];
  67475. /**
  67476. * Post-process used to create a HDR effect (light adaptation)
  67477. */
  67478. hdrPostProcess: Nullable<PostProcess>;
  67479. /**
  67480. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  67481. */
  67482. textureAdderFinalPostProcess: Nullable<PostProcess>;
  67483. /**
  67484. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  67485. */
  67486. lensFlareFinalPostProcess: Nullable<PostProcess>;
  67487. /**
  67488. * Post-process used to merge the final HDR post-process and the real scene color
  67489. */
  67490. hdrFinalPostProcess: Nullable<PostProcess>;
  67491. /**
  67492. * Post-process used to create a lens flare effect
  67493. */
  67494. lensFlarePostProcess: Nullable<PostProcess>;
  67495. /**
  67496. * Post-process that merges the result of the lens flare post-process and the real scene color
  67497. */
  67498. lensFlareComposePostProcess: Nullable<PostProcess>;
  67499. /**
  67500. * Post-process used to create a motion blur effect
  67501. */
  67502. motionBlurPostProcess: Nullable<PostProcess>;
  67503. /**
  67504. * Post-process used to create a depth of field effect
  67505. */
  67506. depthOfFieldPostProcess: Nullable<PostProcess>;
  67507. /**
  67508. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67509. */
  67510. fxaaPostProcess: Nullable<FxaaPostProcess>;
  67511. /**
  67512. * Represents the brightness threshold in order to configure the illuminated surfaces
  67513. */
  67514. brightThreshold: number;
  67515. /**
  67516. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  67517. */
  67518. blurWidth: number;
  67519. /**
  67520. * Sets if the blur for highlighted surfaces must be only horizontal
  67521. */
  67522. horizontalBlur: boolean;
  67523. /**
  67524. * Gets the overall exposure used by the pipeline
  67525. */
  67526. get exposure(): number;
  67527. /**
  67528. * Sets the overall exposure used by the pipeline
  67529. */
  67530. set exposure(value: number);
  67531. /**
  67532. * Texture used typically to simulate "dirty" on camera lens
  67533. */
  67534. lensTexture: Nullable<Texture>;
  67535. /**
  67536. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67537. */
  67538. volumetricLightCoefficient: number;
  67539. /**
  67540. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67541. */
  67542. volumetricLightPower: number;
  67543. /**
  67544. * Used the set the blur intensity to smooth the volumetric lights
  67545. */
  67546. volumetricLightBlurScale: number;
  67547. /**
  67548. * Light (spot or directional) used to generate the volumetric lights rays
  67549. * The source light must have a shadow generate so the pipeline can get its
  67550. * depth map
  67551. */
  67552. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67553. /**
  67554. * For eye adaptation, represents the minimum luminance the eye can see
  67555. */
  67556. hdrMinimumLuminance: number;
  67557. /**
  67558. * For eye adaptation, represents the decrease luminance speed
  67559. */
  67560. hdrDecreaseRate: number;
  67561. /**
  67562. * For eye adaptation, represents the increase luminance speed
  67563. */
  67564. hdrIncreaseRate: number;
  67565. /**
  67566. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67567. */
  67568. get hdrAutoExposure(): boolean;
  67569. /**
  67570. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67571. */
  67572. set hdrAutoExposure(value: boolean);
  67573. /**
  67574. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67575. */
  67576. lensColorTexture: Nullable<Texture>;
  67577. /**
  67578. * The overall strengh for the lens flare effect
  67579. */
  67580. lensFlareStrength: number;
  67581. /**
  67582. * Dispersion coefficient for lens flare ghosts
  67583. */
  67584. lensFlareGhostDispersal: number;
  67585. /**
  67586. * Main lens flare halo width
  67587. */
  67588. lensFlareHaloWidth: number;
  67589. /**
  67590. * Based on the lens distortion effect, defines how much the lens flare result
  67591. * is distorted
  67592. */
  67593. lensFlareDistortionStrength: number;
  67594. /**
  67595. * Configures the blur intensity used for for lens flare (halo)
  67596. */
  67597. lensFlareBlurWidth: number;
  67598. /**
  67599. * Lens star texture must be used to simulate rays on the flares and is available
  67600. * in the documentation
  67601. */
  67602. lensStarTexture: Nullable<Texture>;
  67603. /**
  67604. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67605. * flare effect by taking account of the dirt texture
  67606. */
  67607. lensFlareDirtTexture: Nullable<Texture>;
  67608. /**
  67609. * Represents the focal length for the depth of field effect
  67610. */
  67611. depthOfFieldDistance: number;
  67612. /**
  67613. * Represents the blur intensity for the blurred part of the depth of field effect
  67614. */
  67615. depthOfFieldBlurWidth: number;
  67616. /**
  67617. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67618. */
  67619. get motionStrength(): number;
  67620. /**
  67621. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67622. */
  67623. set motionStrength(strength: number);
  67624. /**
  67625. * Gets wether or not the motion blur post-process is object based or screen based.
  67626. */
  67627. get objectBasedMotionBlur(): boolean;
  67628. /**
  67629. * Sets wether or not the motion blur post-process should be object based or screen based
  67630. */
  67631. set objectBasedMotionBlur(value: boolean);
  67632. /**
  67633. * List of animations for the pipeline (IAnimatable implementation)
  67634. */
  67635. animations: Animation[];
  67636. /**
  67637. * Private members
  67638. */
  67639. private _scene;
  67640. private _currentDepthOfFieldSource;
  67641. private _basePostProcess;
  67642. private _fixedExposure;
  67643. private _currentExposure;
  67644. private _hdrAutoExposure;
  67645. private _hdrCurrentLuminance;
  67646. private _motionStrength;
  67647. private _isObjectBasedMotionBlur;
  67648. private _floatTextureType;
  67649. private _camerasToBeAttached;
  67650. private _ratio;
  67651. private _bloomEnabled;
  67652. private _depthOfFieldEnabled;
  67653. private _vlsEnabled;
  67654. private _lensFlareEnabled;
  67655. private _hdrEnabled;
  67656. private _motionBlurEnabled;
  67657. private _fxaaEnabled;
  67658. private _motionBlurSamples;
  67659. private _volumetricLightStepsCount;
  67660. private _samples;
  67661. /**
  67662. * @ignore
  67663. * Specifies if the bloom pipeline is enabled
  67664. */
  67665. get BloomEnabled(): boolean;
  67666. set BloomEnabled(enabled: boolean);
  67667. /**
  67668. * @ignore
  67669. * Specifies if the depth of field pipeline is enabed
  67670. */
  67671. get DepthOfFieldEnabled(): boolean;
  67672. set DepthOfFieldEnabled(enabled: boolean);
  67673. /**
  67674. * @ignore
  67675. * Specifies if the lens flare pipeline is enabed
  67676. */
  67677. get LensFlareEnabled(): boolean;
  67678. set LensFlareEnabled(enabled: boolean);
  67679. /**
  67680. * @ignore
  67681. * Specifies if the HDR pipeline is enabled
  67682. */
  67683. get HDREnabled(): boolean;
  67684. set HDREnabled(enabled: boolean);
  67685. /**
  67686. * @ignore
  67687. * Specifies if the volumetric lights scattering effect is enabled
  67688. */
  67689. get VLSEnabled(): boolean;
  67690. set VLSEnabled(enabled: boolean);
  67691. /**
  67692. * @ignore
  67693. * Specifies if the motion blur effect is enabled
  67694. */
  67695. get MotionBlurEnabled(): boolean;
  67696. set MotionBlurEnabled(enabled: boolean);
  67697. /**
  67698. * Specifies if anti-aliasing is enabled
  67699. */
  67700. get fxaaEnabled(): boolean;
  67701. set fxaaEnabled(enabled: boolean);
  67702. /**
  67703. * Specifies the number of steps used to calculate the volumetric lights
  67704. * Typically in interval [50, 200]
  67705. */
  67706. get volumetricLightStepsCount(): number;
  67707. set volumetricLightStepsCount(count: number);
  67708. /**
  67709. * Specifies the number of samples used for the motion blur effect
  67710. * Typically in interval [16, 64]
  67711. */
  67712. get motionBlurSamples(): number;
  67713. set motionBlurSamples(samples: number);
  67714. /**
  67715. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67716. */
  67717. get samples(): number;
  67718. set samples(sampleCount: number);
  67719. /**
  67720. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67721. * @constructor
  67722. * @param name The rendering pipeline name
  67723. * @param scene The scene linked to this pipeline
  67724. * @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)
  67725. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67726. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67727. */
  67728. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67729. private _buildPipeline;
  67730. private _createDownSampleX4PostProcess;
  67731. private _createBrightPassPostProcess;
  67732. private _createBlurPostProcesses;
  67733. private _createTextureAdderPostProcess;
  67734. private _createVolumetricLightPostProcess;
  67735. private _createLuminancePostProcesses;
  67736. private _createHdrPostProcess;
  67737. private _createLensFlarePostProcess;
  67738. private _createDepthOfFieldPostProcess;
  67739. private _createMotionBlurPostProcess;
  67740. private _getDepthTexture;
  67741. private _disposePostProcesses;
  67742. /**
  67743. * Dispose of the pipeline and stop all post processes
  67744. */
  67745. dispose(): void;
  67746. /**
  67747. * Serialize the rendering pipeline (Used when exporting)
  67748. * @returns the serialized object
  67749. */
  67750. serialize(): any;
  67751. /**
  67752. * Parse the serialized pipeline
  67753. * @param source Source pipeline.
  67754. * @param scene The scene to load the pipeline to.
  67755. * @param rootUrl The URL of the serialized pipeline.
  67756. * @returns An instantiated pipeline from the serialized object.
  67757. */
  67758. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67759. /**
  67760. * Luminance steps
  67761. */
  67762. static LuminanceSteps: number;
  67763. }
  67764. }
  67765. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  67766. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  67767. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  67768. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  67769. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  67770. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  67771. }
  67772. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  67773. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  67774. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67775. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67776. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67777. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67778. }
  67779. declare module "babylonjs/Shaders/tonemap.fragment" {
  67780. /** @hidden */
  67781. export var tonemapPixelShader: {
  67782. name: string;
  67783. shader: string;
  67784. };
  67785. }
  67786. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  67787. import { Camera } from "babylonjs/Cameras/camera";
  67788. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67789. import "babylonjs/Shaders/tonemap.fragment";
  67790. import { Engine } from "babylonjs/Engines/engine";
  67791. /** Defines operator used for tonemapping */
  67792. export enum TonemappingOperator {
  67793. /** Hable */
  67794. Hable = 0,
  67795. /** Reinhard */
  67796. Reinhard = 1,
  67797. /** HejiDawson */
  67798. HejiDawson = 2,
  67799. /** Photographic */
  67800. Photographic = 3
  67801. }
  67802. /**
  67803. * Defines a post process to apply tone mapping
  67804. */
  67805. export class TonemapPostProcess extends PostProcess {
  67806. private _operator;
  67807. /** Defines the required exposure adjustement */
  67808. exposureAdjustment: number;
  67809. /**
  67810. * Creates a new TonemapPostProcess
  67811. * @param name defines the name of the postprocess
  67812. * @param _operator defines the operator to use
  67813. * @param exposureAdjustment defines the required exposure adjustement
  67814. * @param camera defines the camera to use (can be null)
  67815. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67816. * @param engine defines the hosting engine (can be ignore if camera is set)
  67817. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67818. */
  67819. constructor(name: string, _operator: TonemappingOperator,
  67820. /** Defines the required exposure adjustement */
  67821. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67822. }
  67823. }
  67824. declare module "babylonjs/Shaders/depth.vertex" {
  67825. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67826. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67827. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67828. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67829. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67830. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67831. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67832. /** @hidden */
  67833. export var depthVertexShader: {
  67834. name: string;
  67835. shader: string;
  67836. };
  67837. }
  67838. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  67839. /** @hidden */
  67840. export var volumetricLightScatteringPixelShader: {
  67841. name: string;
  67842. shader: string;
  67843. };
  67844. }
  67845. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  67846. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67847. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67848. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67849. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67850. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67851. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67852. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67853. /** @hidden */
  67854. export var volumetricLightScatteringPassVertexShader: {
  67855. name: string;
  67856. shader: string;
  67857. };
  67858. }
  67859. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  67860. /** @hidden */
  67861. export var volumetricLightScatteringPassPixelShader: {
  67862. name: string;
  67863. shader: string;
  67864. };
  67865. }
  67866. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  67867. import { Vector3 } from "babylonjs/Maths/math.vector";
  67868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67869. import { Mesh } from "babylonjs/Meshes/mesh";
  67870. import { Camera } from "babylonjs/Cameras/camera";
  67871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67872. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67873. import { Scene } from "babylonjs/scene";
  67874. import "babylonjs/Meshes/Builders/planeBuilder";
  67875. import "babylonjs/Shaders/depth.vertex";
  67876. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  67877. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  67878. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  67879. import { Engine } from "babylonjs/Engines/engine";
  67880. /**
  67881. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67882. */
  67883. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67884. private _volumetricLightScatteringPass;
  67885. private _volumetricLightScatteringRTT;
  67886. private _viewPort;
  67887. private _screenCoordinates;
  67888. private _cachedDefines;
  67889. /**
  67890. * If not undefined, the mesh position is computed from the attached node position
  67891. */
  67892. attachedNode: {
  67893. position: Vector3;
  67894. };
  67895. /**
  67896. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67897. */
  67898. customMeshPosition: Vector3;
  67899. /**
  67900. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67901. */
  67902. useCustomMeshPosition: boolean;
  67903. /**
  67904. * If the post-process should inverse the light scattering direction
  67905. */
  67906. invert: boolean;
  67907. /**
  67908. * The internal mesh used by the post-process
  67909. */
  67910. mesh: Mesh;
  67911. /**
  67912. * @hidden
  67913. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67914. */
  67915. get useDiffuseColor(): boolean;
  67916. set useDiffuseColor(useDiffuseColor: boolean);
  67917. /**
  67918. * Array containing the excluded meshes not rendered in the internal pass
  67919. */
  67920. excludedMeshes: AbstractMesh[];
  67921. /**
  67922. * Controls the overall intensity of the post-process
  67923. */
  67924. exposure: number;
  67925. /**
  67926. * Dissipates each sample's contribution in range [0, 1]
  67927. */
  67928. decay: number;
  67929. /**
  67930. * Controls the overall intensity of each sample
  67931. */
  67932. weight: number;
  67933. /**
  67934. * Controls the density of each sample
  67935. */
  67936. density: number;
  67937. /**
  67938. * @constructor
  67939. * @param name The post-process name
  67940. * @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)
  67941. * @param camera The camera that the post-process will be attached to
  67942. * @param mesh The mesh used to create the light scattering
  67943. * @param samples The post-process quality, default 100
  67944. * @param samplingModeThe post-process filtering mode
  67945. * @param engine The babylon engine
  67946. * @param reusable If the post-process is reusable
  67947. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67948. */
  67949. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67950. /**
  67951. * Returns the string "VolumetricLightScatteringPostProcess"
  67952. * @returns "VolumetricLightScatteringPostProcess"
  67953. */
  67954. getClassName(): string;
  67955. private _isReady;
  67956. /**
  67957. * Sets the new light position for light scattering effect
  67958. * @param position The new custom light position
  67959. */
  67960. setCustomMeshPosition(position: Vector3): void;
  67961. /**
  67962. * Returns the light position for light scattering effect
  67963. * @return Vector3 The custom light position
  67964. */
  67965. getCustomMeshPosition(): Vector3;
  67966. /**
  67967. * Disposes the internal assets and detaches the post-process from the camera
  67968. */
  67969. dispose(camera: Camera): void;
  67970. /**
  67971. * Returns the render target texture used by the post-process
  67972. * @return the render target texture used by the post-process
  67973. */
  67974. getPass(): RenderTargetTexture;
  67975. private _meshExcluded;
  67976. private _createPass;
  67977. private _updateMeshScreenCoordinates;
  67978. /**
  67979. * Creates a default mesh for the Volumeric Light Scattering post-process
  67980. * @param name The mesh name
  67981. * @param scene The scene where to create the mesh
  67982. * @return the default mesh
  67983. */
  67984. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67985. }
  67986. }
  67987. declare module "babylonjs/PostProcesses/index" {
  67988. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  67989. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  67990. export * from "babylonjs/PostProcesses/bloomEffect";
  67991. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  67992. export * from "babylonjs/PostProcesses/blurPostProcess";
  67993. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  67994. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  67995. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  67996. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  67997. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67998. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  67999. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  68000. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  68001. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68002. export * from "babylonjs/PostProcesses/filterPostProcess";
  68003. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  68004. export * from "babylonjs/PostProcesses/grainPostProcess";
  68005. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  68006. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68007. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  68008. export * from "babylonjs/PostProcesses/passPostProcess";
  68009. export * from "babylonjs/PostProcesses/postProcess";
  68010. export * from "babylonjs/PostProcesses/postProcessManager";
  68011. export * from "babylonjs/PostProcesses/refractionPostProcess";
  68012. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  68013. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  68014. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  68015. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  68016. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  68017. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  68018. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  68019. }
  68020. declare module "babylonjs/Probes/index" {
  68021. export * from "babylonjs/Probes/reflectionProbe";
  68022. }
  68023. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  68024. import { Scene } from "babylonjs/scene";
  68025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68026. import { SmartArray } from "babylonjs/Misc/smartArray";
  68027. import { ISceneComponent } from "babylonjs/sceneComponent";
  68028. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  68029. import "babylonjs/Meshes/Builders/boxBuilder";
  68030. import "babylonjs/Shaders/color.fragment";
  68031. import "babylonjs/Shaders/color.vertex";
  68032. import { Color3 } from "babylonjs/Maths/math.color";
  68033. module "babylonjs/scene" {
  68034. interface Scene {
  68035. /** @hidden (Backing field) */
  68036. _boundingBoxRenderer: BoundingBoxRenderer;
  68037. /** @hidden (Backing field) */
  68038. _forceShowBoundingBoxes: boolean;
  68039. /**
  68040. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68041. */
  68042. forceShowBoundingBoxes: boolean;
  68043. /**
  68044. * Gets the bounding box renderer associated with the scene
  68045. * @returns a BoundingBoxRenderer
  68046. */
  68047. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68048. }
  68049. }
  68050. module "babylonjs/Meshes/abstractMesh" {
  68051. interface AbstractMesh {
  68052. /** @hidden (Backing field) */
  68053. _showBoundingBox: boolean;
  68054. /**
  68055. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68056. */
  68057. showBoundingBox: boolean;
  68058. }
  68059. }
  68060. /**
  68061. * Component responsible of rendering the bounding box of the meshes in a scene.
  68062. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68063. */
  68064. export class BoundingBoxRenderer implements ISceneComponent {
  68065. /**
  68066. * The component name helpfull to identify the component in the list of scene components.
  68067. */
  68068. readonly name: string;
  68069. /**
  68070. * The scene the component belongs to.
  68071. */
  68072. scene: Scene;
  68073. /**
  68074. * Color of the bounding box lines placed in front of an object
  68075. */
  68076. frontColor: Color3;
  68077. /**
  68078. * Color of the bounding box lines placed behind an object
  68079. */
  68080. backColor: Color3;
  68081. /**
  68082. * Defines if the renderer should show the back lines or not
  68083. */
  68084. showBackLines: boolean;
  68085. /**
  68086. * @hidden
  68087. */
  68088. renderList: SmartArray<BoundingBox>;
  68089. private _colorShader;
  68090. private _vertexBuffers;
  68091. private _indexBuffer;
  68092. private _fillIndexBuffer;
  68093. private _fillIndexData;
  68094. /**
  68095. * Instantiates a new bounding box renderer in a scene.
  68096. * @param scene the scene the renderer renders in
  68097. */
  68098. constructor(scene: Scene);
  68099. /**
  68100. * Registers the component in a given scene
  68101. */
  68102. register(): void;
  68103. private _evaluateSubMesh;
  68104. private _activeMesh;
  68105. private _prepareRessources;
  68106. private _createIndexBuffer;
  68107. /**
  68108. * Rebuilds the elements related to this component in case of
  68109. * context lost for instance.
  68110. */
  68111. rebuild(): void;
  68112. /**
  68113. * @hidden
  68114. */
  68115. reset(): void;
  68116. /**
  68117. * Render the bounding boxes of a specific rendering group
  68118. * @param renderingGroupId defines the rendering group to render
  68119. */
  68120. render(renderingGroupId: number): void;
  68121. /**
  68122. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68123. * @param mesh Define the mesh to render the occlusion bounding box for
  68124. */
  68125. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68126. /**
  68127. * Dispose and release the resources attached to this renderer.
  68128. */
  68129. dispose(): void;
  68130. }
  68131. }
  68132. declare module "babylonjs/Shaders/depth.fragment" {
  68133. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68134. /** @hidden */
  68135. export var depthPixelShader: {
  68136. name: string;
  68137. shader: string;
  68138. };
  68139. }
  68140. declare module "babylonjs/Rendering/depthRenderer" {
  68141. import { Nullable } from "babylonjs/types";
  68142. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68143. import { Scene } from "babylonjs/scene";
  68144. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68145. import { Camera } from "babylonjs/Cameras/camera";
  68146. import "babylonjs/Shaders/depth.fragment";
  68147. import "babylonjs/Shaders/depth.vertex";
  68148. /**
  68149. * This represents a depth renderer in Babylon.
  68150. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  68151. */
  68152. export class DepthRenderer {
  68153. private _scene;
  68154. private _depthMap;
  68155. private _effect;
  68156. private readonly _storeNonLinearDepth;
  68157. private readonly _clearColor;
  68158. /** Get if the depth renderer is using packed depth or not */
  68159. readonly isPacked: boolean;
  68160. private _cachedDefines;
  68161. private _camera;
  68162. /**
  68163. * Specifiess that the depth renderer will only be used within
  68164. * the camera it is created for.
  68165. * This can help forcing its rendering during the camera processing.
  68166. */
  68167. useOnlyInActiveCamera: boolean;
  68168. /** @hidden */
  68169. static _SceneComponentInitialization: (scene: Scene) => void;
  68170. /**
  68171. * Instantiates a depth renderer
  68172. * @param scene The scene the renderer belongs to
  68173. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  68174. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  68175. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68176. */
  68177. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  68178. /**
  68179. * Creates the depth rendering effect and checks if the effect is ready.
  68180. * @param subMesh The submesh to be used to render the depth map of
  68181. * @param useInstances If multiple world instances should be used
  68182. * @returns if the depth renderer is ready to render the depth map
  68183. */
  68184. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68185. /**
  68186. * Gets the texture which the depth map will be written to.
  68187. * @returns The depth map texture
  68188. */
  68189. getDepthMap(): RenderTargetTexture;
  68190. /**
  68191. * Disposes of the depth renderer.
  68192. */
  68193. dispose(): void;
  68194. }
  68195. }
  68196. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  68197. import { Nullable } from "babylonjs/types";
  68198. import { Scene } from "babylonjs/scene";
  68199. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  68200. import { Camera } from "babylonjs/Cameras/camera";
  68201. import { ISceneComponent } from "babylonjs/sceneComponent";
  68202. module "babylonjs/scene" {
  68203. interface Scene {
  68204. /** @hidden (Backing field) */
  68205. _depthRenderer: {
  68206. [id: string]: DepthRenderer;
  68207. };
  68208. /**
  68209. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68210. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68211. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68212. * @returns the created depth renderer
  68213. */
  68214. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68215. /**
  68216. * Disables a depth renderer for a given camera
  68217. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68218. */
  68219. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68220. }
  68221. }
  68222. /**
  68223. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68224. * in several rendering techniques.
  68225. */
  68226. export class DepthRendererSceneComponent implements ISceneComponent {
  68227. /**
  68228. * The component name helpfull to identify the component in the list of scene components.
  68229. */
  68230. readonly name: string;
  68231. /**
  68232. * The scene the component belongs to.
  68233. */
  68234. scene: Scene;
  68235. /**
  68236. * Creates a new instance of the component for the given scene
  68237. * @param scene Defines the scene to register the component in
  68238. */
  68239. constructor(scene: Scene);
  68240. /**
  68241. * Registers the component in a given scene
  68242. */
  68243. register(): void;
  68244. /**
  68245. * Rebuilds the elements related to this component in case of
  68246. * context lost for instance.
  68247. */
  68248. rebuild(): void;
  68249. /**
  68250. * Disposes the component and the associated ressources
  68251. */
  68252. dispose(): void;
  68253. private _gatherRenderTargets;
  68254. private _gatherActiveCameraRenderTargets;
  68255. }
  68256. }
  68257. declare module "babylonjs/Shaders/outline.fragment" {
  68258. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68259. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  68260. /** @hidden */
  68261. export var outlinePixelShader: {
  68262. name: string;
  68263. shader: string;
  68264. };
  68265. }
  68266. declare module "babylonjs/Shaders/outline.vertex" {
  68267. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68268. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68269. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68270. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68271. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68272. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68273. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68274. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68275. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  68276. /** @hidden */
  68277. export var outlineVertexShader: {
  68278. name: string;
  68279. shader: string;
  68280. };
  68281. }
  68282. declare module "babylonjs/Rendering/outlineRenderer" {
  68283. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68284. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  68285. import { Scene } from "babylonjs/scene";
  68286. import { ISceneComponent } from "babylonjs/sceneComponent";
  68287. import "babylonjs/Shaders/outline.fragment";
  68288. import "babylonjs/Shaders/outline.vertex";
  68289. module "babylonjs/scene" {
  68290. interface Scene {
  68291. /** @hidden */
  68292. _outlineRenderer: OutlineRenderer;
  68293. /**
  68294. * Gets the outline renderer associated with the scene
  68295. * @returns a OutlineRenderer
  68296. */
  68297. getOutlineRenderer(): OutlineRenderer;
  68298. }
  68299. }
  68300. module "babylonjs/Meshes/abstractMesh" {
  68301. interface AbstractMesh {
  68302. /** @hidden (Backing field) */
  68303. _renderOutline: boolean;
  68304. /**
  68305. * Gets or sets a boolean indicating if the outline must be rendered as well
  68306. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68307. */
  68308. renderOutline: boolean;
  68309. /** @hidden (Backing field) */
  68310. _renderOverlay: boolean;
  68311. /**
  68312. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68313. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68314. */
  68315. renderOverlay: boolean;
  68316. }
  68317. }
  68318. /**
  68319. * This class is responsible to draw bothe outline/overlay of meshes.
  68320. * It should not be used directly but through the available method on mesh.
  68321. */
  68322. export class OutlineRenderer implements ISceneComponent {
  68323. /**
  68324. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68325. */
  68326. private static _StencilReference;
  68327. /**
  68328. * The name of the component. Each component must have a unique name.
  68329. */
  68330. name: string;
  68331. /**
  68332. * The scene the component belongs to.
  68333. */
  68334. scene: Scene;
  68335. /**
  68336. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68337. */
  68338. zOffset: number;
  68339. private _engine;
  68340. private _effect;
  68341. private _cachedDefines;
  68342. private _savedDepthWrite;
  68343. /**
  68344. * Instantiates a new outline renderer. (There could be only one per scene).
  68345. * @param scene Defines the scene it belongs to
  68346. */
  68347. constructor(scene: Scene);
  68348. /**
  68349. * Register the component to one instance of a scene.
  68350. */
  68351. register(): void;
  68352. /**
  68353. * Rebuilds the elements related to this component in case of
  68354. * context lost for instance.
  68355. */
  68356. rebuild(): void;
  68357. /**
  68358. * Disposes the component and the associated ressources.
  68359. */
  68360. dispose(): void;
  68361. /**
  68362. * Renders the outline in the canvas.
  68363. * @param subMesh Defines the sumesh to render
  68364. * @param batch Defines the batch of meshes in case of instances
  68365. * @param useOverlay Defines if the rendering is for the overlay or the outline
  68366. */
  68367. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  68368. /**
  68369. * Returns whether or not the outline renderer is ready for a given submesh.
  68370. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  68371. * @param subMesh Defines the submesh to check readyness for
  68372. * @param useInstances Defines wheter wee are trying to render instances or not
  68373. * @returns true if ready otherwise false
  68374. */
  68375. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68376. private _beforeRenderingMesh;
  68377. private _afterRenderingMesh;
  68378. }
  68379. }
  68380. declare module "babylonjs/Rendering/index" {
  68381. export * from "babylonjs/Rendering/boundingBoxRenderer";
  68382. export * from "babylonjs/Rendering/depthRenderer";
  68383. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  68384. export * from "babylonjs/Rendering/edgesRenderer";
  68385. export * from "babylonjs/Rendering/geometryBufferRenderer";
  68386. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68387. export * from "babylonjs/Rendering/outlineRenderer";
  68388. export * from "babylonjs/Rendering/renderingGroup";
  68389. export * from "babylonjs/Rendering/renderingManager";
  68390. export * from "babylonjs/Rendering/utilityLayerRenderer";
  68391. }
  68392. declare module "babylonjs/Sprites/ISprites" {
  68393. /**
  68394. * Defines the basic options interface of a Sprite Frame Source Size.
  68395. */
  68396. export interface ISpriteJSONSpriteSourceSize {
  68397. /**
  68398. * number of the original width of the Frame
  68399. */
  68400. w: number;
  68401. /**
  68402. * number of the original height of the Frame
  68403. */
  68404. h: number;
  68405. }
  68406. /**
  68407. * Defines the basic options interface of a Sprite Frame Data.
  68408. */
  68409. export interface ISpriteJSONSpriteFrameData {
  68410. /**
  68411. * number of the x offset of the Frame
  68412. */
  68413. x: number;
  68414. /**
  68415. * number of the y offset of the Frame
  68416. */
  68417. y: number;
  68418. /**
  68419. * number of the width of the Frame
  68420. */
  68421. w: number;
  68422. /**
  68423. * number of the height of the Frame
  68424. */
  68425. h: number;
  68426. }
  68427. /**
  68428. * Defines the basic options interface of a JSON Sprite.
  68429. */
  68430. export interface ISpriteJSONSprite {
  68431. /**
  68432. * string name of the Frame
  68433. */
  68434. filename: string;
  68435. /**
  68436. * ISpriteJSONSpriteFrame basic object of the frame data
  68437. */
  68438. frame: ISpriteJSONSpriteFrameData;
  68439. /**
  68440. * boolean to flag is the frame was rotated.
  68441. */
  68442. rotated: boolean;
  68443. /**
  68444. * boolean to flag is the frame was trimmed.
  68445. */
  68446. trimmed: boolean;
  68447. /**
  68448. * ISpriteJSONSpriteFrame basic object of the source data
  68449. */
  68450. spriteSourceSize: ISpriteJSONSpriteFrameData;
  68451. /**
  68452. * ISpriteJSONSpriteFrame basic object of the source data
  68453. */
  68454. sourceSize: ISpriteJSONSpriteSourceSize;
  68455. }
  68456. /**
  68457. * Defines the basic options interface of a JSON atlas.
  68458. */
  68459. export interface ISpriteJSONAtlas {
  68460. /**
  68461. * Array of objects that contain the frame data.
  68462. */
  68463. frames: Array<ISpriteJSONSprite>;
  68464. /**
  68465. * object basic object containing the sprite meta data.
  68466. */
  68467. meta?: object;
  68468. }
  68469. }
  68470. declare module "babylonjs/Shaders/spriteMap.fragment" {
  68471. /** @hidden */
  68472. export var spriteMapPixelShader: {
  68473. name: string;
  68474. shader: string;
  68475. };
  68476. }
  68477. declare module "babylonjs/Shaders/spriteMap.vertex" {
  68478. /** @hidden */
  68479. export var spriteMapVertexShader: {
  68480. name: string;
  68481. shader: string;
  68482. };
  68483. }
  68484. declare module "babylonjs/Sprites/spriteMap" {
  68485. import { IDisposable, Scene } from "babylonjs/scene";
  68486. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  68487. import { Texture } from "babylonjs/Materials/Textures/texture";
  68488. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68489. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  68490. import "babylonjs/Meshes/Builders/planeBuilder";
  68491. import "babylonjs/Shaders/spriteMap.fragment";
  68492. import "babylonjs/Shaders/spriteMap.vertex";
  68493. /**
  68494. * Defines the basic options interface of a SpriteMap
  68495. */
  68496. export interface ISpriteMapOptions {
  68497. /**
  68498. * Vector2 of the number of cells in the grid.
  68499. */
  68500. stageSize?: Vector2;
  68501. /**
  68502. * Vector2 of the size of the output plane in World Units.
  68503. */
  68504. outputSize?: Vector2;
  68505. /**
  68506. * Vector3 of the position of the output plane in World Units.
  68507. */
  68508. outputPosition?: Vector3;
  68509. /**
  68510. * Vector3 of the rotation of the output plane.
  68511. */
  68512. outputRotation?: Vector3;
  68513. /**
  68514. * number of layers that the system will reserve in resources.
  68515. */
  68516. layerCount?: number;
  68517. /**
  68518. * number of max animation frames a single cell will reserve in resources.
  68519. */
  68520. maxAnimationFrames?: number;
  68521. /**
  68522. * number cell index of the base tile when the system compiles.
  68523. */
  68524. baseTile?: number;
  68525. /**
  68526. * boolean flip the sprite after its been repositioned by the framing data.
  68527. */
  68528. flipU?: boolean;
  68529. /**
  68530. * Vector3 scalar of the global RGB values of the SpriteMap.
  68531. */
  68532. colorMultiply?: Vector3;
  68533. }
  68534. /**
  68535. * Defines the IDisposable interface in order to be cleanable from resources.
  68536. */
  68537. export interface ISpriteMap extends IDisposable {
  68538. /**
  68539. * String name of the SpriteMap.
  68540. */
  68541. name: string;
  68542. /**
  68543. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  68544. */
  68545. atlasJSON: ISpriteJSONAtlas;
  68546. /**
  68547. * Texture of the SpriteMap.
  68548. */
  68549. spriteSheet: Texture;
  68550. /**
  68551. * The parameters to initialize the SpriteMap with.
  68552. */
  68553. options: ISpriteMapOptions;
  68554. }
  68555. /**
  68556. * Class used to manage a grid restricted sprite deployment on an Output plane.
  68557. */
  68558. export class SpriteMap implements ISpriteMap {
  68559. /** The Name of the spriteMap */
  68560. name: string;
  68561. /** The JSON file with the frame and meta data */
  68562. atlasJSON: ISpriteJSONAtlas;
  68563. /** The systems Sprite Sheet Texture */
  68564. spriteSheet: Texture;
  68565. /** Arguments passed with the Constructor */
  68566. options: ISpriteMapOptions;
  68567. /** Public Sprite Storage array, parsed from atlasJSON */
  68568. sprites: Array<ISpriteJSONSprite>;
  68569. /** Returns the Number of Sprites in the System */
  68570. get spriteCount(): number;
  68571. /** Returns the Position of Output Plane*/
  68572. get position(): Vector3;
  68573. /** Returns the Position of Output Plane*/
  68574. set position(v: Vector3);
  68575. /** Returns the Rotation of Output Plane*/
  68576. get rotation(): Vector3;
  68577. /** Returns the Rotation of Output Plane*/
  68578. set rotation(v: Vector3);
  68579. /** Sets the AnimationMap*/
  68580. get animationMap(): RawTexture;
  68581. /** Sets the AnimationMap*/
  68582. set animationMap(v: RawTexture);
  68583. /** Scene that the SpriteMap was created in */
  68584. private _scene;
  68585. /** Texture Buffer of Float32 that holds tile frame data*/
  68586. private _frameMap;
  68587. /** Texture Buffers of Float32 that holds tileMap data*/
  68588. private _tileMaps;
  68589. /** Texture Buffer of Float32 that holds Animation Data*/
  68590. private _animationMap;
  68591. /** Custom ShaderMaterial Central to the System*/
  68592. private _material;
  68593. /** Custom ShaderMaterial Central to the System*/
  68594. private _output;
  68595. /** Systems Time Ticker*/
  68596. private _time;
  68597. /**
  68598. * Creates a new SpriteMap
  68599. * @param name defines the SpriteMaps Name
  68600. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  68601. * @param spriteSheet is the Texture that the Sprites are on.
  68602. * @param options a basic deployment configuration
  68603. * @param scene The Scene that the map is deployed on
  68604. */
  68605. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  68606. /**
  68607. * Returns tileID location
  68608. * @returns Vector2 the cell position ID
  68609. */
  68610. getTileID(): Vector2;
  68611. /**
  68612. * Gets the UV location of the mouse over the SpriteMap.
  68613. * @returns Vector2 the UV position of the mouse interaction
  68614. */
  68615. getMousePosition(): Vector2;
  68616. /**
  68617. * Creates the "frame" texture Buffer
  68618. * -------------------------------------
  68619. * Structure of frames
  68620. * "filename": "Falling-Water-2.png",
  68621. * "frame": {"x":69,"y":103,"w":24,"h":32},
  68622. * "rotated": true,
  68623. * "trimmed": true,
  68624. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  68625. * "sourceSize": {"w":32,"h":32}
  68626. * @returns RawTexture of the frameMap
  68627. */
  68628. private _createFrameBuffer;
  68629. /**
  68630. * Creates the tileMap texture Buffer
  68631. * @param buffer normally and array of numbers, or a false to generate from scratch
  68632. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  68633. * @returns RawTexture of the tileMap
  68634. */
  68635. private _createTileBuffer;
  68636. /**
  68637. * Modifies the data of the tileMaps
  68638. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  68639. * @param pos is the iVector2 Coordinates of the Tile
  68640. * @param tile The SpriteIndex of the new Tile
  68641. */
  68642. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  68643. /**
  68644. * Creates the animationMap texture Buffer
  68645. * @param buffer normally and array of numbers, or a false to generate from scratch
  68646. * @returns RawTexture of the animationMap
  68647. */
  68648. private _createTileAnimationBuffer;
  68649. /**
  68650. * Modifies the data of the animationMap
  68651. * @param cellID is the Index of the Sprite
  68652. * @param _frame is the target Animation frame
  68653. * @param toCell is the Target Index of the next frame of the animation
  68654. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  68655. * @param speed is a global scalar of the time variable on the map.
  68656. */
  68657. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  68658. /**
  68659. * Exports the .tilemaps file
  68660. */
  68661. saveTileMaps(): void;
  68662. /**
  68663. * Imports the .tilemaps file
  68664. * @param url of the .tilemaps file
  68665. */
  68666. loadTileMaps(url: string): void;
  68667. /**
  68668. * Release associated resources
  68669. */
  68670. dispose(): void;
  68671. }
  68672. }
  68673. declare module "babylonjs/Sprites/spritePackedManager" {
  68674. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  68675. import { Scene } from "babylonjs/scene";
  68676. /**
  68677. * Class used to manage multiple sprites of different sizes on the same spritesheet
  68678. * @see http://doc.babylonjs.com/babylon101/sprites
  68679. */
  68680. export class SpritePackedManager extends SpriteManager {
  68681. /** defines the packed manager's name */
  68682. name: string;
  68683. /**
  68684. * Creates a new sprite manager from a packed sprite sheet
  68685. * @param name defines the manager's name
  68686. * @param imgUrl defines the sprite sheet url
  68687. * @param capacity defines the maximum allowed number of sprites
  68688. * @param scene defines the hosting scene
  68689. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  68690. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68691. * @param samplingMode defines the smapling mode to use with spritesheet
  68692. * @param fromPacked set to true; do not alter
  68693. */
  68694. constructor(
  68695. /** defines the packed manager's name */
  68696. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68697. }
  68698. }
  68699. declare module "babylonjs/Sprites/index" {
  68700. export * from "babylonjs/Sprites/sprite";
  68701. export * from "babylonjs/Sprites/ISprites";
  68702. export * from "babylonjs/Sprites/spriteManager";
  68703. export * from "babylonjs/Sprites/spriteMap";
  68704. export * from "babylonjs/Sprites/spritePackedManager";
  68705. export * from "babylonjs/Sprites/spriteSceneComponent";
  68706. }
  68707. declare module "babylonjs/States/index" {
  68708. export * from "babylonjs/States/alphaCullingState";
  68709. export * from "babylonjs/States/depthCullingState";
  68710. export * from "babylonjs/States/stencilState";
  68711. }
  68712. declare module "babylonjs/Misc/assetsManager" {
  68713. import { Scene } from "babylonjs/scene";
  68714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68715. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68716. import { Skeleton } from "babylonjs/Bones/skeleton";
  68717. import { Observable } from "babylonjs/Misc/observable";
  68718. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68719. import { Texture } from "babylonjs/Materials/Textures/texture";
  68720. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  68721. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  68722. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  68723. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  68724. /**
  68725. * Defines the list of states available for a task inside a AssetsManager
  68726. */
  68727. export enum AssetTaskState {
  68728. /**
  68729. * Initialization
  68730. */
  68731. INIT = 0,
  68732. /**
  68733. * Running
  68734. */
  68735. RUNNING = 1,
  68736. /**
  68737. * Done
  68738. */
  68739. DONE = 2,
  68740. /**
  68741. * Error
  68742. */
  68743. ERROR = 3
  68744. }
  68745. /**
  68746. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68747. */
  68748. export abstract class AbstractAssetTask {
  68749. /**
  68750. * Task name
  68751. */ name: string;
  68752. /**
  68753. * Callback called when the task is successful
  68754. */
  68755. onSuccess: (task: any) => void;
  68756. /**
  68757. * Callback called when the task is not successful
  68758. */
  68759. onError: (task: any, message?: string, exception?: any) => void;
  68760. /**
  68761. * Creates a new AssetsManager
  68762. * @param name defines the name of the task
  68763. */
  68764. constructor(
  68765. /**
  68766. * Task name
  68767. */ name: string);
  68768. private _isCompleted;
  68769. private _taskState;
  68770. private _errorObject;
  68771. /**
  68772. * Get if the task is completed
  68773. */
  68774. get isCompleted(): boolean;
  68775. /**
  68776. * Gets the current state of the task
  68777. */
  68778. get taskState(): AssetTaskState;
  68779. /**
  68780. * Gets the current error object (if task is in error)
  68781. */
  68782. get errorObject(): {
  68783. message?: string;
  68784. exception?: any;
  68785. };
  68786. /**
  68787. * Internal only
  68788. * @hidden
  68789. */
  68790. _setErrorObject(message?: string, exception?: any): void;
  68791. /**
  68792. * Execute the current task
  68793. * @param scene defines the scene where you want your assets to be loaded
  68794. * @param onSuccess is a callback called when the task is successfully executed
  68795. * @param onError is a callback called if an error occurs
  68796. */
  68797. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68798. /**
  68799. * Execute the current task
  68800. * @param scene defines the scene where you want your assets to be loaded
  68801. * @param onSuccess is a callback called when the task is successfully executed
  68802. * @param onError is a callback called if an error occurs
  68803. */
  68804. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68805. /**
  68806. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68807. * This can be used with failed tasks that have the reason for failure fixed.
  68808. */
  68809. reset(): void;
  68810. private onErrorCallback;
  68811. private onDoneCallback;
  68812. }
  68813. /**
  68814. * Define the interface used by progress events raised during assets loading
  68815. */
  68816. export interface IAssetsProgressEvent {
  68817. /**
  68818. * Defines the number of remaining tasks to process
  68819. */
  68820. remainingCount: number;
  68821. /**
  68822. * Defines the total number of tasks
  68823. */
  68824. totalCount: number;
  68825. /**
  68826. * Defines the task that was just processed
  68827. */
  68828. task: AbstractAssetTask;
  68829. }
  68830. /**
  68831. * Class used to share progress information about assets loading
  68832. */
  68833. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68834. /**
  68835. * Defines the number of remaining tasks to process
  68836. */
  68837. remainingCount: number;
  68838. /**
  68839. * Defines the total number of tasks
  68840. */
  68841. totalCount: number;
  68842. /**
  68843. * Defines the task that was just processed
  68844. */
  68845. task: AbstractAssetTask;
  68846. /**
  68847. * Creates a AssetsProgressEvent
  68848. * @param remainingCount defines the number of remaining tasks to process
  68849. * @param totalCount defines the total number of tasks
  68850. * @param task defines the task that was just processed
  68851. */
  68852. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68853. }
  68854. /**
  68855. * Define a task used by AssetsManager to load meshes
  68856. */
  68857. export class MeshAssetTask extends AbstractAssetTask {
  68858. /**
  68859. * Defines the name of the task
  68860. */
  68861. name: string;
  68862. /**
  68863. * Defines the list of mesh's names you want to load
  68864. */
  68865. meshesNames: any;
  68866. /**
  68867. * Defines the root url to use as a base to load your meshes and associated resources
  68868. */
  68869. rootUrl: string;
  68870. /**
  68871. * Defines the filename of the scene to load from
  68872. */
  68873. sceneFilename: string;
  68874. /**
  68875. * Gets the list of loaded meshes
  68876. */
  68877. loadedMeshes: Array<AbstractMesh>;
  68878. /**
  68879. * Gets the list of loaded particle systems
  68880. */
  68881. loadedParticleSystems: Array<IParticleSystem>;
  68882. /**
  68883. * Gets the list of loaded skeletons
  68884. */
  68885. loadedSkeletons: Array<Skeleton>;
  68886. /**
  68887. * Gets the list of loaded animation groups
  68888. */
  68889. loadedAnimationGroups: Array<AnimationGroup>;
  68890. /**
  68891. * Callback called when the task is successful
  68892. */
  68893. onSuccess: (task: MeshAssetTask) => void;
  68894. /**
  68895. * Callback called when the task is successful
  68896. */
  68897. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68898. /**
  68899. * Creates a new MeshAssetTask
  68900. * @param name defines the name of the task
  68901. * @param meshesNames defines the list of mesh's names you want to load
  68902. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68903. * @param sceneFilename defines the filename of the scene to load from
  68904. */
  68905. constructor(
  68906. /**
  68907. * Defines the name of the task
  68908. */
  68909. name: string,
  68910. /**
  68911. * Defines the list of mesh's names you want to load
  68912. */
  68913. meshesNames: any,
  68914. /**
  68915. * Defines the root url to use as a base to load your meshes and associated resources
  68916. */
  68917. rootUrl: string,
  68918. /**
  68919. * Defines the filename of the scene to load from
  68920. */
  68921. sceneFilename: string);
  68922. /**
  68923. * Execute the current task
  68924. * @param scene defines the scene where you want your assets to be loaded
  68925. * @param onSuccess is a callback called when the task is successfully executed
  68926. * @param onError is a callback called if an error occurs
  68927. */
  68928. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68929. }
  68930. /**
  68931. * Define a task used by AssetsManager to load text content
  68932. */
  68933. export class TextFileAssetTask extends AbstractAssetTask {
  68934. /**
  68935. * Defines the name of the task
  68936. */
  68937. name: string;
  68938. /**
  68939. * Defines the location of the file to load
  68940. */
  68941. url: string;
  68942. /**
  68943. * Gets the loaded text string
  68944. */
  68945. text: string;
  68946. /**
  68947. * Callback called when the task is successful
  68948. */
  68949. onSuccess: (task: TextFileAssetTask) => void;
  68950. /**
  68951. * Callback called when the task is successful
  68952. */
  68953. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68954. /**
  68955. * Creates a new TextFileAssetTask object
  68956. * @param name defines the name of the task
  68957. * @param url defines the location of the file to load
  68958. */
  68959. constructor(
  68960. /**
  68961. * Defines the name of the task
  68962. */
  68963. name: string,
  68964. /**
  68965. * Defines the location of the file to load
  68966. */
  68967. url: string);
  68968. /**
  68969. * Execute the current task
  68970. * @param scene defines the scene where you want your assets to be loaded
  68971. * @param onSuccess is a callback called when the task is successfully executed
  68972. * @param onError is a callback called if an error occurs
  68973. */
  68974. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68975. }
  68976. /**
  68977. * Define a task used by AssetsManager to load binary data
  68978. */
  68979. export class BinaryFileAssetTask extends AbstractAssetTask {
  68980. /**
  68981. * Defines the name of the task
  68982. */
  68983. name: string;
  68984. /**
  68985. * Defines the location of the file to load
  68986. */
  68987. url: string;
  68988. /**
  68989. * Gets the lodaded data (as an array buffer)
  68990. */
  68991. data: ArrayBuffer;
  68992. /**
  68993. * Callback called when the task is successful
  68994. */
  68995. onSuccess: (task: BinaryFileAssetTask) => void;
  68996. /**
  68997. * Callback called when the task is successful
  68998. */
  68999. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69000. /**
  69001. * Creates a new BinaryFileAssetTask object
  69002. * @param name defines the name of the new task
  69003. * @param url defines the location of the file to load
  69004. */
  69005. constructor(
  69006. /**
  69007. * Defines the name of the task
  69008. */
  69009. name: string,
  69010. /**
  69011. * Defines the location of the file to load
  69012. */
  69013. url: string);
  69014. /**
  69015. * Execute the current task
  69016. * @param scene defines the scene where you want your assets to be loaded
  69017. * @param onSuccess is a callback called when the task is successfully executed
  69018. * @param onError is a callback called if an error occurs
  69019. */
  69020. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69021. }
  69022. /**
  69023. * Define a task used by AssetsManager to load images
  69024. */
  69025. export class ImageAssetTask extends AbstractAssetTask {
  69026. /**
  69027. * Defines the name of the task
  69028. */
  69029. name: string;
  69030. /**
  69031. * Defines the location of the image to load
  69032. */
  69033. url: string;
  69034. /**
  69035. * Gets the loaded images
  69036. */
  69037. image: HTMLImageElement;
  69038. /**
  69039. * Callback called when the task is successful
  69040. */
  69041. onSuccess: (task: ImageAssetTask) => void;
  69042. /**
  69043. * Callback called when the task is successful
  69044. */
  69045. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69046. /**
  69047. * Creates a new ImageAssetTask
  69048. * @param name defines the name of the task
  69049. * @param url defines the location of the image to load
  69050. */
  69051. constructor(
  69052. /**
  69053. * Defines the name of the task
  69054. */
  69055. name: string,
  69056. /**
  69057. * Defines the location of the image to load
  69058. */
  69059. url: string);
  69060. /**
  69061. * Execute the current task
  69062. * @param scene defines the scene where you want your assets to be loaded
  69063. * @param onSuccess is a callback called when the task is successfully executed
  69064. * @param onError is a callback called if an error occurs
  69065. */
  69066. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69067. }
  69068. /**
  69069. * Defines the interface used by texture loading tasks
  69070. */
  69071. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69072. /**
  69073. * Gets the loaded texture
  69074. */
  69075. texture: TEX;
  69076. }
  69077. /**
  69078. * Define a task used by AssetsManager to load 2D textures
  69079. */
  69080. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69081. /**
  69082. * Defines the name of the task
  69083. */
  69084. name: string;
  69085. /**
  69086. * Defines the location of the file to load
  69087. */
  69088. url: string;
  69089. /**
  69090. * Defines if mipmap should not be generated (default is false)
  69091. */
  69092. noMipmap?: boolean | undefined;
  69093. /**
  69094. * Defines if texture must be inverted on Y axis (default is false)
  69095. */
  69096. invertY?: boolean | undefined;
  69097. /**
  69098. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69099. */
  69100. samplingMode: number;
  69101. /**
  69102. * Gets the loaded texture
  69103. */
  69104. texture: Texture;
  69105. /**
  69106. * Callback called when the task is successful
  69107. */
  69108. onSuccess: (task: TextureAssetTask) => void;
  69109. /**
  69110. * Callback called when the task is successful
  69111. */
  69112. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69113. /**
  69114. * Creates a new TextureAssetTask object
  69115. * @param name defines the name of the task
  69116. * @param url defines the location of the file to load
  69117. * @param noMipmap defines if mipmap should not be generated (default is false)
  69118. * @param invertY defines if texture must be inverted on Y axis (default is false)
  69119. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69120. */
  69121. constructor(
  69122. /**
  69123. * Defines the name of the task
  69124. */
  69125. name: string,
  69126. /**
  69127. * Defines the location of the file to load
  69128. */
  69129. url: string,
  69130. /**
  69131. * Defines if mipmap should not be generated (default is false)
  69132. */
  69133. noMipmap?: boolean | undefined,
  69134. /**
  69135. * Defines if texture must be inverted on Y axis (default is false)
  69136. */
  69137. invertY?: boolean | undefined,
  69138. /**
  69139. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69140. */
  69141. samplingMode?: number);
  69142. /**
  69143. * Execute the current task
  69144. * @param scene defines the scene where you want your assets to be loaded
  69145. * @param onSuccess is a callback called when the task is successfully executed
  69146. * @param onError is a callback called if an error occurs
  69147. */
  69148. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69149. }
  69150. /**
  69151. * Define a task used by AssetsManager to load cube textures
  69152. */
  69153. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69154. /**
  69155. * Defines the name of the task
  69156. */
  69157. name: string;
  69158. /**
  69159. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69160. */
  69161. url: string;
  69162. /**
  69163. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69164. */
  69165. extensions?: string[] | undefined;
  69166. /**
  69167. * Defines if mipmaps should not be generated (default is false)
  69168. */
  69169. noMipmap?: boolean | undefined;
  69170. /**
  69171. * Defines the explicit list of files (undefined by default)
  69172. */
  69173. files?: string[] | undefined;
  69174. /**
  69175. * Gets the loaded texture
  69176. */
  69177. texture: CubeTexture;
  69178. /**
  69179. * Callback called when the task is successful
  69180. */
  69181. onSuccess: (task: CubeTextureAssetTask) => void;
  69182. /**
  69183. * Callback called when the task is successful
  69184. */
  69185. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69186. /**
  69187. * Creates a new CubeTextureAssetTask
  69188. * @param name defines the name of the task
  69189. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69190. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69191. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69192. * @param files defines the explicit list of files (undefined by default)
  69193. */
  69194. constructor(
  69195. /**
  69196. * Defines the name of the task
  69197. */
  69198. name: string,
  69199. /**
  69200. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69201. */
  69202. url: string,
  69203. /**
  69204. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69205. */
  69206. extensions?: string[] | undefined,
  69207. /**
  69208. * Defines if mipmaps should not be generated (default is false)
  69209. */
  69210. noMipmap?: boolean | undefined,
  69211. /**
  69212. * Defines the explicit list of files (undefined by default)
  69213. */
  69214. files?: string[] | undefined);
  69215. /**
  69216. * Execute the current task
  69217. * @param scene defines the scene where you want your assets to be loaded
  69218. * @param onSuccess is a callback called when the task is successfully executed
  69219. * @param onError is a callback called if an error occurs
  69220. */
  69221. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69222. }
  69223. /**
  69224. * Define a task used by AssetsManager to load HDR cube textures
  69225. */
  69226. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69227. /**
  69228. * Defines the name of the task
  69229. */
  69230. name: string;
  69231. /**
  69232. * Defines the location of the file to load
  69233. */
  69234. url: string;
  69235. /**
  69236. * Defines the desired size (the more it increases the longer the generation will be)
  69237. */
  69238. size: number;
  69239. /**
  69240. * Defines if mipmaps should not be generated (default is false)
  69241. */
  69242. noMipmap: boolean;
  69243. /**
  69244. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69245. */
  69246. generateHarmonics: boolean;
  69247. /**
  69248. * 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)
  69249. */
  69250. gammaSpace: boolean;
  69251. /**
  69252. * Internal Use Only
  69253. */
  69254. reserved: boolean;
  69255. /**
  69256. * Gets the loaded texture
  69257. */
  69258. texture: HDRCubeTexture;
  69259. /**
  69260. * Callback called when the task is successful
  69261. */
  69262. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69263. /**
  69264. * Callback called when the task is successful
  69265. */
  69266. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69267. /**
  69268. * Creates a new HDRCubeTextureAssetTask object
  69269. * @param name defines the name of the task
  69270. * @param url defines the location of the file to load
  69271. * @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.
  69272. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69273. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69274. * @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)
  69275. * @param reserved Internal use only
  69276. */
  69277. constructor(
  69278. /**
  69279. * Defines the name of the task
  69280. */
  69281. name: string,
  69282. /**
  69283. * Defines the location of the file to load
  69284. */
  69285. url: string,
  69286. /**
  69287. * Defines the desired size (the more it increases the longer the generation will be)
  69288. */
  69289. size: number,
  69290. /**
  69291. * Defines if mipmaps should not be generated (default is false)
  69292. */
  69293. noMipmap?: boolean,
  69294. /**
  69295. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69296. */
  69297. generateHarmonics?: boolean,
  69298. /**
  69299. * 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)
  69300. */
  69301. gammaSpace?: boolean,
  69302. /**
  69303. * Internal Use Only
  69304. */
  69305. reserved?: boolean);
  69306. /**
  69307. * Execute the current task
  69308. * @param scene defines the scene where you want your assets to be loaded
  69309. * @param onSuccess is a callback called when the task is successfully executed
  69310. * @param onError is a callback called if an error occurs
  69311. */
  69312. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69313. }
  69314. /**
  69315. * Define a task used by AssetsManager to load Equirectangular cube textures
  69316. */
  69317. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69318. /**
  69319. * Defines the name of the task
  69320. */
  69321. name: string;
  69322. /**
  69323. * Defines the location of the file to load
  69324. */
  69325. url: string;
  69326. /**
  69327. * Defines the desired size (the more it increases the longer the generation will be)
  69328. */
  69329. size: number;
  69330. /**
  69331. * Defines if mipmaps should not be generated (default is false)
  69332. */
  69333. noMipmap: boolean;
  69334. /**
  69335. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69336. * but the standard material would require them in Gamma space) (default is true)
  69337. */
  69338. gammaSpace: boolean;
  69339. /**
  69340. * Gets the loaded texture
  69341. */
  69342. texture: EquiRectangularCubeTexture;
  69343. /**
  69344. * Callback called when the task is successful
  69345. */
  69346. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69347. /**
  69348. * Callback called when the task is successful
  69349. */
  69350. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69351. /**
  69352. * Creates a new EquiRectangularCubeTextureAssetTask object
  69353. * @param name defines the name of the task
  69354. * @param url defines the location of the file to load
  69355. * @param size defines the desired size (the more it increases the longer the generation will be)
  69356. * If the size is omitted this implies you are using a preprocessed cubemap.
  69357. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69358. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69359. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69360. * (default is true)
  69361. */
  69362. constructor(
  69363. /**
  69364. * Defines the name of the task
  69365. */
  69366. name: string,
  69367. /**
  69368. * Defines the location of the file to load
  69369. */
  69370. url: string,
  69371. /**
  69372. * Defines the desired size (the more it increases the longer the generation will be)
  69373. */
  69374. size: number,
  69375. /**
  69376. * Defines if mipmaps should not be generated (default is false)
  69377. */
  69378. noMipmap?: boolean,
  69379. /**
  69380. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69381. * but the standard material would require them in Gamma space) (default is true)
  69382. */
  69383. gammaSpace?: boolean);
  69384. /**
  69385. * Execute the current task
  69386. * @param scene defines the scene where you want your assets to be loaded
  69387. * @param onSuccess is a callback called when the task is successfully executed
  69388. * @param onError is a callback called if an error occurs
  69389. */
  69390. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69391. }
  69392. /**
  69393. * This class can be used to easily import assets into a scene
  69394. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  69395. */
  69396. export class AssetsManager {
  69397. private _scene;
  69398. private _isLoading;
  69399. protected _tasks: AbstractAssetTask[];
  69400. protected _waitingTasksCount: number;
  69401. protected _totalTasksCount: number;
  69402. /**
  69403. * Callback called when all tasks are processed
  69404. */
  69405. onFinish: (tasks: AbstractAssetTask[]) => void;
  69406. /**
  69407. * Callback called when a task is successful
  69408. */
  69409. onTaskSuccess: (task: AbstractAssetTask) => void;
  69410. /**
  69411. * Callback called when a task had an error
  69412. */
  69413. onTaskError: (task: AbstractAssetTask) => void;
  69414. /**
  69415. * Callback called when a task is done (whatever the result is)
  69416. */
  69417. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  69418. /**
  69419. * Observable called when all tasks are processed
  69420. */
  69421. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  69422. /**
  69423. * Observable called when a task had an error
  69424. */
  69425. onTaskErrorObservable: Observable<AbstractAssetTask>;
  69426. /**
  69427. * Observable called when all tasks were executed
  69428. */
  69429. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  69430. /**
  69431. * Observable called when a task is done (whatever the result is)
  69432. */
  69433. onProgressObservable: Observable<IAssetsProgressEvent>;
  69434. /**
  69435. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  69436. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  69437. */
  69438. useDefaultLoadingScreen: boolean;
  69439. /**
  69440. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  69441. * when all assets have been downloaded.
  69442. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  69443. */
  69444. autoHideLoadingUI: boolean;
  69445. /**
  69446. * Creates a new AssetsManager
  69447. * @param scene defines the scene to work on
  69448. */
  69449. constructor(scene: Scene);
  69450. /**
  69451. * Add a MeshAssetTask to the list of active tasks
  69452. * @param taskName defines the name of the new task
  69453. * @param meshesNames defines the name of meshes to load
  69454. * @param rootUrl defines the root url to use to locate files
  69455. * @param sceneFilename defines the filename of the scene file
  69456. * @returns a new MeshAssetTask object
  69457. */
  69458. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  69459. /**
  69460. * Add a TextFileAssetTask to the list of active tasks
  69461. * @param taskName defines the name of the new task
  69462. * @param url defines the url of the file to load
  69463. * @returns a new TextFileAssetTask object
  69464. */
  69465. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  69466. /**
  69467. * Add a BinaryFileAssetTask to the list of active tasks
  69468. * @param taskName defines the name of the new task
  69469. * @param url defines the url of the file to load
  69470. * @returns a new BinaryFileAssetTask object
  69471. */
  69472. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  69473. /**
  69474. * Add a ImageAssetTask to the list of active tasks
  69475. * @param taskName defines the name of the new task
  69476. * @param url defines the url of the file to load
  69477. * @returns a new ImageAssetTask object
  69478. */
  69479. addImageTask(taskName: string, url: string): ImageAssetTask;
  69480. /**
  69481. * Add a TextureAssetTask to the list of active tasks
  69482. * @param taskName defines the name of the new task
  69483. * @param url defines the url of the file to load
  69484. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69485. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  69486. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69487. * @returns a new TextureAssetTask object
  69488. */
  69489. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  69490. /**
  69491. * Add a CubeTextureAssetTask to the list of active tasks
  69492. * @param taskName defines the name of the new task
  69493. * @param url defines the url of the file to load
  69494. * @param extensions defines the extension to use to load the cube map (can be null)
  69495. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69496. * @param files defines the list of files to load (can be null)
  69497. * @returns a new CubeTextureAssetTask object
  69498. */
  69499. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  69500. /**
  69501. *
  69502. * Add a HDRCubeTextureAssetTask to the list of active tasks
  69503. * @param taskName defines the name of the new task
  69504. * @param url defines the url of the file to load
  69505. * @param size defines the size you want for the cubemap (can be null)
  69506. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69507. * @param generateHarmonics defines if you want to automatically generate (true by default)
  69508. * @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)
  69509. * @param reserved Internal use only
  69510. * @returns a new HDRCubeTextureAssetTask object
  69511. */
  69512. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  69513. /**
  69514. *
  69515. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  69516. * @param taskName defines the name of the new task
  69517. * @param url defines the url of the file to load
  69518. * @param size defines the size you want for the cubemap (can be null)
  69519. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69520. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69521. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69522. * @returns a new EquiRectangularCubeTextureAssetTask object
  69523. */
  69524. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  69525. /**
  69526. * Remove a task from the assets manager.
  69527. * @param task the task to remove
  69528. */
  69529. removeTask(task: AbstractAssetTask): void;
  69530. private _decreaseWaitingTasksCount;
  69531. private _runTask;
  69532. /**
  69533. * Reset the AssetsManager and remove all tasks
  69534. * @return the current instance of the AssetsManager
  69535. */
  69536. reset(): AssetsManager;
  69537. /**
  69538. * Start the loading process
  69539. * @return the current instance of the AssetsManager
  69540. */
  69541. load(): AssetsManager;
  69542. /**
  69543. * Start the loading process as an async operation
  69544. * @return a promise returning the list of failed tasks
  69545. */
  69546. loadAsync(): Promise<void>;
  69547. }
  69548. }
  69549. declare module "babylonjs/Misc/deferred" {
  69550. /**
  69551. * Wrapper class for promise with external resolve and reject.
  69552. */
  69553. export class Deferred<T> {
  69554. /**
  69555. * The promise associated with this deferred object.
  69556. */
  69557. readonly promise: Promise<T>;
  69558. private _resolve;
  69559. private _reject;
  69560. /**
  69561. * The resolve method of the promise associated with this deferred object.
  69562. */
  69563. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  69564. /**
  69565. * The reject method of the promise associated with this deferred object.
  69566. */
  69567. get reject(): (reason?: any) => void;
  69568. /**
  69569. * Constructor for this deferred object.
  69570. */
  69571. constructor();
  69572. }
  69573. }
  69574. declare module "babylonjs/Misc/meshExploder" {
  69575. import { Mesh } from "babylonjs/Meshes/mesh";
  69576. /**
  69577. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  69578. */
  69579. export class MeshExploder {
  69580. private _centerMesh;
  69581. private _meshes;
  69582. private _meshesOrigins;
  69583. private _toCenterVectors;
  69584. private _scaledDirection;
  69585. private _newPosition;
  69586. private _centerPosition;
  69587. /**
  69588. * Explodes meshes from a center mesh.
  69589. * @param meshes The meshes to explode.
  69590. * @param centerMesh The mesh to be center of explosion.
  69591. */
  69592. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  69593. private _setCenterMesh;
  69594. /**
  69595. * Get class name
  69596. * @returns "MeshExploder"
  69597. */
  69598. getClassName(): string;
  69599. /**
  69600. * "Exploded meshes"
  69601. * @returns Array of meshes with the centerMesh at index 0.
  69602. */
  69603. getMeshes(): Array<Mesh>;
  69604. /**
  69605. * Explodes meshes giving a specific direction
  69606. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  69607. */
  69608. explode(direction?: number): void;
  69609. }
  69610. }
  69611. declare module "babylonjs/Misc/filesInput" {
  69612. import { Engine } from "babylonjs/Engines/engine";
  69613. import { Scene } from "babylonjs/scene";
  69614. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  69615. /**
  69616. * Class used to help managing file picking and drag'n'drop
  69617. */
  69618. export class FilesInput {
  69619. /**
  69620. * List of files ready to be loaded
  69621. */
  69622. static get FilesToLoad(): {
  69623. [key: string]: File;
  69624. };
  69625. /**
  69626. * Callback called when a file is processed
  69627. */
  69628. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  69629. private _engine;
  69630. private _currentScene;
  69631. private _sceneLoadedCallback;
  69632. private _progressCallback;
  69633. private _additionalRenderLoopLogicCallback;
  69634. private _textureLoadingCallback;
  69635. private _startingProcessingFilesCallback;
  69636. private _onReloadCallback;
  69637. private _errorCallback;
  69638. private _elementToMonitor;
  69639. private _sceneFileToLoad;
  69640. private _filesToLoad;
  69641. /**
  69642. * Creates a new FilesInput
  69643. * @param engine defines the rendering engine
  69644. * @param scene defines the hosting scene
  69645. * @param sceneLoadedCallback callback called when scene is loaded
  69646. * @param progressCallback callback called to track progress
  69647. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  69648. * @param textureLoadingCallback callback called when a texture is loading
  69649. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  69650. * @param onReloadCallback callback called when a reload is requested
  69651. * @param errorCallback callback call if an error occurs
  69652. */
  69653. 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);
  69654. private _dragEnterHandler;
  69655. private _dragOverHandler;
  69656. private _dropHandler;
  69657. /**
  69658. * Calls this function to listen to drag'n'drop events on a specific DOM element
  69659. * @param elementToMonitor defines the DOM element to track
  69660. */
  69661. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  69662. /**
  69663. * Release all associated resources
  69664. */
  69665. dispose(): void;
  69666. private renderFunction;
  69667. private drag;
  69668. private drop;
  69669. private _traverseFolder;
  69670. private _processFiles;
  69671. /**
  69672. * Load files from a drop event
  69673. * @param event defines the drop event to use as source
  69674. */
  69675. loadFiles(event: any): void;
  69676. private _processReload;
  69677. /**
  69678. * Reload the current scene from the loaded files
  69679. */
  69680. reload(): void;
  69681. }
  69682. }
  69683. declare module "babylonjs/Misc/HighDynamicRange/index" {
  69684. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  69685. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  69686. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  69687. }
  69688. declare module "babylonjs/Misc/sceneOptimizer" {
  69689. import { Scene, IDisposable } from "babylonjs/scene";
  69690. import { Observable } from "babylonjs/Misc/observable";
  69691. /**
  69692. * Defines the root class used to create scene optimization to use with SceneOptimizer
  69693. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69694. */
  69695. export class SceneOptimization {
  69696. /**
  69697. * Defines the priority of this optimization (0 by default which means first in the list)
  69698. */
  69699. priority: number;
  69700. /**
  69701. * Gets a string describing the action executed by the current optimization
  69702. * @returns description string
  69703. */
  69704. getDescription(): string;
  69705. /**
  69706. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69707. * @param scene defines the current scene where to apply this optimization
  69708. * @param optimizer defines the current optimizer
  69709. * @returns true if everything that can be done was applied
  69710. */
  69711. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69712. /**
  69713. * Creates the SceneOptimization object
  69714. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69715. * @param desc defines the description associated with the optimization
  69716. */
  69717. constructor(
  69718. /**
  69719. * Defines the priority of this optimization (0 by default which means first in the list)
  69720. */
  69721. priority?: number);
  69722. }
  69723. /**
  69724. * Defines an optimization used to reduce the size of render target textures
  69725. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69726. */
  69727. export class TextureOptimization extends SceneOptimization {
  69728. /**
  69729. * Defines the priority of this optimization (0 by default which means first in the list)
  69730. */
  69731. priority: number;
  69732. /**
  69733. * 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
  69734. */
  69735. maximumSize: number;
  69736. /**
  69737. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69738. */
  69739. step: number;
  69740. /**
  69741. * Gets a string describing the action executed by the current optimization
  69742. * @returns description string
  69743. */
  69744. getDescription(): string;
  69745. /**
  69746. * Creates the TextureOptimization object
  69747. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69748. * @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
  69749. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69750. */
  69751. constructor(
  69752. /**
  69753. * Defines the priority of this optimization (0 by default which means first in the list)
  69754. */
  69755. priority?: number,
  69756. /**
  69757. * 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
  69758. */
  69759. maximumSize?: number,
  69760. /**
  69761. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69762. */
  69763. step?: number);
  69764. /**
  69765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69766. * @param scene defines the current scene where to apply this optimization
  69767. * @param optimizer defines the current optimizer
  69768. * @returns true if everything that can be done was applied
  69769. */
  69770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69771. }
  69772. /**
  69773. * Defines an optimization used to increase or decrease the rendering resolution
  69774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69775. */
  69776. export class HardwareScalingOptimization extends SceneOptimization {
  69777. /**
  69778. * Defines the priority of this optimization (0 by default which means first in the list)
  69779. */
  69780. priority: number;
  69781. /**
  69782. * Defines the maximum scale to use (2 by default)
  69783. */
  69784. maximumScale: number;
  69785. /**
  69786. * Defines the step to use between two passes (0.5 by default)
  69787. */
  69788. step: number;
  69789. private _currentScale;
  69790. private _directionOffset;
  69791. /**
  69792. * Gets a string describing the action executed by the current optimization
  69793. * @return description string
  69794. */
  69795. getDescription(): string;
  69796. /**
  69797. * Creates the HardwareScalingOptimization object
  69798. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69799. * @param maximumScale defines the maximum scale to use (2 by default)
  69800. * @param step defines the step to use between two passes (0.5 by default)
  69801. */
  69802. constructor(
  69803. /**
  69804. * Defines the priority of this optimization (0 by default which means first in the list)
  69805. */
  69806. priority?: number,
  69807. /**
  69808. * Defines the maximum scale to use (2 by default)
  69809. */
  69810. maximumScale?: number,
  69811. /**
  69812. * Defines the step to use between two passes (0.5 by default)
  69813. */
  69814. step?: number);
  69815. /**
  69816. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69817. * @param scene defines the current scene where to apply this optimization
  69818. * @param optimizer defines the current optimizer
  69819. * @returns true if everything that can be done was applied
  69820. */
  69821. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69822. }
  69823. /**
  69824. * Defines an optimization used to remove shadows
  69825. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69826. */
  69827. export class ShadowsOptimization extends SceneOptimization {
  69828. /**
  69829. * Gets a string describing the action executed by the current optimization
  69830. * @return description string
  69831. */
  69832. getDescription(): string;
  69833. /**
  69834. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69835. * @param scene defines the current scene where to apply this optimization
  69836. * @param optimizer defines the current optimizer
  69837. * @returns true if everything that can be done was applied
  69838. */
  69839. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69840. }
  69841. /**
  69842. * Defines an optimization used to turn post-processes off
  69843. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69844. */
  69845. export class PostProcessesOptimization extends SceneOptimization {
  69846. /**
  69847. * Gets a string describing the action executed by the current optimization
  69848. * @return description string
  69849. */
  69850. getDescription(): string;
  69851. /**
  69852. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69853. * @param scene defines the current scene where to apply this optimization
  69854. * @param optimizer defines the current optimizer
  69855. * @returns true if everything that can be done was applied
  69856. */
  69857. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69858. }
  69859. /**
  69860. * Defines an optimization used to turn lens flares off
  69861. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69862. */
  69863. export class LensFlaresOptimization extends SceneOptimization {
  69864. /**
  69865. * Gets a string describing the action executed by the current optimization
  69866. * @return description string
  69867. */
  69868. getDescription(): string;
  69869. /**
  69870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69871. * @param scene defines the current scene where to apply this optimization
  69872. * @param optimizer defines the current optimizer
  69873. * @returns true if everything that can be done was applied
  69874. */
  69875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69876. }
  69877. /**
  69878. * Defines an optimization based on user defined callback.
  69879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69880. */
  69881. export class CustomOptimization extends SceneOptimization {
  69882. /**
  69883. * Callback called to apply the custom optimization.
  69884. */
  69885. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69886. /**
  69887. * Callback called to get custom description
  69888. */
  69889. onGetDescription: () => string;
  69890. /**
  69891. * Gets a string describing the action executed by the current optimization
  69892. * @returns description string
  69893. */
  69894. getDescription(): string;
  69895. /**
  69896. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69897. * @param scene defines the current scene where to apply this optimization
  69898. * @param optimizer defines the current optimizer
  69899. * @returns true if everything that can be done was applied
  69900. */
  69901. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69902. }
  69903. /**
  69904. * Defines an optimization used to turn particles off
  69905. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69906. */
  69907. export class ParticlesOptimization extends SceneOptimization {
  69908. /**
  69909. * Gets a string describing the action executed by the current optimization
  69910. * @return description string
  69911. */
  69912. getDescription(): string;
  69913. /**
  69914. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69915. * @param scene defines the current scene where to apply this optimization
  69916. * @param optimizer defines the current optimizer
  69917. * @returns true if everything that can be done was applied
  69918. */
  69919. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69920. }
  69921. /**
  69922. * Defines an optimization used to turn render targets off
  69923. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69924. */
  69925. export class RenderTargetsOptimization extends SceneOptimization {
  69926. /**
  69927. * Gets a string describing the action executed by the current optimization
  69928. * @return description string
  69929. */
  69930. getDescription(): string;
  69931. /**
  69932. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69933. * @param scene defines the current scene where to apply this optimization
  69934. * @param optimizer defines the current optimizer
  69935. * @returns true if everything that can be done was applied
  69936. */
  69937. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69938. }
  69939. /**
  69940. * Defines an optimization used to merge meshes with compatible materials
  69941. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69942. */
  69943. export class MergeMeshesOptimization extends SceneOptimization {
  69944. private static _UpdateSelectionTree;
  69945. /**
  69946. * Gets or sets a boolean which defines if optimization octree has to be updated
  69947. */
  69948. static get UpdateSelectionTree(): boolean;
  69949. /**
  69950. * Gets or sets a boolean which defines if optimization octree has to be updated
  69951. */
  69952. static set UpdateSelectionTree(value: boolean);
  69953. /**
  69954. * Gets a string describing the action executed by the current optimization
  69955. * @return description string
  69956. */
  69957. getDescription(): string;
  69958. private _canBeMerged;
  69959. /**
  69960. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69961. * @param scene defines the current scene where to apply this optimization
  69962. * @param optimizer defines the current optimizer
  69963. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69964. * @returns true if everything that can be done was applied
  69965. */
  69966. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69967. }
  69968. /**
  69969. * Defines a list of options used by SceneOptimizer
  69970. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69971. */
  69972. export class SceneOptimizerOptions {
  69973. /**
  69974. * Defines the target frame rate to reach (60 by default)
  69975. */
  69976. targetFrameRate: number;
  69977. /**
  69978. * Defines the interval between two checkes (2000ms by default)
  69979. */
  69980. trackerDuration: number;
  69981. /**
  69982. * Gets the list of optimizations to apply
  69983. */
  69984. optimizations: SceneOptimization[];
  69985. /**
  69986. * Creates a new list of options used by SceneOptimizer
  69987. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69988. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69989. */
  69990. constructor(
  69991. /**
  69992. * Defines the target frame rate to reach (60 by default)
  69993. */
  69994. targetFrameRate?: number,
  69995. /**
  69996. * Defines the interval between two checkes (2000ms by default)
  69997. */
  69998. trackerDuration?: number);
  69999. /**
  70000. * Add a new optimization
  70001. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70002. * @returns the current SceneOptimizerOptions
  70003. */
  70004. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70005. /**
  70006. * Add a new custom optimization
  70007. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70008. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70009. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70010. * @returns the current SceneOptimizerOptions
  70011. */
  70012. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70013. /**
  70014. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70015. * @param targetFrameRate defines the target frame rate (60 by default)
  70016. * @returns a SceneOptimizerOptions object
  70017. */
  70018. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70019. /**
  70020. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70021. * @param targetFrameRate defines the target frame rate (60 by default)
  70022. * @returns a SceneOptimizerOptions object
  70023. */
  70024. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70025. /**
  70026. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70027. * @param targetFrameRate defines the target frame rate (60 by default)
  70028. * @returns a SceneOptimizerOptions object
  70029. */
  70030. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70031. }
  70032. /**
  70033. * Class used to run optimizations in order to reach a target frame rate
  70034. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70035. */
  70036. export class SceneOptimizer implements IDisposable {
  70037. private _isRunning;
  70038. private _options;
  70039. private _scene;
  70040. private _currentPriorityLevel;
  70041. private _targetFrameRate;
  70042. private _trackerDuration;
  70043. private _currentFrameRate;
  70044. private _sceneDisposeObserver;
  70045. private _improvementMode;
  70046. /**
  70047. * Defines an observable called when the optimizer reaches the target frame rate
  70048. */
  70049. onSuccessObservable: Observable<SceneOptimizer>;
  70050. /**
  70051. * Defines an observable called when the optimizer enables an optimization
  70052. */
  70053. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70054. /**
  70055. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70056. */
  70057. onFailureObservable: Observable<SceneOptimizer>;
  70058. /**
  70059. * Gets a boolean indicating if the optimizer is in improvement mode
  70060. */
  70061. get isInImprovementMode(): boolean;
  70062. /**
  70063. * Gets the current priority level (0 at start)
  70064. */
  70065. get currentPriorityLevel(): number;
  70066. /**
  70067. * Gets the current frame rate checked by the SceneOptimizer
  70068. */
  70069. get currentFrameRate(): number;
  70070. /**
  70071. * Gets or sets the current target frame rate (60 by default)
  70072. */
  70073. get targetFrameRate(): number;
  70074. /**
  70075. * Gets or sets the current target frame rate (60 by default)
  70076. */
  70077. set targetFrameRate(value: number);
  70078. /**
  70079. * Gets or sets the current interval between two checks (every 2000ms by default)
  70080. */
  70081. get trackerDuration(): number;
  70082. /**
  70083. * Gets or sets the current interval between two checks (every 2000ms by default)
  70084. */
  70085. set trackerDuration(value: number);
  70086. /**
  70087. * Gets the list of active optimizations
  70088. */
  70089. get optimizations(): SceneOptimization[];
  70090. /**
  70091. * Creates a new SceneOptimizer
  70092. * @param scene defines the scene to work on
  70093. * @param options defines the options to use with the SceneOptimizer
  70094. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70095. * @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)
  70096. */
  70097. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70098. /**
  70099. * Stops the current optimizer
  70100. */
  70101. stop(): void;
  70102. /**
  70103. * Reset the optimizer to initial step (current priority level = 0)
  70104. */
  70105. reset(): void;
  70106. /**
  70107. * Start the optimizer. By default it will try to reach a specific framerate
  70108. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70109. */
  70110. start(): void;
  70111. private _checkCurrentState;
  70112. /**
  70113. * Release all resources
  70114. */
  70115. dispose(): void;
  70116. /**
  70117. * Helper function to create a SceneOptimizer with one single line of code
  70118. * @param scene defines the scene to work on
  70119. * @param options defines the options to use with the SceneOptimizer
  70120. * @param onSuccess defines a callback to call on success
  70121. * @param onFailure defines a callback to call on failure
  70122. * @returns the new SceneOptimizer object
  70123. */
  70124. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70125. }
  70126. }
  70127. declare module "babylonjs/Misc/sceneSerializer" {
  70128. import { Scene } from "babylonjs/scene";
  70129. /**
  70130. * Class used to serialize a scene into a string
  70131. */
  70132. export class SceneSerializer {
  70133. /**
  70134. * Clear cache used by a previous serialization
  70135. */
  70136. static ClearCache(): void;
  70137. /**
  70138. * Serialize a scene into a JSON compatible object
  70139. * @param scene defines the scene to serialize
  70140. * @returns a JSON compatible object
  70141. */
  70142. static Serialize(scene: Scene): any;
  70143. /**
  70144. * Serialize a mesh into a JSON compatible object
  70145. * @param toSerialize defines the mesh to serialize
  70146. * @param withParents defines if parents must be serialized as well
  70147. * @param withChildren defines if children must be serialized as well
  70148. * @returns a JSON compatible object
  70149. */
  70150. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70151. }
  70152. }
  70153. declare module "babylonjs/Misc/textureTools" {
  70154. import { Texture } from "babylonjs/Materials/Textures/texture";
  70155. /**
  70156. * Class used to host texture specific utilities
  70157. */
  70158. export class TextureTools {
  70159. /**
  70160. * Uses the GPU to create a copy texture rescaled at a given size
  70161. * @param texture Texture to copy from
  70162. * @param width defines the desired width
  70163. * @param height defines the desired height
  70164. * @param useBilinearMode defines if bilinear mode has to be used
  70165. * @return the generated texture
  70166. */
  70167. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70168. }
  70169. }
  70170. declare module "babylonjs/Misc/videoRecorder" {
  70171. import { Nullable } from "babylonjs/types";
  70172. import { Engine } from "babylonjs/Engines/engine";
  70173. /**
  70174. * This represents the different options available for the video capture.
  70175. */
  70176. export interface VideoRecorderOptions {
  70177. /** Defines the mime type of the video. */
  70178. mimeType: string;
  70179. /** Defines the FPS the video should be recorded at. */
  70180. fps: number;
  70181. /** Defines the chunk size for the recording data. */
  70182. recordChunckSize: number;
  70183. /** The audio tracks to attach to the recording. */
  70184. audioTracks?: MediaStreamTrack[];
  70185. }
  70186. /**
  70187. * This can help with recording videos from BabylonJS.
  70188. * This is based on the available WebRTC functionalities of the browser.
  70189. *
  70190. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70191. */
  70192. export class VideoRecorder {
  70193. private static readonly _defaultOptions;
  70194. /**
  70195. * Returns whether or not the VideoRecorder is available in your browser.
  70196. * @param engine Defines the Babylon Engine.
  70197. * @returns true if supported otherwise false.
  70198. */
  70199. static IsSupported(engine: Engine): boolean;
  70200. private readonly _options;
  70201. private _canvas;
  70202. private _mediaRecorder;
  70203. private _recordedChunks;
  70204. private _fileName;
  70205. private _resolve;
  70206. private _reject;
  70207. /**
  70208. * True when a recording is already in progress.
  70209. */
  70210. get isRecording(): boolean;
  70211. /**
  70212. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70213. * @param engine Defines the BabylonJS Engine you wish to record.
  70214. * @param options Defines options that can be used to customize the capture.
  70215. */
  70216. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70217. /**
  70218. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70219. */
  70220. stopRecording(): void;
  70221. /**
  70222. * Starts recording the canvas for a max duration specified in parameters.
  70223. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70224. * If null no automatic download will start and you can rely on the promise to get the data back.
  70225. * @param maxDuration Defines the maximum recording time in seconds.
  70226. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70227. * @return A promise callback at the end of the recording with the video data in Blob.
  70228. */
  70229. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70230. /**
  70231. * Releases internal resources used during the recording.
  70232. */
  70233. dispose(): void;
  70234. private _handleDataAvailable;
  70235. private _handleError;
  70236. private _handleStop;
  70237. }
  70238. }
  70239. declare module "babylonjs/Misc/screenshotTools" {
  70240. import { Camera } from "babylonjs/Cameras/camera";
  70241. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  70242. import { Engine } from "babylonjs/Engines/engine";
  70243. /**
  70244. * Class containing a set of static utilities functions for screenshots
  70245. */
  70246. export class ScreenshotTools {
  70247. /**
  70248. * Captures a screenshot of the current rendering
  70249. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70250. * @param engine defines the rendering engine
  70251. * @param camera defines the source camera
  70252. * @param size This parameter can be set to a single number or to an object with the
  70253. * following (optional) properties: precision, width, height. If a single number is passed,
  70254. * it will be used for both width and height. If an object is passed, the screenshot size
  70255. * will be derived from the parameters. The precision property is a multiplier allowing
  70256. * rendering at a higher or lower resolution
  70257. * @param successCallback defines the callback receives a single parameter which contains the
  70258. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70259. * src parameter of an <img> to display it
  70260. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70261. * Check your browser for supported MIME types
  70262. */
  70263. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70264. /**
  70265. * Captures a screenshot of the current rendering
  70266. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70267. * @param engine defines the rendering engine
  70268. * @param camera defines the source camera
  70269. * @param size This parameter can be set to a single number or to an object with the
  70270. * following (optional) properties: precision, width, height. If a single number is passed,
  70271. * it will be used for both width and height. If an object is passed, the screenshot size
  70272. * will be derived from the parameters. The precision property is a multiplier allowing
  70273. * rendering at a higher or lower resolution
  70274. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70275. * Check your browser for supported MIME types
  70276. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70277. * to the src parameter of an <img> to display it
  70278. */
  70279. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70280. /**
  70281. * Generates an image screenshot from the specified camera.
  70282. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70283. * @param engine The engine to use for rendering
  70284. * @param camera The camera to use for rendering
  70285. * @param size This parameter can be set to a single number or to an object with the
  70286. * following (optional) properties: precision, width, height. If a single number is passed,
  70287. * it will be used for both width and height. If an object is passed, the screenshot size
  70288. * will be derived from the parameters. The precision property is a multiplier allowing
  70289. * rendering at a higher or lower resolution
  70290. * @param successCallback The callback receives a single parameter which contains the
  70291. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70292. * src parameter of an <img> to display it
  70293. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70294. * Check your browser for supported MIME types
  70295. * @param samples Texture samples (default: 1)
  70296. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70297. * @param fileName A name for for the downloaded file.
  70298. */
  70299. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  70300. /**
  70301. * Generates an image screenshot from the specified camera.
  70302. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70303. * @param engine The engine to use for rendering
  70304. * @param camera The camera to use for rendering
  70305. * @param size This parameter can be set to a single number or to an object with the
  70306. * following (optional) properties: precision, width, height. If a single number is passed,
  70307. * it will be used for both width and height. If an object is passed, the screenshot size
  70308. * will be derived from the parameters. The precision property is a multiplier allowing
  70309. * rendering at a higher or lower resolution
  70310. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70311. * Check your browser for supported MIME types
  70312. * @param samples Texture samples (default: 1)
  70313. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70314. * @param fileName A name for for the downloaded file.
  70315. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70316. * to the src parameter of an <img> to display it
  70317. */
  70318. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  70319. /**
  70320. * Gets height and width for screenshot size
  70321. * @private
  70322. */
  70323. private static _getScreenshotSize;
  70324. }
  70325. }
  70326. declare module "babylonjs/Misc/dataReader" {
  70327. /**
  70328. * Interface for a data buffer
  70329. */
  70330. export interface IDataBuffer {
  70331. /**
  70332. * Reads bytes from the data buffer.
  70333. * @param byteOffset The byte offset to read
  70334. * @param byteLength The byte length to read
  70335. * @returns A promise that resolves when the bytes are read
  70336. */
  70337. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70338. /**
  70339. * The byte length of the buffer.
  70340. */
  70341. readonly byteLength: number;
  70342. }
  70343. /**
  70344. * Utility class for reading from a data buffer
  70345. */
  70346. export class DataReader {
  70347. /**
  70348. * The data buffer associated with this data reader.
  70349. */
  70350. readonly buffer: IDataBuffer;
  70351. /**
  70352. * The current byte offset from the beginning of the data buffer.
  70353. */
  70354. byteOffset: number;
  70355. private _dataView;
  70356. private _dataByteOffset;
  70357. /**
  70358. * Constructor
  70359. * @param buffer The buffer to read
  70360. */
  70361. constructor(buffer: IDataBuffer);
  70362. /**
  70363. * Loads the given byte length.
  70364. * @param byteLength The byte length to load
  70365. * @returns A promise that resolves when the load is complete
  70366. */
  70367. loadAsync(byteLength: number): Promise<void>;
  70368. /**
  70369. * Read a unsigned 32-bit integer from the currently loaded data range.
  70370. * @returns The 32-bit integer read
  70371. */
  70372. readUint32(): number;
  70373. /**
  70374. * Read a byte array from the currently loaded data range.
  70375. * @param byteLength The byte length to read
  70376. * @returns The byte array read
  70377. */
  70378. readUint8Array(byteLength: number): Uint8Array;
  70379. /**
  70380. * Read a string from the currently loaded data range.
  70381. * @param byteLength The byte length to read
  70382. * @returns The string read
  70383. */
  70384. readString(byteLength: number): string;
  70385. /**
  70386. * Skips the given byte length the currently loaded data range.
  70387. * @param byteLength The byte length to skip
  70388. */
  70389. skipBytes(byteLength: number): void;
  70390. }
  70391. }
  70392. declare module "babylonjs/Misc/index" {
  70393. export * from "babylonjs/Misc/andOrNotEvaluator";
  70394. export * from "babylonjs/Misc/assetsManager";
  70395. export * from "babylonjs/Misc/basis";
  70396. export * from "babylonjs/Misc/dds";
  70397. export * from "babylonjs/Misc/decorators";
  70398. export * from "babylonjs/Misc/deferred";
  70399. export * from "babylonjs/Misc/environmentTextureTools";
  70400. export * from "babylonjs/Misc/meshExploder";
  70401. export * from "babylonjs/Misc/filesInput";
  70402. export * from "babylonjs/Misc/HighDynamicRange/index";
  70403. export * from "babylonjs/Misc/khronosTextureContainer";
  70404. export * from "babylonjs/Misc/observable";
  70405. export * from "babylonjs/Misc/performanceMonitor";
  70406. export * from "babylonjs/Misc/promise";
  70407. export * from "babylonjs/Misc/sceneOptimizer";
  70408. export * from "babylonjs/Misc/sceneSerializer";
  70409. export * from "babylonjs/Misc/smartArray";
  70410. export * from "babylonjs/Misc/stringDictionary";
  70411. export * from "babylonjs/Misc/tags";
  70412. export * from "babylonjs/Misc/textureTools";
  70413. export * from "babylonjs/Misc/tga";
  70414. export * from "babylonjs/Misc/tools";
  70415. export * from "babylonjs/Misc/videoRecorder";
  70416. export * from "babylonjs/Misc/virtualJoystick";
  70417. export * from "babylonjs/Misc/workerPool";
  70418. export * from "babylonjs/Misc/logger";
  70419. export * from "babylonjs/Misc/typeStore";
  70420. export * from "babylonjs/Misc/filesInputStore";
  70421. export * from "babylonjs/Misc/deepCopier";
  70422. export * from "babylonjs/Misc/pivotTools";
  70423. export * from "babylonjs/Misc/precisionDate";
  70424. export * from "babylonjs/Misc/screenshotTools";
  70425. export * from "babylonjs/Misc/typeStore";
  70426. export * from "babylonjs/Misc/webRequest";
  70427. export * from "babylonjs/Misc/iInspectable";
  70428. export * from "babylonjs/Misc/brdfTextureTools";
  70429. export * from "babylonjs/Misc/rgbdTextureTools";
  70430. export * from "babylonjs/Misc/gradients";
  70431. export * from "babylonjs/Misc/perfCounter";
  70432. export * from "babylonjs/Misc/fileRequest";
  70433. export * from "babylonjs/Misc/customAnimationFrameRequester";
  70434. export * from "babylonjs/Misc/retryStrategy";
  70435. export * from "babylonjs/Misc/interfaces/screenshotSize";
  70436. export * from "babylonjs/Misc/canvasGenerator";
  70437. export * from "babylonjs/Misc/fileTools";
  70438. export * from "babylonjs/Misc/stringTools";
  70439. export * from "babylonjs/Misc/dataReader";
  70440. }
  70441. declare module "babylonjs/index" {
  70442. export * from "babylonjs/abstractScene";
  70443. export * from "babylonjs/Actions/index";
  70444. export * from "babylonjs/Animations/index";
  70445. export * from "babylonjs/assetContainer";
  70446. export * from "babylonjs/Audio/index";
  70447. export * from "babylonjs/Behaviors/index";
  70448. export * from "babylonjs/Bones/index";
  70449. export * from "babylonjs/Cameras/index";
  70450. export * from "babylonjs/Collisions/index";
  70451. export * from "babylonjs/Culling/index";
  70452. export * from "babylonjs/Debug/index";
  70453. export * from "babylonjs/Engines/index";
  70454. export * from "babylonjs/Events/index";
  70455. export * from "babylonjs/Gamepads/index";
  70456. export * from "babylonjs/Gizmos/index";
  70457. export * from "babylonjs/Helpers/index";
  70458. export * from "babylonjs/Instrumentation/index";
  70459. export * from "babylonjs/Layers/index";
  70460. export * from "babylonjs/LensFlares/index";
  70461. export * from "babylonjs/Lights/index";
  70462. export * from "babylonjs/Loading/index";
  70463. export * from "babylonjs/Materials/index";
  70464. export * from "babylonjs/Maths/index";
  70465. export * from "babylonjs/Meshes/index";
  70466. export * from "babylonjs/Morph/index";
  70467. export * from "babylonjs/Navigation/index";
  70468. export * from "babylonjs/node";
  70469. export * from "babylonjs/Offline/index";
  70470. export * from "babylonjs/Particles/index";
  70471. export * from "babylonjs/Physics/index";
  70472. export * from "babylonjs/PostProcesses/index";
  70473. export * from "babylonjs/Probes/index";
  70474. export * from "babylonjs/Rendering/index";
  70475. export * from "babylonjs/scene";
  70476. export * from "babylonjs/sceneComponent";
  70477. export * from "babylonjs/Sprites/index";
  70478. export * from "babylonjs/States/index";
  70479. export * from "babylonjs/Misc/index";
  70480. export * from "babylonjs/types";
  70481. }
  70482. declare module "babylonjs/Animations/pathCursor" {
  70483. import { Vector3 } from "babylonjs/Maths/math.vector";
  70484. import { Path2 } from "babylonjs/Maths/math.path";
  70485. /**
  70486. * A cursor which tracks a point on a path
  70487. */
  70488. export class PathCursor {
  70489. private path;
  70490. /**
  70491. * Stores path cursor callbacks for when an onchange event is triggered
  70492. */
  70493. private _onchange;
  70494. /**
  70495. * The value of the path cursor
  70496. */
  70497. value: number;
  70498. /**
  70499. * The animation array of the path cursor
  70500. */
  70501. animations: Animation[];
  70502. /**
  70503. * Initializes the path cursor
  70504. * @param path The path to track
  70505. */
  70506. constructor(path: Path2);
  70507. /**
  70508. * Gets the cursor point on the path
  70509. * @returns A point on the path cursor at the cursor location
  70510. */
  70511. getPoint(): Vector3;
  70512. /**
  70513. * Moves the cursor ahead by the step amount
  70514. * @param step The amount to move the cursor forward
  70515. * @returns This path cursor
  70516. */
  70517. moveAhead(step?: number): PathCursor;
  70518. /**
  70519. * Moves the cursor behind by the step amount
  70520. * @param step The amount to move the cursor back
  70521. * @returns This path cursor
  70522. */
  70523. moveBack(step?: number): PathCursor;
  70524. /**
  70525. * Moves the cursor by the step amount
  70526. * If the step amount is greater than one, an exception is thrown
  70527. * @param step The amount to move the cursor
  70528. * @returns This path cursor
  70529. */
  70530. move(step: number): PathCursor;
  70531. /**
  70532. * Ensures that the value is limited between zero and one
  70533. * @returns This path cursor
  70534. */
  70535. private ensureLimits;
  70536. /**
  70537. * Runs onchange callbacks on change (used by the animation engine)
  70538. * @returns This path cursor
  70539. */
  70540. private raiseOnChange;
  70541. /**
  70542. * Executes a function on change
  70543. * @param f A path cursor onchange callback
  70544. * @returns This path cursor
  70545. */
  70546. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70547. }
  70548. }
  70549. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  70550. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  70551. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  70552. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  70553. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  70554. }
  70555. declare module "babylonjs/Engines/Processors/Expressions/index" {
  70556. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  70557. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  70558. }
  70559. declare module "babylonjs/Engines/Processors/index" {
  70560. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  70561. export * from "babylonjs/Engines/Processors/Expressions/index";
  70562. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  70563. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  70564. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  70565. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  70566. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  70567. export * from "babylonjs/Engines/Processors/shaderProcessor";
  70568. }
  70569. declare module "babylonjs/Legacy/legacy" {
  70570. import * as Babylon from "babylonjs/index";
  70571. export * from "babylonjs/index";
  70572. }
  70573. declare module "babylonjs/Shaders/blur.fragment" {
  70574. /** @hidden */
  70575. export var blurPixelShader: {
  70576. name: string;
  70577. shader: string;
  70578. };
  70579. }
  70580. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  70581. /** @hidden */
  70582. export var pointCloudVertexDeclaration: {
  70583. name: string;
  70584. shader: string;
  70585. };
  70586. }
  70587. declare module "babylonjs" {
  70588. export * from "babylonjs/Legacy/legacy";
  70589. }
  70590. declare module BABYLON {
  70591. /** Alias type for value that can be null */
  70592. export type Nullable<T> = T | null;
  70593. /**
  70594. * Alias type for number that are floats
  70595. * @ignorenaming
  70596. */
  70597. export type float = number;
  70598. /**
  70599. * Alias type for number that are doubles.
  70600. * @ignorenaming
  70601. */
  70602. export type double = number;
  70603. /**
  70604. * Alias type for number that are integer
  70605. * @ignorenaming
  70606. */
  70607. export type int = number;
  70608. /** Alias type for number array or Float32Array */
  70609. export type FloatArray = number[] | Float32Array;
  70610. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  70611. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  70612. /**
  70613. * Alias for types that can be used by a Buffer or VertexBuffer.
  70614. */
  70615. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  70616. /**
  70617. * Alias type for primitive types
  70618. * @ignorenaming
  70619. */
  70620. type Primitive = undefined | null | boolean | string | number | Function;
  70621. /**
  70622. * Type modifier to make all the properties of an object Readonly
  70623. */
  70624. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  70625. /**
  70626. * Type modifier to make all the properties of an object Readonly recursively
  70627. */
  70628. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  70629. /**
  70630. * Type modifier to make object properties readonly.
  70631. */
  70632. export type DeepImmutableObject<T> = {
  70633. readonly [K in keyof T]: DeepImmutable<T[K]>;
  70634. };
  70635. /** @hidden */
  70636. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  70637. }
  70638. }
  70639. declare module BABYLON {
  70640. /**
  70641. * A class serves as a medium between the observable and its observers
  70642. */
  70643. export class EventState {
  70644. /**
  70645. * Create a new EventState
  70646. * @param mask defines the mask associated with this state
  70647. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70648. * @param target defines the original target of the state
  70649. * @param currentTarget defines the current target of the state
  70650. */
  70651. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  70652. /**
  70653. * Initialize the current event state
  70654. * @param mask defines the mask associated with this state
  70655. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70656. * @param target defines the original target of the state
  70657. * @param currentTarget defines the current target of the state
  70658. * @returns the current event state
  70659. */
  70660. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  70661. /**
  70662. * An Observer can set this property to true to prevent subsequent observers of being notified
  70663. */
  70664. skipNextObservers: boolean;
  70665. /**
  70666. * Get the mask value that were used to trigger the event corresponding to this EventState object
  70667. */
  70668. mask: number;
  70669. /**
  70670. * The object that originally notified the event
  70671. */
  70672. target?: any;
  70673. /**
  70674. * The current object in the bubbling phase
  70675. */
  70676. currentTarget?: any;
  70677. /**
  70678. * This will be populated with the return value of the last function that was executed.
  70679. * If it is the first function in the callback chain it will be the event data.
  70680. */
  70681. lastReturnValue?: any;
  70682. }
  70683. /**
  70684. * Represent an Observer registered to a given Observable object.
  70685. */
  70686. export class Observer<T> {
  70687. /**
  70688. * Defines the callback to call when the observer is notified
  70689. */
  70690. callback: (eventData: T, eventState: EventState) => void;
  70691. /**
  70692. * Defines the mask of the observer (used to filter notifications)
  70693. */
  70694. mask: number;
  70695. /**
  70696. * Defines the current scope used to restore the JS context
  70697. */
  70698. scope: any;
  70699. /** @hidden */
  70700. _willBeUnregistered: boolean;
  70701. /**
  70702. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  70703. */
  70704. unregisterOnNextCall: boolean;
  70705. /**
  70706. * Creates a new observer
  70707. * @param callback defines the callback to call when the observer is notified
  70708. * @param mask defines the mask of the observer (used to filter notifications)
  70709. * @param scope defines the current scope used to restore the JS context
  70710. */
  70711. constructor(
  70712. /**
  70713. * Defines the callback to call when the observer is notified
  70714. */
  70715. callback: (eventData: T, eventState: EventState) => void,
  70716. /**
  70717. * Defines the mask of the observer (used to filter notifications)
  70718. */
  70719. mask: number,
  70720. /**
  70721. * Defines the current scope used to restore the JS context
  70722. */
  70723. scope?: any);
  70724. }
  70725. /**
  70726. * Represent a list of observers registered to multiple Observables object.
  70727. */
  70728. export class MultiObserver<T> {
  70729. private _observers;
  70730. private _observables;
  70731. /**
  70732. * Release associated resources
  70733. */
  70734. dispose(): void;
  70735. /**
  70736. * Raise a callback when one of the observable will notify
  70737. * @param observables defines a list of observables to watch
  70738. * @param callback defines the callback to call on notification
  70739. * @param mask defines the mask used to filter notifications
  70740. * @param scope defines the current scope used to restore the JS context
  70741. * @returns the new MultiObserver
  70742. */
  70743. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  70744. }
  70745. /**
  70746. * The Observable class is a simple implementation of the Observable pattern.
  70747. *
  70748. * 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.
  70749. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  70750. * 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).
  70751. * 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.
  70752. */
  70753. export class Observable<T> {
  70754. private _observers;
  70755. private _eventState;
  70756. private _onObserverAdded;
  70757. /**
  70758. * Gets the list of observers
  70759. */
  70760. get observers(): Array<Observer<T>>;
  70761. /**
  70762. * Creates a new observable
  70763. * @param onObserverAdded defines a callback to call when a new observer is added
  70764. */
  70765. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  70766. /**
  70767. * Create a new Observer with the specified callback
  70768. * @param callback the callback that will be executed for that Observer
  70769. * @param mask the mask used to filter observers
  70770. * @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.
  70771. * @param scope optional scope for the callback to be called from
  70772. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  70773. * @returns the new observer created for the callback
  70774. */
  70775. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  70776. /**
  70777. * Create a new Observer with the specified callback and unregisters after the next notification
  70778. * @param callback the callback that will be executed for that Observer
  70779. * @returns the new observer created for the callback
  70780. */
  70781. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  70782. /**
  70783. * Remove an Observer from the Observable object
  70784. * @param observer the instance of the Observer to remove
  70785. * @returns false if it doesn't belong to this Observable
  70786. */
  70787. remove(observer: Nullable<Observer<T>>): boolean;
  70788. /**
  70789. * Remove a callback from the Observable object
  70790. * @param callback the callback to remove
  70791. * @param scope optional scope. If used only the callbacks with this scope will be removed
  70792. * @returns false if it doesn't belong to this Observable
  70793. */
  70794. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  70795. private _deferUnregister;
  70796. private _remove;
  70797. /**
  70798. * Moves the observable to the top of the observer list making it get called first when notified
  70799. * @param observer the observer to move
  70800. */
  70801. makeObserverTopPriority(observer: Observer<T>): void;
  70802. /**
  70803. * Moves the observable to the bottom of the observer list making it get called last when notified
  70804. * @param observer the observer to move
  70805. */
  70806. makeObserverBottomPriority(observer: Observer<T>): void;
  70807. /**
  70808. * Notify all Observers by calling their respective callback with the given data
  70809. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  70810. * @param eventData defines the data to send to all observers
  70811. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  70812. * @param target defines the original target of the state
  70813. * @param currentTarget defines the current target of the state
  70814. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  70815. */
  70816. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  70817. /**
  70818. * Calling this will execute each callback, expecting it to be a promise or return a value.
  70819. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  70820. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  70821. * and it is crucial that all callbacks will be executed.
  70822. * The order of the callbacks is kept, callbacks are not executed parallel.
  70823. *
  70824. * @param eventData The data to be sent to each callback
  70825. * @param mask is used to filter observers defaults to -1
  70826. * @param target defines the callback target (see EventState)
  70827. * @param currentTarget defines he current object in the bubbling phase
  70828. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  70829. */
  70830. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  70831. /**
  70832. * Notify a specific observer
  70833. * @param observer defines the observer to notify
  70834. * @param eventData defines the data to be sent to each callback
  70835. * @param mask is used to filter observers defaults to -1
  70836. */
  70837. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  70838. /**
  70839. * Gets a boolean indicating if the observable has at least one observer
  70840. * @returns true is the Observable has at least one Observer registered
  70841. */
  70842. hasObservers(): boolean;
  70843. /**
  70844. * Clear the list of observers
  70845. */
  70846. clear(): void;
  70847. /**
  70848. * Clone the current observable
  70849. * @returns a new observable
  70850. */
  70851. clone(): Observable<T>;
  70852. /**
  70853. * Does this observable handles observer registered with a given mask
  70854. * @param mask defines the mask to be tested
  70855. * @return whether or not one observer registered with the given mask is handeled
  70856. **/
  70857. hasSpecificMask(mask?: number): boolean;
  70858. }
  70859. }
  70860. declare module BABYLON {
  70861. /**
  70862. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  70863. * Babylon.js
  70864. */
  70865. export class DomManagement {
  70866. /**
  70867. * Checks if the window object exists
  70868. * @returns true if the window object exists
  70869. */
  70870. static IsWindowObjectExist(): boolean;
  70871. /**
  70872. * Checks if the navigator object exists
  70873. * @returns true if the navigator object exists
  70874. */
  70875. static IsNavigatorAvailable(): boolean;
  70876. /**
  70877. * Extracts text content from a DOM element hierarchy
  70878. * @param element defines the root element
  70879. * @returns a string
  70880. */
  70881. static GetDOMTextContent(element: HTMLElement): string;
  70882. }
  70883. }
  70884. declare module BABYLON {
  70885. /**
  70886. * Logger used througouht the application to allow configuration of
  70887. * the log level required for the messages.
  70888. */
  70889. export class Logger {
  70890. /**
  70891. * No log
  70892. */
  70893. static readonly NoneLogLevel: number;
  70894. /**
  70895. * Only message logs
  70896. */
  70897. static readonly MessageLogLevel: number;
  70898. /**
  70899. * Only warning logs
  70900. */
  70901. static readonly WarningLogLevel: number;
  70902. /**
  70903. * Only error logs
  70904. */
  70905. static readonly ErrorLogLevel: number;
  70906. /**
  70907. * All logs
  70908. */
  70909. static readonly AllLogLevel: number;
  70910. private static _LogCache;
  70911. /**
  70912. * Gets a value indicating the number of loading errors
  70913. * @ignorenaming
  70914. */
  70915. static errorsCount: number;
  70916. /**
  70917. * Callback called when a new log is added
  70918. */
  70919. static OnNewCacheEntry: (entry: string) => void;
  70920. private static _AddLogEntry;
  70921. private static _FormatMessage;
  70922. private static _LogDisabled;
  70923. private static _LogEnabled;
  70924. private static _WarnDisabled;
  70925. private static _WarnEnabled;
  70926. private static _ErrorDisabled;
  70927. private static _ErrorEnabled;
  70928. /**
  70929. * Log a message to the console
  70930. */
  70931. static Log: (message: string) => void;
  70932. /**
  70933. * Write a warning message to the console
  70934. */
  70935. static Warn: (message: string) => void;
  70936. /**
  70937. * Write an error message to the console
  70938. */
  70939. static Error: (message: string) => void;
  70940. /**
  70941. * Gets current log cache (list of logs)
  70942. */
  70943. static get LogCache(): string;
  70944. /**
  70945. * Clears the log cache
  70946. */
  70947. static ClearLogCache(): void;
  70948. /**
  70949. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  70950. */
  70951. static set LogLevels(level: number);
  70952. }
  70953. }
  70954. declare module BABYLON {
  70955. /** @hidden */
  70956. export class _TypeStore {
  70957. /** @hidden */
  70958. static RegisteredTypes: {
  70959. [key: string]: Object;
  70960. };
  70961. /** @hidden */
  70962. static GetClass(fqdn: string): any;
  70963. }
  70964. }
  70965. declare module BABYLON {
  70966. /**
  70967. * Helper to manipulate strings
  70968. */
  70969. export class StringTools {
  70970. /**
  70971. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70972. * @param str Source string
  70973. * @param suffix Suffix to search for in the source string
  70974. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70975. */
  70976. static EndsWith(str: string, suffix: string): boolean;
  70977. /**
  70978. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70979. * @param str Source string
  70980. * @param suffix Suffix to search for in the source string
  70981. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70982. */
  70983. static StartsWith(str: string, suffix: string): boolean;
  70984. /**
  70985. * Decodes a buffer into a string
  70986. * @param buffer The buffer to decode
  70987. * @returns The decoded string
  70988. */
  70989. static Decode(buffer: Uint8Array | Uint16Array): string;
  70990. /**
  70991. * Encode a buffer to a base64 string
  70992. * @param buffer defines the buffer to encode
  70993. * @returns the encoded string
  70994. */
  70995. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  70996. }
  70997. }
  70998. declare module BABYLON {
  70999. /**
  71000. * Class containing a set of static utilities functions for deep copy.
  71001. */
  71002. export class DeepCopier {
  71003. /**
  71004. * Tries to copy an object by duplicating every property
  71005. * @param source defines the source object
  71006. * @param destination defines the target object
  71007. * @param doNotCopyList defines a list of properties to avoid
  71008. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  71009. */
  71010. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  71011. }
  71012. }
  71013. declare module BABYLON {
  71014. /**
  71015. * Class containing a set of static utilities functions for precision date
  71016. */
  71017. export class PrecisionDate {
  71018. /**
  71019. * Gets either window.performance.now() if supported or Date.now() else
  71020. */
  71021. static get Now(): number;
  71022. }
  71023. }
  71024. declare module BABYLON {
  71025. /** @hidden */
  71026. export class _DevTools {
  71027. static WarnImport(name: string): string;
  71028. }
  71029. }
  71030. declare module BABYLON {
  71031. /**
  71032. * Interface used to define the mechanism to get data from the network
  71033. */
  71034. export interface IWebRequest {
  71035. /**
  71036. * Returns client's response url
  71037. */
  71038. responseURL: string;
  71039. /**
  71040. * Returns client's status
  71041. */
  71042. status: number;
  71043. /**
  71044. * Returns client's status as a text
  71045. */
  71046. statusText: string;
  71047. }
  71048. }
  71049. declare module BABYLON {
  71050. /**
  71051. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  71052. */
  71053. export class WebRequest implements IWebRequest {
  71054. private _xhr;
  71055. /**
  71056. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  71057. * i.e. when loading files, where the server/service expects an Authorization header
  71058. */
  71059. static CustomRequestHeaders: {
  71060. [key: string]: string;
  71061. };
  71062. /**
  71063. * Add callback functions in this array to update all the requests before they get sent to the network
  71064. */
  71065. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  71066. private _injectCustomRequestHeaders;
  71067. /**
  71068. * Gets or sets a function to be called when loading progress changes
  71069. */
  71070. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  71071. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  71072. /**
  71073. * Returns client's state
  71074. */
  71075. get readyState(): number;
  71076. /**
  71077. * Returns client's status
  71078. */
  71079. get status(): number;
  71080. /**
  71081. * Returns client's status as a text
  71082. */
  71083. get statusText(): string;
  71084. /**
  71085. * Returns client's response
  71086. */
  71087. get response(): any;
  71088. /**
  71089. * Returns client's response url
  71090. */
  71091. get responseURL(): string;
  71092. /**
  71093. * Returns client's response as text
  71094. */
  71095. get responseText(): string;
  71096. /**
  71097. * Gets or sets the expected response type
  71098. */
  71099. get responseType(): XMLHttpRequestResponseType;
  71100. set responseType(value: XMLHttpRequestResponseType);
  71101. /** @hidden */
  71102. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  71103. /** @hidden */
  71104. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  71105. /**
  71106. * Cancels any network activity
  71107. */
  71108. abort(): void;
  71109. /**
  71110. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  71111. * @param body defines an optional request body
  71112. */
  71113. send(body?: Document | BodyInit | null): void;
  71114. /**
  71115. * Sets the request method, request URL
  71116. * @param method defines the method to use (GET, POST, etc..)
  71117. * @param url defines the url to connect with
  71118. */
  71119. open(method: string, url: string): void;
  71120. /**
  71121. * Sets the value of a request header.
  71122. * @param name The name of the header whose value is to be set
  71123. * @param value The value to set as the body of the header
  71124. */
  71125. setRequestHeader(name: string, value: string): void;
  71126. /**
  71127. * Get the string containing the text of a particular header's value.
  71128. * @param name The name of the header
  71129. * @returns The string containing the text of the given header name
  71130. */
  71131. getResponseHeader(name: string): Nullable<string>;
  71132. }
  71133. }
  71134. declare module BABYLON {
  71135. /**
  71136. * File request interface
  71137. */
  71138. export interface IFileRequest {
  71139. /**
  71140. * Raised when the request is complete (success or error).
  71141. */
  71142. onCompleteObservable: Observable<IFileRequest>;
  71143. /**
  71144. * Aborts the request for a file.
  71145. */
  71146. abort: () => void;
  71147. }
  71148. }
  71149. declare module BABYLON {
  71150. /**
  71151. * Define options used to create a render target texture
  71152. */
  71153. export class RenderTargetCreationOptions {
  71154. /**
  71155. * Specifies is mipmaps must be generated
  71156. */
  71157. generateMipMaps?: boolean;
  71158. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71159. generateDepthBuffer?: boolean;
  71160. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71161. generateStencilBuffer?: boolean;
  71162. /** Defines texture type (int by default) */
  71163. type?: number;
  71164. /** Defines sampling mode (trilinear by default) */
  71165. samplingMode?: number;
  71166. /** Defines format (RGBA by default) */
  71167. format?: number;
  71168. }
  71169. }
  71170. declare module BABYLON {
  71171. /**
  71172. * @hidden
  71173. **/
  71174. export class _TimeToken {
  71175. _startTimeQuery: Nullable<WebGLQuery>;
  71176. _endTimeQuery: Nullable<WebGLQuery>;
  71177. _timeElapsedQuery: Nullable<WebGLQuery>;
  71178. _timeElapsedQueryEnded: boolean;
  71179. }
  71180. }
  71181. declare module BABYLON {
  71182. /** Defines the cross module used constants to avoid circular dependncies */
  71183. export class Constants {
  71184. /** Defines that alpha blending is disabled */
  71185. static readonly ALPHA_DISABLE: number;
  71186. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  71187. static readonly ALPHA_ADD: number;
  71188. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71189. static readonly ALPHA_COMBINE: number;
  71190. /** Defines that alpha blending is DEST - SRC * DEST */
  71191. static readonly ALPHA_SUBTRACT: number;
  71192. /** Defines that alpha blending is SRC * DEST */
  71193. static readonly ALPHA_MULTIPLY: number;
  71194. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  71195. static readonly ALPHA_MAXIMIZED: number;
  71196. /** Defines that alpha blending is SRC + DEST */
  71197. static readonly ALPHA_ONEONE: number;
  71198. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  71199. static readonly ALPHA_PREMULTIPLIED: number;
  71200. /**
  71201. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  71202. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71203. */
  71204. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71205. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  71206. static readonly ALPHA_INTERPOLATE: number;
  71207. /**
  71208. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  71209. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71210. */
  71211. static readonly ALPHA_SCREENMODE: number;
  71212. /**
  71213. * Defines that alpha blending is SRC + DST
  71214. * Alpha will be set to SRC ALPHA + DST ALPHA
  71215. */
  71216. static readonly ALPHA_ONEONE_ONEONE: number;
  71217. /**
  71218. * Defines that alpha blending is SRC * DST ALPHA + DST
  71219. * Alpha will be set to 0
  71220. */
  71221. static readonly ALPHA_ALPHATOCOLOR: number;
  71222. /**
  71223. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71224. */
  71225. static readonly ALPHA_REVERSEONEMINUS: number;
  71226. /**
  71227. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  71228. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71229. */
  71230. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71231. /**
  71232. * Defines that alpha blending is SRC + DST
  71233. * Alpha will be set to SRC ALPHA
  71234. */
  71235. static readonly ALPHA_ONEONE_ONEZERO: number;
  71236. /**
  71237. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71238. * Alpha will be set to DST ALPHA
  71239. */
  71240. static readonly ALPHA_EXCLUSION: number;
  71241. /** Defines that alpha blending equation a SUM */
  71242. static readonly ALPHA_EQUATION_ADD: number;
  71243. /** Defines that alpha blending equation a SUBSTRACTION */
  71244. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71245. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71246. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71247. /** Defines that alpha blending equation a MAX operation */
  71248. static readonly ALPHA_EQUATION_MAX: number;
  71249. /** Defines that alpha blending equation a MIN operation */
  71250. static readonly ALPHA_EQUATION_MIN: number;
  71251. /**
  71252. * Defines that alpha blending equation a DARKEN operation:
  71253. * It takes the min of the src and sums the alpha channels.
  71254. */
  71255. static readonly ALPHA_EQUATION_DARKEN: number;
  71256. /** Defines that the ressource is not delayed*/
  71257. static readonly DELAYLOADSTATE_NONE: number;
  71258. /** Defines that the ressource was successfully delay loaded */
  71259. static readonly DELAYLOADSTATE_LOADED: number;
  71260. /** Defines that the ressource is currently delay loading */
  71261. static readonly DELAYLOADSTATE_LOADING: number;
  71262. /** Defines that the ressource is delayed and has not started loading */
  71263. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71264. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71265. static readonly NEVER: number;
  71266. /** 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 */
  71267. static readonly ALWAYS: number;
  71268. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71269. static readonly LESS: number;
  71270. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71271. static readonly EQUAL: number;
  71272. /** 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 */
  71273. static readonly LEQUAL: number;
  71274. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71275. static readonly GREATER: number;
  71276. /** 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 */
  71277. static readonly GEQUAL: number;
  71278. /** 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 */
  71279. static readonly NOTEQUAL: number;
  71280. /** Passed to stencilOperation to specify that stencil value must be kept */
  71281. static readonly KEEP: number;
  71282. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71283. static readonly REPLACE: number;
  71284. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71285. static readonly INCR: number;
  71286. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71287. static readonly DECR: number;
  71288. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71289. static readonly INVERT: number;
  71290. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71291. static readonly INCR_WRAP: number;
  71292. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71293. static readonly DECR_WRAP: number;
  71294. /** Texture is not repeating outside of 0..1 UVs */
  71295. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71296. /** Texture is repeating outside of 0..1 UVs */
  71297. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71298. /** Texture is repeating and mirrored */
  71299. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71300. /** ALPHA */
  71301. static readonly TEXTUREFORMAT_ALPHA: number;
  71302. /** LUMINANCE */
  71303. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71304. /** LUMINANCE_ALPHA */
  71305. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71306. /** RGB */
  71307. static readonly TEXTUREFORMAT_RGB: number;
  71308. /** RGBA */
  71309. static readonly TEXTUREFORMAT_RGBA: number;
  71310. /** RED */
  71311. static readonly TEXTUREFORMAT_RED: number;
  71312. /** RED (2nd reference) */
  71313. static readonly TEXTUREFORMAT_R: number;
  71314. /** RG */
  71315. static readonly TEXTUREFORMAT_RG: number;
  71316. /** RED_INTEGER */
  71317. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71318. /** RED_INTEGER (2nd reference) */
  71319. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71320. /** RG_INTEGER */
  71321. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71322. /** RGB_INTEGER */
  71323. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71324. /** RGBA_INTEGER */
  71325. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71326. /** UNSIGNED_BYTE */
  71327. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71328. /** UNSIGNED_BYTE (2nd reference) */
  71329. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71330. /** FLOAT */
  71331. static readonly TEXTURETYPE_FLOAT: number;
  71332. /** HALF_FLOAT */
  71333. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71334. /** BYTE */
  71335. static readonly TEXTURETYPE_BYTE: number;
  71336. /** SHORT */
  71337. static readonly TEXTURETYPE_SHORT: number;
  71338. /** UNSIGNED_SHORT */
  71339. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71340. /** INT */
  71341. static readonly TEXTURETYPE_INT: number;
  71342. /** UNSIGNED_INT */
  71343. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71344. /** UNSIGNED_SHORT_4_4_4_4 */
  71345. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71346. /** UNSIGNED_SHORT_5_5_5_1 */
  71347. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71348. /** UNSIGNED_SHORT_5_6_5 */
  71349. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71350. /** UNSIGNED_INT_2_10_10_10_REV */
  71351. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71352. /** UNSIGNED_INT_24_8 */
  71353. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71354. /** UNSIGNED_INT_10F_11F_11F_REV */
  71355. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71356. /** UNSIGNED_INT_5_9_9_9_REV */
  71357. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71358. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71359. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71360. /** nearest is mag = nearest and min = nearest and mip = nearest */
  71361. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71362. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71363. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71364. /** Trilinear is mag = linear and min = linear and mip = linear */
  71365. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71366. /** nearest is mag = nearest and min = nearest and mip = linear */
  71367. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71368. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71369. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71370. /** Trilinear is mag = linear and min = linear and mip = linear */
  71371. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71372. /** mag = nearest and min = nearest and mip = nearest */
  71373. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71374. /** mag = nearest and min = linear and mip = nearest */
  71375. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71376. /** mag = nearest and min = linear and mip = linear */
  71377. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71378. /** mag = nearest and min = linear and mip = none */
  71379. static readonly TEXTURE_NEAREST_LINEAR: number;
  71380. /** mag = nearest and min = nearest and mip = none */
  71381. static readonly TEXTURE_NEAREST_NEAREST: number;
  71382. /** mag = linear and min = nearest and mip = nearest */
  71383. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71384. /** mag = linear and min = nearest and mip = linear */
  71385. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71386. /** mag = linear and min = linear and mip = none */
  71387. static readonly TEXTURE_LINEAR_LINEAR: number;
  71388. /** mag = linear and min = nearest and mip = none */
  71389. static readonly TEXTURE_LINEAR_NEAREST: number;
  71390. /** Explicit coordinates mode */
  71391. static readonly TEXTURE_EXPLICIT_MODE: number;
  71392. /** Spherical coordinates mode */
  71393. static readonly TEXTURE_SPHERICAL_MODE: number;
  71394. /** Planar coordinates mode */
  71395. static readonly TEXTURE_PLANAR_MODE: number;
  71396. /** Cubic coordinates mode */
  71397. static readonly TEXTURE_CUBIC_MODE: number;
  71398. /** Projection coordinates mode */
  71399. static readonly TEXTURE_PROJECTION_MODE: number;
  71400. /** Skybox coordinates mode */
  71401. static readonly TEXTURE_SKYBOX_MODE: number;
  71402. /** Inverse Cubic coordinates mode */
  71403. static readonly TEXTURE_INVCUBIC_MODE: number;
  71404. /** Equirectangular coordinates mode */
  71405. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71406. /** Equirectangular Fixed coordinates mode */
  71407. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71408. /** Equirectangular Fixed Mirrored coordinates mode */
  71409. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71410. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71411. static readonly SCALEMODE_FLOOR: number;
  71412. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71413. static readonly SCALEMODE_NEAREST: number;
  71414. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71415. static readonly SCALEMODE_CEILING: number;
  71416. /**
  71417. * The dirty texture flag value
  71418. */
  71419. static readonly MATERIAL_TextureDirtyFlag: number;
  71420. /**
  71421. * The dirty light flag value
  71422. */
  71423. static readonly MATERIAL_LightDirtyFlag: number;
  71424. /**
  71425. * The dirty fresnel flag value
  71426. */
  71427. static readonly MATERIAL_FresnelDirtyFlag: number;
  71428. /**
  71429. * The dirty attribute flag value
  71430. */
  71431. static readonly MATERIAL_AttributesDirtyFlag: number;
  71432. /**
  71433. * The dirty misc flag value
  71434. */
  71435. static readonly MATERIAL_MiscDirtyFlag: number;
  71436. /**
  71437. * The all dirty flag value
  71438. */
  71439. static readonly MATERIAL_AllDirtyFlag: number;
  71440. /**
  71441. * Returns the triangle fill mode
  71442. */
  71443. static readonly MATERIAL_TriangleFillMode: number;
  71444. /**
  71445. * Returns the wireframe mode
  71446. */
  71447. static readonly MATERIAL_WireFrameFillMode: number;
  71448. /**
  71449. * Returns the point fill mode
  71450. */
  71451. static readonly MATERIAL_PointFillMode: number;
  71452. /**
  71453. * Returns the point list draw mode
  71454. */
  71455. static readonly MATERIAL_PointListDrawMode: number;
  71456. /**
  71457. * Returns the line list draw mode
  71458. */
  71459. static readonly MATERIAL_LineListDrawMode: number;
  71460. /**
  71461. * Returns the line loop draw mode
  71462. */
  71463. static readonly MATERIAL_LineLoopDrawMode: number;
  71464. /**
  71465. * Returns the line strip draw mode
  71466. */
  71467. static readonly MATERIAL_LineStripDrawMode: number;
  71468. /**
  71469. * Returns the triangle strip draw mode
  71470. */
  71471. static readonly MATERIAL_TriangleStripDrawMode: number;
  71472. /**
  71473. * Returns the triangle fan draw mode
  71474. */
  71475. static readonly MATERIAL_TriangleFanDrawMode: number;
  71476. /**
  71477. * Stores the clock-wise side orientation
  71478. */
  71479. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71480. /**
  71481. * Stores the counter clock-wise side orientation
  71482. */
  71483. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71484. /**
  71485. * Nothing
  71486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71487. */
  71488. static readonly ACTION_NothingTrigger: number;
  71489. /**
  71490. * On pick
  71491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71492. */
  71493. static readonly ACTION_OnPickTrigger: number;
  71494. /**
  71495. * On left pick
  71496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71497. */
  71498. static readonly ACTION_OnLeftPickTrigger: number;
  71499. /**
  71500. * On right pick
  71501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71502. */
  71503. static readonly ACTION_OnRightPickTrigger: number;
  71504. /**
  71505. * On center pick
  71506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71507. */
  71508. static readonly ACTION_OnCenterPickTrigger: number;
  71509. /**
  71510. * On pick down
  71511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71512. */
  71513. static readonly ACTION_OnPickDownTrigger: number;
  71514. /**
  71515. * On double pick
  71516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71517. */
  71518. static readonly ACTION_OnDoublePickTrigger: number;
  71519. /**
  71520. * On pick up
  71521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71522. */
  71523. static readonly ACTION_OnPickUpTrigger: number;
  71524. /**
  71525. * On pick out.
  71526. * This trigger will only be raised if you also declared a OnPickDown
  71527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71528. */
  71529. static readonly ACTION_OnPickOutTrigger: number;
  71530. /**
  71531. * On long press
  71532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71533. */
  71534. static readonly ACTION_OnLongPressTrigger: number;
  71535. /**
  71536. * On pointer over
  71537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71538. */
  71539. static readonly ACTION_OnPointerOverTrigger: number;
  71540. /**
  71541. * On pointer out
  71542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71543. */
  71544. static readonly ACTION_OnPointerOutTrigger: number;
  71545. /**
  71546. * On every frame
  71547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71548. */
  71549. static readonly ACTION_OnEveryFrameTrigger: number;
  71550. /**
  71551. * On intersection enter
  71552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71553. */
  71554. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71555. /**
  71556. * On intersection exit
  71557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71558. */
  71559. static readonly ACTION_OnIntersectionExitTrigger: number;
  71560. /**
  71561. * On key down
  71562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71563. */
  71564. static readonly ACTION_OnKeyDownTrigger: number;
  71565. /**
  71566. * On key up
  71567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71568. */
  71569. static readonly ACTION_OnKeyUpTrigger: number;
  71570. /**
  71571. * Billboard mode will only apply to Y axis
  71572. */
  71573. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71574. /**
  71575. * Billboard mode will apply to all axes
  71576. */
  71577. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71578. /**
  71579. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71580. */
  71581. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71582. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71583. * Test order :
  71584. * Is the bounding sphere outside the frustum ?
  71585. * If not, are the bounding box vertices outside the frustum ?
  71586. * It not, then the cullable object is in the frustum.
  71587. */
  71588. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71589. /** Culling strategy : Bounding Sphere Only.
  71590. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71591. * It's also less accurate than the standard because some not visible objects can still be selected.
  71592. * Test : is the bounding sphere outside the frustum ?
  71593. * If not, then the cullable object is in the frustum.
  71594. */
  71595. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71596. /** Culling strategy : Optimistic Inclusion.
  71597. * This in an inclusion test first, then the standard exclusion test.
  71598. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71599. * 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.
  71600. * Anyway, it's as accurate as the standard strategy.
  71601. * Test :
  71602. * Is the cullable object bounding sphere center in the frustum ?
  71603. * If not, apply the default culling strategy.
  71604. */
  71605. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71606. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71607. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71608. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71609. * 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.
  71610. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71611. * Test :
  71612. * Is the cullable object bounding sphere center in the frustum ?
  71613. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71614. */
  71615. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71616. /**
  71617. * No logging while loading
  71618. */
  71619. static readonly SCENELOADER_NO_LOGGING: number;
  71620. /**
  71621. * Minimal logging while loading
  71622. */
  71623. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71624. /**
  71625. * Summary logging while loading
  71626. */
  71627. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71628. /**
  71629. * Detailled logging while loading
  71630. */
  71631. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71632. }
  71633. }
  71634. declare module BABYLON {
  71635. /**
  71636. * This represents the required contract to create a new type of texture loader.
  71637. */
  71638. export interface IInternalTextureLoader {
  71639. /**
  71640. * Defines wether the loader supports cascade loading the different faces.
  71641. */
  71642. supportCascades: boolean;
  71643. /**
  71644. * This returns if the loader support the current file information.
  71645. * @param extension defines the file extension of the file being loaded
  71646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71647. * @param fallback defines the fallback internal texture if any
  71648. * @param isBase64 defines whether the texture is encoded as a base64
  71649. * @param isBuffer defines whether the texture data are stored as a buffer
  71650. * @returns true if the loader can load the specified file
  71651. */
  71652. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71653. /**
  71654. * Transform the url before loading if required.
  71655. * @param rootUrl the url of the texture
  71656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71657. * @returns the transformed texture
  71658. */
  71659. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71660. /**
  71661. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71662. * @param rootUrl the url of the texture
  71663. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71664. * @returns the fallback texture
  71665. */
  71666. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71667. /**
  71668. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71669. * @param data contains the texture data
  71670. * @param texture defines the BabylonJS internal texture
  71671. * @param createPolynomials will be true if polynomials have been requested
  71672. * @param onLoad defines the callback to trigger once the texture is ready
  71673. * @param onError defines the callback to trigger in case of error
  71674. */
  71675. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71676. /**
  71677. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71678. * @param data contains the texture data
  71679. * @param texture defines the BabylonJS internal texture
  71680. * @param callback defines the method to call once ready to upload
  71681. */
  71682. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71683. }
  71684. }
  71685. declare module BABYLON {
  71686. /**
  71687. * Class used to store and describe the pipeline context associated with an effect
  71688. */
  71689. export interface IPipelineContext {
  71690. /**
  71691. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71692. */
  71693. isAsync: boolean;
  71694. /**
  71695. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71696. */
  71697. isReady: boolean;
  71698. /** @hidden */
  71699. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71700. }
  71701. }
  71702. declare module BABYLON {
  71703. /**
  71704. * Class used to store gfx data (like WebGLBuffer)
  71705. */
  71706. export class DataBuffer {
  71707. /**
  71708. * Gets or sets the number of objects referencing this buffer
  71709. */
  71710. references: number;
  71711. /** Gets or sets the size of the underlying buffer */
  71712. capacity: number;
  71713. /**
  71714. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71715. */
  71716. is32Bits: boolean;
  71717. /**
  71718. * Gets the underlying buffer
  71719. */
  71720. get underlyingResource(): any;
  71721. }
  71722. }
  71723. declare module BABYLON {
  71724. /** @hidden */
  71725. export interface IShaderProcessor {
  71726. attributeProcessor?: (attribute: string) => string;
  71727. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71728. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71729. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71730. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71731. lineProcessor?: (line: string, isFragment: boolean) => string;
  71732. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71733. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71734. }
  71735. }
  71736. declare module BABYLON {
  71737. /** @hidden */
  71738. export interface ProcessingOptions {
  71739. defines: string[];
  71740. indexParameters: any;
  71741. isFragment: boolean;
  71742. shouldUseHighPrecisionShader: boolean;
  71743. supportsUniformBuffers: boolean;
  71744. shadersRepository: string;
  71745. includesShadersStore: {
  71746. [key: string]: string;
  71747. };
  71748. processor?: IShaderProcessor;
  71749. version: string;
  71750. platformName: string;
  71751. lookForClosingBracketForUniformBuffer?: boolean;
  71752. }
  71753. }
  71754. declare module BABYLON {
  71755. /** @hidden */
  71756. export class ShaderCodeNode {
  71757. line: string;
  71758. children: ShaderCodeNode[];
  71759. additionalDefineKey?: string;
  71760. additionalDefineValue?: string;
  71761. isValid(preprocessors: {
  71762. [key: string]: string;
  71763. }): boolean;
  71764. process(preprocessors: {
  71765. [key: string]: string;
  71766. }, options: ProcessingOptions): string;
  71767. }
  71768. }
  71769. declare module BABYLON {
  71770. /** @hidden */
  71771. export class ShaderCodeCursor {
  71772. private _lines;
  71773. lineIndex: number;
  71774. get currentLine(): string;
  71775. get canRead(): boolean;
  71776. set lines(value: string[]);
  71777. }
  71778. }
  71779. declare module BABYLON {
  71780. /** @hidden */
  71781. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71782. process(preprocessors: {
  71783. [key: string]: string;
  71784. }, options: ProcessingOptions): string;
  71785. }
  71786. }
  71787. declare module BABYLON {
  71788. /** @hidden */
  71789. export class ShaderDefineExpression {
  71790. isTrue(preprocessors: {
  71791. [key: string]: string;
  71792. }): boolean;
  71793. }
  71794. }
  71795. declare module BABYLON {
  71796. /** @hidden */
  71797. export class ShaderCodeTestNode extends ShaderCodeNode {
  71798. testExpression: ShaderDefineExpression;
  71799. isValid(preprocessors: {
  71800. [key: string]: string;
  71801. }): boolean;
  71802. }
  71803. }
  71804. declare module BABYLON {
  71805. /** @hidden */
  71806. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71807. define: string;
  71808. not: boolean;
  71809. constructor(define: string, not?: boolean);
  71810. isTrue(preprocessors: {
  71811. [key: string]: string;
  71812. }): boolean;
  71813. }
  71814. }
  71815. declare module BABYLON {
  71816. /** @hidden */
  71817. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71818. leftOperand: ShaderDefineExpression;
  71819. rightOperand: ShaderDefineExpression;
  71820. isTrue(preprocessors: {
  71821. [key: string]: string;
  71822. }): boolean;
  71823. }
  71824. }
  71825. declare module BABYLON {
  71826. /** @hidden */
  71827. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71828. leftOperand: ShaderDefineExpression;
  71829. rightOperand: ShaderDefineExpression;
  71830. isTrue(preprocessors: {
  71831. [key: string]: string;
  71832. }): boolean;
  71833. }
  71834. }
  71835. declare module BABYLON {
  71836. /** @hidden */
  71837. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71838. define: string;
  71839. operand: string;
  71840. testValue: string;
  71841. constructor(define: string, operand: string, testValue: string);
  71842. isTrue(preprocessors: {
  71843. [key: string]: string;
  71844. }): boolean;
  71845. }
  71846. }
  71847. declare module BABYLON {
  71848. /**
  71849. * Class used to enable access to offline support
  71850. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71851. */
  71852. export interface IOfflineProvider {
  71853. /**
  71854. * Gets a boolean indicating if scene must be saved in the database
  71855. */
  71856. enableSceneOffline: boolean;
  71857. /**
  71858. * Gets a boolean indicating if textures must be saved in the database
  71859. */
  71860. enableTexturesOffline: boolean;
  71861. /**
  71862. * Open the offline support and make it available
  71863. * @param successCallback defines the callback to call on success
  71864. * @param errorCallback defines the callback to call on error
  71865. */
  71866. open(successCallback: () => void, errorCallback: () => void): void;
  71867. /**
  71868. * Loads an image from the offline support
  71869. * @param url defines the url to load from
  71870. * @param image defines the target DOM image
  71871. */
  71872. loadImage(url: string, image: HTMLImageElement): void;
  71873. /**
  71874. * Loads a file from offline support
  71875. * @param url defines the URL to load from
  71876. * @param sceneLoaded defines a callback to call on success
  71877. * @param progressCallBack defines a callback to call when progress changed
  71878. * @param errorCallback defines a callback to call on error
  71879. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71880. */
  71881. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71882. }
  71883. }
  71884. declare module BABYLON {
  71885. /**
  71886. * Class used to help managing file picking and drag'n'drop
  71887. * File Storage
  71888. */
  71889. export class FilesInputStore {
  71890. /**
  71891. * List of files ready to be loaded
  71892. */
  71893. static FilesToLoad: {
  71894. [key: string]: File;
  71895. };
  71896. }
  71897. }
  71898. declare module BABYLON {
  71899. /**
  71900. * Class used to define a retry strategy when error happens while loading assets
  71901. */
  71902. export class RetryStrategy {
  71903. /**
  71904. * Function used to defines an exponential back off strategy
  71905. * @param maxRetries defines the maximum number of retries (3 by default)
  71906. * @param baseInterval defines the interval between retries
  71907. * @returns the strategy function to use
  71908. */
  71909. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71910. }
  71911. }
  71912. declare module BABYLON {
  71913. /**
  71914. * @ignore
  71915. * Application error to support additional information when loading a file
  71916. */
  71917. export abstract class BaseError extends Error {
  71918. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  71919. }
  71920. }
  71921. declare module BABYLON {
  71922. /** @ignore */
  71923. export class LoadFileError extends BaseError {
  71924. request?: WebRequest;
  71925. file?: File;
  71926. /**
  71927. * Creates a new LoadFileError
  71928. * @param message defines the message of the error
  71929. * @param request defines the optional web request
  71930. * @param file defines the optional file
  71931. */
  71932. constructor(message: string, object?: WebRequest | File);
  71933. }
  71934. /** @ignore */
  71935. export class RequestFileError extends BaseError {
  71936. request: WebRequest;
  71937. /**
  71938. * Creates a new LoadFileError
  71939. * @param message defines the message of the error
  71940. * @param request defines the optional web request
  71941. */
  71942. constructor(message: string, request: WebRequest);
  71943. }
  71944. /** @ignore */
  71945. export class ReadFileError extends BaseError {
  71946. file: File;
  71947. /**
  71948. * Creates a new ReadFileError
  71949. * @param message defines the message of the error
  71950. * @param file defines the optional file
  71951. */
  71952. constructor(message: string, file: File);
  71953. }
  71954. /**
  71955. * @hidden
  71956. */
  71957. export class FileTools {
  71958. /**
  71959. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71960. */
  71961. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71962. /**
  71963. * Gets or sets the base URL to use to load assets
  71964. */
  71965. static BaseUrl: string;
  71966. /**
  71967. * Default behaviour for cors in the application.
  71968. * It can be a string if the expected behavior is identical in the entire app.
  71969. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71970. */
  71971. static CorsBehavior: string | ((url: string | string[]) => string);
  71972. /**
  71973. * Gets or sets a function used to pre-process url before using them to load assets
  71974. */
  71975. static PreprocessUrl: (url: string) => string;
  71976. /**
  71977. * Removes unwanted characters from an url
  71978. * @param url defines the url to clean
  71979. * @returns the cleaned url
  71980. */
  71981. private static _CleanUrl;
  71982. /**
  71983. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71984. * @param url define the url we are trying
  71985. * @param element define the dom element where to configure the cors policy
  71986. */
  71987. static SetCorsBehavior(url: string | string[], element: {
  71988. crossOrigin: string | null;
  71989. }): void;
  71990. /**
  71991. * Loads an image as an HTMLImageElement.
  71992. * @param input url string, ArrayBuffer, or Blob to load
  71993. * @param onLoad callback called when the image successfully loads
  71994. * @param onError callback called when the image fails to load
  71995. * @param offlineProvider offline provider for caching
  71996. * @param mimeType optional mime type
  71997. * @returns the HTMLImageElement of the loaded image
  71998. */
  71999. 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>;
  72000. /**
  72001. * Reads a file from a File object
  72002. * @param file defines the file to load
  72003. * @param onSuccess defines the callback to call when data is loaded
  72004. * @param onProgress defines the callback to call during loading process
  72005. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  72006. * @param onError defines the callback to call when an error occurs
  72007. * @returns a file request object
  72008. */
  72009. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  72010. /**
  72011. * Loads a file from a url
  72012. * @param url url to load
  72013. * @param onSuccess callback called when the file successfully loads
  72014. * @param onProgress callback called while file is loading (if the server supports this mode)
  72015. * @param offlineProvider defines the offline provider for caching
  72016. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72017. * @param onError callback called when the file fails to load
  72018. * @returns a file request object
  72019. */
  72020. 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;
  72021. /**
  72022. * Loads a file
  72023. * @param url url to load
  72024. * @param onSuccess callback called when the file successfully loads
  72025. * @param onProgress callback called while file is loading (if the server supports this mode)
  72026. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72027. * @param onError callback called when the file fails to load
  72028. * @param onOpened callback called when the web request is opened
  72029. * @returns a file request object
  72030. */
  72031. 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;
  72032. /**
  72033. * Checks if the loaded document was accessed via `file:`-Protocol.
  72034. * @returns boolean
  72035. */
  72036. static IsFileURL(): boolean;
  72037. }
  72038. }
  72039. declare module BABYLON {
  72040. /** @hidden */
  72041. export class ShaderProcessor {
  72042. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  72043. private static _ProcessPrecision;
  72044. private static _ExtractOperation;
  72045. private static _BuildSubExpression;
  72046. private static _BuildExpression;
  72047. private static _MoveCursorWithinIf;
  72048. private static _MoveCursor;
  72049. private static _EvaluatePreProcessors;
  72050. private static _PreparePreProcessors;
  72051. private static _ProcessShaderConversion;
  72052. private static _ProcessIncludes;
  72053. }
  72054. }
  72055. declare module BABYLON {
  72056. /**
  72057. * @hidden
  72058. */
  72059. export interface IColor4Like {
  72060. r: float;
  72061. g: float;
  72062. b: float;
  72063. a: float;
  72064. }
  72065. /**
  72066. * @hidden
  72067. */
  72068. export interface IColor3Like {
  72069. r: float;
  72070. g: float;
  72071. b: float;
  72072. }
  72073. /**
  72074. * @hidden
  72075. */
  72076. export interface IVector4Like {
  72077. x: float;
  72078. y: float;
  72079. z: float;
  72080. w: float;
  72081. }
  72082. /**
  72083. * @hidden
  72084. */
  72085. export interface IVector3Like {
  72086. x: float;
  72087. y: float;
  72088. z: float;
  72089. }
  72090. /**
  72091. * @hidden
  72092. */
  72093. export interface IVector2Like {
  72094. x: float;
  72095. y: float;
  72096. }
  72097. /**
  72098. * @hidden
  72099. */
  72100. export interface IMatrixLike {
  72101. toArray(): DeepImmutable<Float32Array>;
  72102. updateFlag: int;
  72103. }
  72104. /**
  72105. * @hidden
  72106. */
  72107. export interface IViewportLike {
  72108. x: float;
  72109. y: float;
  72110. width: float;
  72111. height: float;
  72112. }
  72113. /**
  72114. * @hidden
  72115. */
  72116. export interface IPlaneLike {
  72117. normal: IVector3Like;
  72118. d: float;
  72119. normalize(): void;
  72120. }
  72121. }
  72122. declare module BABYLON {
  72123. /**
  72124. * Interface used to define common properties for effect fallbacks
  72125. */
  72126. export interface IEffectFallbacks {
  72127. /**
  72128. * Removes the defines that should be removed when falling back.
  72129. * @param currentDefines defines the current define statements for the shader.
  72130. * @param effect defines the current effect we try to compile
  72131. * @returns The resulting defines with defines of the current rank removed.
  72132. */
  72133. reduce(currentDefines: string, effect: Effect): string;
  72134. /**
  72135. * Removes the fallback from the bound mesh.
  72136. */
  72137. unBindMesh(): void;
  72138. /**
  72139. * Checks to see if more fallbacks are still availible.
  72140. */
  72141. hasMoreFallbacks: boolean;
  72142. }
  72143. }
  72144. declare module BABYLON {
  72145. /**
  72146. * Class used to evalaute queries containing `and` and `or` operators
  72147. */
  72148. export class AndOrNotEvaluator {
  72149. /**
  72150. * Evaluate a query
  72151. * @param query defines the query to evaluate
  72152. * @param evaluateCallback defines the callback used to filter result
  72153. * @returns true if the query matches
  72154. */
  72155. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  72156. private static _HandleParenthesisContent;
  72157. private static _SimplifyNegation;
  72158. }
  72159. }
  72160. declare module BABYLON {
  72161. /**
  72162. * Class used to store custom tags
  72163. */
  72164. export class Tags {
  72165. /**
  72166. * Adds support for tags on the given object
  72167. * @param obj defines the object to use
  72168. */
  72169. static EnableFor(obj: any): void;
  72170. /**
  72171. * Removes tags support
  72172. * @param obj defines the object to use
  72173. */
  72174. static DisableFor(obj: any): void;
  72175. /**
  72176. * Gets a boolean indicating if the given object has tags
  72177. * @param obj defines the object to use
  72178. * @returns a boolean
  72179. */
  72180. static HasTags(obj: any): boolean;
  72181. /**
  72182. * Gets the tags available on a given object
  72183. * @param obj defines the object to use
  72184. * @param asString defines if the tags must be returned as a string instead of an array of strings
  72185. * @returns the tags
  72186. */
  72187. static GetTags(obj: any, asString?: boolean): any;
  72188. /**
  72189. * Adds tags to an object
  72190. * @param obj defines the object to use
  72191. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  72192. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  72193. */
  72194. static AddTagsTo(obj: any, tagsString: string): void;
  72195. /**
  72196. * @hidden
  72197. */
  72198. static _AddTagTo(obj: any, tag: string): void;
  72199. /**
  72200. * Removes specific tags from a specific object
  72201. * @param obj defines the object to use
  72202. * @param tagsString defines the tags to remove
  72203. */
  72204. static RemoveTagsFrom(obj: any, tagsString: string): void;
  72205. /**
  72206. * @hidden
  72207. */
  72208. static _RemoveTagFrom(obj: any, tag: string): void;
  72209. /**
  72210. * Defines if tags hosted on an object match a given query
  72211. * @param obj defines the object to use
  72212. * @param tagsQuery defines the tag query
  72213. * @returns a boolean
  72214. */
  72215. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  72216. }
  72217. }
  72218. declare module BABYLON {
  72219. /**
  72220. * Scalar computation library
  72221. */
  72222. export class Scalar {
  72223. /**
  72224. * Two pi constants convenient for computation.
  72225. */
  72226. static TwoPi: number;
  72227. /**
  72228. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72229. * @param a number
  72230. * @param b number
  72231. * @param epsilon (default = 1.401298E-45)
  72232. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72233. */
  72234. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  72235. /**
  72236. * Returns a string : the upper case translation of the number i to hexadecimal.
  72237. * @param i number
  72238. * @returns the upper case translation of the number i to hexadecimal.
  72239. */
  72240. static ToHex(i: number): string;
  72241. /**
  72242. * Returns -1 if value is negative and +1 is value is positive.
  72243. * @param value the value
  72244. * @returns the value itself if it's equal to zero.
  72245. */
  72246. static Sign(value: number): number;
  72247. /**
  72248. * Returns the value itself if it's between min and max.
  72249. * Returns min if the value is lower than min.
  72250. * Returns max if the value is greater than max.
  72251. * @param value the value to clmap
  72252. * @param min the min value to clamp to (default: 0)
  72253. * @param max the max value to clamp to (default: 1)
  72254. * @returns the clamped value
  72255. */
  72256. static Clamp(value: number, min?: number, max?: number): number;
  72257. /**
  72258. * the log2 of value.
  72259. * @param value the value to compute log2 of
  72260. * @returns the log2 of value.
  72261. */
  72262. static Log2(value: number): number;
  72263. /**
  72264. * Loops the value, so that it is never larger than length and never smaller than 0.
  72265. *
  72266. * This is similar to the modulo operator but it works with floating point numbers.
  72267. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  72268. * With t = 5 and length = 2.5, the result would be 0.0.
  72269. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  72270. * @param value the value
  72271. * @param length the length
  72272. * @returns the looped value
  72273. */
  72274. static Repeat(value: number, length: number): number;
  72275. /**
  72276. * Normalize the value between 0.0 and 1.0 using min and max values
  72277. * @param value value to normalize
  72278. * @param min max to normalize between
  72279. * @param max min to normalize between
  72280. * @returns the normalized value
  72281. */
  72282. static Normalize(value: number, min: number, max: number): number;
  72283. /**
  72284. * Denormalize the value from 0.0 and 1.0 using min and max values
  72285. * @param normalized value to denormalize
  72286. * @param min max to denormalize between
  72287. * @param max min to denormalize between
  72288. * @returns the denormalized value
  72289. */
  72290. static Denormalize(normalized: number, min: number, max: number): number;
  72291. /**
  72292. * Calculates the shortest difference between two given angles given in degrees.
  72293. * @param current current angle in degrees
  72294. * @param target target angle in degrees
  72295. * @returns the delta
  72296. */
  72297. static DeltaAngle(current: number, target: number): number;
  72298. /**
  72299. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  72300. * @param tx value
  72301. * @param length length
  72302. * @returns The returned value will move back and forth between 0 and length
  72303. */
  72304. static PingPong(tx: number, length: number): number;
  72305. /**
  72306. * Interpolates between min and max with smoothing at the limits.
  72307. *
  72308. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  72309. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  72310. * @param from from
  72311. * @param to to
  72312. * @param tx value
  72313. * @returns the smooth stepped value
  72314. */
  72315. static SmoothStep(from: number, to: number, tx: number): number;
  72316. /**
  72317. * Moves a value current towards target.
  72318. *
  72319. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  72320. * Negative values of maxDelta pushes the value away from target.
  72321. * @param current current value
  72322. * @param target target value
  72323. * @param maxDelta max distance to move
  72324. * @returns resulting value
  72325. */
  72326. static MoveTowards(current: number, target: number, maxDelta: number): number;
  72327. /**
  72328. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72329. *
  72330. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  72331. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  72332. * @param current current value
  72333. * @param target target value
  72334. * @param maxDelta max distance to move
  72335. * @returns resulting angle
  72336. */
  72337. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  72338. /**
  72339. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  72340. * @param start start value
  72341. * @param end target value
  72342. * @param amount amount to lerp between
  72343. * @returns the lerped value
  72344. */
  72345. static Lerp(start: number, end: number, amount: number): number;
  72346. /**
  72347. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72348. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  72349. * @param start start value
  72350. * @param end target value
  72351. * @param amount amount to lerp between
  72352. * @returns the lerped value
  72353. */
  72354. static LerpAngle(start: number, end: number, amount: number): number;
  72355. /**
  72356. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  72357. * @param a start value
  72358. * @param b target value
  72359. * @param value value between a and b
  72360. * @returns the inverseLerp value
  72361. */
  72362. static InverseLerp(a: number, b: number, value: number): number;
  72363. /**
  72364. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  72365. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  72366. * @param value1 spline value
  72367. * @param tangent1 spline value
  72368. * @param value2 spline value
  72369. * @param tangent2 spline value
  72370. * @param amount input value
  72371. * @returns hermite result
  72372. */
  72373. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  72374. /**
  72375. * Returns a random float number between and min and max values
  72376. * @param min min value of random
  72377. * @param max max value of random
  72378. * @returns random value
  72379. */
  72380. static RandomRange(min: number, max: number): number;
  72381. /**
  72382. * This function returns percentage of a number in a given range.
  72383. *
  72384. * RangeToPercent(40,20,60) will return 0.5 (50%)
  72385. * RangeToPercent(34,0,100) will return 0.34 (34%)
  72386. * @param number to convert to percentage
  72387. * @param min min range
  72388. * @param max max range
  72389. * @returns the percentage
  72390. */
  72391. static RangeToPercent(number: number, min: number, max: number): number;
  72392. /**
  72393. * This function returns number that corresponds to the percentage in a given range.
  72394. *
  72395. * PercentToRange(0.34,0,100) will return 34.
  72396. * @param percent to convert to number
  72397. * @param min min range
  72398. * @param max max range
  72399. * @returns the number
  72400. */
  72401. static PercentToRange(percent: number, min: number, max: number): number;
  72402. /**
  72403. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  72404. * @param angle The angle to normalize in radian.
  72405. * @return The converted angle.
  72406. */
  72407. static NormalizeRadians(angle: number): number;
  72408. }
  72409. }
  72410. declare module BABYLON {
  72411. /**
  72412. * Constant used to convert a value to gamma space
  72413. * @ignorenaming
  72414. */
  72415. export const ToGammaSpace: number;
  72416. /**
  72417. * Constant used to convert a value to linear space
  72418. * @ignorenaming
  72419. */
  72420. export const ToLinearSpace = 2.2;
  72421. /**
  72422. * Constant used to define the minimal number value in Babylon.js
  72423. * @ignorenaming
  72424. */
  72425. let Epsilon: number;
  72426. }
  72427. declare module BABYLON {
  72428. /**
  72429. * Class used to represent a viewport on screen
  72430. */
  72431. export class Viewport {
  72432. /** viewport left coordinate */
  72433. x: number;
  72434. /** viewport top coordinate */
  72435. y: number;
  72436. /**viewport width */
  72437. width: number;
  72438. /** viewport height */
  72439. height: number;
  72440. /**
  72441. * Creates a Viewport object located at (x, y) and sized (width, height)
  72442. * @param x defines viewport left coordinate
  72443. * @param y defines viewport top coordinate
  72444. * @param width defines the viewport width
  72445. * @param height defines the viewport height
  72446. */
  72447. constructor(
  72448. /** viewport left coordinate */
  72449. x: number,
  72450. /** viewport top coordinate */
  72451. y: number,
  72452. /**viewport width */
  72453. width: number,
  72454. /** viewport height */
  72455. height: number);
  72456. /**
  72457. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  72458. * @param renderWidth defines the rendering width
  72459. * @param renderHeight defines the rendering height
  72460. * @returns a new Viewport
  72461. */
  72462. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  72463. /**
  72464. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  72465. * @param renderWidth defines the rendering width
  72466. * @param renderHeight defines the rendering height
  72467. * @param ref defines the target viewport
  72468. * @returns the current viewport
  72469. */
  72470. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  72471. /**
  72472. * Returns a new Viewport copied from the current one
  72473. * @returns a new Viewport
  72474. */
  72475. clone(): Viewport;
  72476. }
  72477. }
  72478. declare module BABYLON {
  72479. /**
  72480. * Class containing a set of static utilities functions for arrays.
  72481. */
  72482. export class ArrayTools {
  72483. /**
  72484. * Returns an array of the given size filled with element built from the given constructor and the paramters
  72485. * @param size the number of element to construct and put in the array
  72486. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  72487. * @returns a new array filled with new objects
  72488. */
  72489. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  72490. }
  72491. }
  72492. declare module BABYLON {
  72493. /**
  72494. * Class representing a vector containing 2 coordinates
  72495. */
  72496. export class Vector2 {
  72497. /** defines the first coordinate */
  72498. x: number;
  72499. /** defines the second coordinate */
  72500. y: number;
  72501. /**
  72502. * Creates a new Vector2 from the given x and y coordinates
  72503. * @param x defines the first coordinate
  72504. * @param y defines the second coordinate
  72505. */
  72506. constructor(
  72507. /** defines the first coordinate */
  72508. x?: number,
  72509. /** defines the second coordinate */
  72510. y?: number);
  72511. /**
  72512. * Gets a string with the Vector2 coordinates
  72513. * @returns a string with the Vector2 coordinates
  72514. */
  72515. toString(): string;
  72516. /**
  72517. * Gets class name
  72518. * @returns the string "Vector2"
  72519. */
  72520. getClassName(): string;
  72521. /**
  72522. * Gets current vector hash code
  72523. * @returns the Vector2 hash code as a number
  72524. */
  72525. getHashCode(): number;
  72526. /**
  72527. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  72528. * @param array defines the source array
  72529. * @param index defines the offset in source array
  72530. * @returns the current Vector2
  72531. */
  72532. toArray(array: FloatArray, index?: number): Vector2;
  72533. /**
  72534. * Copy the current vector to an array
  72535. * @returns a new array with 2 elements: the Vector2 coordinates.
  72536. */
  72537. asArray(): number[];
  72538. /**
  72539. * Sets the Vector2 coordinates with the given Vector2 coordinates
  72540. * @param source defines the source Vector2
  72541. * @returns the current updated Vector2
  72542. */
  72543. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  72544. /**
  72545. * Sets the Vector2 coordinates with the given floats
  72546. * @param x defines the first coordinate
  72547. * @param y defines the second coordinate
  72548. * @returns the current updated Vector2
  72549. */
  72550. copyFromFloats(x: number, y: number): Vector2;
  72551. /**
  72552. * Sets the Vector2 coordinates with the given floats
  72553. * @param x defines the first coordinate
  72554. * @param y defines the second coordinate
  72555. * @returns the current updated Vector2
  72556. */
  72557. set(x: number, y: number): Vector2;
  72558. /**
  72559. * Add another vector with the current one
  72560. * @param otherVector defines the other vector
  72561. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  72562. */
  72563. add(otherVector: DeepImmutable<Vector2>): Vector2;
  72564. /**
  72565. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  72566. * @param otherVector defines the other vector
  72567. * @param result defines the target vector
  72568. * @returns the unmodified current Vector2
  72569. */
  72570. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72571. /**
  72572. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  72573. * @param otherVector defines the other vector
  72574. * @returns the current updated Vector2
  72575. */
  72576. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72577. /**
  72578. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  72579. * @param otherVector defines the other vector
  72580. * @returns a new Vector2
  72581. */
  72582. addVector3(otherVector: Vector3): Vector2;
  72583. /**
  72584. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  72585. * @param otherVector defines the other vector
  72586. * @returns a new Vector2
  72587. */
  72588. subtract(otherVector: Vector2): Vector2;
  72589. /**
  72590. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  72591. * @param otherVector defines the other vector
  72592. * @param result defines the target vector
  72593. * @returns the unmodified current Vector2
  72594. */
  72595. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72596. /**
  72597. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  72598. * @param otherVector defines the other vector
  72599. * @returns the current updated Vector2
  72600. */
  72601. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72602. /**
  72603. * Multiplies in place the current Vector2 coordinates by the given ones
  72604. * @param otherVector defines the other vector
  72605. * @returns the current updated Vector2
  72606. */
  72607. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72608. /**
  72609. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72610. * @param otherVector defines the other vector
  72611. * @returns a new Vector2
  72612. */
  72613. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  72614. /**
  72615. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72616. * @param otherVector defines the other vector
  72617. * @param result defines the target vector
  72618. * @returns the unmodified current Vector2
  72619. */
  72620. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72621. /**
  72622. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72623. * @param x defines the first coordinate
  72624. * @param y defines the second coordinate
  72625. * @returns a new Vector2
  72626. */
  72627. multiplyByFloats(x: number, y: number): Vector2;
  72628. /**
  72629. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72630. * @param otherVector defines the other vector
  72631. * @returns a new Vector2
  72632. */
  72633. divide(otherVector: Vector2): Vector2;
  72634. /**
  72635. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72636. * @param otherVector defines the other vector
  72637. * @param result defines the target vector
  72638. * @returns the unmodified current Vector2
  72639. */
  72640. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72641. /**
  72642. * Divides the current Vector2 coordinates by the given ones
  72643. * @param otherVector defines the other vector
  72644. * @returns the current updated Vector2
  72645. */
  72646. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72647. /**
  72648. * Gets a new Vector2 with current Vector2 negated coordinates
  72649. * @returns a new Vector2
  72650. */
  72651. negate(): Vector2;
  72652. /**
  72653. * Multiply the Vector2 coordinates by scale
  72654. * @param scale defines the scaling factor
  72655. * @returns the current updated Vector2
  72656. */
  72657. scaleInPlace(scale: number): Vector2;
  72658. /**
  72659. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72660. * @param scale defines the scaling factor
  72661. * @returns a new Vector2
  72662. */
  72663. scale(scale: number): Vector2;
  72664. /**
  72665. * Scale the current Vector2 values by a factor to a given Vector2
  72666. * @param scale defines the scale factor
  72667. * @param result defines the Vector2 object where to store the result
  72668. * @returns the unmodified current Vector2
  72669. */
  72670. scaleToRef(scale: number, result: Vector2): Vector2;
  72671. /**
  72672. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72673. * @param scale defines the scale factor
  72674. * @param result defines the Vector2 object where to store the result
  72675. * @returns the unmodified current Vector2
  72676. */
  72677. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  72678. /**
  72679. * Gets a boolean if two vectors are equals
  72680. * @param otherVector defines the other vector
  72681. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72682. */
  72683. equals(otherVector: DeepImmutable<Vector2>): boolean;
  72684. /**
  72685. * Gets a boolean if two vectors are equals (using an epsilon value)
  72686. * @param otherVector defines the other vector
  72687. * @param epsilon defines the minimal distance to consider equality
  72688. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72689. */
  72690. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  72691. /**
  72692. * Gets a new Vector2 from current Vector2 floored values
  72693. * @returns a new Vector2
  72694. */
  72695. floor(): Vector2;
  72696. /**
  72697. * Gets a new Vector2 from current Vector2 floored values
  72698. * @returns a new Vector2
  72699. */
  72700. fract(): Vector2;
  72701. /**
  72702. * Gets the length of the vector
  72703. * @returns the vector length (float)
  72704. */
  72705. length(): number;
  72706. /**
  72707. * Gets the vector squared length
  72708. * @returns the vector squared length (float)
  72709. */
  72710. lengthSquared(): number;
  72711. /**
  72712. * Normalize the vector
  72713. * @returns the current updated Vector2
  72714. */
  72715. normalize(): Vector2;
  72716. /**
  72717. * Gets a new Vector2 copied from the Vector2
  72718. * @returns a new Vector2
  72719. */
  72720. clone(): Vector2;
  72721. /**
  72722. * Gets a new Vector2(0, 0)
  72723. * @returns a new Vector2
  72724. */
  72725. static Zero(): Vector2;
  72726. /**
  72727. * Gets a new Vector2(1, 1)
  72728. * @returns a new Vector2
  72729. */
  72730. static One(): Vector2;
  72731. /**
  72732. * Gets a new Vector2 set from the given index element of the given array
  72733. * @param array defines the data source
  72734. * @param offset defines the offset in the data source
  72735. * @returns a new Vector2
  72736. */
  72737. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  72738. /**
  72739. * Sets "result" from the given index element of the given array
  72740. * @param array defines the data source
  72741. * @param offset defines the offset in the data source
  72742. * @param result defines the target vector
  72743. */
  72744. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  72745. /**
  72746. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72747. * @param value1 defines 1st point of control
  72748. * @param value2 defines 2nd point of control
  72749. * @param value3 defines 3rd point of control
  72750. * @param value4 defines 4th point of control
  72751. * @param amount defines the interpolation factor
  72752. * @returns a new Vector2
  72753. */
  72754. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  72755. /**
  72756. * 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".
  72757. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72758. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72759. * @param value defines the value to clamp
  72760. * @param min defines the lower limit
  72761. * @param max defines the upper limit
  72762. * @returns a new Vector2
  72763. */
  72764. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  72765. /**
  72766. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72767. * @param value1 defines the 1st control point
  72768. * @param tangent1 defines the outgoing tangent
  72769. * @param value2 defines the 2nd control point
  72770. * @param tangent2 defines the incoming tangent
  72771. * @param amount defines the interpolation factor
  72772. * @returns a new Vector2
  72773. */
  72774. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  72775. /**
  72776. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72777. * @param start defines the start vector
  72778. * @param end defines the end vector
  72779. * @param amount defines the interpolation factor
  72780. * @returns a new Vector2
  72781. */
  72782. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  72783. /**
  72784. * Gets the dot product of the vector "left" and the vector "right"
  72785. * @param left defines first vector
  72786. * @param right defines second vector
  72787. * @returns the dot product (float)
  72788. */
  72789. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  72790. /**
  72791. * Returns a new Vector2 equal to the normalized given vector
  72792. * @param vector defines the vector to normalize
  72793. * @returns a new Vector2
  72794. */
  72795. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  72796. /**
  72797. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72798. * @param left defines 1st vector
  72799. * @param right defines 2nd vector
  72800. * @returns a new Vector2
  72801. */
  72802. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72803. /**
  72804. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72805. * @param left defines 1st vector
  72806. * @param right defines 2nd vector
  72807. * @returns a new Vector2
  72808. */
  72809. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72810. /**
  72811. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72812. * @param vector defines the vector to transform
  72813. * @param transformation defines the matrix to apply
  72814. * @returns a new Vector2
  72815. */
  72816. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  72817. /**
  72818. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72819. * @param vector defines the vector to transform
  72820. * @param transformation defines the matrix to apply
  72821. * @param result defines the target vector
  72822. */
  72823. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  72824. /**
  72825. * Determines if a given vector is included in a triangle
  72826. * @param p defines the vector to test
  72827. * @param p0 defines 1st triangle point
  72828. * @param p1 defines 2nd triangle point
  72829. * @param p2 defines 3rd triangle point
  72830. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72831. */
  72832. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  72833. /**
  72834. * Gets the distance between the vectors "value1" and "value2"
  72835. * @param value1 defines first vector
  72836. * @param value2 defines second vector
  72837. * @returns the distance between vectors
  72838. */
  72839. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72840. /**
  72841. * Returns the squared distance between the vectors "value1" and "value2"
  72842. * @param value1 defines first vector
  72843. * @param value2 defines second vector
  72844. * @returns the squared distance between vectors
  72845. */
  72846. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72847. /**
  72848. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72849. * @param value1 defines first vector
  72850. * @param value2 defines second vector
  72851. * @returns a new Vector2
  72852. */
  72853. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  72854. /**
  72855. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72856. * @param p defines the middle point
  72857. * @param segA defines one point of the segment
  72858. * @param segB defines the other point of the segment
  72859. * @returns the shortest distance
  72860. */
  72861. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  72862. }
  72863. /**
  72864. * Class used to store (x,y,z) vector representation
  72865. * A Vector3 is the main object used in 3D geometry
  72866. * It can represent etiher the coordinates of a point the space, either a direction
  72867. * Reminder: js uses a left handed forward facing system
  72868. */
  72869. export class Vector3 {
  72870. /**
  72871. * Defines the first coordinates (on X axis)
  72872. */
  72873. x: number;
  72874. /**
  72875. * Defines the second coordinates (on Y axis)
  72876. */
  72877. y: number;
  72878. /**
  72879. * Defines the third coordinates (on Z axis)
  72880. */
  72881. z: number;
  72882. private static _UpReadOnly;
  72883. private static _ZeroReadOnly;
  72884. /**
  72885. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  72886. * @param x defines the first coordinates (on X axis)
  72887. * @param y defines the second coordinates (on Y axis)
  72888. * @param z defines the third coordinates (on Z axis)
  72889. */
  72890. constructor(
  72891. /**
  72892. * Defines the first coordinates (on X axis)
  72893. */
  72894. x?: number,
  72895. /**
  72896. * Defines the second coordinates (on Y axis)
  72897. */
  72898. y?: number,
  72899. /**
  72900. * Defines the third coordinates (on Z axis)
  72901. */
  72902. z?: number);
  72903. /**
  72904. * Creates a string representation of the Vector3
  72905. * @returns a string with the Vector3 coordinates.
  72906. */
  72907. toString(): string;
  72908. /**
  72909. * Gets the class name
  72910. * @returns the string "Vector3"
  72911. */
  72912. getClassName(): string;
  72913. /**
  72914. * Creates the Vector3 hash code
  72915. * @returns a number which tends to be unique between Vector3 instances
  72916. */
  72917. getHashCode(): number;
  72918. /**
  72919. * Creates an array containing three elements : the coordinates of the Vector3
  72920. * @returns a new array of numbers
  72921. */
  72922. asArray(): number[];
  72923. /**
  72924. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  72925. * @param array defines the destination array
  72926. * @param index defines the offset in the destination array
  72927. * @returns the current Vector3
  72928. */
  72929. toArray(array: FloatArray, index?: number): Vector3;
  72930. /**
  72931. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  72932. * @returns a new Quaternion object, computed from the Vector3 coordinates
  72933. */
  72934. toQuaternion(): Quaternion;
  72935. /**
  72936. * Adds the given vector to the current Vector3
  72937. * @param otherVector defines the second operand
  72938. * @returns the current updated Vector3
  72939. */
  72940. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  72941. /**
  72942. * Adds the given coordinates to the current Vector3
  72943. * @param x defines the x coordinate of the operand
  72944. * @param y defines the y coordinate of the operand
  72945. * @param z defines the z coordinate of the operand
  72946. * @returns the current updated Vector3
  72947. */
  72948. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  72949. /**
  72950. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  72951. * @param otherVector defines the second operand
  72952. * @returns the resulting Vector3
  72953. */
  72954. add(otherVector: DeepImmutable<Vector3>): Vector3;
  72955. /**
  72956. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  72957. * @param otherVector defines the second operand
  72958. * @param result defines the Vector3 object where to store the result
  72959. * @returns the current Vector3
  72960. */
  72961. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72962. /**
  72963. * Subtract the given vector from the current Vector3
  72964. * @param otherVector defines the second operand
  72965. * @returns the current updated Vector3
  72966. */
  72967. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  72968. /**
  72969. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  72970. * @param otherVector defines the second operand
  72971. * @returns the resulting Vector3
  72972. */
  72973. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  72974. /**
  72975. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  72976. * @param otherVector defines the second operand
  72977. * @param result defines the Vector3 object where to store the result
  72978. * @returns the current Vector3
  72979. */
  72980. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  72981. /**
  72982. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  72983. * @param x defines the x coordinate of the operand
  72984. * @param y defines the y coordinate of the operand
  72985. * @param z defines the z coordinate of the operand
  72986. * @returns the resulting Vector3
  72987. */
  72988. subtractFromFloats(x: number, y: number, z: number): Vector3;
  72989. /**
  72990. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  72991. * @param x defines the x coordinate of the operand
  72992. * @param y defines the y coordinate of the operand
  72993. * @param z defines the z coordinate of the operand
  72994. * @param result defines the Vector3 object where to store the result
  72995. * @returns the current Vector3
  72996. */
  72997. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  72998. /**
  72999. * Gets a new Vector3 set with the current Vector3 negated coordinates
  73000. * @returns a new Vector3
  73001. */
  73002. negate(): Vector3;
  73003. /**
  73004. * Multiplies the Vector3 coordinates by the float "scale"
  73005. * @param scale defines the multiplier factor
  73006. * @returns the current updated Vector3
  73007. */
  73008. scaleInPlace(scale: number): Vector3;
  73009. /**
  73010. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  73011. * @param scale defines the multiplier factor
  73012. * @returns a new Vector3
  73013. */
  73014. scale(scale: number): Vector3;
  73015. /**
  73016. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  73017. * @param scale defines the multiplier factor
  73018. * @param result defines the Vector3 object where to store the result
  73019. * @returns the current Vector3
  73020. */
  73021. scaleToRef(scale: number, result: Vector3): Vector3;
  73022. /**
  73023. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  73024. * @param scale defines the scale factor
  73025. * @param result defines the Vector3 object where to store the result
  73026. * @returns the unmodified current Vector3
  73027. */
  73028. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  73029. /**
  73030. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73031. * @param otherVector defines the second operand
  73032. * @returns true if both vectors are equals
  73033. */
  73034. equals(otherVector: DeepImmutable<Vector3>): boolean;
  73035. /**
  73036. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73037. * @param otherVector defines the second operand
  73038. * @param epsilon defines the minimal distance to define values as equals
  73039. * @returns true if both vectors are distant less than epsilon
  73040. */
  73041. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  73042. /**
  73043. * Returns true if the current Vector3 coordinates equals the given floats
  73044. * @param x defines the x coordinate of the operand
  73045. * @param y defines the y coordinate of the operand
  73046. * @param z defines the z coordinate of the operand
  73047. * @returns true if both vectors are equals
  73048. */
  73049. equalsToFloats(x: number, y: number, z: number): boolean;
  73050. /**
  73051. * Multiplies the current Vector3 coordinates by the given ones
  73052. * @param otherVector defines the second operand
  73053. * @returns the current updated Vector3
  73054. */
  73055. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73056. /**
  73057. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73058. * @param otherVector defines the second operand
  73059. * @returns the new Vector3
  73060. */
  73061. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  73062. /**
  73063. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73064. * @param otherVector defines the second operand
  73065. * @param result defines the Vector3 object where to store the result
  73066. * @returns the current Vector3
  73067. */
  73068. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73069. /**
  73070. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73071. * @param x defines the x coordinate of the operand
  73072. * @param y defines the y coordinate of the operand
  73073. * @param z defines the z coordinate of the operand
  73074. * @returns the new Vector3
  73075. */
  73076. multiplyByFloats(x: number, y: number, z: number): Vector3;
  73077. /**
  73078. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73079. * @param otherVector defines the second operand
  73080. * @returns the new Vector3
  73081. */
  73082. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  73083. /**
  73084. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73085. * @param otherVector defines the second operand
  73086. * @param result defines the Vector3 object where to store the result
  73087. * @returns the current Vector3
  73088. */
  73089. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73090. /**
  73091. * Divides the current Vector3 coordinates by the given ones.
  73092. * @param otherVector defines the second operand
  73093. * @returns the current updated Vector3
  73094. */
  73095. divideInPlace(otherVector: Vector3): Vector3;
  73096. /**
  73097. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73098. * @param other defines the second operand
  73099. * @returns the current updated Vector3
  73100. */
  73101. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73102. /**
  73103. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73104. * @param other defines the second operand
  73105. * @returns the current updated Vector3
  73106. */
  73107. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73108. /**
  73109. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73110. * @param x defines the x coordinate of the operand
  73111. * @param y defines the y coordinate of the operand
  73112. * @param z defines the z coordinate of the operand
  73113. * @returns the current updated Vector3
  73114. */
  73115. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73116. /**
  73117. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73118. * @param x defines the x coordinate of the operand
  73119. * @param y defines the y coordinate of the operand
  73120. * @param z defines the z coordinate of the operand
  73121. * @returns the current updated Vector3
  73122. */
  73123. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73124. /**
  73125. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73126. * Check if is non uniform within a certain amount of decimal places to account for this
  73127. * @param epsilon the amount the values can differ
  73128. * @returns if the the vector is non uniform to a certain number of decimal places
  73129. */
  73130. isNonUniformWithinEpsilon(epsilon: number): boolean;
  73131. /**
  73132. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73133. */
  73134. get isNonUniform(): boolean;
  73135. /**
  73136. * Gets a new Vector3 from current Vector3 floored values
  73137. * @returns a new Vector3
  73138. */
  73139. floor(): Vector3;
  73140. /**
  73141. * Gets a new Vector3 from current Vector3 floored values
  73142. * @returns a new Vector3
  73143. */
  73144. fract(): Vector3;
  73145. /**
  73146. * Gets the length of the Vector3
  73147. * @returns the length of the Vector3
  73148. */
  73149. length(): number;
  73150. /**
  73151. * Gets the squared length of the Vector3
  73152. * @returns squared length of the Vector3
  73153. */
  73154. lengthSquared(): number;
  73155. /**
  73156. * Normalize the current Vector3.
  73157. * Please note that this is an in place operation.
  73158. * @returns the current updated Vector3
  73159. */
  73160. normalize(): Vector3;
  73161. /**
  73162. * Reorders the x y z properties of the vector in place
  73163. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  73164. * @returns the current updated vector
  73165. */
  73166. reorderInPlace(order: string): this;
  73167. /**
  73168. * Rotates the vector around 0,0,0 by a quaternion
  73169. * @param quaternion the rotation quaternion
  73170. * @param result vector to store the result
  73171. * @returns the resulting vector
  73172. */
  73173. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  73174. /**
  73175. * Rotates a vector around a given point
  73176. * @param quaternion the rotation quaternion
  73177. * @param point the point to rotate around
  73178. * @param result vector to store the result
  73179. * @returns the resulting vector
  73180. */
  73181. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  73182. /**
  73183. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  73184. * The cross product is then orthogonal to both current and "other"
  73185. * @param other defines the right operand
  73186. * @returns the cross product
  73187. */
  73188. cross(other: Vector3): Vector3;
  73189. /**
  73190. * Normalize the current Vector3 with the given input length.
  73191. * Please note that this is an in place operation.
  73192. * @param len the length of the vector
  73193. * @returns the current updated Vector3
  73194. */
  73195. normalizeFromLength(len: number): Vector3;
  73196. /**
  73197. * Normalize the current Vector3 to a new vector
  73198. * @returns the new Vector3
  73199. */
  73200. normalizeToNew(): Vector3;
  73201. /**
  73202. * Normalize the current Vector3 to the reference
  73203. * @param reference define the Vector3 to update
  73204. * @returns the updated Vector3
  73205. */
  73206. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  73207. /**
  73208. * Creates a new Vector3 copied from the current Vector3
  73209. * @returns the new Vector3
  73210. */
  73211. clone(): Vector3;
  73212. /**
  73213. * Copies the given vector coordinates to the current Vector3 ones
  73214. * @param source defines the source Vector3
  73215. * @returns the current updated Vector3
  73216. */
  73217. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  73218. /**
  73219. * Copies the given floats to the current Vector3 coordinates
  73220. * @param x defines the x coordinate of the operand
  73221. * @param y defines the y coordinate of the operand
  73222. * @param z defines the z coordinate of the operand
  73223. * @returns the current updated Vector3
  73224. */
  73225. copyFromFloats(x: number, y: number, z: number): Vector3;
  73226. /**
  73227. * Copies the given floats to the current Vector3 coordinates
  73228. * @param x defines the x coordinate of the operand
  73229. * @param y defines the y coordinate of the operand
  73230. * @param z defines the z coordinate of the operand
  73231. * @returns the current updated Vector3
  73232. */
  73233. set(x: number, y: number, z: number): Vector3;
  73234. /**
  73235. * Copies the given float to the current Vector3 coordinates
  73236. * @param v defines the x, y and z coordinates of the operand
  73237. * @returns the current updated Vector3
  73238. */
  73239. setAll(v: number): Vector3;
  73240. /**
  73241. * Get the clip factor between two vectors
  73242. * @param vector0 defines the first operand
  73243. * @param vector1 defines the second operand
  73244. * @param axis defines the axis to use
  73245. * @param size defines the size along the axis
  73246. * @returns the clip factor
  73247. */
  73248. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  73249. /**
  73250. * Get angle between two vectors
  73251. * @param vector0 angle between vector0 and vector1
  73252. * @param vector1 angle between vector0 and vector1
  73253. * @param normal direction of the normal
  73254. * @return the angle between vector0 and vector1
  73255. */
  73256. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  73257. /**
  73258. * Returns a new Vector3 set from the index "offset" of the given array
  73259. * @param array defines the source array
  73260. * @param offset defines the offset in the source array
  73261. * @returns the new Vector3
  73262. */
  73263. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  73264. /**
  73265. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  73266. * @param array defines the source array
  73267. * @param offset defines the offset in the source array
  73268. * @returns the new Vector3
  73269. * @deprecated Please use FromArray instead.
  73270. */
  73271. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  73272. /**
  73273. * Sets the given vector "result" with the element values from the index "offset" of the given array
  73274. * @param array defines the source array
  73275. * @param offset defines the offset in the source array
  73276. * @param result defines the Vector3 where to store the result
  73277. */
  73278. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  73279. /**
  73280. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  73281. * @param array defines the source array
  73282. * @param offset defines the offset in the source array
  73283. * @param result defines the Vector3 where to store the result
  73284. * @deprecated Please use FromArrayToRef instead.
  73285. */
  73286. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  73287. /**
  73288. * Sets the given vector "result" with the given floats.
  73289. * @param x defines the x coordinate of the source
  73290. * @param y defines the y coordinate of the source
  73291. * @param z defines the z coordinate of the source
  73292. * @param result defines the Vector3 where to store the result
  73293. */
  73294. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  73295. /**
  73296. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  73297. * @returns a new empty Vector3
  73298. */
  73299. static Zero(): Vector3;
  73300. /**
  73301. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  73302. * @returns a new unit Vector3
  73303. */
  73304. static One(): Vector3;
  73305. /**
  73306. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  73307. * @returns a new up Vector3
  73308. */
  73309. static Up(): Vector3;
  73310. /**
  73311. * Gets a up Vector3 that must not be updated
  73312. */
  73313. static get UpReadOnly(): DeepImmutable<Vector3>;
  73314. /**
  73315. * Gets a zero Vector3 that must not be updated
  73316. */
  73317. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  73318. /**
  73319. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  73320. * @returns a new down Vector3
  73321. */
  73322. static Down(): Vector3;
  73323. /**
  73324. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  73325. * @returns a new forward Vector3
  73326. */
  73327. static Forward(): Vector3;
  73328. /**
  73329. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  73330. * @returns a new forward Vector3
  73331. */
  73332. static Backward(): Vector3;
  73333. /**
  73334. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  73335. * @returns a new right Vector3
  73336. */
  73337. static Right(): Vector3;
  73338. /**
  73339. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  73340. * @returns a new left Vector3
  73341. */
  73342. static Left(): Vector3;
  73343. /**
  73344. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  73345. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73346. * @param vector defines the Vector3 to transform
  73347. * @param transformation defines the transformation matrix
  73348. * @returns the transformed Vector3
  73349. */
  73350. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73351. /**
  73352. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  73353. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73354. * @param vector defines the Vector3 to transform
  73355. * @param transformation defines the transformation matrix
  73356. * @param result defines the Vector3 where to store the result
  73357. */
  73358. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73359. /**
  73360. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  73361. * This method computes tranformed coordinates only, not transformed direction vectors
  73362. * @param x define the x coordinate of the source vector
  73363. * @param y define the y coordinate of the source vector
  73364. * @param z define the z coordinate of the source vector
  73365. * @param transformation defines the transformation matrix
  73366. * @param result defines the Vector3 where to store the result
  73367. */
  73368. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73369. /**
  73370. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  73371. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73372. * @param vector defines the Vector3 to transform
  73373. * @param transformation defines the transformation matrix
  73374. * @returns the new Vector3
  73375. */
  73376. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73377. /**
  73378. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  73379. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73380. * @param vector defines the Vector3 to transform
  73381. * @param transformation defines the transformation matrix
  73382. * @param result defines the Vector3 where to store the result
  73383. */
  73384. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73385. /**
  73386. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  73387. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73388. * @param x define the x coordinate of the source vector
  73389. * @param y define the y coordinate of the source vector
  73390. * @param z define the z coordinate of the source vector
  73391. * @param transformation defines the transformation matrix
  73392. * @param result defines the Vector3 where to store the result
  73393. */
  73394. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73395. /**
  73396. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  73397. * @param value1 defines the first control point
  73398. * @param value2 defines the second control point
  73399. * @param value3 defines the third control point
  73400. * @param value4 defines the fourth control point
  73401. * @param amount defines the amount on the spline to use
  73402. * @returns the new Vector3
  73403. */
  73404. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  73405. /**
  73406. * 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"
  73407. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73408. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73409. * @param value defines the current value
  73410. * @param min defines the lower range value
  73411. * @param max defines the upper range value
  73412. * @returns the new Vector3
  73413. */
  73414. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  73415. /**
  73416. * 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"
  73417. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73418. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73419. * @param value defines the current value
  73420. * @param min defines the lower range value
  73421. * @param max defines the upper range value
  73422. * @param result defines the Vector3 where to store the result
  73423. */
  73424. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  73425. /**
  73426. * Checks if a given vector is inside a specific range
  73427. * @param v defines the vector to test
  73428. * @param min defines the minimum range
  73429. * @param max defines the maximum range
  73430. */
  73431. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  73432. /**
  73433. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  73434. * @param value1 defines the first control point
  73435. * @param tangent1 defines the first tangent vector
  73436. * @param value2 defines the second control point
  73437. * @param tangent2 defines the second tangent vector
  73438. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  73439. * @returns the new Vector3
  73440. */
  73441. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  73442. /**
  73443. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  73444. * @param start defines the start value
  73445. * @param end defines the end value
  73446. * @param amount max defines amount between both (between 0 and 1)
  73447. * @returns the new Vector3
  73448. */
  73449. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  73450. /**
  73451. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  73452. * @param start defines the start value
  73453. * @param end defines the end value
  73454. * @param amount max defines amount between both (between 0 and 1)
  73455. * @param result defines the Vector3 where to store the result
  73456. */
  73457. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  73458. /**
  73459. * Returns the dot product (float) between the vectors "left" and "right"
  73460. * @param left defines the left operand
  73461. * @param right defines the right operand
  73462. * @returns the dot product
  73463. */
  73464. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  73465. /**
  73466. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  73467. * The cross product is then orthogonal to both "left" and "right"
  73468. * @param left defines the left operand
  73469. * @param right defines the right operand
  73470. * @returns the cross product
  73471. */
  73472. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73473. /**
  73474. * Sets the given vector "result" with the cross product of "left" and "right"
  73475. * The cross product is then orthogonal to both "left" and "right"
  73476. * @param left defines the left operand
  73477. * @param right defines the right operand
  73478. * @param result defines the Vector3 where to store the result
  73479. */
  73480. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  73481. /**
  73482. * Returns a new Vector3 as the normalization of the given vector
  73483. * @param vector defines the Vector3 to normalize
  73484. * @returns the new Vector3
  73485. */
  73486. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  73487. /**
  73488. * Sets the given vector "result" with the normalization of the given first vector
  73489. * @param vector defines the Vector3 to normalize
  73490. * @param result defines the Vector3 where to store the result
  73491. */
  73492. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  73493. /**
  73494. * Project a Vector3 onto screen space
  73495. * @param vector defines the Vector3 to project
  73496. * @param world defines the world matrix to use
  73497. * @param transform defines the transform (view x projection) matrix to use
  73498. * @param viewport defines the screen viewport to use
  73499. * @returns the new Vector3
  73500. */
  73501. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  73502. /** @hidden */
  73503. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  73504. /**
  73505. * Unproject from screen space to object space
  73506. * @param source defines the screen space Vector3 to use
  73507. * @param viewportWidth defines the current width of the viewport
  73508. * @param viewportHeight defines the current height of the viewport
  73509. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73510. * @param transform defines the transform (view x projection) matrix to use
  73511. * @returns the new Vector3
  73512. */
  73513. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  73514. /**
  73515. * Unproject from screen space to object space
  73516. * @param source defines the screen space Vector3 to use
  73517. * @param viewportWidth defines the current width of the viewport
  73518. * @param viewportHeight defines the current height of the viewport
  73519. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73520. * @param view defines the view matrix to use
  73521. * @param projection defines the projection matrix to use
  73522. * @returns the new Vector3
  73523. */
  73524. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  73525. /**
  73526. * Unproject from screen space to object space
  73527. * @param source defines the screen space Vector3 to use
  73528. * @param viewportWidth defines the current width of the viewport
  73529. * @param viewportHeight defines the current height of the viewport
  73530. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73531. * @param view defines the view matrix to use
  73532. * @param projection defines the projection matrix to use
  73533. * @param result defines the Vector3 where to store the result
  73534. */
  73535. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73536. /**
  73537. * Unproject from screen space to object space
  73538. * @param sourceX defines the screen space x coordinate to use
  73539. * @param sourceY defines the screen space y coordinate to use
  73540. * @param sourceZ defines the screen space z coordinate to use
  73541. * @param viewportWidth defines the current width of the viewport
  73542. * @param viewportHeight defines the current height of the viewport
  73543. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73544. * @param view defines the view matrix to use
  73545. * @param projection defines the projection matrix to use
  73546. * @param result defines the Vector3 where to store the result
  73547. */
  73548. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73549. /**
  73550. * Gets the minimal coordinate values between two Vector3
  73551. * @param left defines the first operand
  73552. * @param right defines the second operand
  73553. * @returns the new Vector3
  73554. */
  73555. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73556. /**
  73557. * Gets the maximal coordinate values between two Vector3
  73558. * @param left defines the first operand
  73559. * @param right defines the second operand
  73560. * @returns the new Vector3
  73561. */
  73562. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73563. /**
  73564. * Returns the distance between the vectors "value1" and "value2"
  73565. * @param value1 defines the first operand
  73566. * @param value2 defines the second operand
  73567. * @returns the distance
  73568. */
  73569. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73570. /**
  73571. * Returns the squared distance between the vectors "value1" and "value2"
  73572. * @param value1 defines the first operand
  73573. * @param value2 defines the second operand
  73574. * @returns the squared distance
  73575. */
  73576. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73577. /**
  73578. * Returns a new Vector3 located at the center between "value1" and "value2"
  73579. * @param value1 defines the first operand
  73580. * @param value2 defines the second operand
  73581. * @returns the new Vector3
  73582. */
  73583. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  73584. /**
  73585. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73586. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73587. * to something in order to rotate it from its local system to the given target system
  73588. * Note: axis1, axis2 and axis3 are normalized during this operation
  73589. * @param axis1 defines the first axis
  73590. * @param axis2 defines the second axis
  73591. * @param axis3 defines the third axis
  73592. * @returns a new Vector3
  73593. */
  73594. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  73595. /**
  73596. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73597. * @param axis1 defines the first axis
  73598. * @param axis2 defines the second axis
  73599. * @param axis3 defines the third axis
  73600. * @param ref defines the Vector3 where to store the result
  73601. */
  73602. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  73603. }
  73604. /**
  73605. * Vector4 class created for EulerAngle class conversion to Quaternion
  73606. */
  73607. export class Vector4 {
  73608. /** x value of the vector */
  73609. x: number;
  73610. /** y value of the vector */
  73611. y: number;
  73612. /** z value of the vector */
  73613. z: number;
  73614. /** w value of the vector */
  73615. w: number;
  73616. /**
  73617. * Creates a Vector4 object from the given floats.
  73618. * @param x x value of the vector
  73619. * @param y y value of the vector
  73620. * @param z z value of the vector
  73621. * @param w w value of the vector
  73622. */
  73623. constructor(
  73624. /** x value of the vector */
  73625. x: number,
  73626. /** y value of the vector */
  73627. y: number,
  73628. /** z value of the vector */
  73629. z: number,
  73630. /** w value of the vector */
  73631. w: number);
  73632. /**
  73633. * Returns the string with the Vector4 coordinates.
  73634. * @returns a string containing all the vector values
  73635. */
  73636. toString(): string;
  73637. /**
  73638. * Returns the string "Vector4".
  73639. * @returns "Vector4"
  73640. */
  73641. getClassName(): string;
  73642. /**
  73643. * Returns the Vector4 hash code.
  73644. * @returns a unique hash code
  73645. */
  73646. getHashCode(): number;
  73647. /**
  73648. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73649. * @returns the resulting array
  73650. */
  73651. asArray(): number[];
  73652. /**
  73653. * Populates the given array from the given index with the Vector4 coordinates.
  73654. * @param array array to populate
  73655. * @param index index of the array to start at (default: 0)
  73656. * @returns the Vector4.
  73657. */
  73658. toArray(array: FloatArray, index?: number): Vector4;
  73659. /**
  73660. * Adds the given vector to the current Vector4.
  73661. * @param otherVector the vector to add
  73662. * @returns the updated Vector4.
  73663. */
  73664. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73665. /**
  73666. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73667. * @param otherVector the vector to add
  73668. * @returns the resulting vector
  73669. */
  73670. add(otherVector: DeepImmutable<Vector4>): Vector4;
  73671. /**
  73672. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73673. * @param otherVector the vector to add
  73674. * @param result the vector to store the result
  73675. * @returns the current Vector4.
  73676. */
  73677. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73678. /**
  73679. * Subtract in place the given vector from the current Vector4.
  73680. * @param otherVector the vector to subtract
  73681. * @returns the updated Vector4.
  73682. */
  73683. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73684. /**
  73685. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73686. * @param otherVector the vector to add
  73687. * @returns the new vector with the result
  73688. */
  73689. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  73690. /**
  73691. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73692. * @param otherVector the vector to subtract
  73693. * @param result the vector to store the result
  73694. * @returns the current Vector4.
  73695. */
  73696. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73697. /**
  73698. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73699. */
  73700. /**
  73701. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73702. * @param x value to subtract
  73703. * @param y value to subtract
  73704. * @param z value to subtract
  73705. * @param w value to subtract
  73706. * @returns new vector containing the result
  73707. */
  73708. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73709. /**
  73710. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73711. * @param x value to subtract
  73712. * @param y value to subtract
  73713. * @param z value to subtract
  73714. * @param w value to subtract
  73715. * @param result the vector to store the result in
  73716. * @returns the current Vector4.
  73717. */
  73718. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  73719. /**
  73720. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73721. * @returns a new vector with the negated values
  73722. */
  73723. negate(): Vector4;
  73724. /**
  73725. * Multiplies the current Vector4 coordinates by scale (float).
  73726. * @param scale the number to scale with
  73727. * @returns the updated Vector4.
  73728. */
  73729. scaleInPlace(scale: number): Vector4;
  73730. /**
  73731. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73732. * @param scale the number to scale with
  73733. * @returns a new vector with the result
  73734. */
  73735. scale(scale: number): Vector4;
  73736. /**
  73737. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73738. * @param scale the number to scale with
  73739. * @param result a vector to store the result in
  73740. * @returns the current Vector4.
  73741. */
  73742. scaleToRef(scale: number, result: Vector4): Vector4;
  73743. /**
  73744. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73745. * @param scale defines the scale factor
  73746. * @param result defines the Vector4 object where to store the result
  73747. * @returns the unmodified current Vector4
  73748. */
  73749. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  73750. /**
  73751. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73752. * @param otherVector the vector to compare against
  73753. * @returns true if they are equal
  73754. */
  73755. equals(otherVector: DeepImmutable<Vector4>): boolean;
  73756. /**
  73757. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73758. * @param otherVector vector to compare against
  73759. * @param epsilon (Default: very small number)
  73760. * @returns true if they are equal
  73761. */
  73762. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  73763. /**
  73764. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73765. * @param x x value to compare against
  73766. * @param y y value to compare against
  73767. * @param z z value to compare against
  73768. * @param w w value to compare against
  73769. * @returns true if equal
  73770. */
  73771. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  73772. /**
  73773. * Multiplies in place the current Vector4 by the given one.
  73774. * @param otherVector vector to multiple with
  73775. * @returns the updated Vector4.
  73776. */
  73777. multiplyInPlace(otherVector: Vector4): Vector4;
  73778. /**
  73779. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73780. * @param otherVector vector to multiple with
  73781. * @returns resulting new vector
  73782. */
  73783. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  73784. /**
  73785. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73786. * @param otherVector vector to multiple with
  73787. * @param result vector to store the result
  73788. * @returns the current Vector4.
  73789. */
  73790. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73791. /**
  73792. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73793. * @param x x value multiply with
  73794. * @param y y value multiply with
  73795. * @param z z value multiply with
  73796. * @param w w value multiply with
  73797. * @returns resulting new vector
  73798. */
  73799. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  73800. /**
  73801. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73802. * @param otherVector vector to devide with
  73803. * @returns resulting new vector
  73804. */
  73805. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  73806. /**
  73807. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73808. * @param otherVector vector to devide with
  73809. * @param result vector to store the result
  73810. * @returns the current Vector4.
  73811. */
  73812. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73813. /**
  73814. * Divides the current Vector3 coordinates by the given ones.
  73815. * @param otherVector vector to devide with
  73816. * @returns the updated Vector3.
  73817. */
  73818. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73819. /**
  73820. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73821. * @param other defines the second operand
  73822. * @returns the current updated Vector4
  73823. */
  73824. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73825. /**
  73826. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73827. * @param other defines the second operand
  73828. * @returns the current updated Vector4
  73829. */
  73830. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73831. /**
  73832. * Gets a new Vector4 from current Vector4 floored values
  73833. * @returns a new Vector4
  73834. */
  73835. floor(): Vector4;
  73836. /**
  73837. * Gets a new Vector4 from current Vector3 floored values
  73838. * @returns a new Vector4
  73839. */
  73840. fract(): Vector4;
  73841. /**
  73842. * Returns the Vector4 length (float).
  73843. * @returns the length
  73844. */
  73845. length(): number;
  73846. /**
  73847. * Returns the Vector4 squared length (float).
  73848. * @returns the length squared
  73849. */
  73850. lengthSquared(): number;
  73851. /**
  73852. * Normalizes in place the Vector4.
  73853. * @returns the updated Vector4.
  73854. */
  73855. normalize(): Vector4;
  73856. /**
  73857. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  73858. * @returns this converted to a new vector3
  73859. */
  73860. toVector3(): Vector3;
  73861. /**
  73862. * Returns a new Vector4 copied from the current one.
  73863. * @returns the new cloned vector
  73864. */
  73865. clone(): Vector4;
  73866. /**
  73867. * Updates the current Vector4 with the given one coordinates.
  73868. * @param source the source vector to copy from
  73869. * @returns the updated Vector4.
  73870. */
  73871. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  73872. /**
  73873. * Updates the current Vector4 coordinates with the given floats.
  73874. * @param x float to copy from
  73875. * @param y float to copy from
  73876. * @param z float to copy from
  73877. * @param w float to copy from
  73878. * @returns the updated Vector4.
  73879. */
  73880. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73881. /**
  73882. * Updates the current Vector4 coordinates with the given floats.
  73883. * @param x float to set from
  73884. * @param y float to set from
  73885. * @param z float to set from
  73886. * @param w float to set from
  73887. * @returns the updated Vector4.
  73888. */
  73889. set(x: number, y: number, z: number, w: number): Vector4;
  73890. /**
  73891. * Copies the given float to the current Vector3 coordinates
  73892. * @param v defines the x, y, z and w coordinates of the operand
  73893. * @returns the current updated Vector3
  73894. */
  73895. setAll(v: number): Vector4;
  73896. /**
  73897. * Returns a new Vector4 set from the starting index of the given array.
  73898. * @param array the array to pull values from
  73899. * @param offset the offset into the array to start at
  73900. * @returns the new vector
  73901. */
  73902. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  73903. /**
  73904. * Updates the given vector "result" from the starting index of the given array.
  73905. * @param array the array to pull values from
  73906. * @param offset the offset into the array to start at
  73907. * @param result the vector to store the result in
  73908. */
  73909. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  73910. /**
  73911. * Updates the given vector "result" from the starting index of the given Float32Array.
  73912. * @param array the array to pull values from
  73913. * @param offset the offset into the array to start at
  73914. * @param result the vector to store the result in
  73915. */
  73916. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  73917. /**
  73918. * Updates the given vector "result" coordinates from the given floats.
  73919. * @param x float to set from
  73920. * @param y float to set from
  73921. * @param z float to set from
  73922. * @param w float to set from
  73923. * @param result the vector to the floats in
  73924. */
  73925. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  73926. /**
  73927. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  73928. * @returns the new vector
  73929. */
  73930. static Zero(): Vector4;
  73931. /**
  73932. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  73933. * @returns the new vector
  73934. */
  73935. static One(): Vector4;
  73936. /**
  73937. * Returns a new normalized Vector4 from the given one.
  73938. * @param vector the vector to normalize
  73939. * @returns the vector
  73940. */
  73941. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  73942. /**
  73943. * Updates the given vector "result" from the normalization of the given one.
  73944. * @param vector the vector to normalize
  73945. * @param result the vector to store the result in
  73946. */
  73947. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  73948. /**
  73949. * Returns a vector with the minimum values from the left and right vectors
  73950. * @param left left vector to minimize
  73951. * @param right right vector to minimize
  73952. * @returns a new vector with the minimum of the left and right vector values
  73953. */
  73954. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  73955. /**
  73956. * Returns a vector with the maximum values from the left and right vectors
  73957. * @param left left vector to maximize
  73958. * @param right right vector to maximize
  73959. * @returns a new vector with the maximum of the left and right vector values
  73960. */
  73961. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  73962. /**
  73963. * Returns the distance (float) between the vectors "value1" and "value2".
  73964. * @param value1 value to calulate the distance between
  73965. * @param value2 value to calulate the distance between
  73966. * @return the distance between the two vectors
  73967. */
  73968. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  73969. /**
  73970. * Returns the squared distance (float) between the vectors "value1" and "value2".
  73971. * @param value1 value to calulate the distance between
  73972. * @param value2 value to calulate the distance between
  73973. * @return the distance between the two vectors squared
  73974. */
  73975. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  73976. /**
  73977. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  73978. * @param value1 value to calulate the center between
  73979. * @param value2 value to calulate the center between
  73980. * @return the center between the two vectors
  73981. */
  73982. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  73983. /**
  73984. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  73985. * This methods computes transformed normalized direction vectors only.
  73986. * @param vector the vector to transform
  73987. * @param transformation the transformation matrix to apply
  73988. * @returns the new vector
  73989. */
  73990. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  73991. /**
  73992. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  73993. * This methods computes transformed normalized direction vectors only.
  73994. * @param vector the vector to transform
  73995. * @param transformation the transformation matrix to apply
  73996. * @param result the vector to store the result in
  73997. */
  73998. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  73999. /**
  74000. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74001. * This methods computes transformed normalized direction vectors only.
  74002. * @param x value to transform
  74003. * @param y value to transform
  74004. * @param z value to transform
  74005. * @param w value to transform
  74006. * @param transformation the transformation matrix to apply
  74007. * @param result the vector to store the results in
  74008. */
  74009. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74010. /**
  74011. * Creates a new Vector4 from a Vector3
  74012. * @param source defines the source data
  74013. * @param w defines the 4th component (default is 0)
  74014. * @returns a new Vector4
  74015. */
  74016. static FromVector3(source: Vector3, w?: number): Vector4;
  74017. }
  74018. /**
  74019. * Class used to store quaternion data
  74020. * @see https://en.wikipedia.org/wiki/Quaternion
  74021. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74022. */
  74023. export class Quaternion {
  74024. /** defines the first component (0 by default) */
  74025. x: number;
  74026. /** defines the second component (0 by default) */
  74027. y: number;
  74028. /** defines the third component (0 by default) */
  74029. z: number;
  74030. /** defines the fourth component (1.0 by default) */
  74031. w: number;
  74032. /**
  74033. * Creates a new Quaternion from the given floats
  74034. * @param x defines the first component (0 by default)
  74035. * @param y defines the second component (0 by default)
  74036. * @param z defines the third component (0 by default)
  74037. * @param w defines the fourth component (1.0 by default)
  74038. */
  74039. constructor(
  74040. /** defines the first component (0 by default) */
  74041. x?: number,
  74042. /** defines the second component (0 by default) */
  74043. y?: number,
  74044. /** defines the third component (0 by default) */
  74045. z?: number,
  74046. /** defines the fourth component (1.0 by default) */
  74047. w?: number);
  74048. /**
  74049. * Gets a string representation for the current quaternion
  74050. * @returns a string with the Quaternion coordinates
  74051. */
  74052. toString(): string;
  74053. /**
  74054. * Gets the class name of the quaternion
  74055. * @returns the string "Quaternion"
  74056. */
  74057. getClassName(): string;
  74058. /**
  74059. * Gets a hash code for this quaternion
  74060. * @returns the quaternion hash code
  74061. */
  74062. getHashCode(): number;
  74063. /**
  74064. * Copy the quaternion to an array
  74065. * @returns a new array populated with 4 elements from the quaternion coordinates
  74066. */
  74067. asArray(): number[];
  74068. /**
  74069. * Check if two quaternions are equals
  74070. * @param otherQuaternion defines the second operand
  74071. * @return true if the current quaternion and the given one coordinates are strictly equals
  74072. */
  74073. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  74074. /**
  74075. * Clone the current quaternion
  74076. * @returns a new quaternion copied from the current one
  74077. */
  74078. clone(): Quaternion;
  74079. /**
  74080. * Copy a quaternion to the current one
  74081. * @param other defines the other quaternion
  74082. * @returns the updated current quaternion
  74083. */
  74084. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  74085. /**
  74086. * Updates the current quaternion with the given float coordinates
  74087. * @param x defines the x coordinate
  74088. * @param y defines the y coordinate
  74089. * @param z defines the z coordinate
  74090. * @param w defines the w coordinate
  74091. * @returns the updated current quaternion
  74092. */
  74093. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  74094. /**
  74095. * Updates the current quaternion from the given float coordinates
  74096. * @param x defines the x coordinate
  74097. * @param y defines the y coordinate
  74098. * @param z defines the z coordinate
  74099. * @param w defines the w coordinate
  74100. * @returns the updated current quaternion
  74101. */
  74102. set(x: number, y: number, z: number, w: number): Quaternion;
  74103. /**
  74104. * Adds two quaternions
  74105. * @param other defines the second operand
  74106. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74107. */
  74108. add(other: DeepImmutable<Quaternion>): Quaternion;
  74109. /**
  74110. * Add a quaternion to the current one
  74111. * @param other defines the quaternion to add
  74112. * @returns the current quaternion
  74113. */
  74114. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  74115. /**
  74116. * Subtract two quaternions
  74117. * @param other defines the second operand
  74118. * @returns a new quaternion as the subtraction result of the given one from the current one
  74119. */
  74120. subtract(other: Quaternion): Quaternion;
  74121. /**
  74122. * Multiplies the current quaternion by a scale factor
  74123. * @param value defines the scale factor
  74124. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74125. */
  74126. scale(value: number): Quaternion;
  74127. /**
  74128. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74129. * @param scale defines the scale factor
  74130. * @param result defines the Quaternion object where to store the result
  74131. * @returns the unmodified current quaternion
  74132. */
  74133. scaleToRef(scale: number, result: Quaternion): Quaternion;
  74134. /**
  74135. * Multiplies in place the current quaternion by a scale factor
  74136. * @param value defines the scale factor
  74137. * @returns the current modified quaternion
  74138. */
  74139. scaleInPlace(value: number): Quaternion;
  74140. /**
  74141. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74142. * @param scale defines the scale factor
  74143. * @param result defines the Quaternion object where to store the result
  74144. * @returns the unmodified current quaternion
  74145. */
  74146. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  74147. /**
  74148. * Multiplies two quaternions
  74149. * @param q1 defines the second operand
  74150. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74151. */
  74152. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  74153. /**
  74154. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74155. * @param q1 defines the second operand
  74156. * @param result defines the target quaternion
  74157. * @returns the current quaternion
  74158. */
  74159. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  74160. /**
  74161. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74162. * @param q1 defines the second operand
  74163. * @returns the currentupdated quaternion
  74164. */
  74165. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  74166. /**
  74167. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74168. * @param ref defines the target quaternion
  74169. * @returns the current quaternion
  74170. */
  74171. conjugateToRef(ref: Quaternion): Quaternion;
  74172. /**
  74173. * Conjugates in place (1-q) the current quaternion
  74174. * @returns the current updated quaternion
  74175. */
  74176. conjugateInPlace(): Quaternion;
  74177. /**
  74178. * Conjugates in place (1-q) the current quaternion
  74179. * @returns a new quaternion
  74180. */
  74181. conjugate(): Quaternion;
  74182. /**
  74183. * Gets length of current quaternion
  74184. * @returns the quaternion length (float)
  74185. */
  74186. length(): number;
  74187. /**
  74188. * Normalize in place the current quaternion
  74189. * @returns the current updated quaternion
  74190. */
  74191. normalize(): Quaternion;
  74192. /**
  74193. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  74194. * @param order is a reserved parameter and is ignore for now
  74195. * @returns a new Vector3 containing the Euler angles
  74196. */
  74197. toEulerAngles(order?: string): Vector3;
  74198. /**
  74199. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  74200. * @param result defines the vector which will be filled with the Euler angles
  74201. * @param order is a reserved parameter and is ignore for now
  74202. * @returns the current unchanged quaternion
  74203. */
  74204. toEulerAnglesToRef(result: Vector3): Quaternion;
  74205. /**
  74206. * Updates the given rotation matrix with the current quaternion values
  74207. * @param result defines the target matrix
  74208. * @returns the current unchanged quaternion
  74209. */
  74210. toRotationMatrix(result: Matrix): Quaternion;
  74211. /**
  74212. * Updates the current quaternion from the given rotation matrix values
  74213. * @param matrix defines the source matrix
  74214. * @returns the current updated quaternion
  74215. */
  74216. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74217. /**
  74218. * Creates a new quaternion from a rotation matrix
  74219. * @param matrix defines the source matrix
  74220. * @returns a new quaternion created from the given rotation matrix values
  74221. */
  74222. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74223. /**
  74224. * Updates the given quaternion with the given rotation matrix values
  74225. * @param matrix defines the source matrix
  74226. * @param result defines the target quaternion
  74227. */
  74228. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  74229. /**
  74230. * Returns the dot product (float) between the quaternions "left" and "right"
  74231. * @param left defines the left operand
  74232. * @param right defines the right operand
  74233. * @returns the dot product
  74234. */
  74235. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  74236. /**
  74237. * Checks if the two quaternions are close to each other
  74238. * @param quat0 defines the first quaternion to check
  74239. * @param quat1 defines the second quaternion to check
  74240. * @returns true if the two quaternions are close to each other
  74241. */
  74242. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  74243. /**
  74244. * Creates an empty quaternion
  74245. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  74246. */
  74247. static Zero(): Quaternion;
  74248. /**
  74249. * Inverse a given quaternion
  74250. * @param q defines the source quaternion
  74251. * @returns a new quaternion as the inverted current quaternion
  74252. */
  74253. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  74254. /**
  74255. * Inverse a given quaternion
  74256. * @param q defines the source quaternion
  74257. * @param result the quaternion the result will be stored in
  74258. * @returns the result quaternion
  74259. */
  74260. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  74261. /**
  74262. * Creates an identity quaternion
  74263. * @returns the identity quaternion
  74264. */
  74265. static Identity(): Quaternion;
  74266. /**
  74267. * Gets a boolean indicating if the given quaternion is identity
  74268. * @param quaternion defines the quaternion to check
  74269. * @returns true if the quaternion is identity
  74270. */
  74271. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  74272. /**
  74273. * Creates a quaternion from a rotation around an axis
  74274. * @param axis defines the axis to use
  74275. * @param angle defines the angle to use
  74276. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74277. */
  74278. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  74279. /**
  74280. * Creates a rotation around an axis and stores it into the given quaternion
  74281. * @param axis defines the axis to use
  74282. * @param angle defines the angle to use
  74283. * @param result defines the target quaternion
  74284. * @returns the target quaternion
  74285. */
  74286. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  74287. /**
  74288. * Creates a new quaternion from data stored into an array
  74289. * @param array defines the data source
  74290. * @param offset defines the offset in the source array where the data starts
  74291. * @returns a new quaternion
  74292. */
  74293. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  74294. /**
  74295. * Create a quaternion from Euler rotation angles
  74296. * @param x Pitch
  74297. * @param y Yaw
  74298. * @param z Roll
  74299. * @returns the new Quaternion
  74300. */
  74301. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  74302. /**
  74303. * Updates a quaternion from Euler rotation angles
  74304. * @param x Pitch
  74305. * @param y Yaw
  74306. * @param z Roll
  74307. * @param result the quaternion to store the result
  74308. * @returns the updated quaternion
  74309. */
  74310. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  74311. /**
  74312. * Create a quaternion from Euler rotation vector
  74313. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74314. * @returns the new Quaternion
  74315. */
  74316. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  74317. /**
  74318. * Updates a quaternion from Euler rotation vector
  74319. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74320. * @param result the quaternion to store the result
  74321. * @returns the updated quaternion
  74322. */
  74323. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  74324. /**
  74325. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74326. * @param yaw defines the rotation around Y axis
  74327. * @param pitch defines the rotation around X axis
  74328. * @param roll defines the rotation around Z axis
  74329. * @returns the new quaternion
  74330. */
  74331. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  74332. /**
  74333. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74334. * @param yaw defines the rotation around Y axis
  74335. * @param pitch defines the rotation around X axis
  74336. * @param roll defines the rotation around Z axis
  74337. * @param result defines the target quaternion
  74338. */
  74339. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  74340. /**
  74341. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  74342. * @param alpha defines the rotation around first axis
  74343. * @param beta defines the rotation around second axis
  74344. * @param gamma defines the rotation around third axis
  74345. * @returns the new quaternion
  74346. */
  74347. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  74348. /**
  74349. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  74350. * @param alpha defines the rotation around first axis
  74351. * @param beta defines the rotation around second axis
  74352. * @param gamma defines the rotation around third axis
  74353. * @param result defines the target quaternion
  74354. */
  74355. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  74356. /**
  74357. * 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)
  74358. * @param axis1 defines the first axis
  74359. * @param axis2 defines the second axis
  74360. * @param axis3 defines the third axis
  74361. * @returns the new quaternion
  74362. */
  74363. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  74364. /**
  74365. * 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
  74366. * @param axis1 defines the first axis
  74367. * @param axis2 defines the second axis
  74368. * @param axis3 defines the third axis
  74369. * @param ref defines the target quaternion
  74370. */
  74371. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  74372. /**
  74373. * Interpolates between two quaternions
  74374. * @param left defines first quaternion
  74375. * @param right defines second quaternion
  74376. * @param amount defines the gradient to use
  74377. * @returns the new interpolated quaternion
  74378. */
  74379. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74380. /**
  74381. * Interpolates between two quaternions and stores it into a target quaternion
  74382. * @param left defines first quaternion
  74383. * @param right defines second quaternion
  74384. * @param amount defines the gradient to use
  74385. * @param result defines the target quaternion
  74386. */
  74387. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  74388. /**
  74389. * Interpolate between two quaternions using Hermite interpolation
  74390. * @param value1 defines first quaternion
  74391. * @param tangent1 defines the incoming tangent
  74392. * @param value2 defines second quaternion
  74393. * @param tangent2 defines the outgoing tangent
  74394. * @param amount defines the target quaternion
  74395. * @returns the new interpolated quaternion
  74396. */
  74397. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74398. }
  74399. /**
  74400. * Class used to store matrix data (4x4)
  74401. */
  74402. export class Matrix {
  74403. private static _updateFlagSeed;
  74404. private static _identityReadOnly;
  74405. private _isIdentity;
  74406. private _isIdentityDirty;
  74407. private _isIdentity3x2;
  74408. private _isIdentity3x2Dirty;
  74409. /**
  74410. * Gets the update flag of the matrix which is an unique number for the matrix.
  74411. * It will be incremented every time the matrix data change.
  74412. * You can use it to speed the comparison between two versions of the same matrix.
  74413. */
  74414. updateFlag: number;
  74415. private readonly _m;
  74416. /**
  74417. * Gets the internal data of the matrix
  74418. */
  74419. get m(): DeepImmutable<Float32Array>;
  74420. /** @hidden */
  74421. _markAsUpdated(): void;
  74422. /** @hidden */
  74423. private _updateIdentityStatus;
  74424. /**
  74425. * Creates an empty matrix (filled with zeros)
  74426. */
  74427. constructor();
  74428. /**
  74429. * Check if the current matrix is identity
  74430. * @returns true is the matrix is the identity matrix
  74431. */
  74432. isIdentity(): boolean;
  74433. /**
  74434. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  74435. * @returns true is the matrix is the identity matrix
  74436. */
  74437. isIdentityAs3x2(): boolean;
  74438. /**
  74439. * Gets the determinant of the matrix
  74440. * @returns the matrix determinant
  74441. */
  74442. determinant(): number;
  74443. /**
  74444. * Returns the matrix as a Float32Array
  74445. * @returns the matrix underlying array
  74446. */
  74447. toArray(): DeepImmutable<Float32Array>;
  74448. /**
  74449. * Returns the matrix as a Float32Array
  74450. * @returns the matrix underlying array.
  74451. */
  74452. asArray(): DeepImmutable<Float32Array>;
  74453. /**
  74454. * Inverts the current matrix in place
  74455. * @returns the current inverted matrix
  74456. */
  74457. invert(): Matrix;
  74458. /**
  74459. * Sets all the matrix elements to zero
  74460. * @returns the current matrix
  74461. */
  74462. reset(): Matrix;
  74463. /**
  74464. * Adds the current matrix with a second one
  74465. * @param other defines the matrix to add
  74466. * @returns a new matrix as the addition of the current matrix and the given one
  74467. */
  74468. add(other: DeepImmutable<Matrix>): Matrix;
  74469. /**
  74470. * Sets the given matrix "result" to the addition of the current matrix and the given one
  74471. * @param other defines the matrix to add
  74472. * @param result defines the target matrix
  74473. * @returns the current matrix
  74474. */
  74475. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74476. /**
  74477. * Adds in place the given matrix to the current matrix
  74478. * @param other defines the second operand
  74479. * @returns the current updated matrix
  74480. */
  74481. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  74482. /**
  74483. * Sets the given matrix to the current inverted Matrix
  74484. * @param other defines the target matrix
  74485. * @returns the unmodified current matrix
  74486. */
  74487. invertToRef(other: Matrix): Matrix;
  74488. /**
  74489. * add a value at the specified position in the current Matrix
  74490. * @param index the index of the value within the matrix. between 0 and 15.
  74491. * @param value the value to be added
  74492. * @returns the current updated matrix
  74493. */
  74494. addAtIndex(index: number, value: number): Matrix;
  74495. /**
  74496. * mutiply the specified position in the current Matrix by a value
  74497. * @param index the index of the value within the matrix. between 0 and 15.
  74498. * @param value the value to be added
  74499. * @returns the current updated matrix
  74500. */
  74501. multiplyAtIndex(index: number, value: number): Matrix;
  74502. /**
  74503. * Inserts the translation vector (using 3 floats) in the current matrix
  74504. * @param x defines the 1st component of the translation
  74505. * @param y defines the 2nd component of the translation
  74506. * @param z defines the 3rd component of the translation
  74507. * @returns the current updated matrix
  74508. */
  74509. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74510. /**
  74511. * Adds the translation vector (using 3 floats) in the current matrix
  74512. * @param x defines the 1st component of the translation
  74513. * @param y defines the 2nd component of the translation
  74514. * @param z defines the 3rd component of the translation
  74515. * @returns the current updated matrix
  74516. */
  74517. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74518. /**
  74519. * Inserts the translation vector in the current matrix
  74520. * @param vector3 defines the translation to insert
  74521. * @returns the current updated matrix
  74522. */
  74523. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  74524. /**
  74525. * Gets the translation value of the current matrix
  74526. * @returns a new Vector3 as the extracted translation from the matrix
  74527. */
  74528. getTranslation(): Vector3;
  74529. /**
  74530. * Fill a Vector3 with the extracted translation from the matrix
  74531. * @param result defines the Vector3 where to store the translation
  74532. * @returns the current matrix
  74533. */
  74534. getTranslationToRef(result: Vector3): Matrix;
  74535. /**
  74536. * Remove rotation and scaling part from the matrix
  74537. * @returns the updated matrix
  74538. */
  74539. removeRotationAndScaling(): Matrix;
  74540. /**
  74541. * Multiply two matrices
  74542. * @param other defines the second operand
  74543. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74544. */
  74545. multiply(other: DeepImmutable<Matrix>): Matrix;
  74546. /**
  74547. * Copy the current matrix from the given one
  74548. * @param other defines the source matrix
  74549. * @returns the current updated matrix
  74550. */
  74551. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  74552. /**
  74553. * Populates the given array from the starting index with the current matrix values
  74554. * @param array defines the target array
  74555. * @param offset defines the offset in the target array where to start storing values
  74556. * @returns the current matrix
  74557. */
  74558. copyToArray(array: Float32Array, offset?: number): Matrix;
  74559. /**
  74560. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74561. * @param other defines the second operand
  74562. * @param result defines the matrix where to store the multiplication
  74563. * @returns the current matrix
  74564. */
  74565. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74566. /**
  74567. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74568. * @param other defines the second operand
  74569. * @param result defines the array where to store the multiplication
  74570. * @param offset defines the offset in the target array where to start storing values
  74571. * @returns the current matrix
  74572. */
  74573. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  74574. /**
  74575. * Check equality between this matrix and a second one
  74576. * @param value defines the second matrix to compare
  74577. * @returns true is the current matrix and the given one values are strictly equal
  74578. */
  74579. equals(value: DeepImmutable<Matrix>): boolean;
  74580. /**
  74581. * Clone the current matrix
  74582. * @returns a new matrix from the current matrix
  74583. */
  74584. clone(): Matrix;
  74585. /**
  74586. * Returns the name of the current matrix class
  74587. * @returns the string "Matrix"
  74588. */
  74589. getClassName(): string;
  74590. /**
  74591. * Gets the hash code of the current matrix
  74592. * @returns the hash code
  74593. */
  74594. getHashCode(): number;
  74595. /**
  74596. * Decomposes the current Matrix into a translation, rotation and scaling components
  74597. * @param scale defines the scale vector3 given as a reference to update
  74598. * @param rotation defines the rotation quaternion given as a reference to update
  74599. * @param translation defines the translation vector3 given as a reference to update
  74600. * @returns true if operation was successful
  74601. */
  74602. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  74603. /**
  74604. * Gets specific row of the matrix
  74605. * @param index defines the number of the row to get
  74606. * @returns the index-th row of the current matrix as a new Vector4
  74607. */
  74608. getRow(index: number): Nullable<Vector4>;
  74609. /**
  74610. * Sets the index-th row of the current matrix to the vector4 values
  74611. * @param index defines the number of the row to set
  74612. * @param row defines the target vector4
  74613. * @returns the updated current matrix
  74614. */
  74615. setRow(index: number, row: Vector4): Matrix;
  74616. /**
  74617. * Compute the transpose of the matrix
  74618. * @returns the new transposed matrix
  74619. */
  74620. transpose(): Matrix;
  74621. /**
  74622. * Compute the transpose of the matrix and store it in a given matrix
  74623. * @param result defines the target matrix
  74624. * @returns the current matrix
  74625. */
  74626. transposeToRef(result: Matrix): Matrix;
  74627. /**
  74628. * Sets the index-th row of the current matrix with the given 4 x float values
  74629. * @param index defines the row index
  74630. * @param x defines the x component to set
  74631. * @param y defines the y component to set
  74632. * @param z defines the z component to set
  74633. * @param w defines the w component to set
  74634. * @returns the updated current matrix
  74635. */
  74636. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  74637. /**
  74638. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74639. * @param scale defines the scale factor
  74640. * @returns a new matrix
  74641. */
  74642. scale(scale: number): Matrix;
  74643. /**
  74644. * Scale the current matrix values by a factor to a given result matrix
  74645. * @param scale defines the scale factor
  74646. * @param result defines the matrix to store the result
  74647. * @returns the current matrix
  74648. */
  74649. scaleToRef(scale: number, result: Matrix): Matrix;
  74650. /**
  74651. * Scale the current matrix values by a factor and add the result to a given matrix
  74652. * @param scale defines the scale factor
  74653. * @param result defines the Matrix to store the result
  74654. * @returns the current matrix
  74655. */
  74656. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  74657. /**
  74658. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74659. * @param ref matrix to store the result
  74660. */
  74661. toNormalMatrix(ref: Matrix): void;
  74662. /**
  74663. * Gets only rotation part of the current matrix
  74664. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74665. */
  74666. getRotationMatrix(): Matrix;
  74667. /**
  74668. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74669. * @param result defines the target matrix to store data to
  74670. * @returns the current matrix
  74671. */
  74672. getRotationMatrixToRef(result: Matrix): Matrix;
  74673. /**
  74674. * Toggles model matrix from being right handed to left handed in place and vice versa
  74675. */
  74676. toggleModelMatrixHandInPlace(): void;
  74677. /**
  74678. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74679. */
  74680. toggleProjectionMatrixHandInPlace(): void;
  74681. /**
  74682. * Creates a matrix from an array
  74683. * @param array defines the source array
  74684. * @param offset defines an offset in the source array
  74685. * @returns a new Matrix set from the starting index of the given array
  74686. */
  74687. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  74688. /**
  74689. * Copy the content of an array into a given matrix
  74690. * @param array defines the source array
  74691. * @param offset defines an offset in the source array
  74692. * @param result defines the target matrix
  74693. */
  74694. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  74695. /**
  74696. * Stores an array into a matrix after having multiplied each component by a given factor
  74697. * @param array defines the source array
  74698. * @param offset defines the offset in the source array
  74699. * @param scale defines the scaling factor
  74700. * @param result defines the target matrix
  74701. */
  74702. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  74703. /**
  74704. * Gets an identity matrix that must not be updated
  74705. */
  74706. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  74707. /**
  74708. * Stores a list of values (16) inside a given matrix
  74709. * @param initialM11 defines 1st value of 1st row
  74710. * @param initialM12 defines 2nd value of 1st row
  74711. * @param initialM13 defines 3rd value of 1st row
  74712. * @param initialM14 defines 4th value of 1st row
  74713. * @param initialM21 defines 1st value of 2nd row
  74714. * @param initialM22 defines 2nd value of 2nd row
  74715. * @param initialM23 defines 3rd value of 2nd row
  74716. * @param initialM24 defines 4th value of 2nd row
  74717. * @param initialM31 defines 1st value of 3rd row
  74718. * @param initialM32 defines 2nd value of 3rd row
  74719. * @param initialM33 defines 3rd value of 3rd row
  74720. * @param initialM34 defines 4th value of 3rd row
  74721. * @param initialM41 defines 1st value of 4th row
  74722. * @param initialM42 defines 2nd value of 4th row
  74723. * @param initialM43 defines 3rd value of 4th row
  74724. * @param initialM44 defines 4th value of 4th row
  74725. * @param result defines the target matrix
  74726. */
  74727. 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;
  74728. /**
  74729. * Creates new matrix from a list of values (16)
  74730. * @param initialM11 defines 1st value of 1st row
  74731. * @param initialM12 defines 2nd value of 1st row
  74732. * @param initialM13 defines 3rd value of 1st row
  74733. * @param initialM14 defines 4th value of 1st row
  74734. * @param initialM21 defines 1st value of 2nd row
  74735. * @param initialM22 defines 2nd value of 2nd row
  74736. * @param initialM23 defines 3rd value of 2nd row
  74737. * @param initialM24 defines 4th value of 2nd row
  74738. * @param initialM31 defines 1st value of 3rd row
  74739. * @param initialM32 defines 2nd value of 3rd row
  74740. * @param initialM33 defines 3rd value of 3rd row
  74741. * @param initialM34 defines 4th value of 3rd row
  74742. * @param initialM41 defines 1st value of 4th row
  74743. * @param initialM42 defines 2nd value of 4th row
  74744. * @param initialM43 defines 3rd value of 4th row
  74745. * @param initialM44 defines 4th value of 4th row
  74746. * @returns the new matrix
  74747. */
  74748. 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;
  74749. /**
  74750. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74751. * @param scale defines the scale vector3
  74752. * @param rotation defines the rotation quaternion
  74753. * @param translation defines the translation vector3
  74754. * @returns a new matrix
  74755. */
  74756. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  74757. /**
  74758. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74759. * @param scale defines the scale vector3
  74760. * @param rotation defines the rotation quaternion
  74761. * @param translation defines the translation vector3
  74762. * @param result defines the target matrix
  74763. */
  74764. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  74765. /**
  74766. * Creates a new identity matrix
  74767. * @returns a new identity matrix
  74768. */
  74769. static Identity(): Matrix;
  74770. /**
  74771. * Creates a new identity matrix and stores the result in a given matrix
  74772. * @param result defines the target matrix
  74773. */
  74774. static IdentityToRef(result: Matrix): void;
  74775. /**
  74776. * Creates a new zero matrix
  74777. * @returns a new zero matrix
  74778. */
  74779. static Zero(): Matrix;
  74780. /**
  74781. * Creates a new rotation matrix for "angle" radians around the X axis
  74782. * @param angle defines the angle (in radians) to use
  74783. * @return the new matrix
  74784. */
  74785. static RotationX(angle: number): Matrix;
  74786. /**
  74787. * Creates a new matrix as the invert of a given matrix
  74788. * @param source defines the source matrix
  74789. * @returns the new matrix
  74790. */
  74791. static Invert(source: DeepImmutable<Matrix>): Matrix;
  74792. /**
  74793. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74794. * @param angle defines the angle (in radians) to use
  74795. * @param result defines the target matrix
  74796. */
  74797. static RotationXToRef(angle: number, result: Matrix): void;
  74798. /**
  74799. * Creates a new rotation matrix for "angle" radians around the Y axis
  74800. * @param angle defines the angle (in radians) to use
  74801. * @return the new matrix
  74802. */
  74803. static RotationY(angle: number): Matrix;
  74804. /**
  74805. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74806. * @param angle defines the angle (in radians) to use
  74807. * @param result defines the target matrix
  74808. */
  74809. static RotationYToRef(angle: number, result: Matrix): void;
  74810. /**
  74811. * Creates a new rotation matrix for "angle" radians around the Z axis
  74812. * @param angle defines the angle (in radians) to use
  74813. * @return the new matrix
  74814. */
  74815. static RotationZ(angle: number): Matrix;
  74816. /**
  74817. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74818. * @param angle defines the angle (in radians) to use
  74819. * @param result defines the target matrix
  74820. */
  74821. static RotationZToRef(angle: number, result: Matrix): void;
  74822. /**
  74823. * Creates a new rotation matrix for "angle" radians around the given axis
  74824. * @param axis defines the axis to use
  74825. * @param angle defines the angle (in radians) to use
  74826. * @return the new matrix
  74827. */
  74828. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  74829. /**
  74830. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74831. * @param axis defines the axis to use
  74832. * @param angle defines the angle (in radians) to use
  74833. * @param result defines the target matrix
  74834. */
  74835. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  74836. /**
  74837. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  74838. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  74839. * @param from defines the vector to align
  74840. * @param to defines the vector to align to
  74841. * @param result defines the target matrix
  74842. */
  74843. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  74844. /**
  74845. * Creates a rotation matrix
  74846. * @param yaw defines the yaw angle in radians (Y axis)
  74847. * @param pitch defines the pitch angle in radians (X axis)
  74848. * @param roll defines the roll angle in radians (X axis)
  74849. * @returns the new rotation matrix
  74850. */
  74851. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  74852. /**
  74853. * Creates a rotation matrix and stores it in a given matrix
  74854. * @param yaw defines the yaw angle in radians (Y axis)
  74855. * @param pitch defines the pitch angle in radians (X axis)
  74856. * @param roll defines the roll angle in radians (X axis)
  74857. * @param result defines the target matrix
  74858. */
  74859. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  74860. /**
  74861. * Creates a scaling matrix
  74862. * @param x defines the scale factor on X axis
  74863. * @param y defines the scale factor on Y axis
  74864. * @param z defines the scale factor on Z axis
  74865. * @returns the new matrix
  74866. */
  74867. static Scaling(x: number, y: number, z: number): Matrix;
  74868. /**
  74869. * Creates a scaling matrix and stores it in a given matrix
  74870. * @param x defines the scale factor on X axis
  74871. * @param y defines the scale factor on Y axis
  74872. * @param z defines the scale factor on Z axis
  74873. * @param result defines the target matrix
  74874. */
  74875. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  74876. /**
  74877. * Creates a translation matrix
  74878. * @param x defines the translation on X axis
  74879. * @param y defines the translation on Y axis
  74880. * @param z defines the translationon Z axis
  74881. * @returns the new matrix
  74882. */
  74883. static Translation(x: number, y: number, z: number): Matrix;
  74884. /**
  74885. * Creates a translation matrix and stores it in a given matrix
  74886. * @param x defines the translation on X axis
  74887. * @param y defines the translation on Y axis
  74888. * @param z defines the translationon Z axis
  74889. * @param result defines the target matrix
  74890. */
  74891. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  74892. /**
  74893. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74894. * @param startValue defines the start value
  74895. * @param endValue defines the end value
  74896. * @param gradient defines the gradient factor
  74897. * @returns the new matrix
  74898. */
  74899. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74900. /**
  74901. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74902. * @param startValue defines the start value
  74903. * @param endValue defines the end value
  74904. * @param gradient defines the gradient factor
  74905. * @param result defines the Matrix object where to store data
  74906. */
  74907. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74908. /**
  74909. * Builds a new matrix whose values are computed by:
  74910. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74911. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74912. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74913. * @param startValue defines the first matrix
  74914. * @param endValue defines the second matrix
  74915. * @param gradient defines the gradient between the two matrices
  74916. * @returns the new matrix
  74917. */
  74918. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74919. /**
  74920. * Update a matrix to values which are computed by:
  74921. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74922. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74923. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74924. * @param startValue defines the first matrix
  74925. * @param endValue defines the second matrix
  74926. * @param gradient defines the gradient between the two matrices
  74927. * @param result defines the target matrix
  74928. */
  74929. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74930. /**
  74931. * 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"
  74932. * This function works in left handed mode
  74933. * @param eye defines the final position of the entity
  74934. * @param target defines where the entity should look at
  74935. * @param up defines the up vector for the entity
  74936. * @returns the new matrix
  74937. */
  74938. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  74939. /**
  74940. * 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".
  74941. * This function works in left handed mode
  74942. * @param eye defines the final position of the entity
  74943. * @param target defines where the entity should look at
  74944. * @param up defines the up vector for the entity
  74945. * @param result defines the target matrix
  74946. */
  74947. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  74948. /**
  74949. * 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"
  74950. * This function works in right handed mode
  74951. * @param eye defines the final position of the entity
  74952. * @param target defines where the entity should look at
  74953. * @param up defines the up vector for the entity
  74954. * @returns the new matrix
  74955. */
  74956. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  74957. /**
  74958. * 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".
  74959. * This function works in right handed mode
  74960. * @param eye defines the final position of the entity
  74961. * @param target defines where the entity should look at
  74962. * @param up defines the up vector for the entity
  74963. * @param result defines the target matrix
  74964. */
  74965. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  74966. /**
  74967. * Create a left-handed orthographic projection matrix
  74968. * @param width defines the viewport width
  74969. * @param height defines the viewport height
  74970. * @param znear defines the near clip plane
  74971. * @param zfar defines the far clip plane
  74972. * @returns a new matrix as a left-handed orthographic projection matrix
  74973. */
  74974. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  74975. /**
  74976. * Store a left-handed orthographic projection to a given matrix
  74977. * @param width defines the viewport width
  74978. * @param height defines the viewport height
  74979. * @param znear defines the near clip plane
  74980. * @param zfar defines the far clip plane
  74981. * @param result defines the target matrix
  74982. */
  74983. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  74984. /**
  74985. * Create a left-handed orthographic projection matrix
  74986. * @param left defines the viewport left coordinate
  74987. * @param right defines the viewport right coordinate
  74988. * @param bottom defines the viewport bottom coordinate
  74989. * @param top defines the viewport top coordinate
  74990. * @param znear defines the near clip plane
  74991. * @param zfar defines the far clip plane
  74992. * @returns a new matrix as a left-handed orthographic projection matrix
  74993. */
  74994. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  74995. /**
  74996. * Stores a left-handed orthographic projection into a given matrix
  74997. * @param left defines the viewport left coordinate
  74998. * @param right defines the viewport right coordinate
  74999. * @param bottom defines the viewport bottom coordinate
  75000. * @param top defines the viewport top coordinate
  75001. * @param znear defines the near clip plane
  75002. * @param zfar defines the far clip plane
  75003. * @param result defines the target matrix
  75004. */
  75005. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75006. /**
  75007. * Creates a right-handed orthographic projection matrix
  75008. * @param left defines the viewport left coordinate
  75009. * @param right defines the viewport right coordinate
  75010. * @param bottom defines the viewport bottom coordinate
  75011. * @param top defines the viewport top coordinate
  75012. * @param znear defines the near clip plane
  75013. * @param zfar defines the far clip plane
  75014. * @returns a new matrix as a right-handed orthographic projection matrix
  75015. */
  75016. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75017. /**
  75018. * Stores a right-handed orthographic projection into a given matrix
  75019. * @param left defines the viewport left coordinate
  75020. * @param right defines the viewport right coordinate
  75021. * @param bottom defines the viewport bottom coordinate
  75022. * @param top defines the viewport top coordinate
  75023. * @param znear defines the near clip plane
  75024. * @param zfar defines the far clip plane
  75025. * @param result defines the target matrix
  75026. */
  75027. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75028. /**
  75029. * Creates a left-handed perspective projection matrix
  75030. * @param width defines the viewport width
  75031. * @param height defines the viewport height
  75032. * @param znear defines the near clip plane
  75033. * @param zfar defines the far clip plane
  75034. * @returns a new matrix as a left-handed perspective projection matrix
  75035. */
  75036. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75037. /**
  75038. * Creates a left-handed perspective projection matrix
  75039. * @param fov defines the horizontal field of view
  75040. * @param aspect defines the aspect ratio
  75041. * @param znear defines the near clip plane
  75042. * @param zfar defines the far clip plane
  75043. * @returns a new matrix as a left-handed perspective projection matrix
  75044. */
  75045. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75046. /**
  75047. * Stores a left-handed perspective projection into a given matrix
  75048. * @param fov defines the horizontal field of view
  75049. * @param aspect defines the aspect ratio
  75050. * @param znear defines the near clip plane
  75051. * @param zfar defines the far clip plane
  75052. * @param result defines the target matrix
  75053. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75054. */
  75055. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75056. /**
  75057. * Stores a left-handed perspective projection into a given matrix with depth reversed
  75058. * @param fov defines the horizontal field of view
  75059. * @param aspect defines the aspect ratio
  75060. * @param znear defines the near clip plane
  75061. * @param zfar not used as infinity is used as far clip
  75062. * @param result defines the target matrix
  75063. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75064. */
  75065. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75066. /**
  75067. * Creates a right-handed perspective projection matrix
  75068. * @param fov defines the horizontal field of view
  75069. * @param aspect defines the aspect ratio
  75070. * @param znear defines the near clip plane
  75071. * @param zfar defines the far clip plane
  75072. * @returns a new matrix as a right-handed perspective projection matrix
  75073. */
  75074. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75075. /**
  75076. * Stores a right-handed perspective projection into a given matrix
  75077. * @param fov defines the horizontal field of view
  75078. * @param aspect defines the aspect ratio
  75079. * @param znear defines the near clip plane
  75080. * @param zfar defines the far clip plane
  75081. * @param result defines the target matrix
  75082. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75083. */
  75084. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75085. /**
  75086. * Stores a right-handed perspective projection into a given matrix
  75087. * @param fov defines the horizontal field of view
  75088. * @param aspect defines the aspect ratio
  75089. * @param znear defines the near clip plane
  75090. * @param zfar not used as infinity is used as far clip
  75091. * @param result defines the target matrix
  75092. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75093. */
  75094. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75095. /**
  75096. * Stores a perspective projection for WebVR info a given matrix
  75097. * @param fov defines the field of view
  75098. * @param znear defines the near clip plane
  75099. * @param zfar defines the far clip plane
  75100. * @param result defines the target matrix
  75101. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75102. */
  75103. static PerspectiveFovWebVRToRef(fov: {
  75104. upDegrees: number;
  75105. downDegrees: number;
  75106. leftDegrees: number;
  75107. rightDegrees: number;
  75108. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  75109. /**
  75110. * Computes a complete transformation matrix
  75111. * @param viewport defines the viewport to use
  75112. * @param world defines the world matrix
  75113. * @param view defines the view matrix
  75114. * @param projection defines the projection matrix
  75115. * @param zmin defines the near clip plane
  75116. * @param zmax defines the far clip plane
  75117. * @returns the transformation matrix
  75118. */
  75119. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  75120. /**
  75121. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75122. * @param matrix defines the matrix to use
  75123. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75124. */
  75125. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  75126. /**
  75127. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75128. * @param matrix defines the matrix to use
  75129. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75130. */
  75131. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  75132. /**
  75133. * Compute the transpose of a given matrix
  75134. * @param matrix defines the matrix to transpose
  75135. * @returns the new matrix
  75136. */
  75137. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  75138. /**
  75139. * Compute the transpose of a matrix and store it in a target matrix
  75140. * @param matrix defines the matrix to transpose
  75141. * @param result defines the target matrix
  75142. */
  75143. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  75144. /**
  75145. * Computes a reflection matrix from a plane
  75146. * @param plane defines the reflection plane
  75147. * @returns a new matrix
  75148. */
  75149. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  75150. /**
  75151. * Computes a reflection matrix from a plane
  75152. * @param plane defines the reflection plane
  75153. * @param result defines the target matrix
  75154. */
  75155. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  75156. /**
  75157. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75158. * @param xaxis defines the value of the 1st axis
  75159. * @param yaxis defines the value of the 2nd axis
  75160. * @param zaxis defines the value of the 3rd axis
  75161. * @param result defines the target matrix
  75162. */
  75163. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  75164. /**
  75165. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75166. * @param quat defines the quaternion to use
  75167. * @param result defines the target matrix
  75168. */
  75169. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  75170. }
  75171. /**
  75172. * @hidden
  75173. */
  75174. export class TmpVectors {
  75175. static Vector2: Vector2[];
  75176. static Vector3: Vector3[];
  75177. static Vector4: Vector4[];
  75178. static Quaternion: Quaternion[];
  75179. static Matrix: Matrix[];
  75180. }
  75181. }
  75182. declare module BABYLON {
  75183. /**
  75184. * Defines potential orientation for back face culling
  75185. */
  75186. export enum Orientation {
  75187. /**
  75188. * Clockwise
  75189. */
  75190. CW = 0,
  75191. /** Counter clockwise */
  75192. CCW = 1
  75193. }
  75194. /** Class used to represent a Bezier curve */
  75195. export class BezierCurve {
  75196. /**
  75197. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  75198. * @param t defines the time
  75199. * @param x1 defines the left coordinate on X axis
  75200. * @param y1 defines the left coordinate on Y axis
  75201. * @param x2 defines the right coordinate on X axis
  75202. * @param y2 defines the right coordinate on Y axis
  75203. * @returns the interpolated value
  75204. */
  75205. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  75206. }
  75207. /**
  75208. * Defines angle representation
  75209. */
  75210. export class Angle {
  75211. private _radians;
  75212. /**
  75213. * Creates an Angle object of "radians" radians (float).
  75214. * @param radians the angle in radians
  75215. */
  75216. constructor(radians: number);
  75217. /**
  75218. * Get value in degrees
  75219. * @returns the Angle value in degrees (float)
  75220. */
  75221. degrees(): number;
  75222. /**
  75223. * Get value in radians
  75224. * @returns the Angle value in radians (float)
  75225. */
  75226. radians(): number;
  75227. /**
  75228. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  75229. * @param a defines first vector
  75230. * @param b defines second vector
  75231. * @returns a new Angle
  75232. */
  75233. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  75234. /**
  75235. * Gets a new Angle object from the given float in radians
  75236. * @param radians defines the angle value in radians
  75237. * @returns a new Angle
  75238. */
  75239. static FromRadians(radians: number): Angle;
  75240. /**
  75241. * Gets a new Angle object from the given float in degrees
  75242. * @param degrees defines the angle value in degrees
  75243. * @returns a new Angle
  75244. */
  75245. static FromDegrees(degrees: number): Angle;
  75246. }
  75247. /**
  75248. * This represents an arc in a 2d space.
  75249. */
  75250. export class Arc2 {
  75251. /** Defines the start point of the arc */
  75252. startPoint: Vector2;
  75253. /** Defines the mid point of the arc */
  75254. midPoint: Vector2;
  75255. /** Defines the end point of the arc */
  75256. endPoint: Vector2;
  75257. /**
  75258. * Defines the center point of the arc.
  75259. */
  75260. centerPoint: Vector2;
  75261. /**
  75262. * Defines the radius of the arc.
  75263. */
  75264. radius: number;
  75265. /**
  75266. * Defines the angle of the arc (from mid point to end point).
  75267. */
  75268. angle: Angle;
  75269. /**
  75270. * Defines the start angle of the arc (from start point to middle point).
  75271. */
  75272. startAngle: Angle;
  75273. /**
  75274. * Defines the orientation of the arc (clock wise/counter clock wise).
  75275. */
  75276. orientation: Orientation;
  75277. /**
  75278. * Creates an Arc object from the three given points : start, middle and end.
  75279. * @param startPoint Defines the start point of the arc
  75280. * @param midPoint Defines the midlle point of the arc
  75281. * @param endPoint Defines the end point of the arc
  75282. */
  75283. constructor(
  75284. /** Defines the start point of the arc */
  75285. startPoint: Vector2,
  75286. /** Defines the mid point of the arc */
  75287. midPoint: Vector2,
  75288. /** Defines the end point of the arc */
  75289. endPoint: Vector2);
  75290. }
  75291. /**
  75292. * Represents a 2D path made up of multiple 2D points
  75293. */
  75294. export class Path2 {
  75295. private _points;
  75296. private _length;
  75297. /**
  75298. * If the path start and end point are the same
  75299. */
  75300. closed: boolean;
  75301. /**
  75302. * Creates a Path2 object from the starting 2D coordinates x and y.
  75303. * @param x the starting points x value
  75304. * @param y the starting points y value
  75305. */
  75306. constructor(x: number, y: number);
  75307. /**
  75308. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  75309. * @param x the added points x value
  75310. * @param y the added points y value
  75311. * @returns the updated Path2.
  75312. */
  75313. addLineTo(x: number, y: number): Path2;
  75314. /**
  75315. * 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.
  75316. * @param midX middle point x value
  75317. * @param midY middle point y value
  75318. * @param endX end point x value
  75319. * @param endY end point y value
  75320. * @param numberOfSegments (default: 36)
  75321. * @returns the updated Path2.
  75322. */
  75323. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  75324. /**
  75325. * Closes the Path2.
  75326. * @returns the Path2.
  75327. */
  75328. close(): Path2;
  75329. /**
  75330. * Gets the sum of the distance between each sequential point in the path
  75331. * @returns the Path2 total length (float).
  75332. */
  75333. length(): number;
  75334. /**
  75335. * Gets the points which construct the path
  75336. * @returns the Path2 internal array of points.
  75337. */
  75338. getPoints(): Vector2[];
  75339. /**
  75340. * Retreives the point at the distance aways from the starting point
  75341. * @param normalizedLengthPosition the length along the path to retreive the point from
  75342. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  75343. */
  75344. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  75345. /**
  75346. * Creates a new path starting from an x and y position
  75347. * @param x starting x value
  75348. * @param y starting y value
  75349. * @returns a new Path2 starting at the coordinates (x, y).
  75350. */
  75351. static StartingAt(x: number, y: number): Path2;
  75352. }
  75353. /**
  75354. * Represents a 3D path made up of multiple 3D points
  75355. */
  75356. export class Path3D {
  75357. /**
  75358. * an array of Vector3, the curve axis of the Path3D
  75359. */
  75360. path: Vector3[];
  75361. private _curve;
  75362. private _distances;
  75363. private _tangents;
  75364. private _normals;
  75365. private _binormals;
  75366. private _raw;
  75367. private _alignTangentsWithPath;
  75368. private readonly _pointAtData;
  75369. /**
  75370. * new Path3D(path, normal, raw)
  75371. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  75372. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  75373. * @param path an array of Vector3, the curve axis of the Path3D
  75374. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  75375. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  75376. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  75377. */
  75378. constructor(
  75379. /**
  75380. * an array of Vector3, the curve axis of the Path3D
  75381. */
  75382. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  75383. /**
  75384. * Returns the Path3D array of successive Vector3 designing its curve.
  75385. * @returns the Path3D array of successive Vector3 designing its curve.
  75386. */
  75387. getCurve(): Vector3[];
  75388. /**
  75389. * Returns the Path3D array of successive Vector3 designing its curve.
  75390. * @returns the Path3D array of successive Vector3 designing its curve.
  75391. */
  75392. getPoints(): Vector3[];
  75393. /**
  75394. * @returns the computed length (float) of the path.
  75395. */
  75396. length(): number;
  75397. /**
  75398. * Returns an array populated with tangent vectors on each Path3D curve point.
  75399. * @returns an array populated with tangent vectors on each Path3D curve point.
  75400. */
  75401. getTangents(): Vector3[];
  75402. /**
  75403. * Returns an array populated with normal vectors on each Path3D curve point.
  75404. * @returns an array populated with normal vectors on each Path3D curve point.
  75405. */
  75406. getNormals(): Vector3[];
  75407. /**
  75408. * Returns an array populated with binormal vectors on each Path3D curve point.
  75409. * @returns an array populated with binormal vectors on each Path3D curve point.
  75410. */
  75411. getBinormals(): Vector3[];
  75412. /**
  75413. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  75414. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  75415. */
  75416. getDistances(): number[];
  75417. /**
  75418. * Returns an interpolated point along this path
  75419. * @param position the position of the point along this path, from 0.0 to 1.0
  75420. * @returns a new Vector3 as the point
  75421. */
  75422. getPointAt(position: number): Vector3;
  75423. /**
  75424. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75425. * @param position the position of the point along this path, from 0.0 to 1.0
  75426. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  75427. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  75428. */
  75429. getTangentAt(position: number, interpolated?: boolean): Vector3;
  75430. /**
  75431. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75432. * @param position the position of the point along this path, from 0.0 to 1.0
  75433. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  75434. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  75435. */
  75436. getNormalAt(position: number, interpolated?: boolean): Vector3;
  75437. /**
  75438. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  75439. * @param position the position of the point along this path, from 0.0 to 1.0
  75440. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  75441. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  75442. */
  75443. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  75444. /**
  75445. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  75446. * @param position the position of the point along this path, from 0.0 to 1.0
  75447. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  75448. */
  75449. getDistanceAt(position: number): number;
  75450. /**
  75451. * Returns the array index of the previous point of an interpolated point along this path
  75452. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75453. * @returns the array index
  75454. */
  75455. getPreviousPointIndexAt(position: number): number;
  75456. /**
  75457. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  75458. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75459. * @returns the sub position
  75460. */
  75461. getSubPositionAt(position: number): number;
  75462. /**
  75463. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  75464. * @param target the vector of which to get the closest position to
  75465. * @returns the position of the closest virtual point on this path to the target vector
  75466. */
  75467. getClosestPositionTo(target: Vector3): number;
  75468. /**
  75469. * Returns a sub path (slice) of this path
  75470. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  75471. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  75472. * @returns a sub path (slice) of this path
  75473. */
  75474. slice(start?: number, end?: number): Path3D;
  75475. /**
  75476. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  75477. * @param path path which all values are copied into the curves points
  75478. * @param firstNormal which should be projected onto the curve
  75479. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  75480. * @returns the same object updated.
  75481. */
  75482. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  75483. private _compute;
  75484. private _getFirstNonNullVector;
  75485. private _getLastNonNullVector;
  75486. private _normalVector;
  75487. /**
  75488. * Updates the point at data for an interpolated point along this curve
  75489. * @param position the position of the point along this curve, from 0.0 to 1.0
  75490. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  75491. * @returns the (updated) point at data
  75492. */
  75493. private _updatePointAtData;
  75494. /**
  75495. * Updates the point at data from the specified parameters
  75496. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  75497. * @param point the interpolated point
  75498. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  75499. */
  75500. private _setPointAtData;
  75501. /**
  75502. * Updates the point at interpolation matrix for the tangents, normals and binormals
  75503. */
  75504. private _updateInterpolationMatrix;
  75505. }
  75506. /**
  75507. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75508. * A Curve3 is designed from a series of successive Vector3.
  75509. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  75510. */
  75511. export class Curve3 {
  75512. private _points;
  75513. private _length;
  75514. /**
  75515. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  75516. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  75517. * @param v1 (Vector3) the control point
  75518. * @param v2 (Vector3) the end point of the Quadratic Bezier
  75519. * @param nbPoints (integer) the wanted number of points in the curve
  75520. * @returns the created Curve3
  75521. */
  75522. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75523. /**
  75524. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  75525. * @param v0 (Vector3) the origin point of the Cubic Bezier
  75526. * @param v1 (Vector3) the first control point
  75527. * @param v2 (Vector3) the second control point
  75528. * @param v3 (Vector3) the end point of the Cubic Bezier
  75529. * @param nbPoints (integer) the wanted number of points in the curve
  75530. * @returns the created Curve3
  75531. */
  75532. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75533. /**
  75534. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  75535. * @param p1 (Vector3) the origin point of the Hermite Spline
  75536. * @param t1 (Vector3) the tangent vector at the origin point
  75537. * @param p2 (Vector3) the end point of the Hermite Spline
  75538. * @param t2 (Vector3) the tangent vector at the end point
  75539. * @param nbPoints (integer) the wanted number of points in the curve
  75540. * @returns the created Curve3
  75541. */
  75542. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75543. /**
  75544. * Returns a Curve3 object along a CatmullRom Spline curve :
  75545. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  75546. * @param nbPoints (integer) the wanted number of points between each curve control points
  75547. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  75548. * @returns the created Curve3
  75549. */
  75550. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  75551. /**
  75552. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75553. * A Curve3 is designed from a series of successive Vector3.
  75554. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  75555. * @param points points which make up the curve
  75556. */
  75557. constructor(points: Vector3[]);
  75558. /**
  75559. * @returns the Curve3 stored array of successive Vector3
  75560. */
  75561. getPoints(): Vector3[];
  75562. /**
  75563. * @returns the computed length (float) of the curve.
  75564. */
  75565. length(): number;
  75566. /**
  75567. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  75568. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  75569. * curveA and curveB keep unchanged.
  75570. * @param curve the curve to continue from this curve
  75571. * @returns the newly constructed curve
  75572. */
  75573. continue(curve: DeepImmutable<Curve3>): Curve3;
  75574. private _computeLength;
  75575. }
  75576. }
  75577. declare module BABYLON {
  75578. /**
  75579. * This represents the main contract an easing function should follow.
  75580. * Easing functions are used throughout the animation system.
  75581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75582. */
  75583. export interface IEasingFunction {
  75584. /**
  75585. * Given an input gradient between 0 and 1, this returns the corrseponding value
  75586. * of the easing function.
  75587. * The link below provides some of the most common examples of easing functions.
  75588. * @see https://easings.net/
  75589. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75590. * @returns the corresponding value on the curve defined by the easing function
  75591. */
  75592. ease(gradient: number): number;
  75593. }
  75594. /**
  75595. * Base class used for every default easing function.
  75596. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75597. */
  75598. export class EasingFunction implements IEasingFunction {
  75599. /**
  75600. * Interpolation follows the mathematical formula associated with the easing function.
  75601. */
  75602. static readonly EASINGMODE_EASEIN: number;
  75603. /**
  75604. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  75605. */
  75606. static readonly EASINGMODE_EASEOUT: number;
  75607. /**
  75608. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  75609. */
  75610. static readonly EASINGMODE_EASEINOUT: number;
  75611. private _easingMode;
  75612. /**
  75613. * Sets the easing mode of the current function.
  75614. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  75615. */
  75616. setEasingMode(easingMode: number): void;
  75617. /**
  75618. * Gets the current easing mode.
  75619. * @returns the easing mode
  75620. */
  75621. getEasingMode(): number;
  75622. /**
  75623. * @hidden
  75624. */
  75625. easeInCore(gradient: number): number;
  75626. /**
  75627. * Given an input gradient between 0 and 1, this returns the corresponding value
  75628. * of the easing function.
  75629. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75630. * @returns the corresponding value on the curve defined by the easing function
  75631. */
  75632. ease(gradient: number): number;
  75633. }
  75634. /**
  75635. * Easing function with a circle shape (see link below).
  75636. * @see https://easings.net/#easeInCirc
  75637. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75638. */
  75639. export class CircleEase extends EasingFunction implements IEasingFunction {
  75640. /** @hidden */
  75641. easeInCore(gradient: number): number;
  75642. }
  75643. /**
  75644. * Easing function with a ease back shape (see link below).
  75645. * @see https://easings.net/#easeInBack
  75646. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75647. */
  75648. export class BackEase extends EasingFunction implements IEasingFunction {
  75649. /** Defines the amplitude of the function */
  75650. amplitude: number;
  75651. /**
  75652. * Instantiates a back ease easing
  75653. * @see https://easings.net/#easeInBack
  75654. * @param amplitude Defines the amplitude of the function
  75655. */
  75656. constructor(
  75657. /** Defines the amplitude of the function */
  75658. amplitude?: number);
  75659. /** @hidden */
  75660. easeInCore(gradient: number): number;
  75661. }
  75662. /**
  75663. * Easing function with a bouncing shape (see link below).
  75664. * @see https://easings.net/#easeInBounce
  75665. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75666. */
  75667. export class BounceEase extends EasingFunction implements IEasingFunction {
  75668. /** Defines the number of bounces */
  75669. bounces: number;
  75670. /** Defines the amplitude of the bounce */
  75671. bounciness: number;
  75672. /**
  75673. * Instantiates a bounce easing
  75674. * @see https://easings.net/#easeInBounce
  75675. * @param bounces Defines the number of bounces
  75676. * @param bounciness Defines the amplitude of the bounce
  75677. */
  75678. constructor(
  75679. /** Defines the number of bounces */
  75680. bounces?: number,
  75681. /** Defines the amplitude of the bounce */
  75682. bounciness?: number);
  75683. /** @hidden */
  75684. easeInCore(gradient: number): number;
  75685. }
  75686. /**
  75687. * Easing function with a power of 3 shape (see link below).
  75688. * @see https://easings.net/#easeInCubic
  75689. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75690. */
  75691. export class CubicEase extends EasingFunction implements IEasingFunction {
  75692. /** @hidden */
  75693. easeInCore(gradient: number): number;
  75694. }
  75695. /**
  75696. * Easing function with an elastic shape (see link below).
  75697. * @see https://easings.net/#easeInElastic
  75698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75699. */
  75700. export class ElasticEase extends EasingFunction implements IEasingFunction {
  75701. /** Defines the number of oscillations*/
  75702. oscillations: number;
  75703. /** Defines the amplitude of the oscillations*/
  75704. springiness: number;
  75705. /**
  75706. * Instantiates an elastic easing function
  75707. * @see https://easings.net/#easeInElastic
  75708. * @param oscillations Defines the number of oscillations
  75709. * @param springiness Defines the amplitude of the oscillations
  75710. */
  75711. constructor(
  75712. /** Defines the number of oscillations*/
  75713. oscillations?: number,
  75714. /** Defines the amplitude of the oscillations*/
  75715. springiness?: number);
  75716. /** @hidden */
  75717. easeInCore(gradient: number): number;
  75718. }
  75719. /**
  75720. * Easing function with an exponential shape (see link below).
  75721. * @see https://easings.net/#easeInExpo
  75722. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75723. */
  75724. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  75725. /** Defines the exponent of the function */
  75726. exponent: number;
  75727. /**
  75728. * Instantiates an exponential easing function
  75729. * @see https://easings.net/#easeInExpo
  75730. * @param exponent Defines the exponent of the function
  75731. */
  75732. constructor(
  75733. /** Defines the exponent of the function */
  75734. exponent?: number);
  75735. /** @hidden */
  75736. easeInCore(gradient: number): number;
  75737. }
  75738. /**
  75739. * Easing function with a power shape (see link below).
  75740. * @see https://easings.net/#easeInQuad
  75741. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75742. */
  75743. export class PowerEase extends EasingFunction implements IEasingFunction {
  75744. /** Defines the power of the function */
  75745. power: number;
  75746. /**
  75747. * Instantiates an power base easing function
  75748. * @see https://easings.net/#easeInQuad
  75749. * @param power Defines the power of the function
  75750. */
  75751. constructor(
  75752. /** Defines the power of the function */
  75753. power?: number);
  75754. /** @hidden */
  75755. easeInCore(gradient: number): number;
  75756. }
  75757. /**
  75758. * Easing function with a power of 2 shape (see link below).
  75759. * @see https://easings.net/#easeInQuad
  75760. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75761. */
  75762. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  75763. /** @hidden */
  75764. easeInCore(gradient: number): number;
  75765. }
  75766. /**
  75767. * Easing function with a power of 4 shape (see link below).
  75768. * @see https://easings.net/#easeInQuart
  75769. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75770. */
  75771. export class QuarticEase extends EasingFunction implements IEasingFunction {
  75772. /** @hidden */
  75773. easeInCore(gradient: number): number;
  75774. }
  75775. /**
  75776. * Easing function with a power of 5 shape (see link below).
  75777. * @see https://easings.net/#easeInQuint
  75778. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75779. */
  75780. export class QuinticEase extends EasingFunction implements IEasingFunction {
  75781. /** @hidden */
  75782. easeInCore(gradient: number): number;
  75783. }
  75784. /**
  75785. * Easing function with a sin shape (see link below).
  75786. * @see https://easings.net/#easeInSine
  75787. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75788. */
  75789. export class SineEase extends EasingFunction implements IEasingFunction {
  75790. /** @hidden */
  75791. easeInCore(gradient: number): number;
  75792. }
  75793. /**
  75794. * Easing function with a bezier shape (see link below).
  75795. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75797. */
  75798. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  75799. /** Defines the x component of the start tangent in the bezier curve */
  75800. x1: number;
  75801. /** Defines the y component of the start tangent in the bezier curve */
  75802. y1: number;
  75803. /** Defines the x component of the end tangent in the bezier curve */
  75804. x2: number;
  75805. /** Defines the y component of the end tangent in the bezier curve */
  75806. y2: number;
  75807. /**
  75808. * Instantiates a bezier function
  75809. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75810. * @param x1 Defines the x component of the start tangent in the bezier curve
  75811. * @param y1 Defines the y component of the start tangent in the bezier curve
  75812. * @param x2 Defines the x component of the end tangent in the bezier curve
  75813. * @param y2 Defines the y component of the end tangent in the bezier curve
  75814. */
  75815. constructor(
  75816. /** Defines the x component of the start tangent in the bezier curve */
  75817. x1?: number,
  75818. /** Defines the y component of the start tangent in the bezier curve */
  75819. y1?: number,
  75820. /** Defines the x component of the end tangent in the bezier curve */
  75821. x2?: number,
  75822. /** Defines the y component of the end tangent in the bezier curve */
  75823. y2?: number);
  75824. /** @hidden */
  75825. easeInCore(gradient: number): number;
  75826. }
  75827. }
  75828. declare module BABYLON {
  75829. /**
  75830. * Class used to hold a RBG color
  75831. */
  75832. export class Color3 {
  75833. /**
  75834. * Defines the red component (between 0 and 1, default is 0)
  75835. */
  75836. r: number;
  75837. /**
  75838. * Defines the green component (between 0 and 1, default is 0)
  75839. */
  75840. g: number;
  75841. /**
  75842. * Defines the blue component (between 0 and 1, default is 0)
  75843. */
  75844. b: number;
  75845. /**
  75846. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  75847. * @param r defines the red component (between 0 and 1, default is 0)
  75848. * @param g defines the green component (between 0 and 1, default is 0)
  75849. * @param b defines the blue component (between 0 and 1, default is 0)
  75850. */
  75851. constructor(
  75852. /**
  75853. * Defines the red component (between 0 and 1, default is 0)
  75854. */
  75855. r?: number,
  75856. /**
  75857. * Defines the green component (between 0 and 1, default is 0)
  75858. */
  75859. g?: number,
  75860. /**
  75861. * Defines the blue component (between 0 and 1, default is 0)
  75862. */
  75863. b?: number);
  75864. /**
  75865. * Creates a string with the Color3 current values
  75866. * @returns the string representation of the Color3 object
  75867. */
  75868. toString(): string;
  75869. /**
  75870. * Returns the string "Color3"
  75871. * @returns "Color3"
  75872. */
  75873. getClassName(): string;
  75874. /**
  75875. * Compute the Color3 hash code
  75876. * @returns an unique number that can be used to hash Color3 objects
  75877. */
  75878. getHashCode(): number;
  75879. /**
  75880. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  75881. * @param array defines the array where to store the r,g,b components
  75882. * @param index defines an optional index in the target array to define where to start storing values
  75883. * @returns the current Color3 object
  75884. */
  75885. toArray(array: FloatArray, index?: number): Color3;
  75886. /**
  75887. * Returns a new Color4 object from the current Color3 and the given alpha
  75888. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  75889. * @returns a new Color4 object
  75890. */
  75891. toColor4(alpha?: number): Color4;
  75892. /**
  75893. * Returns a new array populated with 3 numeric elements : red, green and blue values
  75894. * @returns the new array
  75895. */
  75896. asArray(): number[];
  75897. /**
  75898. * Returns the luminance value
  75899. * @returns a float value
  75900. */
  75901. toLuminance(): number;
  75902. /**
  75903. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  75904. * @param otherColor defines the second operand
  75905. * @returns the new Color3 object
  75906. */
  75907. multiply(otherColor: DeepImmutable<Color3>): Color3;
  75908. /**
  75909. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  75910. * @param otherColor defines the second operand
  75911. * @param result defines the Color3 object where to store the result
  75912. * @returns the current Color3
  75913. */
  75914. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75915. /**
  75916. * Determines equality between Color3 objects
  75917. * @param otherColor defines the second operand
  75918. * @returns true if the rgb values are equal to the given ones
  75919. */
  75920. equals(otherColor: DeepImmutable<Color3>): boolean;
  75921. /**
  75922. * Determines equality between the current Color3 object and a set of r,b,g values
  75923. * @param r defines the red component to check
  75924. * @param g defines the green component to check
  75925. * @param b defines the blue component to check
  75926. * @returns true if the rgb values are equal to the given ones
  75927. */
  75928. equalsFloats(r: number, g: number, b: number): boolean;
  75929. /**
  75930. * Multiplies in place each rgb value by scale
  75931. * @param scale defines the scaling factor
  75932. * @returns the updated Color3
  75933. */
  75934. scale(scale: number): Color3;
  75935. /**
  75936. * Multiplies the rgb values by scale and stores the result into "result"
  75937. * @param scale defines the scaling factor
  75938. * @param result defines the Color3 object where to store the result
  75939. * @returns the unmodified current Color3
  75940. */
  75941. scaleToRef(scale: number, result: Color3): Color3;
  75942. /**
  75943. * Scale the current Color3 values by a factor and add the result to a given Color3
  75944. * @param scale defines the scale factor
  75945. * @param result defines color to store the result into
  75946. * @returns the unmodified current Color3
  75947. */
  75948. scaleAndAddToRef(scale: number, result: Color3): Color3;
  75949. /**
  75950. * Clamps the rgb values by the min and max values and stores the result into "result"
  75951. * @param min defines minimum clamping value (default is 0)
  75952. * @param max defines maximum clamping value (default is 1)
  75953. * @param result defines color to store the result into
  75954. * @returns the original Color3
  75955. */
  75956. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  75957. /**
  75958. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  75959. * @param otherColor defines the second operand
  75960. * @returns the new Color3
  75961. */
  75962. add(otherColor: DeepImmutable<Color3>): Color3;
  75963. /**
  75964. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  75965. * @param otherColor defines the second operand
  75966. * @param result defines Color3 object to store the result into
  75967. * @returns the unmodified current Color3
  75968. */
  75969. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75970. /**
  75971. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  75972. * @param otherColor defines the second operand
  75973. * @returns the new Color3
  75974. */
  75975. subtract(otherColor: DeepImmutable<Color3>): Color3;
  75976. /**
  75977. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  75978. * @param otherColor defines the second operand
  75979. * @param result defines Color3 object to store the result into
  75980. * @returns the unmodified current Color3
  75981. */
  75982. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75983. /**
  75984. * Copy the current object
  75985. * @returns a new Color3 copied the current one
  75986. */
  75987. clone(): Color3;
  75988. /**
  75989. * Copies the rgb values from the source in the current Color3
  75990. * @param source defines the source Color3 object
  75991. * @returns the updated Color3 object
  75992. */
  75993. copyFrom(source: DeepImmutable<Color3>): Color3;
  75994. /**
  75995. * Updates the Color3 rgb values from the given floats
  75996. * @param r defines the red component to read from
  75997. * @param g defines the green component to read from
  75998. * @param b defines the blue component to read from
  75999. * @returns the current Color3 object
  76000. */
  76001. copyFromFloats(r: number, g: number, b: number): Color3;
  76002. /**
  76003. * Updates the Color3 rgb values from the given floats
  76004. * @param r defines the red component to read from
  76005. * @param g defines the green component to read from
  76006. * @param b defines the blue component to read from
  76007. * @returns the current Color3 object
  76008. */
  76009. set(r: number, g: number, b: number): Color3;
  76010. /**
  76011. * Compute the Color3 hexadecimal code as a string
  76012. * @returns a string containing the hexadecimal representation of the Color3 object
  76013. */
  76014. toHexString(): string;
  76015. /**
  76016. * Computes a new Color3 converted from the current one to linear space
  76017. * @returns a new Color3 object
  76018. */
  76019. toLinearSpace(): Color3;
  76020. /**
  76021. * Converts current color in rgb space to HSV values
  76022. * @returns a new color3 representing the HSV values
  76023. */
  76024. toHSV(): Color3;
  76025. /**
  76026. * Converts current color in rgb space to HSV values
  76027. * @param result defines the Color3 where to store the HSV values
  76028. */
  76029. toHSVToRef(result: Color3): void;
  76030. /**
  76031. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  76032. * @param convertedColor defines the Color3 object where to store the linear space version
  76033. * @returns the unmodified Color3
  76034. */
  76035. toLinearSpaceToRef(convertedColor: Color3): Color3;
  76036. /**
  76037. * Computes a new Color3 converted from the current one to gamma space
  76038. * @returns a new Color3 object
  76039. */
  76040. toGammaSpace(): Color3;
  76041. /**
  76042. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  76043. * @param convertedColor defines the Color3 object where to store the gamma space version
  76044. * @returns the unmodified Color3
  76045. */
  76046. toGammaSpaceToRef(convertedColor: Color3): Color3;
  76047. private static _BlackReadOnly;
  76048. /**
  76049. * Convert Hue, saturation and value to a Color3 (RGB)
  76050. * @param hue defines the hue
  76051. * @param saturation defines the saturation
  76052. * @param value defines the value
  76053. * @param result defines the Color3 where to store the RGB values
  76054. */
  76055. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  76056. /**
  76057. * Creates a new Color3 from the string containing valid hexadecimal values
  76058. * @param hex defines a string containing valid hexadecimal values
  76059. * @returns a new Color3 object
  76060. */
  76061. static FromHexString(hex: string): Color3;
  76062. /**
  76063. * Creates a new Color3 from the starting index of the given array
  76064. * @param array defines the source array
  76065. * @param offset defines an offset in the source array
  76066. * @returns a new Color3 object
  76067. */
  76068. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  76069. /**
  76070. * Creates a new Color3 from integer values (< 256)
  76071. * @param r defines the red component to read from (value between 0 and 255)
  76072. * @param g defines the green component to read from (value between 0 and 255)
  76073. * @param b defines the blue component to read from (value between 0 and 255)
  76074. * @returns a new Color3 object
  76075. */
  76076. static FromInts(r: number, g: number, b: number): Color3;
  76077. /**
  76078. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76079. * @param start defines the start Color3 value
  76080. * @param end defines the end Color3 value
  76081. * @param amount defines the gradient value between start and end
  76082. * @returns a new Color3 object
  76083. */
  76084. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  76085. /**
  76086. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76087. * @param left defines the start value
  76088. * @param right defines the end value
  76089. * @param amount defines the gradient factor
  76090. * @param result defines the Color3 object where to store the result
  76091. */
  76092. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  76093. /**
  76094. * Returns a Color3 value containing a red color
  76095. * @returns a new Color3 object
  76096. */
  76097. static Red(): Color3;
  76098. /**
  76099. * Returns a Color3 value containing a green color
  76100. * @returns a new Color3 object
  76101. */
  76102. static Green(): Color3;
  76103. /**
  76104. * Returns a Color3 value containing a blue color
  76105. * @returns a new Color3 object
  76106. */
  76107. static Blue(): Color3;
  76108. /**
  76109. * Returns a Color3 value containing a black color
  76110. * @returns a new Color3 object
  76111. */
  76112. static Black(): Color3;
  76113. /**
  76114. * Gets a Color3 value containing a black color that must not be updated
  76115. */
  76116. static get BlackReadOnly(): DeepImmutable<Color3>;
  76117. /**
  76118. * Returns a Color3 value containing a white color
  76119. * @returns a new Color3 object
  76120. */
  76121. static White(): Color3;
  76122. /**
  76123. * Returns a Color3 value containing a purple color
  76124. * @returns a new Color3 object
  76125. */
  76126. static Purple(): Color3;
  76127. /**
  76128. * Returns a Color3 value containing a magenta color
  76129. * @returns a new Color3 object
  76130. */
  76131. static Magenta(): Color3;
  76132. /**
  76133. * Returns a Color3 value containing a yellow color
  76134. * @returns a new Color3 object
  76135. */
  76136. static Yellow(): Color3;
  76137. /**
  76138. * Returns a Color3 value containing a gray color
  76139. * @returns a new Color3 object
  76140. */
  76141. static Gray(): Color3;
  76142. /**
  76143. * Returns a Color3 value containing a teal color
  76144. * @returns a new Color3 object
  76145. */
  76146. static Teal(): Color3;
  76147. /**
  76148. * Returns a Color3 value containing a random color
  76149. * @returns a new Color3 object
  76150. */
  76151. static Random(): Color3;
  76152. }
  76153. /**
  76154. * Class used to hold a RBGA color
  76155. */
  76156. export class Color4 {
  76157. /**
  76158. * Defines the red component (between 0 and 1, default is 0)
  76159. */
  76160. r: number;
  76161. /**
  76162. * Defines the green component (between 0 and 1, default is 0)
  76163. */
  76164. g: number;
  76165. /**
  76166. * Defines the blue component (between 0 and 1, default is 0)
  76167. */
  76168. b: number;
  76169. /**
  76170. * Defines the alpha component (between 0 and 1, default is 1)
  76171. */
  76172. a: number;
  76173. /**
  76174. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  76175. * @param r defines the red component (between 0 and 1, default is 0)
  76176. * @param g defines the green component (between 0 and 1, default is 0)
  76177. * @param b defines the blue component (between 0 and 1, default is 0)
  76178. * @param a defines the alpha component (between 0 and 1, default is 1)
  76179. */
  76180. constructor(
  76181. /**
  76182. * Defines the red component (between 0 and 1, default is 0)
  76183. */
  76184. r?: number,
  76185. /**
  76186. * Defines the green component (between 0 and 1, default is 0)
  76187. */
  76188. g?: number,
  76189. /**
  76190. * Defines the blue component (between 0 and 1, default is 0)
  76191. */
  76192. b?: number,
  76193. /**
  76194. * Defines the alpha component (between 0 and 1, default is 1)
  76195. */
  76196. a?: number);
  76197. /**
  76198. * Adds in place the given Color4 values to the current Color4 object
  76199. * @param right defines the second operand
  76200. * @returns the current updated Color4 object
  76201. */
  76202. addInPlace(right: DeepImmutable<Color4>): Color4;
  76203. /**
  76204. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  76205. * @returns the new array
  76206. */
  76207. asArray(): number[];
  76208. /**
  76209. * Stores from the starting index in the given array the Color4 successive values
  76210. * @param array defines the array where to store the r,g,b components
  76211. * @param index defines an optional index in the target array to define where to start storing values
  76212. * @returns the current Color4 object
  76213. */
  76214. toArray(array: number[], index?: number): Color4;
  76215. /**
  76216. * Determines equality between Color4 objects
  76217. * @param otherColor defines the second operand
  76218. * @returns true if the rgba values are equal to the given ones
  76219. */
  76220. equals(otherColor: DeepImmutable<Color4>): boolean;
  76221. /**
  76222. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  76223. * @param right defines the second operand
  76224. * @returns a new Color4 object
  76225. */
  76226. add(right: DeepImmutable<Color4>): Color4;
  76227. /**
  76228. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  76229. * @param right defines the second operand
  76230. * @returns a new Color4 object
  76231. */
  76232. subtract(right: DeepImmutable<Color4>): Color4;
  76233. /**
  76234. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  76235. * @param right defines the second operand
  76236. * @param result defines the Color4 object where to store the result
  76237. * @returns the current Color4 object
  76238. */
  76239. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  76240. /**
  76241. * Creates a new Color4 with the current Color4 values multiplied by scale
  76242. * @param scale defines the scaling factor to apply
  76243. * @returns a new Color4 object
  76244. */
  76245. scale(scale: number): Color4;
  76246. /**
  76247. * Multiplies the current Color4 values by scale and stores the result in "result"
  76248. * @param scale defines the scaling factor to apply
  76249. * @param result defines the Color4 object where to store the result
  76250. * @returns the current unmodified Color4
  76251. */
  76252. scaleToRef(scale: number, result: Color4): Color4;
  76253. /**
  76254. * Scale the current Color4 values by a factor and add the result to a given Color4
  76255. * @param scale defines the scale factor
  76256. * @param result defines the Color4 object where to store the result
  76257. * @returns the unmodified current Color4
  76258. */
  76259. scaleAndAddToRef(scale: number, result: Color4): Color4;
  76260. /**
  76261. * Clamps the rgb values by the min and max values and stores the result into "result"
  76262. * @param min defines minimum clamping value (default is 0)
  76263. * @param max defines maximum clamping value (default is 1)
  76264. * @param result defines color to store the result into.
  76265. * @returns the cuurent Color4
  76266. */
  76267. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  76268. /**
  76269. * Multipy an Color4 value by another and return a new Color4 object
  76270. * @param color defines the Color4 value to multiply by
  76271. * @returns a new Color4 object
  76272. */
  76273. multiply(color: Color4): Color4;
  76274. /**
  76275. * Multipy a Color4 value by another and push the result in a reference value
  76276. * @param color defines the Color4 value to multiply by
  76277. * @param result defines the Color4 to fill the result in
  76278. * @returns the result Color4
  76279. */
  76280. multiplyToRef(color: Color4, result: Color4): Color4;
  76281. /**
  76282. * Creates a string with the Color4 current values
  76283. * @returns the string representation of the Color4 object
  76284. */
  76285. toString(): string;
  76286. /**
  76287. * Returns the string "Color4"
  76288. * @returns "Color4"
  76289. */
  76290. getClassName(): string;
  76291. /**
  76292. * Compute the Color4 hash code
  76293. * @returns an unique number that can be used to hash Color4 objects
  76294. */
  76295. getHashCode(): number;
  76296. /**
  76297. * Creates a new Color4 copied from the current one
  76298. * @returns a new Color4 object
  76299. */
  76300. clone(): Color4;
  76301. /**
  76302. * Copies the given Color4 values into the current one
  76303. * @param source defines the source Color4 object
  76304. * @returns the current updated Color4 object
  76305. */
  76306. copyFrom(source: Color4): Color4;
  76307. /**
  76308. * Copies the given float values into the current one
  76309. * @param r defines the red component to read from
  76310. * @param g defines the green component to read from
  76311. * @param b defines the blue component to read from
  76312. * @param a defines the alpha component to read from
  76313. * @returns the current updated Color4 object
  76314. */
  76315. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  76316. /**
  76317. * Copies the given float values into the current one
  76318. * @param r defines the red component to read from
  76319. * @param g defines the green component to read from
  76320. * @param b defines the blue component to read from
  76321. * @param a defines the alpha component to read from
  76322. * @returns the current updated Color4 object
  76323. */
  76324. set(r: number, g: number, b: number, a: number): Color4;
  76325. /**
  76326. * Compute the Color4 hexadecimal code as a string
  76327. * @returns a string containing the hexadecimal representation of the Color4 object
  76328. */
  76329. toHexString(): string;
  76330. /**
  76331. * Computes a new Color4 converted from the current one to linear space
  76332. * @returns a new Color4 object
  76333. */
  76334. toLinearSpace(): Color4;
  76335. /**
  76336. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  76337. * @param convertedColor defines the Color4 object where to store the linear space version
  76338. * @returns the unmodified Color4
  76339. */
  76340. toLinearSpaceToRef(convertedColor: Color4): Color4;
  76341. /**
  76342. * Computes a new Color4 converted from the current one to gamma space
  76343. * @returns a new Color4 object
  76344. */
  76345. toGammaSpace(): Color4;
  76346. /**
  76347. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  76348. * @param convertedColor defines the Color4 object where to store the gamma space version
  76349. * @returns the unmodified Color4
  76350. */
  76351. toGammaSpaceToRef(convertedColor: Color4): Color4;
  76352. /**
  76353. * Creates a new Color4 from the string containing valid hexadecimal values
  76354. * @param hex defines a string containing valid hexadecimal values
  76355. * @returns a new Color4 object
  76356. */
  76357. static FromHexString(hex: string): Color4;
  76358. /**
  76359. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76360. * @param left defines the start value
  76361. * @param right defines the end value
  76362. * @param amount defines the gradient factor
  76363. * @returns a new Color4 object
  76364. */
  76365. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  76366. /**
  76367. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76368. * @param left defines the start value
  76369. * @param right defines the end value
  76370. * @param amount defines the gradient factor
  76371. * @param result defines the Color4 object where to store data
  76372. */
  76373. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  76374. /**
  76375. * Creates a new Color4 from a Color3 and an alpha value
  76376. * @param color3 defines the source Color3 to read from
  76377. * @param alpha defines the alpha component (1.0 by default)
  76378. * @returns a new Color4 object
  76379. */
  76380. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  76381. /**
  76382. * Creates a new Color4 from the starting index element of the given array
  76383. * @param array defines the source array to read from
  76384. * @param offset defines the offset in the source array
  76385. * @returns a new Color4 object
  76386. */
  76387. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  76388. /**
  76389. * Creates a new Color3 from integer values (< 256)
  76390. * @param r defines the red component to read from (value between 0 and 255)
  76391. * @param g defines the green component to read from (value between 0 and 255)
  76392. * @param b defines the blue component to read from (value between 0 and 255)
  76393. * @param a defines the alpha component to read from (value between 0 and 255)
  76394. * @returns a new Color3 object
  76395. */
  76396. static FromInts(r: number, g: number, b: number, a: number): Color4;
  76397. /**
  76398. * Check the content of a given array and convert it to an array containing RGBA data
  76399. * If the original array was already containing count * 4 values then it is returned directly
  76400. * @param colors defines the array to check
  76401. * @param count defines the number of RGBA data to expect
  76402. * @returns an array containing count * 4 values (RGBA)
  76403. */
  76404. static CheckColors4(colors: number[], count: number): number[];
  76405. }
  76406. /**
  76407. * @hidden
  76408. */
  76409. export class TmpColors {
  76410. static Color3: Color3[];
  76411. static Color4: Color4[];
  76412. }
  76413. }
  76414. declare module BABYLON {
  76415. /**
  76416. * Defines an interface which represents an animation key frame
  76417. */
  76418. export interface IAnimationKey {
  76419. /**
  76420. * Frame of the key frame
  76421. */
  76422. frame: number;
  76423. /**
  76424. * Value at the specifies key frame
  76425. */
  76426. value: any;
  76427. /**
  76428. * The input tangent for the cubic hermite spline
  76429. */
  76430. inTangent?: any;
  76431. /**
  76432. * The output tangent for the cubic hermite spline
  76433. */
  76434. outTangent?: any;
  76435. /**
  76436. * The animation interpolation type
  76437. */
  76438. interpolation?: AnimationKeyInterpolation;
  76439. }
  76440. /**
  76441. * Enum for the animation key frame interpolation type
  76442. */
  76443. export enum AnimationKeyInterpolation {
  76444. /**
  76445. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  76446. */
  76447. STEP = 1
  76448. }
  76449. }
  76450. declare module BABYLON {
  76451. /**
  76452. * Represents the range of an animation
  76453. */
  76454. export class AnimationRange {
  76455. /**The name of the animation range**/
  76456. name: string;
  76457. /**The starting frame of the animation */
  76458. from: number;
  76459. /**The ending frame of the animation*/
  76460. to: number;
  76461. /**
  76462. * Initializes the range of an animation
  76463. * @param name The name of the animation range
  76464. * @param from The starting frame of the animation
  76465. * @param to The ending frame of the animation
  76466. */
  76467. constructor(
  76468. /**The name of the animation range**/
  76469. name: string,
  76470. /**The starting frame of the animation */
  76471. from: number,
  76472. /**The ending frame of the animation*/
  76473. to: number);
  76474. /**
  76475. * Makes a copy of the animation range
  76476. * @returns A copy of the animation range
  76477. */
  76478. clone(): AnimationRange;
  76479. }
  76480. }
  76481. declare module BABYLON {
  76482. /**
  76483. * Composed of a frame, and an action function
  76484. */
  76485. export class AnimationEvent {
  76486. /** The frame for which the event is triggered **/
  76487. frame: number;
  76488. /** The event to perform when triggered **/
  76489. action: (currentFrame: number) => void;
  76490. /** Specifies if the event should be triggered only once**/
  76491. onlyOnce?: boolean | undefined;
  76492. /**
  76493. * Specifies if the animation event is done
  76494. */
  76495. isDone: boolean;
  76496. /**
  76497. * Initializes the animation event
  76498. * @param frame The frame for which the event is triggered
  76499. * @param action The event to perform when triggered
  76500. * @param onlyOnce Specifies if the event should be triggered only once
  76501. */
  76502. constructor(
  76503. /** The frame for which the event is triggered **/
  76504. frame: number,
  76505. /** The event to perform when triggered **/
  76506. action: (currentFrame: number) => void,
  76507. /** Specifies if the event should be triggered only once**/
  76508. onlyOnce?: boolean | undefined);
  76509. /** @hidden */
  76510. _clone(): AnimationEvent;
  76511. }
  76512. }
  76513. declare module BABYLON {
  76514. /**
  76515. * Interface used to define a behavior
  76516. */
  76517. export interface Behavior<T> {
  76518. /** gets or sets behavior's name */
  76519. name: string;
  76520. /**
  76521. * Function called when the behavior needs to be initialized (after attaching it to a target)
  76522. */
  76523. init(): void;
  76524. /**
  76525. * Called when the behavior is attached to a target
  76526. * @param target defines the target where the behavior is attached to
  76527. */
  76528. attach(target: T): void;
  76529. /**
  76530. * Called when the behavior is detached from its target
  76531. */
  76532. detach(): void;
  76533. }
  76534. /**
  76535. * Interface implemented by classes supporting behaviors
  76536. */
  76537. export interface IBehaviorAware<T> {
  76538. /**
  76539. * Attach a behavior
  76540. * @param behavior defines the behavior to attach
  76541. * @returns the current host
  76542. */
  76543. addBehavior(behavior: Behavior<T>): T;
  76544. /**
  76545. * Remove a behavior from the current object
  76546. * @param behavior defines the behavior to detach
  76547. * @returns the current host
  76548. */
  76549. removeBehavior(behavior: Behavior<T>): T;
  76550. /**
  76551. * Gets a behavior using its name to search
  76552. * @param name defines the name to search
  76553. * @returns the behavior or null if not found
  76554. */
  76555. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  76556. }
  76557. }
  76558. declare module BABYLON {
  76559. /**
  76560. * Defines an array and its length.
  76561. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  76562. */
  76563. export interface ISmartArrayLike<T> {
  76564. /**
  76565. * The data of the array.
  76566. */
  76567. data: Array<T>;
  76568. /**
  76569. * The active length of the array.
  76570. */
  76571. length: number;
  76572. }
  76573. /**
  76574. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76575. */
  76576. export class SmartArray<T> implements ISmartArrayLike<T> {
  76577. /**
  76578. * The full set of data from the array.
  76579. */
  76580. data: Array<T>;
  76581. /**
  76582. * The active length of the array.
  76583. */
  76584. length: number;
  76585. protected _id: number;
  76586. /**
  76587. * Instantiates a Smart Array.
  76588. * @param capacity defines the default capacity of the array.
  76589. */
  76590. constructor(capacity: number);
  76591. /**
  76592. * Pushes a value at the end of the active data.
  76593. * @param value defines the object to push in the array.
  76594. */
  76595. push(value: T): void;
  76596. /**
  76597. * Iterates over the active data and apply the lambda to them.
  76598. * @param func defines the action to apply on each value.
  76599. */
  76600. forEach(func: (content: T) => void): void;
  76601. /**
  76602. * Sorts the full sets of data.
  76603. * @param compareFn defines the comparison function to apply.
  76604. */
  76605. sort(compareFn: (a: T, b: T) => number): void;
  76606. /**
  76607. * Resets the active data to an empty array.
  76608. */
  76609. reset(): void;
  76610. /**
  76611. * Releases all the data from the array as well as the array.
  76612. */
  76613. dispose(): void;
  76614. /**
  76615. * Concats the active data with a given array.
  76616. * @param array defines the data to concatenate with.
  76617. */
  76618. concat(array: any): void;
  76619. /**
  76620. * Returns the position of a value in the active data.
  76621. * @param value defines the value to find the index for
  76622. * @returns the index if found in the active data otherwise -1
  76623. */
  76624. indexOf(value: T): number;
  76625. /**
  76626. * Returns whether an element is part of the active data.
  76627. * @param value defines the value to look for
  76628. * @returns true if found in the active data otherwise false
  76629. */
  76630. contains(value: T): boolean;
  76631. private static _GlobalId;
  76632. }
  76633. /**
  76634. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76635. * The data in this array can only be present once
  76636. */
  76637. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  76638. private _duplicateId;
  76639. /**
  76640. * Pushes a value at the end of the active data.
  76641. * THIS DOES NOT PREVENT DUPPLICATE DATA
  76642. * @param value defines the object to push in the array.
  76643. */
  76644. push(value: T): void;
  76645. /**
  76646. * Pushes a value at the end of the active data.
  76647. * If the data is already present, it won t be added again
  76648. * @param value defines the object to push in the array.
  76649. * @returns true if added false if it was already present
  76650. */
  76651. pushNoDuplicate(value: T): boolean;
  76652. /**
  76653. * Resets the active data to an empty array.
  76654. */
  76655. reset(): void;
  76656. /**
  76657. * Concats the active data with a given array.
  76658. * This ensures no dupplicate will be present in the result.
  76659. * @param array defines the data to concatenate with.
  76660. */
  76661. concatWithNoDuplicate(array: any): void;
  76662. }
  76663. }
  76664. declare module BABYLON {
  76665. /**
  76666. * @ignore
  76667. * This is a list of all the different input types that are available in the application.
  76668. * Fo instance: ArcRotateCameraGamepadInput...
  76669. */
  76670. export var CameraInputTypes: {};
  76671. /**
  76672. * This is the contract to implement in order to create a new input class.
  76673. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  76674. */
  76675. export interface ICameraInput<TCamera extends Camera> {
  76676. /**
  76677. * Defines the camera the input is attached to.
  76678. */
  76679. camera: Nullable<TCamera>;
  76680. /**
  76681. * Gets the class name of the current intput.
  76682. * @returns the class name
  76683. */
  76684. getClassName(): string;
  76685. /**
  76686. * Get the friendly name associated with the input class.
  76687. * @returns the input friendly name
  76688. */
  76689. getSimpleName(): string;
  76690. /**
  76691. * Attach the input controls to a specific dom element to get the input from.
  76692. * @param element Defines the element the controls should be listened from
  76693. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76694. */
  76695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76696. /**
  76697. * Detach the current controls from the specified dom element.
  76698. * @param element Defines the element to stop listening the inputs from
  76699. */
  76700. detachControl(element: Nullable<HTMLElement>): void;
  76701. /**
  76702. * Update the current camera state depending on the inputs that have been used this frame.
  76703. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76704. */
  76705. checkInputs?: () => void;
  76706. }
  76707. /**
  76708. * Represents a map of input types to input instance or input index to input instance.
  76709. */
  76710. export interface CameraInputsMap<TCamera extends Camera> {
  76711. /**
  76712. * Accessor to the input by input type.
  76713. */
  76714. [name: string]: ICameraInput<TCamera>;
  76715. /**
  76716. * Accessor to the input by input index.
  76717. */
  76718. [idx: number]: ICameraInput<TCamera>;
  76719. }
  76720. /**
  76721. * This represents the input manager used within a camera.
  76722. * It helps dealing with all the different kind of input attached to a camera.
  76723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76724. */
  76725. export class CameraInputsManager<TCamera extends Camera> {
  76726. /**
  76727. * Defines the list of inputs attahed to the camera.
  76728. */
  76729. attached: CameraInputsMap<TCamera>;
  76730. /**
  76731. * Defines the dom element the camera is collecting inputs from.
  76732. * This is null if the controls have not been attached.
  76733. */
  76734. attachedElement: Nullable<HTMLElement>;
  76735. /**
  76736. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76737. */
  76738. noPreventDefault: boolean;
  76739. /**
  76740. * Defined the camera the input manager belongs to.
  76741. */
  76742. camera: TCamera;
  76743. /**
  76744. * Update the current camera state depending on the inputs that have been used this frame.
  76745. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76746. */
  76747. checkInputs: () => void;
  76748. /**
  76749. * Instantiate a new Camera Input Manager.
  76750. * @param camera Defines the camera the input manager blongs to
  76751. */
  76752. constructor(camera: TCamera);
  76753. /**
  76754. * Add an input method to a camera
  76755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76756. * @param input camera input method
  76757. */
  76758. add(input: ICameraInput<TCamera>): void;
  76759. /**
  76760. * Remove a specific input method from a camera
  76761. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  76762. * @param inputToRemove camera input method
  76763. */
  76764. remove(inputToRemove: ICameraInput<TCamera>): void;
  76765. /**
  76766. * Remove a specific input type from a camera
  76767. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  76768. * @param inputType the type of the input to remove
  76769. */
  76770. removeByType(inputType: string): void;
  76771. private _addCheckInputs;
  76772. /**
  76773. * Attach the input controls to the currently attached dom element to listen the events from.
  76774. * @param input Defines the input to attach
  76775. */
  76776. attachInput(input: ICameraInput<TCamera>): void;
  76777. /**
  76778. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  76779. * @param element Defines the dom element to collect the events from
  76780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76781. */
  76782. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  76783. /**
  76784. * Detach the current manager inputs controls from a specific dom element.
  76785. * @param element Defines the dom element to collect the events from
  76786. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  76787. */
  76788. detachElement(element: HTMLElement, disconnect?: boolean): void;
  76789. /**
  76790. * Rebuild the dynamic inputCheck function from the current list of
  76791. * defined inputs in the manager.
  76792. */
  76793. rebuildInputCheck(): void;
  76794. /**
  76795. * Remove all attached input methods from a camera
  76796. */
  76797. clear(): void;
  76798. /**
  76799. * Serialize the current input manager attached to a camera.
  76800. * This ensures than once parsed,
  76801. * the input associated to the camera will be identical to the current ones
  76802. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  76803. */
  76804. serialize(serializedCamera: any): void;
  76805. /**
  76806. * Parses an input manager serialized JSON to restore the previous list of inputs
  76807. * and states associated to a camera.
  76808. * @param parsedCamera Defines the JSON to parse
  76809. */
  76810. parse(parsedCamera: any): void;
  76811. }
  76812. }
  76813. declare module BABYLON {
  76814. /**
  76815. * Class used to store data that will be store in GPU memory
  76816. */
  76817. export class Buffer {
  76818. private _engine;
  76819. private _buffer;
  76820. /** @hidden */
  76821. _data: Nullable<DataArray>;
  76822. private _updatable;
  76823. private _instanced;
  76824. private _divisor;
  76825. /**
  76826. * Gets the byte stride.
  76827. */
  76828. readonly byteStride: number;
  76829. /**
  76830. * Constructor
  76831. * @param engine the engine
  76832. * @param data the data to use for this buffer
  76833. * @param updatable whether the data is updatable
  76834. * @param stride the stride (optional)
  76835. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76836. * @param instanced whether the buffer is instanced (optional)
  76837. * @param useBytes set to true if the stride in in bytes (optional)
  76838. * @param divisor sets an optional divisor for instances (1 by default)
  76839. */
  76840. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  76841. /**
  76842. * Create a new VertexBuffer based on the current buffer
  76843. * @param kind defines the vertex buffer kind (position, normal, etc.)
  76844. * @param offset defines offset in the buffer (0 by default)
  76845. * @param size defines the size in floats of attributes (position is 3 for instance)
  76846. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  76847. * @param instanced defines if the vertex buffer contains indexed data
  76848. * @param useBytes defines if the offset and stride are in bytes *
  76849. * @param divisor sets an optional divisor for instances (1 by default)
  76850. * @returns the new vertex buffer
  76851. */
  76852. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  76853. /**
  76854. * Gets a boolean indicating if the Buffer is updatable?
  76855. * @returns true if the buffer is updatable
  76856. */
  76857. isUpdatable(): boolean;
  76858. /**
  76859. * Gets current buffer's data
  76860. * @returns a DataArray or null
  76861. */
  76862. getData(): Nullable<DataArray>;
  76863. /**
  76864. * Gets underlying native buffer
  76865. * @returns underlying native buffer
  76866. */
  76867. getBuffer(): Nullable<DataBuffer>;
  76868. /**
  76869. * Gets the stride in float32 units (i.e. byte stride / 4).
  76870. * May not be an integer if the byte stride is not divisible by 4.
  76871. * @returns the stride in float32 units
  76872. * @deprecated Please use byteStride instead.
  76873. */
  76874. getStrideSize(): number;
  76875. /**
  76876. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76877. * @param data defines the data to store
  76878. */
  76879. create(data?: Nullable<DataArray>): void;
  76880. /** @hidden */
  76881. _rebuild(): void;
  76882. /**
  76883. * Update current buffer data
  76884. * @param data defines the data to store
  76885. */
  76886. update(data: DataArray): void;
  76887. /**
  76888. * Updates the data directly.
  76889. * @param data the new data
  76890. * @param offset the new offset
  76891. * @param vertexCount the vertex count (optional)
  76892. * @param useBytes set to true if the offset is in bytes
  76893. */
  76894. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  76895. /**
  76896. * Release all resources
  76897. */
  76898. dispose(): void;
  76899. }
  76900. /**
  76901. * Specialized buffer used to store vertex data
  76902. */
  76903. export class VertexBuffer {
  76904. /** @hidden */
  76905. _buffer: Buffer;
  76906. private _kind;
  76907. private _size;
  76908. private _ownsBuffer;
  76909. private _instanced;
  76910. private _instanceDivisor;
  76911. /**
  76912. * The byte type.
  76913. */
  76914. static readonly BYTE: number;
  76915. /**
  76916. * The unsigned byte type.
  76917. */
  76918. static readonly UNSIGNED_BYTE: number;
  76919. /**
  76920. * The short type.
  76921. */
  76922. static readonly SHORT: number;
  76923. /**
  76924. * The unsigned short type.
  76925. */
  76926. static readonly UNSIGNED_SHORT: number;
  76927. /**
  76928. * The integer type.
  76929. */
  76930. static readonly INT: number;
  76931. /**
  76932. * The unsigned integer type.
  76933. */
  76934. static readonly UNSIGNED_INT: number;
  76935. /**
  76936. * The float type.
  76937. */
  76938. static readonly FLOAT: number;
  76939. /**
  76940. * Gets or sets the instance divisor when in instanced mode
  76941. */
  76942. get instanceDivisor(): number;
  76943. set instanceDivisor(value: number);
  76944. /**
  76945. * Gets the byte stride.
  76946. */
  76947. readonly byteStride: number;
  76948. /**
  76949. * Gets the byte offset.
  76950. */
  76951. readonly byteOffset: number;
  76952. /**
  76953. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  76954. */
  76955. readonly normalized: boolean;
  76956. /**
  76957. * Gets the data type of each component in the array.
  76958. */
  76959. readonly type: number;
  76960. /**
  76961. * Constructor
  76962. * @param engine the engine
  76963. * @param data the data to use for this vertex buffer
  76964. * @param kind the vertex buffer kind
  76965. * @param updatable whether the data is updatable
  76966. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76967. * @param stride the stride (optional)
  76968. * @param instanced whether the buffer is instanced (optional)
  76969. * @param offset the offset of the data (optional)
  76970. * @param size the number of components (optional)
  76971. * @param type the type of the component (optional)
  76972. * @param normalized whether the data contains normalized data (optional)
  76973. * @param useBytes set to true if stride and offset are in bytes (optional)
  76974. * @param divisor defines the instance divisor to use (1 by default)
  76975. */
  76976. 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);
  76977. /** @hidden */
  76978. _rebuild(): void;
  76979. /**
  76980. * Returns the kind of the VertexBuffer (string)
  76981. * @returns a string
  76982. */
  76983. getKind(): string;
  76984. /**
  76985. * Gets a boolean indicating if the VertexBuffer is updatable?
  76986. * @returns true if the buffer is updatable
  76987. */
  76988. isUpdatable(): boolean;
  76989. /**
  76990. * Gets current buffer's data
  76991. * @returns a DataArray or null
  76992. */
  76993. getData(): Nullable<DataArray>;
  76994. /**
  76995. * Gets underlying native buffer
  76996. * @returns underlying native buffer
  76997. */
  76998. getBuffer(): Nullable<DataBuffer>;
  76999. /**
  77000. * Gets the stride in float32 units (i.e. byte stride / 4).
  77001. * May not be an integer if the byte stride is not divisible by 4.
  77002. * @returns the stride in float32 units
  77003. * @deprecated Please use byteStride instead.
  77004. */
  77005. getStrideSize(): number;
  77006. /**
  77007. * Returns the offset as a multiple of the type byte length.
  77008. * @returns the offset in bytes
  77009. * @deprecated Please use byteOffset instead.
  77010. */
  77011. getOffset(): number;
  77012. /**
  77013. * Returns the number of components per vertex attribute (integer)
  77014. * @returns the size in float
  77015. */
  77016. getSize(): number;
  77017. /**
  77018. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  77019. * @returns true if this buffer is instanced
  77020. */
  77021. getIsInstanced(): boolean;
  77022. /**
  77023. * Returns the instancing divisor, zero for non-instanced (integer).
  77024. * @returns a number
  77025. */
  77026. getInstanceDivisor(): number;
  77027. /**
  77028. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77029. * @param data defines the data to store
  77030. */
  77031. create(data?: DataArray): void;
  77032. /**
  77033. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  77034. * This function will create a new buffer if the current one is not updatable
  77035. * @param data defines the data to store
  77036. */
  77037. update(data: DataArray): void;
  77038. /**
  77039. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  77040. * Returns the directly updated WebGLBuffer.
  77041. * @param data the new data
  77042. * @param offset the new offset
  77043. * @param useBytes set to true if the offset is in bytes
  77044. */
  77045. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  77046. /**
  77047. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  77048. */
  77049. dispose(): void;
  77050. /**
  77051. * Enumerates each value of this vertex buffer as numbers.
  77052. * @param count the number of values to enumerate
  77053. * @param callback the callback function called for each value
  77054. */
  77055. forEach(count: number, callback: (value: number, index: number) => void): void;
  77056. /**
  77057. * Positions
  77058. */
  77059. static readonly PositionKind: string;
  77060. /**
  77061. * Normals
  77062. */
  77063. static readonly NormalKind: string;
  77064. /**
  77065. * Tangents
  77066. */
  77067. static readonly TangentKind: string;
  77068. /**
  77069. * Texture coordinates
  77070. */
  77071. static readonly UVKind: string;
  77072. /**
  77073. * Texture coordinates 2
  77074. */
  77075. static readonly UV2Kind: string;
  77076. /**
  77077. * Texture coordinates 3
  77078. */
  77079. static readonly UV3Kind: string;
  77080. /**
  77081. * Texture coordinates 4
  77082. */
  77083. static readonly UV4Kind: string;
  77084. /**
  77085. * Texture coordinates 5
  77086. */
  77087. static readonly UV5Kind: string;
  77088. /**
  77089. * Texture coordinates 6
  77090. */
  77091. static readonly UV6Kind: string;
  77092. /**
  77093. * Colors
  77094. */
  77095. static readonly ColorKind: string;
  77096. /**
  77097. * Matrix indices (for bones)
  77098. */
  77099. static readonly MatricesIndicesKind: string;
  77100. /**
  77101. * Matrix weights (for bones)
  77102. */
  77103. static readonly MatricesWeightsKind: string;
  77104. /**
  77105. * Additional matrix indices (for bones)
  77106. */
  77107. static readonly MatricesIndicesExtraKind: string;
  77108. /**
  77109. * Additional matrix weights (for bones)
  77110. */
  77111. static readonly MatricesWeightsExtraKind: string;
  77112. /**
  77113. * Deduces the stride given a kind.
  77114. * @param kind The kind string to deduce
  77115. * @returns The deduced stride
  77116. */
  77117. static DeduceStride(kind: string): number;
  77118. /**
  77119. * Gets the byte length of the given type.
  77120. * @param type the type
  77121. * @returns the number of bytes
  77122. */
  77123. static GetTypeByteLength(type: number): number;
  77124. /**
  77125. * Enumerates each value of the given parameters as numbers.
  77126. * @param data the data to enumerate
  77127. * @param byteOffset the byte offset of the data
  77128. * @param byteStride the byte stride of the data
  77129. * @param componentCount the number of components per element
  77130. * @param componentType the type of the component
  77131. * @param count the number of values to enumerate
  77132. * @param normalized whether the data is normalized
  77133. * @param callback the callback function called for each value
  77134. */
  77135. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  77136. private static _GetFloatValue;
  77137. }
  77138. }
  77139. declare module BABYLON {
  77140. /**
  77141. * @hidden
  77142. */
  77143. export class IntersectionInfo {
  77144. bu: Nullable<number>;
  77145. bv: Nullable<number>;
  77146. distance: number;
  77147. faceId: number;
  77148. subMeshId: number;
  77149. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  77150. }
  77151. }
  77152. declare module BABYLON {
  77153. /**
  77154. * Represens a plane by the equation ax + by + cz + d = 0
  77155. */
  77156. export class Plane {
  77157. private static _TmpMatrix;
  77158. /**
  77159. * Normal of the plane (a,b,c)
  77160. */
  77161. normal: Vector3;
  77162. /**
  77163. * d component of the plane
  77164. */
  77165. d: number;
  77166. /**
  77167. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77168. * @param a a component of the plane
  77169. * @param b b component of the plane
  77170. * @param c c component of the plane
  77171. * @param d d component of the plane
  77172. */
  77173. constructor(a: number, b: number, c: number, d: number);
  77174. /**
  77175. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77176. */
  77177. asArray(): number[];
  77178. /**
  77179. * @returns a new plane copied from the current Plane.
  77180. */
  77181. clone(): Plane;
  77182. /**
  77183. * @returns the string "Plane".
  77184. */
  77185. getClassName(): string;
  77186. /**
  77187. * @returns the Plane hash code.
  77188. */
  77189. getHashCode(): number;
  77190. /**
  77191. * Normalize the current Plane in place.
  77192. * @returns the updated Plane.
  77193. */
  77194. normalize(): Plane;
  77195. /**
  77196. * Applies a transformation the plane and returns the result
  77197. * @param transformation the transformation matrix to be applied to the plane
  77198. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77199. */
  77200. transform(transformation: DeepImmutable<Matrix>): Plane;
  77201. /**
  77202. * Calcualtte the dot product between the point and the plane normal
  77203. * @param point point to calculate the dot product with
  77204. * @returns the dot product (float) of the point coordinates and the plane normal.
  77205. */
  77206. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77207. /**
  77208. * Updates the current Plane from the plane defined by the three given points.
  77209. * @param point1 one of the points used to contruct the plane
  77210. * @param point2 one of the points used to contruct the plane
  77211. * @param point3 one of the points used to contruct the plane
  77212. * @returns the updated Plane.
  77213. */
  77214. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77215. /**
  77216. * Checks if the plane is facing a given direction
  77217. * @param direction the direction to check if the plane is facing
  77218. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77219. * @returns True is the vector "direction" is the same side than the plane normal.
  77220. */
  77221. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77222. /**
  77223. * Calculates the distance to a point
  77224. * @param point point to calculate distance to
  77225. * @returns the signed distance (float) from the given point to the Plane.
  77226. */
  77227. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77228. /**
  77229. * Creates a plane from an array
  77230. * @param array the array to create a plane from
  77231. * @returns a new Plane from the given array.
  77232. */
  77233. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77234. /**
  77235. * Creates a plane from three points
  77236. * @param point1 point used to create the plane
  77237. * @param point2 point used to create the plane
  77238. * @param point3 point used to create the plane
  77239. * @returns a new Plane defined by the three given points.
  77240. */
  77241. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77242. /**
  77243. * Creates a plane from an origin point and a normal
  77244. * @param origin origin of the plane to be constructed
  77245. * @param normal normal of the plane to be constructed
  77246. * @returns a new Plane the normal vector to this plane at the given origin point.
  77247. * Note : the vector "normal" is updated because normalized.
  77248. */
  77249. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77250. /**
  77251. * Calculates the distance from a plane and a point
  77252. * @param origin origin of the plane to be constructed
  77253. * @param normal normal of the plane to be constructed
  77254. * @param point point to calculate distance to
  77255. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77256. */
  77257. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77258. }
  77259. }
  77260. declare module BABYLON {
  77261. /**
  77262. * Class used to store bounding sphere information
  77263. */
  77264. export class BoundingSphere {
  77265. /**
  77266. * Gets the center of the bounding sphere in local space
  77267. */
  77268. readonly center: Vector3;
  77269. /**
  77270. * Radius of the bounding sphere in local space
  77271. */
  77272. radius: number;
  77273. /**
  77274. * Gets the center of the bounding sphere in world space
  77275. */
  77276. readonly centerWorld: Vector3;
  77277. /**
  77278. * Radius of the bounding sphere in world space
  77279. */
  77280. radiusWorld: number;
  77281. /**
  77282. * Gets the minimum vector in local space
  77283. */
  77284. readonly minimum: Vector3;
  77285. /**
  77286. * Gets the maximum vector in local space
  77287. */
  77288. readonly maximum: Vector3;
  77289. private _worldMatrix;
  77290. private static readonly TmpVector3;
  77291. /**
  77292. * Creates a new bounding sphere
  77293. * @param min defines the minimum vector (in local space)
  77294. * @param max defines the maximum vector (in local space)
  77295. * @param worldMatrix defines the new world matrix
  77296. */
  77297. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77298. /**
  77299. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  77300. * @param min defines the new minimum vector (in local space)
  77301. * @param max defines the new maximum vector (in local space)
  77302. * @param worldMatrix defines the new world matrix
  77303. */
  77304. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77305. /**
  77306. * Scale the current bounding sphere by applying a scale factor
  77307. * @param factor defines the scale factor to apply
  77308. * @returns the current bounding box
  77309. */
  77310. scale(factor: number): BoundingSphere;
  77311. /**
  77312. * Gets the world matrix of the bounding box
  77313. * @returns a matrix
  77314. */
  77315. getWorldMatrix(): DeepImmutable<Matrix>;
  77316. /** @hidden */
  77317. _update(worldMatrix: DeepImmutable<Matrix>): void;
  77318. /**
  77319. * Tests if the bounding sphere is intersecting the frustum planes
  77320. * @param frustumPlanes defines the frustum planes to test
  77321. * @returns true if there is an intersection
  77322. */
  77323. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77324. /**
  77325. * Tests if the bounding sphere center is in between the frustum planes.
  77326. * Used for optimistic fast inclusion.
  77327. * @param frustumPlanes defines the frustum planes to test
  77328. * @returns true if the sphere center is in between the frustum planes
  77329. */
  77330. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77331. /**
  77332. * Tests if a point is inside the bounding sphere
  77333. * @param point defines the point to test
  77334. * @returns true if the point is inside the bounding sphere
  77335. */
  77336. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77337. /**
  77338. * Checks if two sphere intersct
  77339. * @param sphere0 sphere 0
  77340. * @param sphere1 sphere 1
  77341. * @returns true if the speres intersect
  77342. */
  77343. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  77344. }
  77345. }
  77346. declare module BABYLON {
  77347. /**
  77348. * Class used to store bounding box information
  77349. */
  77350. export class BoundingBox implements ICullable {
  77351. /**
  77352. * Gets the 8 vectors representing the bounding box in local space
  77353. */
  77354. readonly vectors: Vector3[];
  77355. /**
  77356. * Gets the center of the bounding box in local space
  77357. */
  77358. readonly center: Vector3;
  77359. /**
  77360. * Gets the center of the bounding box in world space
  77361. */
  77362. readonly centerWorld: Vector3;
  77363. /**
  77364. * Gets the extend size in local space
  77365. */
  77366. readonly extendSize: Vector3;
  77367. /**
  77368. * Gets the extend size in world space
  77369. */
  77370. readonly extendSizeWorld: Vector3;
  77371. /**
  77372. * Gets the OBB (object bounding box) directions
  77373. */
  77374. readonly directions: Vector3[];
  77375. /**
  77376. * Gets the 8 vectors representing the bounding box in world space
  77377. */
  77378. readonly vectorsWorld: Vector3[];
  77379. /**
  77380. * Gets the minimum vector in world space
  77381. */
  77382. readonly minimumWorld: Vector3;
  77383. /**
  77384. * Gets the maximum vector in world space
  77385. */
  77386. readonly maximumWorld: Vector3;
  77387. /**
  77388. * Gets the minimum vector in local space
  77389. */
  77390. readonly minimum: Vector3;
  77391. /**
  77392. * Gets the maximum vector in local space
  77393. */
  77394. readonly maximum: Vector3;
  77395. private _worldMatrix;
  77396. private static readonly TmpVector3;
  77397. /**
  77398. * @hidden
  77399. */
  77400. _tag: number;
  77401. /**
  77402. * Creates a new bounding box
  77403. * @param min defines the minimum vector (in local space)
  77404. * @param max defines the maximum vector (in local space)
  77405. * @param worldMatrix defines the new world matrix
  77406. */
  77407. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77408. /**
  77409. * Recreates the entire bounding box from scratch as if we call the constructor in place
  77410. * @param min defines the new minimum vector (in local space)
  77411. * @param max defines the new maximum vector (in local space)
  77412. * @param worldMatrix defines the new world matrix
  77413. */
  77414. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77415. /**
  77416. * Scale the current bounding box by applying a scale factor
  77417. * @param factor defines the scale factor to apply
  77418. * @returns the current bounding box
  77419. */
  77420. scale(factor: number): BoundingBox;
  77421. /**
  77422. * Gets the world matrix of the bounding box
  77423. * @returns a matrix
  77424. */
  77425. getWorldMatrix(): DeepImmutable<Matrix>;
  77426. /** @hidden */
  77427. _update(world: DeepImmutable<Matrix>): void;
  77428. /**
  77429. * Tests if the bounding box is intersecting the frustum planes
  77430. * @param frustumPlanes defines the frustum planes to test
  77431. * @returns true if there is an intersection
  77432. */
  77433. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77434. /**
  77435. * Tests if the bounding box is entirely inside the frustum planes
  77436. * @param frustumPlanes defines the frustum planes to test
  77437. * @returns true if there is an inclusion
  77438. */
  77439. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77440. /**
  77441. * Tests if a point is inside the bounding box
  77442. * @param point defines the point to test
  77443. * @returns true if the point is inside the bounding box
  77444. */
  77445. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77446. /**
  77447. * Tests if the bounding box intersects with a bounding sphere
  77448. * @param sphere defines the sphere to test
  77449. * @returns true if there is an intersection
  77450. */
  77451. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  77452. /**
  77453. * Tests if the bounding box intersects with a box defined by a min and max vectors
  77454. * @param min defines the min vector to use
  77455. * @param max defines the max vector to use
  77456. * @returns true if there is an intersection
  77457. */
  77458. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  77459. /**
  77460. * Tests if two bounding boxes are intersections
  77461. * @param box0 defines the first box to test
  77462. * @param box1 defines the second box to test
  77463. * @returns true if there is an intersection
  77464. */
  77465. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  77466. /**
  77467. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  77468. * @param minPoint defines the minimum vector of the bounding box
  77469. * @param maxPoint defines the maximum vector of the bounding box
  77470. * @param sphereCenter defines the sphere center
  77471. * @param sphereRadius defines the sphere radius
  77472. * @returns true if there is an intersection
  77473. */
  77474. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  77475. /**
  77476. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  77477. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77478. * @param frustumPlanes defines the frustum planes to test
  77479. * @return true if there is an inclusion
  77480. */
  77481. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77482. /**
  77483. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  77484. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77485. * @param frustumPlanes defines the frustum planes to test
  77486. * @return true if there is an intersection
  77487. */
  77488. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77489. }
  77490. }
  77491. declare module BABYLON {
  77492. /** @hidden */
  77493. export class Collider {
  77494. /** Define if a collision was found */
  77495. collisionFound: boolean;
  77496. /**
  77497. * Define last intersection point in local space
  77498. */
  77499. intersectionPoint: Vector3;
  77500. /**
  77501. * Define last collided mesh
  77502. */
  77503. collidedMesh: Nullable<AbstractMesh>;
  77504. private _collisionPoint;
  77505. private _planeIntersectionPoint;
  77506. private _tempVector;
  77507. private _tempVector2;
  77508. private _tempVector3;
  77509. private _tempVector4;
  77510. private _edge;
  77511. private _baseToVertex;
  77512. private _destinationPoint;
  77513. private _slidePlaneNormal;
  77514. private _displacementVector;
  77515. /** @hidden */
  77516. _radius: Vector3;
  77517. /** @hidden */
  77518. _retry: number;
  77519. private _velocity;
  77520. private _basePoint;
  77521. private _epsilon;
  77522. /** @hidden */
  77523. _velocityWorldLength: number;
  77524. /** @hidden */
  77525. _basePointWorld: Vector3;
  77526. private _velocityWorld;
  77527. private _normalizedVelocity;
  77528. /** @hidden */
  77529. _initialVelocity: Vector3;
  77530. /** @hidden */
  77531. _initialPosition: Vector3;
  77532. private _nearestDistance;
  77533. private _collisionMask;
  77534. get collisionMask(): number;
  77535. set collisionMask(mask: number);
  77536. /**
  77537. * Gets the plane normal used to compute the sliding response (in local space)
  77538. */
  77539. get slidePlaneNormal(): Vector3;
  77540. /** @hidden */
  77541. _initialize(source: Vector3, dir: Vector3, e: number): void;
  77542. /** @hidden */
  77543. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  77544. /** @hidden */
  77545. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  77546. /** @hidden */
  77547. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77548. /** @hidden */
  77549. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77550. /** @hidden */
  77551. _getResponse(pos: Vector3, vel: Vector3): void;
  77552. }
  77553. }
  77554. declare module BABYLON {
  77555. /**
  77556. * Interface for cullable objects
  77557. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  77558. */
  77559. export interface ICullable {
  77560. /**
  77561. * Checks if the object or part of the object is in the frustum
  77562. * @param frustumPlanes Camera near/planes
  77563. * @returns true if the object is in frustum otherwise false
  77564. */
  77565. isInFrustum(frustumPlanes: Plane[]): boolean;
  77566. /**
  77567. * Checks if a cullable object (mesh...) is in the camera frustum
  77568. * Unlike isInFrustum this cheks the full bounding box
  77569. * @param frustumPlanes Camera near/planes
  77570. * @returns true if the object is in frustum otherwise false
  77571. */
  77572. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77573. }
  77574. /**
  77575. * Info for a bounding data of a mesh
  77576. */
  77577. export class BoundingInfo implements ICullable {
  77578. /**
  77579. * Bounding box for the mesh
  77580. */
  77581. readonly boundingBox: BoundingBox;
  77582. /**
  77583. * Bounding sphere for the mesh
  77584. */
  77585. readonly boundingSphere: BoundingSphere;
  77586. private _isLocked;
  77587. private static readonly TmpVector3;
  77588. /**
  77589. * Constructs bounding info
  77590. * @param minimum min vector of the bounding box/sphere
  77591. * @param maximum max vector of the bounding box/sphere
  77592. * @param worldMatrix defines the new world matrix
  77593. */
  77594. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77595. /**
  77596. * Recreates the entire bounding info from scratch as if we call the constructor in place
  77597. * @param min defines the new minimum vector (in local space)
  77598. * @param max defines the new maximum vector (in local space)
  77599. * @param worldMatrix defines the new world matrix
  77600. */
  77601. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77602. /**
  77603. * min vector of the bounding box/sphere
  77604. */
  77605. get minimum(): Vector3;
  77606. /**
  77607. * max vector of the bounding box/sphere
  77608. */
  77609. get maximum(): Vector3;
  77610. /**
  77611. * If the info is locked and won't be updated to avoid perf overhead
  77612. */
  77613. get isLocked(): boolean;
  77614. set isLocked(value: boolean);
  77615. /**
  77616. * Updates the bounding sphere and box
  77617. * @param world world matrix to be used to update
  77618. */
  77619. update(world: DeepImmutable<Matrix>): void;
  77620. /**
  77621. * Recreate the bounding info to be centered around a specific point given a specific extend.
  77622. * @param center New center of the bounding info
  77623. * @param extend New extend of the bounding info
  77624. * @returns the current bounding info
  77625. */
  77626. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  77627. /**
  77628. * Scale the current bounding info by applying a scale factor
  77629. * @param factor defines the scale factor to apply
  77630. * @returns the current bounding info
  77631. */
  77632. scale(factor: number): BoundingInfo;
  77633. /**
  77634. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  77635. * @param frustumPlanes defines the frustum to test
  77636. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  77637. * @returns true if the bounding info is in the frustum planes
  77638. */
  77639. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  77640. /**
  77641. * Gets the world distance between the min and max points of the bounding box
  77642. */
  77643. get diagonalLength(): number;
  77644. /**
  77645. * Checks if a cullable object (mesh...) is in the camera frustum
  77646. * Unlike isInFrustum this cheks the full bounding box
  77647. * @param frustumPlanes Camera near/planes
  77648. * @returns true if the object is in frustum otherwise false
  77649. */
  77650. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77651. /** @hidden */
  77652. _checkCollision(collider: Collider): boolean;
  77653. /**
  77654. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  77655. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77656. * @param point the point to check intersection with
  77657. * @returns if the point intersects
  77658. */
  77659. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77660. /**
  77661. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  77662. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77663. * @param boundingInfo the bounding info to check intersection with
  77664. * @param precise if the intersection should be done using OBB
  77665. * @returns if the bounding info intersects
  77666. */
  77667. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  77668. }
  77669. }
  77670. declare module BABYLON {
  77671. /**
  77672. * Extracts minimum and maximum values from a list of indexed positions
  77673. * @param positions defines the positions to use
  77674. * @param indices defines the indices to the positions
  77675. * @param indexStart defines the start index
  77676. * @param indexCount defines the end index
  77677. * @param bias defines bias value to add to the result
  77678. * @return minimum and maximum values
  77679. */
  77680. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  77681. minimum: Vector3;
  77682. maximum: Vector3;
  77683. };
  77684. /**
  77685. * Extracts minimum and maximum values from a list of positions
  77686. * @param positions defines the positions to use
  77687. * @param start defines the start index in the positions array
  77688. * @param count defines the number of positions to handle
  77689. * @param bias defines bias value to add to the result
  77690. * @param stride defines the stride size to use (distance between two positions in the positions array)
  77691. * @return minimum and maximum values
  77692. */
  77693. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  77694. minimum: Vector3;
  77695. maximum: Vector3;
  77696. };
  77697. }
  77698. declare module BABYLON {
  77699. /** @hidden */
  77700. export class WebGLDataBuffer extends DataBuffer {
  77701. private _buffer;
  77702. constructor(resource: WebGLBuffer);
  77703. get underlyingResource(): any;
  77704. }
  77705. }
  77706. declare module BABYLON {
  77707. /** @hidden */
  77708. export class WebGLPipelineContext implements IPipelineContext {
  77709. engine: ThinEngine;
  77710. program: Nullable<WebGLProgram>;
  77711. context?: WebGLRenderingContext;
  77712. vertexShader?: WebGLShader;
  77713. fragmentShader?: WebGLShader;
  77714. isParallelCompiled: boolean;
  77715. onCompiled?: () => void;
  77716. transformFeedback?: WebGLTransformFeedback | null;
  77717. vertexCompilationError: Nullable<string>;
  77718. fragmentCompilationError: Nullable<string>;
  77719. programLinkError: Nullable<string>;
  77720. programValidationError: Nullable<string>;
  77721. get isAsync(): boolean;
  77722. get isReady(): boolean;
  77723. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  77724. }
  77725. }
  77726. declare module BABYLON {
  77727. interface ThinEngine {
  77728. /**
  77729. * Create an uniform buffer
  77730. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77731. * @param elements defines the content of the uniform buffer
  77732. * @returns the webGL uniform buffer
  77733. */
  77734. createUniformBuffer(elements: FloatArray): DataBuffer;
  77735. /**
  77736. * Create a dynamic uniform buffer
  77737. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77738. * @param elements defines the content of the uniform buffer
  77739. * @returns the webGL uniform buffer
  77740. */
  77741. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  77742. /**
  77743. * Update an existing uniform buffer
  77744. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77745. * @param uniformBuffer defines the target uniform buffer
  77746. * @param elements defines the content to update
  77747. * @param offset defines the offset in the uniform buffer where update should start
  77748. * @param count defines the size of the data to update
  77749. */
  77750. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  77751. /**
  77752. * Bind an uniform buffer to the current webGL context
  77753. * @param buffer defines the buffer to bind
  77754. */
  77755. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  77756. /**
  77757. * Bind a buffer to the current webGL context at a given location
  77758. * @param buffer defines the buffer to bind
  77759. * @param location defines the index where to bind the buffer
  77760. */
  77761. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  77762. /**
  77763. * Bind a specific block at a given index in a specific shader program
  77764. * @param pipelineContext defines the pipeline context to use
  77765. * @param blockName defines the block name
  77766. * @param index defines the index where to bind the block
  77767. */
  77768. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  77769. }
  77770. }
  77771. declare module BABYLON {
  77772. /**
  77773. * Uniform buffer objects.
  77774. *
  77775. * Handles blocks of uniform on the GPU.
  77776. *
  77777. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77778. *
  77779. * For more information, please refer to :
  77780. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77781. */
  77782. export class UniformBuffer {
  77783. private _engine;
  77784. private _buffer;
  77785. private _data;
  77786. private _bufferData;
  77787. private _dynamic?;
  77788. private _uniformLocations;
  77789. private _uniformSizes;
  77790. private _uniformLocationPointer;
  77791. private _needSync;
  77792. private _noUBO;
  77793. private _currentEffect;
  77794. /** @hidden */
  77795. _alreadyBound: boolean;
  77796. private static _MAX_UNIFORM_SIZE;
  77797. private static _tempBuffer;
  77798. /**
  77799. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  77800. * This is dynamic to allow compat with webgl 1 and 2.
  77801. * You will need to pass the name of the uniform as well as the value.
  77802. */
  77803. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  77804. /**
  77805. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  77806. * This is dynamic to allow compat with webgl 1 and 2.
  77807. * You will need to pass the name of the uniform as well as the value.
  77808. */
  77809. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  77810. /**
  77811. * Lambda to Update a single float in a uniform buffer.
  77812. * This is dynamic to allow compat with webgl 1 and 2.
  77813. * You will need to pass the name of the uniform as well as the value.
  77814. */
  77815. updateFloat: (name: string, x: number) => void;
  77816. /**
  77817. * Lambda to Update a vec2 of float in a uniform buffer.
  77818. * This is dynamic to allow compat with webgl 1 and 2.
  77819. * You will need to pass the name of the uniform as well as the value.
  77820. */
  77821. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  77822. /**
  77823. * Lambda to Update a vec3 of float in a uniform buffer.
  77824. * This is dynamic to allow compat with webgl 1 and 2.
  77825. * You will need to pass the name of the uniform as well as the value.
  77826. */
  77827. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  77828. /**
  77829. * Lambda to Update a vec4 of float in a uniform buffer.
  77830. * This is dynamic to allow compat with webgl 1 and 2.
  77831. * You will need to pass the name of the uniform as well as the value.
  77832. */
  77833. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  77834. /**
  77835. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  77836. * This is dynamic to allow compat with webgl 1 and 2.
  77837. * You will need to pass the name of the uniform as well as the value.
  77838. */
  77839. updateMatrix: (name: string, mat: Matrix) => void;
  77840. /**
  77841. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  77842. * This is dynamic to allow compat with webgl 1 and 2.
  77843. * You will need to pass the name of the uniform as well as the value.
  77844. */
  77845. updateVector3: (name: string, vector: Vector3) => void;
  77846. /**
  77847. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  77848. * This is dynamic to allow compat with webgl 1 and 2.
  77849. * You will need to pass the name of the uniform as well as the value.
  77850. */
  77851. updateVector4: (name: string, vector: Vector4) => void;
  77852. /**
  77853. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  77854. * This is dynamic to allow compat with webgl 1 and 2.
  77855. * You will need to pass the name of the uniform as well as the value.
  77856. */
  77857. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  77858. /**
  77859. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  77860. * This is dynamic to allow compat with webgl 1 and 2.
  77861. * You will need to pass the name of the uniform as well as the value.
  77862. */
  77863. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  77864. /**
  77865. * Instantiates a new Uniform buffer objects.
  77866. *
  77867. * Handles blocks of uniform on the GPU.
  77868. *
  77869. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77870. *
  77871. * For more information, please refer to :
  77872. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77873. * @param engine Define the engine the buffer is associated with
  77874. * @param data Define the data contained in the buffer
  77875. * @param dynamic Define if the buffer is updatable
  77876. */
  77877. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  77878. /**
  77879. * Indicates if the buffer is using the WebGL2 UBO implementation,
  77880. * or just falling back on setUniformXXX calls.
  77881. */
  77882. get useUbo(): boolean;
  77883. /**
  77884. * Indicates if the WebGL underlying uniform buffer is in sync
  77885. * with the javascript cache data.
  77886. */
  77887. get isSync(): boolean;
  77888. /**
  77889. * Indicates if the WebGL underlying uniform buffer is dynamic.
  77890. * Also, a dynamic UniformBuffer will disable cache verification and always
  77891. * update the underlying WebGL uniform buffer to the GPU.
  77892. * @returns if Dynamic, otherwise false
  77893. */
  77894. isDynamic(): boolean;
  77895. /**
  77896. * The data cache on JS side.
  77897. * @returns the underlying data as a float array
  77898. */
  77899. getData(): Float32Array;
  77900. /**
  77901. * The underlying WebGL Uniform buffer.
  77902. * @returns the webgl buffer
  77903. */
  77904. getBuffer(): Nullable<DataBuffer>;
  77905. /**
  77906. * std140 layout specifies how to align data within an UBO structure.
  77907. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  77908. * for specs.
  77909. */
  77910. private _fillAlignment;
  77911. /**
  77912. * Adds an uniform in the buffer.
  77913. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  77914. * for the layout to be correct !
  77915. * @param name Name of the uniform, as used in the uniform block in the shader.
  77916. * @param size Data size, or data directly.
  77917. */
  77918. addUniform(name: string, size: number | number[]): void;
  77919. /**
  77920. * Adds a Matrix 4x4 to the uniform buffer.
  77921. * @param name Name of the uniform, as used in the uniform block in the shader.
  77922. * @param mat A 4x4 matrix.
  77923. */
  77924. addMatrix(name: string, mat: Matrix): void;
  77925. /**
  77926. * Adds a vec2 to the uniform buffer.
  77927. * @param name Name of the uniform, as used in the uniform block in the shader.
  77928. * @param x Define the x component value of the vec2
  77929. * @param y Define the y component value of the vec2
  77930. */
  77931. addFloat2(name: string, x: number, y: number): void;
  77932. /**
  77933. * Adds a vec3 to the uniform buffer.
  77934. * @param name Name of the uniform, as used in the uniform block in the shader.
  77935. * @param x Define the x component value of the vec3
  77936. * @param y Define the y component value of the vec3
  77937. * @param z Define the z component value of the vec3
  77938. */
  77939. addFloat3(name: string, x: number, y: number, z: number): void;
  77940. /**
  77941. * Adds a vec3 to the uniform buffer.
  77942. * @param name Name of the uniform, as used in the uniform block in the shader.
  77943. * @param color Define the vec3 from a Color
  77944. */
  77945. addColor3(name: string, color: Color3): void;
  77946. /**
  77947. * Adds a vec4 to the uniform buffer.
  77948. * @param name Name of the uniform, as used in the uniform block in the shader.
  77949. * @param color Define the rgb components from a Color
  77950. * @param alpha Define the a component of the vec4
  77951. */
  77952. addColor4(name: string, color: Color3, alpha: number): void;
  77953. /**
  77954. * Adds a vec3 to the uniform buffer.
  77955. * @param name Name of the uniform, as used in the uniform block in the shader.
  77956. * @param vector Define the vec3 components from a Vector
  77957. */
  77958. addVector3(name: string, vector: Vector3): void;
  77959. /**
  77960. * Adds a Matrix 3x3 to the uniform buffer.
  77961. * @param name Name of the uniform, as used in the uniform block in the shader.
  77962. */
  77963. addMatrix3x3(name: string): void;
  77964. /**
  77965. * Adds a Matrix 2x2 to the uniform buffer.
  77966. * @param name Name of the uniform, as used in the uniform block in the shader.
  77967. */
  77968. addMatrix2x2(name: string): void;
  77969. /**
  77970. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  77971. */
  77972. create(): void;
  77973. /** @hidden */
  77974. _rebuild(): void;
  77975. /**
  77976. * Updates the WebGL Uniform Buffer on the GPU.
  77977. * If the `dynamic` flag is set to true, no cache comparison is done.
  77978. * Otherwise, the buffer will be updated only if the cache differs.
  77979. */
  77980. update(): void;
  77981. /**
  77982. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  77983. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  77984. * @param data Define the flattened data
  77985. * @param size Define the size of the data.
  77986. */
  77987. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  77988. private _valueCache;
  77989. private _cacheMatrix;
  77990. private _updateMatrix3x3ForUniform;
  77991. private _updateMatrix3x3ForEffect;
  77992. private _updateMatrix2x2ForEffect;
  77993. private _updateMatrix2x2ForUniform;
  77994. private _updateFloatForEffect;
  77995. private _updateFloatForUniform;
  77996. private _updateFloat2ForEffect;
  77997. private _updateFloat2ForUniform;
  77998. private _updateFloat3ForEffect;
  77999. private _updateFloat3ForUniform;
  78000. private _updateFloat4ForEffect;
  78001. private _updateFloat4ForUniform;
  78002. private _updateMatrixForEffect;
  78003. private _updateMatrixForUniform;
  78004. private _updateVector3ForEffect;
  78005. private _updateVector3ForUniform;
  78006. private _updateVector4ForEffect;
  78007. private _updateVector4ForUniform;
  78008. private _updateColor3ForEffect;
  78009. private _updateColor3ForUniform;
  78010. private _updateColor4ForEffect;
  78011. private _updateColor4ForUniform;
  78012. /**
  78013. * Sets a sampler uniform on the effect.
  78014. * @param name Define the name of the sampler.
  78015. * @param texture Define the texture to set in the sampler
  78016. */
  78017. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  78018. /**
  78019. * Directly updates the value of the uniform in the cache AND on the GPU.
  78020. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78021. * @param data Define the flattened data
  78022. */
  78023. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  78024. /**
  78025. * Binds this uniform buffer to an effect.
  78026. * @param effect Define the effect to bind the buffer to
  78027. * @param name Name of the uniform block in the shader.
  78028. */
  78029. bindToEffect(effect: Effect, name: string): void;
  78030. /**
  78031. * Disposes the uniform buffer.
  78032. */
  78033. dispose(): void;
  78034. }
  78035. }
  78036. declare module BABYLON {
  78037. /**
  78038. * Enum that determines the text-wrapping mode to use.
  78039. */
  78040. export enum InspectableType {
  78041. /**
  78042. * Checkbox for booleans
  78043. */
  78044. Checkbox = 0,
  78045. /**
  78046. * Sliders for numbers
  78047. */
  78048. Slider = 1,
  78049. /**
  78050. * Vector3
  78051. */
  78052. Vector3 = 2,
  78053. /**
  78054. * Quaternions
  78055. */
  78056. Quaternion = 3,
  78057. /**
  78058. * Color3
  78059. */
  78060. Color3 = 4,
  78061. /**
  78062. * String
  78063. */
  78064. String = 5
  78065. }
  78066. /**
  78067. * Interface used to define custom inspectable properties.
  78068. * This interface is used by the inspector to display custom property grids
  78069. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78070. */
  78071. export interface IInspectable {
  78072. /**
  78073. * Gets the label to display
  78074. */
  78075. label: string;
  78076. /**
  78077. * Gets the name of the property to edit
  78078. */
  78079. propertyName: string;
  78080. /**
  78081. * Gets the type of the editor to use
  78082. */
  78083. type: InspectableType;
  78084. /**
  78085. * Gets the minimum value of the property when using in "slider" mode
  78086. */
  78087. min?: number;
  78088. /**
  78089. * Gets the maximum value of the property when using in "slider" mode
  78090. */
  78091. max?: number;
  78092. /**
  78093. * Gets the setp to use when using in "slider" mode
  78094. */
  78095. step?: number;
  78096. }
  78097. }
  78098. declare module BABYLON {
  78099. /**
  78100. * Class used to provide helper for timing
  78101. */
  78102. export class TimingTools {
  78103. /**
  78104. * Polyfill for setImmediate
  78105. * @param action defines the action to execute after the current execution block
  78106. */
  78107. static SetImmediate(action: () => void): void;
  78108. }
  78109. }
  78110. declare module BABYLON {
  78111. /**
  78112. * Class used to enable instatition of objects by class name
  78113. */
  78114. export class InstantiationTools {
  78115. /**
  78116. * Use this object to register external classes like custom textures or material
  78117. * to allow the laoders to instantiate them
  78118. */
  78119. static RegisteredExternalClasses: {
  78120. [key: string]: Object;
  78121. };
  78122. /**
  78123. * Tries to instantiate a new object from a given class name
  78124. * @param className defines the class name to instantiate
  78125. * @returns the new object or null if the system was not able to do the instantiation
  78126. */
  78127. static Instantiate(className: string): any;
  78128. }
  78129. }
  78130. declare module BABYLON {
  78131. /**
  78132. * Define options used to create a depth texture
  78133. */
  78134. export class DepthTextureCreationOptions {
  78135. /** Specifies whether or not a stencil should be allocated in the texture */
  78136. generateStencil?: boolean;
  78137. /** Specifies whether or not bilinear filtering is enable on the texture */
  78138. bilinearFiltering?: boolean;
  78139. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  78140. comparisonFunction?: number;
  78141. /** Specifies if the created texture is a cube texture */
  78142. isCube?: boolean;
  78143. }
  78144. }
  78145. declare module BABYLON {
  78146. interface ThinEngine {
  78147. /**
  78148. * Creates a depth stencil cube texture.
  78149. * This is only available in WebGL 2.
  78150. * @param size The size of face edge in the cube texture.
  78151. * @param options The options defining the cube texture.
  78152. * @returns The cube texture
  78153. */
  78154. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  78155. /**
  78156. * Creates a cube texture
  78157. * @param rootUrl defines the url where the files to load is located
  78158. * @param scene defines the current scene
  78159. * @param files defines the list of files to load (1 per face)
  78160. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78161. * @param onLoad defines an optional callback raised when the texture is loaded
  78162. * @param onError defines an optional callback raised if there is an issue to load the texture
  78163. * @param format defines the format of the data
  78164. * @param forcedExtension defines the extension to use to pick the right loader
  78165. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78166. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78167. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78168. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  78169. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  78170. * @returns the cube texture as an InternalTexture
  78171. */
  78172. 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;
  78173. /**
  78174. * Creates a cube texture
  78175. * @param rootUrl defines the url where the files to load is located
  78176. * @param scene defines the current scene
  78177. * @param files defines the list of files to load (1 per face)
  78178. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78179. * @param onLoad defines an optional callback raised when the texture is loaded
  78180. * @param onError defines an optional callback raised if there is an issue to load the texture
  78181. * @param format defines the format of the data
  78182. * @param forcedExtension defines the extension to use to pick the right loader
  78183. * @returns the cube texture as an InternalTexture
  78184. */
  78185. 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;
  78186. /**
  78187. * Creates a cube texture
  78188. * @param rootUrl defines the url where the files to load is located
  78189. * @param scene defines the current scene
  78190. * @param files defines the list of files to load (1 per face)
  78191. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78192. * @param onLoad defines an optional callback raised when the texture is loaded
  78193. * @param onError defines an optional callback raised if there is an issue to load the texture
  78194. * @param format defines the format of the data
  78195. * @param forcedExtension defines the extension to use to pick the right loader
  78196. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78197. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78198. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78199. * @returns the cube texture as an InternalTexture
  78200. */
  78201. 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;
  78202. /** @hidden */
  78203. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  78204. /** @hidden */
  78205. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  78206. /** @hidden */
  78207. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78208. /** @hidden */
  78209. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78210. /**
  78211. * @hidden
  78212. */
  78213. _setCubeMapTextureParams(loadMipmap: boolean): void;
  78214. }
  78215. }
  78216. declare module BABYLON {
  78217. /**
  78218. * Class for creating a cube texture
  78219. */
  78220. export class CubeTexture extends BaseTexture {
  78221. private _delayedOnLoad;
  78222. /**
  78223. * The url of the texture
  78224. */
  78225. url: string;
  78226. /**
  78227. * Gets or sets the center of the bounding box associated with the cube texture.
  78228. * It must define where the camera used to render the texture was set
  78229. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78230. */
  78231. boundingBoxPosition: Vector3;
  78232. private _boundingBoxSize;
  78233. /**
  78234. * Gets or sets the size of the bounding box associated with the cube texture
  78235. * When defined, the cubemap will switch to local mode
  78236. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  78237. * @example https://www.babylonjs-playground.com/#RNASML
  78238. */
  78239. set boundingBoxSize(value: Vector3);
  78240. /**
  78241. * Returns the bounding box size
  78242. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78243. */
  78244. get boundingBoxSize(): Vector3;
  78245. protected _rotationY: number;
  78246. /**
  78247. * Sets texture matrix rotation angle around Y axis in radians.
  78248. */
  78249. set rotationY(value: number);
  78250. /**
  78251. * Gets texture matrix rotation angle around Y axis radians.
  78252. */
  78253. get rotationY(): number;
  78254. /**
  78255. * Are mip maps generated for this texture or not.
  78256. */
  78257. get noMipmap(): boolean;
  78258. private _noMipmap;
  78259. private _files;
  78260. protected _forcedExtension: Nullable<string>;
  78261. private _extensions;
  78262. private _textureMatrix;
  78263. private _format;
  78264. private _createPolynomials;
  78265. /** @hidden */
  78266. _prefiltered: boolean;
  78267. /**
  78268. * Creates a cube texture from an array of image urls
  78269. * @param files defines an array of image urls
  78270. * @param scene defines the hosting scene
  78271. * @param noMipmap specifies if mip maps are not used
  78272. * @returns a cube texture
  78273. */
  78274. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  78275. /**
  78276. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  78277. * @param url defines the url of the prefiltered texture
  78278. * @param scene defines the scene the texture is attached to
  78279. * @param forcedExtension defines the extension of the file if different from the url
  78280. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78281. * @return the prefiltered texture
  78282. */
  78283. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  78284. /**
  78285. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  78286. * as prefiltered data.
  78287. * @param rootUrl defines the url of the texture or the root name of the six images
  78288. * @param scene defines the scene the texture is attached to
  78289. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  78290. * @param noMipmap defines if mipmaps should be created or not
  78291. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  78292. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  78293. * @param onError defines a callback triggered in case of error during load
  78294. * @param format defines the internal format to use for the texture once loaded
  78295. * @param prefiltered defines whether or not the texture is created from prefiltered data
  78296. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  78297. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78298. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78299. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78300. * @return the cube texture
  78301. */
  78302. 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);
  78303. /**
  78304. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  78305. */
  78306. get isPrefiltered(): boolean;
  78307. /**
  78308. * Get the current class name of the texture useful for serialization or dynamic coding.
  78309. * @returns "CubeTexture"
  78310. */
  78311. getClassName(): string;
  78312. /**
  78313. * Update the url (and optional buffer) of this texture if url was null during construction.
  78314. * @param url the url of the texture
  78315. * @param forcedExtension defines the extension to use
  78316. * @param onLoad callback called when the texture is loaded (defaults to null)
  78317. */
  78318. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  78319. /**
  78320. * Delays loading of the cube texture
  78321. * @param forcedExtension defines the extension to use
  78322. */
  78323. delayLoad(forcedExtension?: string): void;
  78324. /**
  78325. * Returns the reflection texture matrix
  78326. * @returns the reflection texture matrix
  78327. */
  78328. getReflectionTextureMatrix(): Matrix;
  78329. /**
  78330. * Sets the reflection texture matrix
  78331. * @param value Reflection texture matrix
  78332. */
  78333. setReflectionTextureMatrix(value: Matrix): void;
  78334. /**
  78335. * Parses text to create a cube texture
  78336. * @param parsedTexture define the serialized text to read from
  78337. * @param scene defines the hosting scene
  78338. * @param rootUrl defines the root url of the cube texture
  78339. * @returns a cube texture
  78340. */
  78341. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  78342. /**
  78343. * Makes a clone, or deep copy, of the cube texture
  78344. * @returns a new cube texture
  78345. */
  78346. clone(): CubeTexture;
  78347. }
  78348. }
  78349. declare module BABYLON {
  78350. /**
  78351. * Manages the defines for the Material
  78352. */
  78353. export class MaterialDefines {
  78354. /** @hidden */
  78355. protected _keys: string[];
  78356. private _isDirty;
  78357. /** @hidden */
  78358. _renderId: number;
  78359. /** @hidden */
  78360. _areLightsDirty: boolean;
  78361. /** @hidden */
  78362. _areLightsDisposed: boolean;
  78363. /** @hidden */
  78364. _areAttributesDirty: boolean;
  78365. /** @hidden */
  78366. _areTexturesDirty: boolean;
  78367. /** @hidden */
  78368. _areFresnelDirty: boolean;
  78369. /** @hidden */
  78370. _areMiscDirty: boolean;
  78371. /** @hidden */
  78372. _areImageProcessingDirty: boolean;
  78373. /** @hidden */
  78374. _normals: boolean;
  78375. /** @hidden */
  78376. _uvs: boolean;
  78377. /** @hidden */
  78378. _needNormals: boolean;
  78379. /** @hidden */
  78380. _needUVs: boolean;
  78381. [id: string]: any;
  78382. /**
  78383. * Specifies if the material needs to be re-calculated
  78384. */
  78385. get isDirty(): boolean;
  78386. /**
  78387. * Marks the material to indicate that it has been re-calculated
  78388. */
  78389. markAsProcessed(): void;
  78390. /**
  78391. * Marks the material to indicate that it needs to be re-calculated
  78392. */
  78393. markAsUnprocessed(): void;
  78394. /**
  78395. * Marks the material to indicate all of its defines need to be re-calculated
  78396. */
  78397. markAllAsDirty(): void;
  78398. /**
  78399. * Marks the material to indicate that image processing needs to be re-calculated
  78400. */
  78401. markAsImageProcessingDirty(): void;
  78402. /**
  78403. * Marks the material to indicate the lights need to be re-calculated
  78404. * @param disposed Defines whether the light is dirty due to dispose or not
  78405. */
  78406. markAsLightDirty(disposed?: boolean): void;
  78407. /**
  78408. * Marks the attribute state as changed
  78409. */
  78410. markAsAttributesDirty(): void;
  78411. /**
  78412. * Marks the texture state as changed
  78413. */
  78414. markAsTexturesDirty(): void;
  78415. /**
  78416. * Marks the fresnel state as changed
  78417. */
  78418. markAsFresnelDirty(): void;
  78419. /**
  78420. * Marks the misc state as changed
  78421. */
  78422. markAsMiscDirty(): void;
  78423. /**
  78424. * Rebuilds the material defines
  78425. */
  78426. rebuild(): void;
  78427. /**
  78428. * Specifies if two material defines are equal
  78429. * @param other - A material define instance to compare to
  78430. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  78431. */
  78432. isEqual(other: MaterialDefines): boolean;
  78433. /**
  78434. * Clones this instance's defines to another instance
  78435. * @param other - material defines to clone values to
  78436. */
  78437. cloneTo(other: MaterialDefines): void;
  78438. /**
  78439. * Resets the material define values
  78440. */
  78441. reset(): void;
  78442. /**
  78443. * Converts the material define values to a string
  78444. * @returns - String of material define information
  78445. */
  78446. toString(): string;
  78447. }
  78448. }
  78449. declare module BABYLON {
  78450. /**
  78451. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  78452. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  78453. * 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;
  78454. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  78455. */
  78456. export class ColorCurves {
  78457. private _dirty;
  78458. private _tempColor;
  78459. private _globalCurve;
  78460. private _highlightsCurve;
  78461. private _midtonesCurve;
  78462. private _shadowsCurve;
  78463. private _positiveCurve;
  78464. private _negativeCurve;
  78465. private _globalHue;
  78466. private _globalDensity;
  78467. private _globalSaturation;
  78468. private _globalExposure;
  78469. /**
  78470. * Gets the global Hue value.
  78471. * 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).
  78472. */
  78473. get globalHue(): number;
  78474. /**
  78475. * Sets the global Hue value.
  78476. * 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).
  78477. */
  78478. set globalHue(value: number);
  78479. /**
  78480. * Gets the global Density value.
  78481. * 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.
  78482. * Values less than zero provide a filter of opposite hue.
  78483. */
  78484. get globalDensity(): number;
  78485. /**
  78486. * Sets the global Density value.
  78487. * 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.
  78488. * Values less than zero provide a filter of opposite hue.
  78489. */
  78490. set globalDensity(value: number);
  78491. /**
  78492. * Gets the global Saturation value.
  78493. * 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.
  78494. */
  78495. get globalSaturation(): number;
  78496. /**
  78497. * Sets the global Saturation value.
  78498. * 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.
  78499. */
  78500. set globalSaturation(value: number);
  78501. /**
  78502. * Gets the global Exposure value.
  78503. * 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.
  78504. */
  78505. get globalExposure(): number;
  78506. /**
  78507. * Sets the global Exposure value.
  78508. * 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.
  78509. */
  78510. set globalExposure(value: number);
  78511. private _highlightsHue;
  78512. private _highlightsDensity;
  78513. private _highlightsSaturation;
  78514. private _highlightsExposure;
  78515. /**
  78516. * Gets the highlights Hue value.
  78517. * 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).
  78518. */
  78519. get highlightsHue(): number;
  78520. /**
  78521. * Sets the highlights Hue value.
  78522. * 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).
  78523. */
  78524. set highlightsHue(value: number);
  78525. /**
  78526. * Gets the highlights Density value.
  78527. * 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.
  78528. * Values less than zero provide a filter of opposite hue.
  78529. */
  78530. get highlightsDensity(): number;
  78531. /**
  78532. * Sets the highlights Density value.
  78533. * 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.
  78534. * Values less than zero provide a filter of opposite hue.
  78535. */
  78536. set highlightsDensity(value: number);
  78537. /**
  78538. * Gets the highlights Saturation value.
  78539. * 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.
  78540. */
  78541. get highlightsSaturation(): number;
  78542. /**
  78543. * Sets the highlights Saturation value.
  78544. * 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.
  78545. */
  78546. set highlightsSaturation(value: number);
  78547. /**
  78548. * Gets the highlights Exposure value.
  78549. * 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.
  78550. */
  78551. get highlightsExposure(): number;
  78552. /**
  78553. * Sets the highlights Exposure value.
  78554. * 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.
  78555. */
  78556. set highlightsExposure(value: number);
  78557. private _midtonesHue;
  78558. private _midtonesDensity;
  78559. private _midtonesSaturation;
  78560. private _midtonesExposure;
  78561. /**
  78562. * Gets the midtones Hue value.
  78563. * 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).
  78564. */
  78565. get midtonesHue(): number;
  78566. /**
  78567. * Sets the midtones Hue value.
  78568. * 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).
  78569. */
  78570. set midtonesHue(value: number);
  78571. /**
  78572. * Gets the midtones Density value.
  78573. * 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.
  78574. * Values less than zero provide a filter of opposite hue.
  78575. */
  78576. get midtonesDensity(): number;
  78577. /**
  78578. * Sets the midtones Density value.
  78579. * 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.
  78580. * Values less than zero provide a filter of opposite hue.
  78581. */
  78582. set midtonesDensity(value: number);
  78583. /**
  78584. * Gets the midtones Saturation value.
  78585. * 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.
  78586. */
  78587. get midtonesSaturation(): number;
  78588. /**
  78589. * Sets the midtones Saturation value.
  78590. * 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.
  78591. */
  78592. set midtonesSaturation(value: number);
  78593. /**
  78594. * Gets the midtones Exposure value.
  78595. * 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.
  78596. */
  78597. get midtonesExposure(): number;
  78598. /**
  78599. * Sets the midtones Exposure value.
  78600. * 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.
  78601. */
  78602. set midtonesExposure(value: number);
  78603. private _shadowsHue;
  78604. private _shadowsDensity;
  78605. private _shadowsSaturation;
  78606. private _shadowsExposure;
  78607. /**
  78608. * Gets the shadows Hue value.
  78609. * 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).
  78610. */
  78611. get shadowsHue(): number;
  78612. /**
  78613. * Sets the shadows Hue value.
  78614. * 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).
  78615. */
  78616. set shadowsHue(value: number);
  78617. /**
  78618. * Gets the shadows Density value.
  78619. * 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.
  78620. * Values less than zero provide a filter of opposite hue.
  78621. */
  78622. get shadowsDensity(): number;
  78623. /**
  78624. * Sets the shadows Density value.
  78625. * 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.
  78626. * Values less than zero provide a filter of opposite hue.
  78627. */
  78628. set shadowsDensity(value: number);
  78629. /**
  78630. * Gets the shadows Saturation value.
  78631. * 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.
  78632. */
  78633. get shadowsSaturation(): number;
  78634. /**
  78635. * Sets the shadows Saturation value.
  78636. * 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.
  78637. */
  78638. set shadowsSaturation(value: number);
  78639. /**
  78640. * Gets the shadows Exposure value.
  78641. * 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.
  78642. */
  78643. get shadowsExposure(): number;
  78644. /**
  78645. * Sets the shadows Exposure value.
  78646. * 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.
  78647. */
  78648. set shadowsExposure(value: number);
  78649. /**
  78650. * Returns the class name
  78651. * @returns The class name
  78652. */
  78653. getClassName(): string;
  78654. /**
  78655. * Binds the color curves to the shader.
  78656. * @param colorCurves The color curve to bind
  78657. * @param effect The effect to bind to
  78658. * @param positiveUniform The positive uniform shader parameter
  78659. * @param neutralUniform The neutral uniform shader parameter
  78660. * @param negativeUniform The negative uniform shader parameter
  78661. */
  78662. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  78663. /**
  78664. * Prepare the list of uniforms associated with the ColorCurves effects.
  78665. * @param uniformsList The list of uniforms used in the effect
  78666. */
  78667. static PrepareUniforms(uniformsList: string[]): void;
  78668. /**
  78669. * Returns color grading data based on a hue, density, saturation and exposure value.
  78670. * @param filterHue The hue of the color filter.
  78671. * @param filterDensity The density of the color filter.
  78672. * @param saturation The saturation.
  78673. * @param exposure The exposure.
  78674. * @param result The result data container.
  78675. */
  78676. private getColorGradingDataToRef;
  78677. /**
  78678. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  78679. * @param value The input slider value in range [-100,100].
  78680. * @returns Adjusted value.
  78681. */
  78682. private static applyColorGradingSliderNonlinear;
  78683. /**
  78684. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  78685. * @param hue The hue (H) input.
  78686. * @param saturation The saturation (S) input.
  78687. * @param brightness The brightness (B) input.
  78688. * @result An RGBA color represented as Vector4.
  78689. */
  78690. private static fromHSBToRef;
  78691. /**
  78692. * Returns a value clamped between min and max
  78693. * @param value The value to clamp
  78694. * @param min The minimum of value
  78695. * @param max The maximum of value
  78696. * @returns The clamped value.
  78697. */
  78698. private static clamp;
  78699. /**
  78700. * Clones the current color curve instance.
  78701. * @return The cloned curves
  78702. */
  78703. clone(): ColorCurves;
  78704. /**
  78705. * Serializes the current color curve instance to a json representation.
  78706. * @return a JSON representation
  78707. */
  78708. serialize(): any;
  78709. /**
  78710. * Parses the color curve from a json representation.
  78711. * @param source the JSON source to parse
  78712. * @return The parsed curves
  78713. */
  78714. static Parse(source: any): ColorCurves;
  78715. }
  78716. }
  78717. declare module BABYLON {
  78718. /**
  78719. * Interface to follow in your material defines to integrate easily the
  78720. * Image proccessing functions.
  78721. * @hidden
  78722. */
  78723. export interface IImageProcessingConfigurationDefines {
  78724. IMAGEPROCESSING: boolean;
  78725. VIGNETTE: boolean;
  78726. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78727. VIGNETTEBLENDMODEOPAQUE: boolean;
  78728. TONEMAPPING: boolean;
  78729. TONEMAPPING_ACES: boolean;
  78730. CONTRAST: boolean;
  78731. EXPOSURE: boolean;
  78732. COLORCURVES: boolean;
  78733. COLORGRADING: boolean;
  78734. COLORGRADING3D: boolean;
  78735. SAMPLER3DGREENDEPTH: boolean;
  78736. SAMPLER3DBGRMAP: boolean;
  78737. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78738. }
  78739. /**
  78740. * @hidden
  78741. */
  78742. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  78743. IMAGEPROCESSING: boolean;
  78744. VIGNETTE: boolean;
  78745. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78746. VIGNETTEBLENDMODEOPAQUE: boolean;
  78747. TONEMAPPING: boolean;
  78748. TONEMAPPING_ACES: boolean;
  78749. CONTRAST: boolean;
  78750. COLORCURVES: boolean;
  78751. COLORGRADING: boolean;
  78752. COLORGRADING3D: boolean;
  78753. SAMPLER3DGREENDEPTH: boolean;
  78754. SAMPLER3DBGRMAP: boolean;
  78755. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78756. EXPOSURE: boolean;
  78757. constructor();
  78758. }
  78759. /**
  78760. * This groups together the common properties used for image processing either in direct forward pass
  78761. * or through post processing effect depending on the use of the image processing pipeline in your scene
  78762. * or not.
  78763. */
  78764. export class ImageProcessingConfiguration {
  78765. /**
  78766. * Default tone mapping applied in BabylonJS.
  78767. */
  78768. static readonly TONEMAPPING_STANDARD: number;
  78769. /**
  78770. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  78771. * to other engines rendering to increase portability.
  78772. */
  78773. static readonly TONEMAPPING_ACES: number;
  78774. /**
  78775. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  78776. */
  78777. colorCurves: Nullable<ColorCurves>;
  78778. private _colorCurvesEnabled;
  78779. /**
  78780. * Gets wether the color curves effect is enabled.
  78781. */
  78782. get colorCurvesEnabled(): boolean;
  78783. /**
  78784. * Sets wether the color curves effect is enabled.
  78785. */
  78786. set colorCurvesEnabled(value: boolean);
  78787. private _colorGradingTexture;
  78788. /**
  78789. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78790. */
  78791. get colorGradingTexture(): Nullable<BaseTexture>;
  78792. /**
  78793. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78794. */
  78795. set colorGradingTexture(value: Nullable<BaseTexture>);
  78796. private _colorGradingEnabled;
  78797. /**
  78798. * Gets wether the color grading effect is enabled.
  78799. */
  78800. get colorGradingEnabled(): boolean;
  78801. /**
  78802. * Sets wether the color grading effect is enabled.
  78803. */
  78804. set colorGradingEnabled(value: boolean);
  78805. private _colorGradingWithGreenDepth;
  78806. /**
  78807. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  78808. */
  78809. get colorGradingWithGreenDepth(): boolean;
  78810. /**
  78811. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  78812. */
  78813. set colorGradingWithGreenDepth(value: boolean);
  78814. private _colorGradingBGR;
  78815. /**
  78816. * Gets wether the color grading texture contains BGR values.
  78817. */
  78818. get colorGradingBGR(): boolean;
  78819. /**
  78820. * Sets wether the color grading texture contains BGR values.
  78821. */
  78822. set colorGradingBGR(value: boolean);
  78823. /** @hidden */
  78824. _exposure: number;
  78825. /**
  78826. * Gets the Exposure used in the effect.
  78827. */
  78828. get exposure(): number;
  78829. /**
  78830. * Sets the Exposure used in the effect.
  78831. */
  78832. set exposure(value: number);
  78833. private _toneMappingEnabled;
  78834. /**
  78835. * Gets wether the tone mapping effect is enabled.
  78836. */
  78837. get toneMappingEnabled(): boolean;
  78838. /**
  78839. * Sets wether the tone mapping effect is enabled.
  78840. */
  78841. set toneMappingEnabled(value: boolean);
  78842. private _toneMappingType;
  78843. /**
  78844. * Gets the type of tone mapping effect.
  78845. */
  78846. get toneMappingType(): number;
  78847. /**
  78848. * Sets the type of tone mapping effect used in BabylonJS.
  78849. */
  78850. set toneMappingType(value: number);
  78851. protected _contrast: number;
  78852. /**
  78853. * Gets the contrast used in the effect.
  78854. */
  78855. get contrast(): number;
  78856. /**
  78857. * Sets the contrast used in the effect.
  78858. */
  78859. set contrast(value: number);
  78860. /**
  78861. * Vignette stretch size.
  78862. */
  78863. vignetteStretch: number;
  78864. /**
  78865. * Vignette centre X Offset.
  78866. */
  78867. vignetteCentreX: number;
  78868. /**
  78869. * Vignette centre Y Offset.
  78870. */
  78871. vignetteCentreY: number;
  78872. /**
  78873. * Vignette weight or intensity of the vignette effect.
  78874. */
  78875. vignetteWeight: number;
  78876. /**
  78877. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  78878. * if vignetteEnabled is set to true.
  78879. */
  78880. vignetteColor: Color4;
  78881. /**
  78882. * Camera field of view used by the Vignette effect.
  78883. */
  78884. vignetteCameraFov: number;
  78885. private _vignetteBlendMode;
  78886. /**
  78887. * Gets the vignette blend mode allowing different kind of effect.
  78888. */
  78889. get vignetteBlendMode(): number;
  78890. /**
  78891. * Sets the vignette blend mode allowing different kind of effect.
  78892. */
  78893. set vignetteBlendMode(value: number);
  78894. private _vignetteEnabled;
  78895. /**
  78896. * Gets wether the vignette effect is enabled.
  78897. */
  78898. get vignetteEnabled(): boolean;
  78899. /**
  78900. * Sets wether the vignette effect is enabled.
  78901. */
  78902. set vignetteEnabled(value: boolean);
  78903. private _applyByPostProcess;
  78904. /**
  78905. * Gets wether the image processing is applied through a post process or not.
  78906. */
  78907. get applyByPostProcess(): boolean;
  78908. /**
  78909. * Sets wether the image processing is applied through a post process or not.
  78910. */
  78911. set applyByPostProcess(value: boolean);
  78912. private _isEnabled;
  78913. /**
  78914. * Gets wether the image processing is enabled or not.
  78915. */
  78916. get isEnabled(): boolean;
  78917. /**
  78918. * Sets wether the image processing is enabled or not.
  78919. */
  78920. set isEnabled(value: boolean);
  78921. /**
  78922. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  78923. */
  78924. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  78925. /**
  78926. * Method called each time the image processing information changes requires to recompile the effect.
  78927. */
  78928. protected _updateParameters(): void;
  78929. /**
  78930. * Gets the current class name.
  78931. * @return "ImageProcessingConfiguration"
  78932. */
  78933. getClassName(): string;
  78934. /**
  78935. * Prepare the list of uniforms associated with the Image Processing effects.
  78936. * @param uniforms The list of uniforms used in the effect
  78937. * @param defines the list of defines currently in use
  78938. */
  78939. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  78940. /**
  78941. * Prepare the list of samplers associated with the Image Processing effects.
  78942. * @param samplersList The list of uniforms used in the effect
  78943. * @param defines the list of defines currently in use
  78944. */
  78945. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  78946. /**
  78947. * Prepare the list of defines associated to the shader.
  78948. * @param defines the list of defines to complete
  78949. * @param forPostProcess Define if we are currently in post process mode or not
  78950. */
  78951. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  78952. /**
  78953. * Returns true if all the image processing information are ready.
  78954. * @returns True if ready, otherwise, false
  78955. */
  78956. isReady(): boolean;
  78957. /**
  78958. * Binds the image processing to the shader.
  78959. * @param effect The effect to bind to
  78960. * @param overrideAspectRatio Override the aspect ratio of the effect
  78961. */
  78962. bind(effect: Effect, overrideAspectRatio?: number): void;
  78963. /**
  78964. * Clones the current image processing instance.
  78965. * @return The cloned image processing
  78966. */
  78967. clone(): ImageProcessingConfiguration;
  78968. /**
  78969. * Serializes the current image processing instance to a json representation.
  78970. * @return a JSON representation
  78971. */
  78972. serialize(): any;
  78973. /**
  78974. * Parses the image processing from a json representation.
  78975. * @param source the JSON source to parse
  78976. * @return The parsed image processing
  78977. */
  78978. static Parse(source: any): ImageProcessingConfiguration;
  78979. private static _VIGNETTEMODE_MULTIPLY;
  78980. private static _VIGNETTEMODE_OPAQUE;
  78981. /**
  78982. * Used to apply the vignette as a mix with the pixel color.
  78983. */
  78984. static get VIGNETTEMODE_MULTIPLY(): number;
  78985. /**
  78986. * Used to apply the vignette as a replacement of the pixel color.
  78987. */
  78988. static get VIGNETTEMODE_OPAQUE(): number;
  78989. }
  78990. }
  78991. declare module BABYLON {
  78992. /** @hidden */
  78993. export var postprocessVertexShader: {
  78994. name: string;
  78995. shader: string;
  78996. };
  78997. }
  78998. declare module BABYLON {
  78999. interface ThinEngine {
  79000. /**
  79001. * Creates a new render target texture
  79002. * @param size defines the size of the texture
  79003. * @param options defines the options used to create the texture
  79004. * @returns a new render target texture stored in an InternalTexture
  79005. */
  79006. createRenderTargetTexture(size: number | {
  79007. width: number;
  79008. height: number;
  79009. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  79010. /**
  79011. * Creates a depth stencil texture.
  79012. * This is only available in WebGL 2 or with the depth texture extension available.
  79013. * @param size The size of face edge in the texture.
  79014. * @param options The options defining the texture.
  79015. * @returns The texture
  79016. */
  79017. createDepthStencilTexture(size: number | {
  79018. width: number;
  79019. height: number;
  79020. }, options: DepthTextureCreationOptions): InternalTexture;
  79021. /** @hidden */
  79022. _createDepthStencilTexture(size: number | {
  79023. width: number;
  79024. height: number;
  79025. }, options: DepthTextureCreationOptions): InternalTexture;
  79026. }
  79027. }
  79028. declare module BABYLON {
  79029. /** Defines supported spaces */
  79030. export enum Space {
  79031. /** Local (object) space */
  79032. LOCAL = 0,
  79033. /** World space */
  79034. WORLD = 1,
  79035. /** Bone space */
  79036. BONE = 2
  79037. }
  79038. /** Defines the 3 main axes */
  79039. export class Axis {
  79040. /** X axis */
  79041. static X: Vector3;
  79042. /** Y axis */
  79043. static Y: Vector3;
  79044. /** Z axis */
  79045. static Z: Vector3;
  79046. }
  79047. }
  79048. declare module BABYLON {
  79049. /**
  79050. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  79051. * This is the base of the follow, arc rotate cameras and Free camera
  79052. * @see http://doc.babylonjs.com/features/cameras
  79053. */
  79054. export class TargetCamera extends Camera {
  79055. private static _RigCamTransformMatrix;
  79056. private static _TargetTransformMatrix;
  79057. private static _TargetFocalPoint;
  79058. /**
  79059. * Define the current direction the camera is moving to
  79060. */
  79061. cameraDirection: Vector3;
  79062. /**
  79063. * Define the current rotation the camera is rotating to
  79064. */
  79065. cameraRotation: Vector2;
  79066. /**
  79067. * When set, the up vector of the camera will be updated by the rotation of the camera
  79068. */
  79069. updateUpVectorFromRotation: boolean;
  79070. private _tmpQuaternion;
  79071. /**
  79072. * Define the current rotation of the camera
  79073. */
  79074. rotation: Vector3;
  79075. /**
  79076. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  79077. */
  79078. rotationQuaternion: Quaternion;
  79079. /**
  79080. * Define the current speed of the camera
  79081. */
  79082. speed: number;
  79083. /**
  79084. * Add constraint to the camera to prevent it to move freely in all directions and
  79085. * around all axis.
  79086. */
  79087. noRotationConstraint: boolean;
  79088. /**
  79089. * Define the current target of the camera as an object or a position.
  79090. */
  79091. lockedTarget: any;
  79092. /** @hidden */
  79093. _currentTarget: Vector3;
  79094. /** @hidden */
  79095. _initialFocalDistance: number;
  79096. /** @hidden */
  79097. _viewMatrix: Matrix;
  79098. /** @hidden */
  79099. _camMatrix: Matrix;
  79100. /** @hidden */
  79101. _cameraTransformMatrix: Matrix;
  79102. /** @hidden */
  79103. _cameraRotationMatrix: Matrix;
  79104. /** @hidden */
  79105. _referencePoint: Vector3;
  79106. /** @hidden */
  79107. _transformedReferencePoint: Vector3;
  79108. protected _globalCurrentTarget: Vector3;
  79109. protected _globalCurrentUpVector: Vector3;
  79110. /** @hidden */
  79111. _reset: () => void;
  79112. private _defaultUp;
  79113. /**
  79114. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  79115. * This is the base of the follow, arc rotate cameras and Free camera
  79116. * @see http://doc.babylonjs.com/features/cameras
  79117. * @param name Defines the name of the camera in the scene
  79118. * @param position Defines the start position of the camera in the scene
  79119. * @param scene Defines the scene the camera belongs to
  79120. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79121. */
  79122. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79123. /**
  79124. * Gets the position in front of the camera at a given distance.
  79125. * @param distance The distance from the camera we want the position to be
  79126. * @returns the position
  79127. */
  79128. getFrontPosition(distance: number): Vector3;
  79129. /** @hidden */
  79130. _getLockedTargetPosition(): Nullable<Vector3>;
  79131. private _storedPosition;
  79132. private _storedRotation;
  79133. private _storedRotationQuaternion;
  79134. /**
  79135. * Store current camera state of the camera (fov, position, rotation, etc..)
  79136. * @returns the camera
  79137. */
  79138. storeState(): Camera;
  79139. /**
  79140. * Restored camera state. You must call storeState() first
  79141. * @returns whether it was successful or not
  79142. * @hidden
  79143. */
  79144. _restoreStateValues(): boolean;
  79145. /** @hidden */
  79146. _initCache(): void;
  79147. /** @hidden */
  79148. _updateCache(ignoreParentClass?: boolean): void;
  79149. /** @hidden */
  79150. _isSynchronizedViewMatrix(): boolean;
  79151. /** @hidden */
  79152. _computeLocalCameraSpeed(): number;
  79153. /**
  79154. * Defines the target the camera should look at.
  79155. * @param target Defines the new target as a Vector or a mesh
  79156. */
  79157. setTarget(target: Vector3): void;
  79158. /**
  79159. * Return the current target position of the camera. This value is expressed in local space.
  79160. * @returns the target position
  79161. */
  79162. getTarget(): Vector3;
  79163. /** @hidden */
  79164. _decideIfNeedsToMove(): boolean;
  79165. /** @hidden */
  79166. _updatePosition(): void;
  79167. /** @hidden */
  79168. _checkInputs(): void;
  79169. protected _updateCameraRotationMatrix(): void;
  79170. /**
  79171. * 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)
  79172. * @returns the current camera
  79173. */
  79174. private _rotateUpVectorWithCameraRotationMatrix;
  79175. private _cachedRotationZ;
  79176. private _cachedQuaternionRotationZ;
  79177. /** @hidden */
  79178. _getViewMatrix(): Matrix;
  79179. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  79180. /**
  79181. * @hidden
  79182. */
  79183. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  79184. /**
  79185. * @hidden
  79186. */
  79187. _updateRigCameras(): void;
  79188. private _getRigCamPositionAndTarget;
  79189. /**
  79190. * Gets the current object class name.
  79191. * @return the class name
  79192. */
  79193. getClassName(): string;
  79194. }
  79195. }
  79196. declare module BABYLON {
  79197. /**
  79198. * Gather the list of keyboard event types as constants.
  79199. */
  79200. export class KeyboardEventTypes {
  79201. /**
  79202. * The keydown event is fired when a key becomes active (pressed).
  79203. */
  79204. static readonly KEYDOWN: number;
  79205. /**
  79206. * The keyup event is fired when a key has been released.
  79207. */
  79208. static readonly KEYUP: number;
  79209. }
  79210. /**
  79211. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79212. */
  79213. export class KeyboardInfo {
  79214. /**
  79215. * Defines the type of event (KeyboardEventTypes)
  79216. */
  79217. type: number;
  79218. /**
  79219. * Defines the related dom event
  79220. */
  79221. event: KeyboardEvent;
  79222. /**
  79223. * Instantiates a new keyboard info.
  79224. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79225. * @param type Defines the type of event (KeyboardEventTypes)
  79226. * @param event Defines the related dom event
  79227. */
  79228. constructor(
  79229. /**
  79230. * Defines the type of event (KeyboardEventTypes)
  79231. */
  79232. type: number,
  79233. /**
  79234. * Defines the related dom event
  79235. */
  79236. event: KeyboardEvent);
  79237. }
  79238. /**
  79239. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79240. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  79241. */
  79242. export class KeyboardInfoPre extends KeyboardInfo {
  79243. /**
  79244. * Defines the type of event (KeyboardEventTypes)
  79245. */
  79246. type: number;
  79247. /**
  79248. * Defines the related dom event
  79249. */
  79250. event: KeyboardEvent;
  79251. /**
  79252. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  79253. */
  79254. skipOnPointerObservable: boolean;
  79255. /**
  79256. * Instantiates a new keyboard pre info.
  79257. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79258. * @param type Defines the type of event (KeyboardEventTypes)
  79259. * @param event Defines the related dom event
  79260. */
  79261. constructor(
  79262. /**
  79263. * Defines the type of event (KeyboardEventTypes)
  79264. */
  79265. type: number,
  79266. /**
  79267. * Defines the related dom event
  79268. */
  79269. event: KeyboardEvent);
  79270. }
  79271. }
  79272. declare module BABYLON {
  79273. /**
  79274. * Manage the keyboard inputs to control the movement of a free camera.
  79275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79276. */
  79277. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  79278. /**
  79279. * Defines the camera the input is attached to.
  79280. */
  79281. camera: FreeCamera;
  79282. /**
  79283. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79284. */
  79285. keysUp: number[];
  79286. /**
  79287. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79288. */
  79289. keysDown: number[];
  79290. /**
  79291. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79292. */
  79293. keysLeft: number[];
  79294. /**
  79295. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79296. */
  79297. keysRight: number[];
  79298. private _keys;
  79299. private _onCanvasBlurObserver;
  79300. private _onKeyboardObserver;
  79301. private _engine;
  79302. private _scene;
  79303. /**
  79304. * Attach the input controls to a specific dom element to get the input from.
  79305. * @param element Defines the element the controls should be listened from
  79306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79307. */
  79308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79309. /**
  79310. * Detach the current controls from the specified dom element.
  79311. * @param element Defines the element to stop listening the inputs from
  79312. */
  79313. detachControl(element: Nullable<HTMLElement>): void;
  79314. /**
  79315. * Update the current camera state depending on the inputs that have been used this frame.
  79316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79317. */
  79318. checkInputs(): void;
  79319. /**
  79320. * Gets the class name of the current intput.
  79321. * @returns the class name
  79322. */
  79323. getClassName(): string;
  79324. /** @hidden */
  79325. _onLostFocus(): void;
  79326. /**
  79327. * Get the friendly name associated with the input class.
  79328. * @returns the input friendly name
  79329. */
  79330. getSimpleName(): string;
  79331. }
  79332. }
  79333. declare module BABYLON {
  79334. /**
  79335. * Interface describing all the common properties and methods a shadow light needs to implement.
  79336. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  79337. * as well as binding the different shadow properties to the effects.
  79338. */
  79339. export interface IShadowLight extends Light {
  79340. /**
  79341. * The light id in the scene (used in scene.findLighById for instance)
  79342. */
  79343. id: string;
  79344. /**
  79345. * The position the shdow will be casted from.
  79346. */
  79347. position: Vector3;
  79348. /**
  79349. * In 2d mode (needCube being false), the direction used to cast the shadow.
  79350. */
  79351. direction: Vector3;
  79352. /**
  79353. * The transformed position. Position of the light in world space taking parenting in account.
  79354. */
  79355. transformedPosition: Vector3;
  79356. /**
  79357. * The transformed direction. Direction of the light in world space taking parenting in account.
  79358. */
  79359. transformedDirection: Vector3;
  79360. /**
  79361. * The friendly name of the light in the scene.
  79362. */
  79363. name: string;
  79364. /**
  79365. * Defines the shadow projection clipping minimum z value.
  79366. */
  79367. shadowMinZ: number;
  79368. /**
  79369. * Defines the shadow projection clipping maximum z value.
  79370. */
  79371. shadowMaxZ: number;
  79372. /**
  79373. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79374. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79375. */
  79376. computeTransformedInformation(): boolean;
  79377. /**
  79378. * Gets the scene the light belongs to.
  79379. * @returns The scene
  79380. */
  79381. getScene(): Scene;
  79382. /**
  79383. * Callback defining a custom Projection Matrix Builder.
  79384. * This can be used to override the default projection matrix computation.
  79385. */
  79386. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79387. /**
  79388. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79389. * @param matrix The materix to updated with the projection information
  79390. * @param viewMatrix The transform matrix of the light
  79391. * @param renderList The list of mesh to render in the map
  79392. * @returns The current light
  79393. */
  79394. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79395. /**
  79396. * Gets the current depth scale used in ESM.
  79397. * @returns The scale
  79398. */
  79399. getDepthScale(): number;
  79400. /**
  79401. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79402. * @returns true if a cube texture needs to be use
  79403. */
  79404. needCube(): boolean;
  79405. /**
  79406. * Detects if the projection matrix requires to be recomputed this frame.
  79407. * @returns true if it requires to be recomputed otherwise, false.
  79408. */
  79409. needProjectionMatrixCompute(): boolean;
  79410. /**
  79411. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79412. */
  79413. forceProjectionMatrixCompute(): void;
  79414. /**
  79415. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79416. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79417. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79418. */
  79419. getShadowDirection(faceIndex?: number): Vector3;
  79420. /**
  79421. * Gets the minZ used for shadow according to both the scene and the light.
  79422. * @param activeCamera The camera we are returning the min for
  79423. * @returns the depth min z
  79424. */
  79425. getDepthMinZ(activeCamera: Camera): number;
  79426. /**
  79427. * Gets the maxZ used for shadow according to both the scene and the light.
  79428. * @param activeCamera The camera we are returning the max for
  79429. * @returns the depth max z
  79430. */
  79431. getDepthMaxZ(activeCamera: Camera): number;
  79432. }
  79433. /**
  79434. * Base implementation IShadowLight
  79435. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  79436. */
  79437. export abstract class ShadowLight extends Light implements IShadowLight {
  79438. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  79439. protected _position: Vector3;
  79440. protected _setPosition(value: Vector3): void;
  79441. /**
  79442. * Sets the position the shadow will be casted from. Also use as the light position for both
  79443. * point and spot lights.
  79444. */
  79445. get position(): Vector3;
  79446. /**
  79447. * Sets the position the shadow will be casted from. Also use as the light position for both
  79448. * point and spot lights.
  79449. */
  79450. set position(value: Vector3);
  79451. protected _direction: Vector3;
  79452. protected _setDirection(value: Vector3): void;
  79453. /**
  79454. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  79455. * Also use as the light direction on spot and directional lights.
  79456. */
  79457. get direction(): Vector3;
  79458. /**
  79459. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  79460. * Also use as the light direction on spot and directional lights.
  79461. */
  79462. set direction(value: Vector3);
  79463. private _shadowMinZ;
  79464. /**
  79465. * Gets the shadow projection clipping minimum z value.
  79466. */
  79467. get shadowMinZ(): number;
  79468. /**
  79469. * Sets the shadow projection clipping minimum z value.
  79470. */
  79471. set shadowMinZ(value: number);
  79472. private _shadowMaxZ;
  79473. /**
  79474. * Sets the shadow projection clipping maximum z value.
  79475. */
  79476. get shadowMaxZ(): number;
  79477. /**
  79478. * Gets the shadow projection clipping maximum z value.
  79479. */
  79480. set shadowMaxZ(value: number);
  79481. /**
  79482. * Callback defining a custom Projection Matrix Builder.
  79483. * This can be used to override the default projection matrix computation.
  79484. */
  79485. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79486. /**
  79487. * The transformed position. Position of the light in world space taking parenting in account.
  79488. */
  79489. transformedPosition: Vector3;
  79490. /**
  79491. * The transformed direction. Direction of the light in world space taking parenting in account.
  79492. */
  79493. transformedDirection: Vector3;
  79494. private _needProjectionMatrixCompute;
  79495. /**
  79496. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79497. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79498. */
  79499. computeTransformedInformation(): boolean;
  79500. /**
  79501. * Return the depth scale used for the shadow map.
  79502. * @returns the depth scale.
  79503. */
  79504. getDepthScale(): number;
  79505. /**
  79506. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79507. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79508. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79509. */
  79510. getShadowDirection(faceIndex?: number): Vector3;
  79511. /**
  79512. * Returns the ShadowLight absolute position in the World.
  79513. * @returns the position vector in world space
  79514. */
  79515. getAbsolutePosition(): Vector3;
  79516. /**
  79517. * Sets the ShadowLight direction toward the passed target.
  79518. * @param target The point to target in local space
  79519. * @returns the updated ShadowLight direction
  79520. */
  79521. setDirectionToTarget(target: Vector3): Vector3;
  79522. /**
  79523. * Returns the light rotation in euler definition.
  79524. * @returns the x y z rotation in local space.
  79525. */
  79526. getRotation(): Vector3;
  79527. /**
  79528. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79529. * @returns true if a cube texture needs to be use
  79530. */
  79531. needCube(): boolean;
  79532. /**
  79533. * Detects if the projection matrix requires to be recomputed this frame.
  79534. * @returns true if it requires to be recomputed otherwise, false.
  79535. */
  79536. needProjectionMatrixCompute(): boolean;
  79537. /**
  79538. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79539. */
  79540. forceProjectionMatrixCompute(): void;
  79541. /** @hidden */
  79542. _initCache(): void;
  79543. /** @hidden */
  79544. _isSynchronized(): boolean;
  79545. /**
  79546. * Computes the world matrix of the node
  79547. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79548. * @returns the world matrix
  79549. */
  79550. computeWorldMatrix(force?: boolean): Matrix;
  79551. /**
  79552. * Gets the minZ used for shadow according to both the scene and the light.
  79553. * @param activeCamera The camera we are returning the min for
  79554. * @returns the depth min z
  79555. */
  79556. getDepthMinZ(activeCamera: Camera): number;
  79557. /**
  79558. * Gets the maxZ used for shadow according to both the scene and the light.
  79559. * @param activeCamera The camera we are returning the max for
  79560. * @returns the depth max z
  79561. */
  79562. getDepthMaxZ(activeCamera: Camera): number;
  79563. /**
  79564. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79565. * @param matrix The materix to updated with the projection information
  79566. * @param viewMatrix The transform matrix of the light
  79567. * @param renderList The list of mesh to render in the map
  79568. * @returns The current light
  79569. */
  79570. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79571. }
  79572. }
  79573. declare module BABYLON {
  79574. /**
  79575. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  79576. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  79577. */
  79578. export class EffectFallbacks implements IEffectFallbacks {
  79579. private _defines;
  79580. private _currentRank;
  79581. private _maxRank;
  79582. private _mesh;
  79583. /**
  79584. * Removes the fallback from the bound mesh.
  79585. */
  79586. unBindMesh(): void;
  79587. /**
  79588. * Adds a fallback on the specified property.
  79589. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79590. * @param define The name of the define in the shader
  79591. */
  79592. addFallback(rank: number, define: string): void;
  79593. /**
  79594. * Sets the mesh to use CPU skinning when needing to fallback.
  79595. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79596. * @param mesh The mesh to use the fallbacks.
  79597. */
  79598. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  79599. /**
  79600. * Checks to see if more fallbacks are still availible.
  79601. */
  79602. get hasMoreFallbacks(): boolean;
  79603. /**
  79604. * Removes the defines that should be removed when falling back.
  79605. * @param currentDefines defines the current define statements for the shader.
  79606. * @param effect defines the current effect we try to compile
  79607. * @returns The resulting defines with defines of the current rank removed.
  79608. */
  79609. reduce(currentDefines: string, effect: Effect): string;
  79610. }
  79611. }
  79612. declare module BABYLON {
  79613. /**
  79614. * "Static Class" containing the most commonly used helper while dealing with material for
  79615. * rendering purpose.
  79616. *
  79617. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  79618. *
  79619. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  79620. */
  79621. export class MaterialHelper {
  79622. /**
  79623. * Bind the current view position to an effect.
  79624. * @param effect The effect to be bound
  79625. * @param scene The scene the eyes position is used from
  79626. */
  79627. static BindEyePosition(effect: Effect, scene: Scene): void;
  79628. /**
  79629. * Helps preparing the defines values about the UVs in used in the effect.
  79630. * UVs are shared as much as we can accross channels in the shaders.
  79631. * @param texture The texture we are preparing the UVs for
  79632. * @param defines The defines to update
  79633. * @param key The channel key "diffuse", "specular"... used in the shader
  79634. */
  79635. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  79636. /**
  79637. * Binds a texture matrix value to its corrsponding uniform
  79638. * @param texture The texture to bind the matrix for
  79639. * @param uniformBuffer The uniform buffer receivin the data
  79640. * @param key The channel key "diffuse", "specular"... used in the shader
  79641. */
  79642. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  79643. /**
  79644. * Gets the current status of the fog (should it be enabled?)
  79645. * @param mesh defines the mesh to evaluate for fog support
  79646. * @param scene defines the hosting scene
  79647. * @returns true if fog must be enabled
  79648. */
  79649. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  79650. /**
  79651. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  79652. * @param mesh defines the current mesh
  79653. * @param scene defines the current scene
  79654. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  79655. * @param pointsCloud defines if point cloud rendering has to be turned on
  79656. * @param fogEnabled defines if fog has to be turned on
  79657. * @param alphaTest defines if alpha testing has to be turned on
  79658. * @param defines defines the current list of defines
  79659. */
  79660. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  79661. /**
  79662. * Helper used to prepare the list of defines associated with frame values for shader compilation
  79663. * @param scene defines the current scene
  79664. * @param engine defines the current engine
  79665. * @param defines specifies the list of active defines
  79666. * @param useInstances defines if instances have to be turned on
  79667. * @param useClipPlane defines if clip plane have to be turned on
  79668. */
  79669. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  79670. /**
  79671. * Prepares the defines for bones
  79672. * @param mesh The mesh containing the geometry data we will draw
  79673. * @param defines The defines to update
  79674. */
  79675. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  79676. /**
  79677. * Prepares the defines for morph targets
  79678. * @param mesh The mesh containing the geometry data we will draw
  79679. * @param defines The defines to update
  79680. */
  79681. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  79682. /**
  79683. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  79684. * @param mesh The mesh containing the geometry data we will draw
  79685. * @param defines The defines to update
  79686. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  79687. * @param useBones Precise whether bones should be used or not (override mesh info)
  79688. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  79689. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  79690. * @returns false if defines are considered not dirty and have not been checked
  79691. */
  79692. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  79693. /**
  79694. * Prepares the defines related to multiview
  79695. * @param scene The scene we are intending to draw
  79696. * @param defines The defines to update
  79697. */
  79698. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  79699. /**
  79700. * Prepares the defines related to the light information passed in parameter
  79701. * @param scene The scene we are intending to draw
  79702. * @param mesh The mesh the effect is compiling for
  79703. * @param light The light the effect is compiling for
  79704. * @param lightIndex The index of the light
  79705. * @param defines The defines to update
  79706. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79707. * @param state Defines the current state regarding what is needed (normals, etc...)
  79708. */
  79709. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  79710. needNormals: boolean;
  79711. needRebuild: boolean;
  79712. shadowEnabled: boolean;
  79713. specularEnabled: boolean;
  79714. lightmapMode: boolean;
  79715. }): void;
  79716. /**
  79717. * Prepares the defines related to the light information passed in parameter
  79718. * @param scene The scene we are intending to draw
  79719. * @param mesh The mesh the effect is compiling for
  79720. * @param defines The defines to update
  79721. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79722. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  79723. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  79724. * @returns true if normals will be required for the rest of the effect
  79725. */
  79726. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  79727. /**
  79728. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  79729. * @param lightIndex defines the light index
  79730. * @param uniformsList The uniform list
  79731. * @param samplersList The sampler list
  79732. * @param projectedLightTexture defines if projected texture must be used
  79733. * @param uniformBuffersList defines an optional list of uniform buffers
  79734. */
  79735. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  79736. /**
  79737. * Prepares the uniforms and samplers list to be used in the effect
  79738. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  79739. * @param samplersList The sampler list
  79740. * @param defines The defines helping in the list generation
  79741. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  79742. */
  79743. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  79744. /**
  79745. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  79746. * @param defines The defines to update while falling back
  79747. * @param fallbacks The authorized effect fallbacks
  79748. * @param maxSimultaneousLights The maximum number of lights allowed
  79749. * @param rank the current rank of the Effect
  79750. * @returns The newly affected rank
  79751. */
  79752. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  79753. private static _TmpMorphInfluencers;
  79754. /**
  79755. * Prepares the list of attributes required for morph targets according to the effect defines.
  79756. * @param attribs The current list of supported attribs
  79757. * @param mesh The mesh to prepare the morph targets attributes for
  79758. * @param influencers The number of influencers
  79759. */
  79760. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  79761. /**
  79762. * Prepares the list of attributes required for morph targets according to the effect defines.
  79763. * @param attribs The current list of supported attribs
  79764. * @param mesh The mesh to prepare the morph targets attributes for
  79765. * @param defines The current Defines of the effect
  79766. */
  79767. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  79768. /**
  79769. * Prepares the list of attributes required for bones according to the effect defines.
  79770. * @param attribs The current list of supported attribs
  79771. * @param mesh The mesh to prepare the bones attributes for
  79772. * @param defines The current Defines of the effect
  79773. * @param fallbacks The current efffect fallback strategy
  79774. */
  79775. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  79776. /**
  79777. * Check and prepare the list of attributes required for instances according to the effect defines.
  79778. * @param attribs The current list of supported attribs
  79779. * @param defines The current MaterialDefines of the effect
  79780. */
  79781. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  79782. /**
  79783. * Add the list of attributes required for instances to the attribs array.
  79784. * @param attribs The current list of supported attribs
  79785. */
  79786. static PushAttributesForInstances(attribs: string[]): void;
  79787. /**
  79788. * Binds the light information to the effect.
  79789. * @param light The light containing the generator
  79790. * @param effect The effect we are binding the data to
  79791. * @param lightIndex The light index in the effect used to render
  79792. */
  79793. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  79794. /**
  79795. * Binds the lights information from the scene to the effect for the given mesh.
  79796. * @param light Light to bind
  79797. * @param lightIndex Light index
  79798. * @param scene The scene where the light belongs to
  79799. * @param effect The effect we are binding the data to
  79800. * @param useSpecular Defines if specular is supported
  79801. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79802. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79803. */
  79804. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79805. /**
  79806. * Binds the lights information from the scene to the effect for the given mesh.
  79807. * @param scene The scene the lights belongs to
  79808. * @param mesh The mesh we are binding the information to render
  79809. * @param effect The effect we are binding the data to
  79810. * @param defines The generated defines for the effect
  79811. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  79812. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79813. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79814. */
  79815. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79816. private static _tempFogColor;
  79817. /**
  79818. * Binds the fog information from the scene to the effect for the given mesh.
  79819. * @param scene The scene the lights belongs to
  79820. * @param mesh The mesh we are binding the information to render
  79821. * @param effect The effect we are binding the data to
  79822. * @param linearSpace Defines if the fog effect is applied in linear space
  79823. */
  79824. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  79825. /**
  79826. * Binds the bones information from the mesh to the effect.
  79827. * @param mesh The mesh we are binding the information to render
  79828. * @param effect The effect we are binding the data to
  79829. */
  79830. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  79831. /**
  79832. * Binds the morph targets information from the mesh to the effect.
  79833. * @param abstractMesh The mesh we are binding the information to render
  79834. * @param effect The effect we are binding the data to
  79835. */
  79836. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  79837. /**
  79838. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  79839. * @param defines The generated defines used in the effect
  79840. * @param effect The effect we are binding the data to
  79841. * @param scene The scene we are willing to render with logarithmic scale for
  79842. */
  79843. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  79844. /**
  79845. * Binds the clip plane information from the scene to the effect.
  79846. * @param scene The scene the clip plane information are extracted from
  79847. * @param effect The effect we are binding the data to
  79848. */
  79849. static BindClipPlane(effect: Effect, scene: Scene): void;
  79850. }
  79851. }
  79852. declare module BABYLON {
  79853. /** @hidden */
  79854. export var packingFunctions: {
  79855. name: string;
  79856. shader: string;
  79857. };
  79858. }
  79859. declare module BABYLON {
  79860. /** @hidden */
  79861. export var shadowMapPixelShader: {
  79862. name: string;
  79863. shader: string;
  79864. };
  79865. }
  79866. declare module BABYLON {
  79867. /** @hidden */
  79868. export var bonesDeclaration: {
  79869. name: string;
  79870. shader: string;
  79871. };
  79872. }
  79873. declare module BABYLON {
  79874. /** @hidden */
  79875. export var morphTargetsVertexGlobalDeclaration: {
  79876. name: string;
  79877. shader: string;
  79878. };
  79879. }
  79880. declare module BABYLON {
  79881. /** @hidden */
  79882. export var morphTargetsVertexDeclaration: {
  79883. name: string;
  79884. shader: string;
  79885. };
  79886. }
  79887. declare module BABYLON {
  79888. /** @hidden */
  79889. export var instancesDeclaration: {
  79890. name: string;
  79891. shader: string;
  79892. };
  79893. }
  79894. declare module BABYLON {
  79895. /** @hidden */
  79896. export var helperFunctions: {
  79897. name: string;
  79898. shader: string;
  79899. };
  79900. }
  79901. declare module BABYLON {
  79902. /** @hidden */
  79903. export var morphTargetsVertex: {
  79904. name: string;
  79905. shader: string;
  79906. };
  79907. }
  79908. declare module BABYLON {
  79909. /** @hidden */
  79910. export var instancesVertex: {
  79911. name: string;
  79912. shader: string;
  79913. };
  79914. }
  79915. declare module BABYLON {
  79916. /** @hidden */
  79917. export var bonesVertex: {
  79918. name: string;
  79919. shader: string;
  79920. };
  79921. }
  79922. declare module BABYLON {
  79923. /** @hidden */
  79924. export var shadowMapVertexShader: {
  79925. name: string;
  79926. shader: string;
  79927. };
  79928. }
  79929. declare module BABYLON {
  79930. /** @hidden */
  79931. export var depthBoxBlurPixelShader: {
  79932. name: string;
  79933. shader: string;
  79934. };
  79935. }
  79936. declare module BABYLON {
  79937. /**
  79938. * Defines the options associated with the creation of a custom shader for a shadow generator.
  79939. */
  79940. export interface ICustomShaderOptions {
  79941. /**
  79942. * Gets or sets the custom shader name to use
  79943. */
  79944. shaderName: string;
  79945. /**
  79946. * The list of attribute names used in the shader
  79947. */
  79948. attributes?: string[];
  79949. /**
  79950. * The list of unifrom names used in the shader
  79951. */
  79952. uniforms?: string[];
  79953. /**
  79954. * The list of sampler names used in the shader
  79955. */
  79956. samplers?: string[];
  79957. /**
  79958. * The list of defines used in the shader
  79959. */
  79960. defines?: string[];
  79961. }
  79962. /**
  79963. * Interface to implement to create a shadow generator compatible with BJS.
  79964. */
  79965. export interface IShadowGenerator {
  79966. /**
  79967. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  79968. * @returns The render target texture if present otherwise, null
  79969. */
  79970. getShadowMap(): Nullable<RenderTargetTexture>;
  79971. /**
  79972. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  79973. * @returns The render target texture if the shadow map is present otherwise, null
  79974. */
  79975. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  79976. /**
  79977. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  79978. * @param subMesh The submesh we want to render in the shadow map
  79979. * @param useInstances Defines wether will draw in the map using instances
  79980. * @returns true if ready otherwise, false
  79981. */
  79982. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  79983. /**
  79984. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  79985. * @param defines Defines of the material we want to update
  79986. * @param lightIndex Index of the light in the enabled light list of the material
  79987. */
  79988. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  79989. /**
  79990. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  79991. * defined in the generator but impacting the effect).
  79992. * It implies the unifroms available on the materials are the standard BJS ones.
  79993. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  79994. * @param effect The effect we are binfing the information for
  79995. */
  79996. bindShadowLight(lightIndex: string, effect: Effect): void;
  79997. /**
  79998. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  79999. * (eq to shadow prjection matrix * light transform matrix)
  80000. * @returns The transform matrix used to create the shadow map
  80001. */
  80002. getTransformMatrix(): Matrix;
  80003. /**
  80004. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80005. * Cube and 2D textures for instance.
  80006. */
  80007. recreateShadowMap(): void;
  80008. /**
  80009. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80010. * @param onCompiled Callback triggered at the and of the effects compilation
  80011. * @param options Sets of optional options forcing the compilation with different modes
  80012. */
  80013. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80014. useInstances: boolean;
  80015. }>): void;
  80016. /**
  80017. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80018. * @param options Sets of optional options forcing the compilation with different modes
  80019. * @returns A promise that resolves when the compilation completes
  80020. */
  80021. forceCompilationAsync(options?: Partial<{
  80022. useInstances: boolean;
  80023. }>): Promise<void>;
  80024. /**
  80025. * Serializes the shadow generator setup to a json object.
  80026. * @returns The serialized JSON object
  80027. */
  80028. serialize(): any;
  80029. /**
  80030. * Disposes the Shadow map and related Textures and effects.
  80031. */
  80032. dispose(): void;
  80033. }
  80034. /**
  80035. * Default implementation IShadowGenerator.
  80036. * This is the main object responsible of generating shadows in the framework.
  80037. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  80038. */
  80039. export class ShadowGenerator implements IShadowGenerator {
  80040. /**
  80041. * Shadow generator mode None: no filtering applied.
  80042. */
  80043. static readonly FILTER_NONE: number;
  80044. /**
  80045. * Shadow generator mode ESM: Exponential Shadow Mapping.
  80046. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80047. */
  80048. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  80049. /**
  80050. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  80051. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  80052. */
  80053. static readonly FILTER_POISSONSAMPLING: number;
  80054. /**
  80055. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  80056. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80057. */
  80058. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  80059. /**
  80060. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  80061. * edge artifacts on steep falloff.
  80062. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80063. */
  80064. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  80065. /**
  80066. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  80067. * edge artifacts on steep falloff.
  80068. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80069. */
  80070. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  80071. /**
  80072. * Shadow generator mode PCF: Percentage Closer Filtering
  80073. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80074. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  80075. */
  80076. static readonly FILTER_PCF: number;
  80077. /**
  80078. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  80079. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80080. * Contact Hardening
  80081. */
  80082. static readonly FILTER_PCSS: number;
  80083. /**
  80084. * Reserved for PCF and PCSS
  80085. * Highest Quality.
  80086. *
  80087. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  80088. *
  80089. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  80090. */
  80091. static readonly QUALITY_HIGH: number;
  80092. /**
  80093. * Reserved for PCF and PCSS
  80094. * Good tradeoff for quality/perf cross devices
  80095. *
  80096. * Execute PCF on a 3*3 kernel.
  80097. *
  80098. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  80099. */
  80100. static readonly QUALITY_MEDIUM: number;
  80101. /**
  80102. * Reserved for PCF and PCSS
  80103. * The lowest quality but the fastest.
  80104. *
  80105. * Execute PCF on a 1*1 kernel.
  80106. *
  80107. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  80108. */
  80109. static readonly QUALITY_LOW: number;
  80110. /** Gets or sets the custom shader name to use */
  80111. customShaderOptions: ICustomShaderOptions;
  80112. /**
  80113. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  80114. */
  80115. onBeforeShadowMapRenderObservable: Observable<Effect>;
  80116. /**
  80117. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  80118. */
  80119. onAfterShadowMapRenderObservable: Observable<Effect>;
  80120. /**
  80121. * Observable triggered before a mesh is rendered in the shadow map.
  80122. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  80123. */
  80124. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  80125. /**
  80126. * Observable triggered after a mesh is rendered in the shadow map.
  80127. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  80128. */
  80129. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  80130. private _bias;
  80131. /**
  80132. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  80133. */
  80134. get bias(): number;
  80135. /**
  80136. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  80137. */
  80138. set bias(bias: number);
  80139. private _normalBias;
  80140. /**
  80141. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80142. */
  80143. get normalBias(): number;
  80144. /**
  80145. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80146. */
  80147. set normalBias(normalBias: number);
  80148. private _blurBoxOffset;
  80149. /**
  80150. * Gets the blur box offset: offset applied during the blur pass.
  80151. * Only useful if useKernelBlur = false
  80152. */
  80153. get blurBoxOffset(): number;
  80154. /**
  80155. * Sets the blur box offset: offset applied during the blur pass.
  80156. * Only useful if useKernelBlur = false
  80157. */
  80158. set blurBoxOffset(value: number);
  80159. private _blurScale;
  80160. /**
  80161. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  80162. * 2 means half of the size.
  80163. */
  80164. get blurScale(): number;
  80165. /**
  80166. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  80167. * 2 means half of the size.
  80168. */
  80169. set blurScale(value: number);
  80170. private _blurKernel;
  80171. /**
  80172. * Gets the blur kernel: kernel size of the blur pass.
  80173. * Only useful if useKernelBlur = true
  80174. */
  80175. get blurKernel(): number;
  80176. /**
  80177. * Sets the blur kernel: kernel size of the blur pass.
  80178. * Only useful if useKernelBlur = true
  80179. */
  80180. set blurKernel(value: number);
  80181. private _useKernelBlur;
  80182. /**
  80183. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  80184. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80185. */
  80186. get useKernelBlur(): boolean;
  80187. /**
  80188. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  80189. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80190. */
  80191. set useKernelBlur(value: boolean);
  80192. private _depthScale;
  80193. /**
  80194. * Gets the depth scale used in ESM mode.
  80195. */
  80196. get depthScale(): number;
  80197. /**
  80198. * Sets the depth scale used in ESM mode.
  80199. * This can override the scale stored on the light.
  80200. */
  80201. set depthScale(value: number);
  80202. private _filter;
  80203. /**
  80204. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  80205. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80206. */
  80207. get filter(): number;
  80208. /**
  80209. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  80210. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80211. */
  80212. set filter(value: number);
  80213. /**
  80214. * Gets if the current filter is set to Poisson Sampling.
  80215. */
  80216. get usePoissonSampling(): boolean;
  80217. /**
  80218. * Sets the current filter to Poisson Sampling.
  80219. */
  80220. set usePoissonSampling(value: boolean);
  80221. /**
  80222. * Gets if the current filter is set to ESM.
  80223. */
  80224. get useExponentialShadowMap(): boolean;
  80225. /**
  80226. * Sets the current filter is to ESM.
  80227. */
  80228. set useExponentialShadowMap(value: boolean);
  80229. /**
  80230. * Gets if the current filter is set to filtered ESM.
  80231. */
  80232. get useBlurExponentialShadowMap(): boolean;
  80233. /**
  80234. * Gets if the current filter is set to filtered ESM.
  80235. */
  80236. set useBlurExponentialShadowMap(value: boolean);
  80237. /**
  80238. * Gets if the current filter is set to "close ESM" (using the inverse of the
  80239. * exponential to prevent steep falloff artifacts).
  80240. */
  80241. get useCloseExponentialShadowMap(): boolean;
  80242. /**
  80243. * Sets the current filter to "close ESM" (using the inverse of the
  80244. * exponential to prevent steep falloff artifacts).
  80245. */
  80246. set useCloseExponentialShadowMap(value: boolean);
  80247. /**
  80248. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  80249. * exponential to prevent steep falloff artifacts).
  80250. */
  80251. get useBlurCloseExponentialShadowMap(): boolean;
  80252. /**
  80253. * Sets the current filter to filtered "close ESM" (using the inverse of the
  80254. * exponential to prevent steep falloff artifacts).
  80255. */
  80256. set useBlurCloseExponentialShadowMap(value: boolean);
  80257. /**
  80258. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  80259. */
  80260. get usePercentageCloserFiltering(): boolean;
  80261. /**
  80262. * Sets the current filter to "PCF" (percentage closer filtering).
  80263. */
  80264. set usePercentageCloserFiltering(value: boolean);
  80265. private _filteringQuality;
  80266. /**
  80267. * Gets the PCF or PCSS Quality.
  80268. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80269. */
  80270. get filteringQuality(): number;
  80271. /**
  80272. * Sets the PCF or PCSS Quality.
  80273. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80274. */
  80275. set filteringQuality(filteringQuality: number);
  80276. /**
  80277. * Gets if the current filter is set to "PCSS" (contact hardening).
  80278. */
  80279. get useContactHardeningShadow(): boolean;
  80280. /**
  80281. * Sets the current filter to "PCSS" (contact hardening).
  80282. */
  80283. set useContactHardeningShadow(value: boolean);
  80284. private _contactHardeningLightSizeUVRatio;
  80285. /**
  80286. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80287. * Using a ratio helps keeping shape stability independently of the map size.
  80288. *
  80289. * It does not account for the light projection as it was having too much
  80290. * instability during the light setup or during light position changes.
  80291. *
  80292. * Only valid if useContactHardeningShadow is true.
  80293. */
  80294. get contactHardeningLightSizeUVRatio(): number;
  80295. /**
  80296. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80297. * Using a ratio helps keeping shape stability independently of the map size.
  80298. *
  80299. * It does not account for the light projection as it was having too much
  80300. * instability during the light setup or during light position changes.
  80301. *
  80302. * Only valid if useContactHardeningShadow is true.
  80303. */
  80304. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  80305. private _darkness;
  80306. /** Gets or sets the actual darkness of a shadow */
  80307. get darkness(): number;
  80308. set darkness(value: number);
  80309. /**
  80310. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  80311. * 0 means strongest and 1 would means no shadow.
  80312. * @returns the darkness.
  80313. */
  80314. getDarkness(): number;
  80315. /**
  80316. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  80317. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  80318. * @returns the shadow generator allowing fluent coding.
  80319. */
  80320. setDarkness(darkness: number): ShadowGenerator;
  80321. private _transparencyShadow;
  80322. /** Gets or sets the ability to have transparent shadow */
  80323. get transparencyShadow(): boolean;
  80324. set transparencyShadow(value: boolean);
  80325. /**
  80326. * Sets the ability to have transparent shadow (boolean).
  80327. * @param transparent True if transparent else False
  80328. * @returns the shadow generator allowing fluent coding
  80329. */
  80330. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  80331. private _shadowMap;
  80332. private _shadowMap2;
  80333. /**
  80334. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80335. * @returns The render target texture if present otherwise, null
  80336. */
  80337. getShadowMap(): Nullable<RenderTargetTexture>;
  80338. /**
  80339. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80340. * @returns The render target texture if the shadow map is present otherwise, null
  80341. */
  80342. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80343. /**
  80344. * Gets the class name of that object
  80345. * @returns "ShadowGenerator"
  80346. */
  80347. getClassName(): string;
  80348. /**
  80349. * Helper function to add a mesh and its descendants to the list of shadow casters.
  80350. * @param mesh Mesh to add
  80351. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  80352. * @returns the Shadow Generator itself
  80353. */
  80354. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80355. /**
  80356. * Helper function to remove a mesh and its descendants from the list of shadow casters
  80357. * @param mesh Mesh to remove
  80358. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  80359. * @returns the Shadow Generator itself
  80360. */
  80361. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80362. /**
  80363. * Controls the extent to which the shadows fade out at the edge of the frustum
  80364. * Used only by directionals and spots
  80365. */
  80366. frustumEdgeFalloff: number;
  80367. private _light;
  80368. /**
  80369. * Returns the associated light object.
  80370. * @returns the light generating the shadow
  80371. */
  80372. getLight(): IShadowLight;
  80373. /**
  80374. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  80375. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  80376. * It might on the other hand introduce peter panning.
  80377. */
  80378. forceBackFacesOnly: boolean;
  80379. private _scene;
  80380. private _lightDirection;
  80381. private _effect;
  80382. private _viewMatrix;
  80383. private _projectionMatrix;
  80384. private _transformMatrix;
  80385. private _cachedPosition;
  80386. private _cachedDirection;
  80387. private _cachedDefines;
  80388. private _currentRenderID;
  80389. private _boxBlurPostprocess;
  80390. private _kernelBlurXPostprocess;
  80391. private _kernelBlurYPostprocess;
  80392. private _blurPostProcesses;
  80393. private _mapSize;
  80394. private _currentFaceIndex;
  80395. private _currentFaceIndexCache;
  80396. private _textureType;
  80397. private _defaultTextureMatrix;
  80398. private _storedUniqueId;
  80399. /** @hidden */
  80400. static _SceneComponentInitialization: (scene: Scene) => void;
  80401. /**
  80402. * Creates a ShadowGenerator object.
  80403. * A ShadowGenerator is the required tool to use the shadows.
  80404. * Each light casting shadows needs to use its own ShadowGenerator.
  80405. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  80406. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  80407. * @param light The light object generating the shadows.
  80408. * @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.
  80409. */
  80410. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  80411. private _initializeGenerator;
  80412. private _initializeShadowMap;
  80413. private _initializeBlurRTTAndPostProcesses;
  80414. private _renderForShadowMap;
  80415. private _renderSubMeshForShadowMap;
  80416. private _applyFilterValues;
  80417. /**
  80418. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80419. * @param onCompiled Callback triggered at the and of the effects compilation
  80420. * @param options Sets of optional options forcing the compilation with different modes
  80421. */
  80422. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80423. useInstances: boolean;
  80424. }>): void;
  80425. /**
  80426. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80427. * @param options Sets of optional options forcing the compilation with different modes
  80428. * @returns A promise that resolves when the compilation completes
  80429. */
  80430. forceCompilationAsync(options?: Partial<{
  80431. useInstances: boolean;
  80432. }>): Promise<void>;
  80433. /**
  80434. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80435. * @param subMesh The submesh we want to render in the shadow map
  80436. * @param useInstances Defines wether will draw in the map using instances
  80437. * @returns true if ready otherwise, false
  80438. */
  80439. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80440. /**
  80441. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80442. * @param defines Defines of the material we want to update
  80443. * @param lightIndex Index of the light in the enabled light list of the material
  80444. */
  80445. prepareDefines(defines: any, lightIndex: number): void;
  80446. /**
  80447. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80448. * defined in the generator but impacting the effect).
  80449. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80450. * @param effect The effect we are binfing the information for
  80451. */
  80452. bindShadowLight(lightIndex: string, effect: Effect): void;
  80453. /**
  80454. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80455. * (eq to shadow prjection matrix * light transform matrix)
  80456. * @returns The transform matrix used to create the shadow map
  80457. */
  80458. getTransformMatrix(): Matrix;
  80459. /**
  80460. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80461. * Cube and 2D textures for instance.
  80462. */
  80463. recreateShadowMap(): void;
  80464. private _disposeBlurPostProcesses;
  80465. private _disposeRTTandPostProcesses;
  80466. /**
  80467. * Disposes the ShadowGenerator.
  80468. * Returns nothing.
  80469. */
  80470. dispose(): void;
  80471. /**
  80472. * Serializes the shadow generator setup to a json object.
  80473. * @returns The serialized JSON object
  80474. */
  80475. serialize(): any;
  80476. /**
  80477. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  80478. * @param parsedShadowGenerator The JSON object to parse
  80479. * @param scene The scene to create the shadow map for
  80480. * @returns The parsed shadow generator
  80481. */
  80482. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  80483. }
  80484. }
  80485. declare module BABYLON {
  80486. /**
  80487. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  80488. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  80489. * 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.
  80490. */
  80491. export abstract class Light extends Node {
  80492. /**
  80493. * Falloff Default: light is falling off following the material specification:
  80494. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  80495. */
  80496. static readonly FALLOFF_DEFAULT: number;
  80497. /**
  80498. * Falloff Physical: light is falling off following the inverse squared distance law.
  80499. */
  80500. static readonly FALLOFF_PHYSICAL: number;
  80501. /**
  80502. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  80503. * to enhance interoperability with other engines.
  80504. */
  80505. static readonly FALLOFF_GLTF: number;
  80506. /**
  80507. * Falloff Standard: light is falling off like in the standard material
  80508. * to enhance interoperability with other materials.
  80509. */
  80510. static readonly FALLOFF_STANDARD: number;
  80511. /**
  80512. * If every light affecting the material is in this lightmapMode,
  80513. * material.lightmapTexture adds or multiplies
  80514. * (depends on material.useLightmapAsShadowmap)
  80515. * after every other light calculations.
  80516. */
  80517. static readonly LIGHTMAP_DEFAULT: number;
  80518. /**
  80519. * material.lightmapTexture as only diffuse lighting from this light
  80520. * adds only specular lighting from this light
  80521. * adds dynamic shadows
  80522. */
  80523. static readonly LIGHTMAP_SPECULAR: number;
  80524. /**
  80525. * material.lightmapTexture as only lighting
  80526. * no light calculation from this light
  80527. * only adds dynamic shadows from this light
  80528. */
  80529. static readonly LIGHTMAP_SHADOWSONLY: number;
  80530. /**
  80531. * Each light type uses the default quantity according to its type:
  80532. * point/spot lights use luminous intensity
  80533. * directional lights use illuminance
  80534. */
  80535. static readonly INTENSITYMODE_AUTOMATIC: number;
  80536. /**
  80537. * lumen (lm)
  80538. */
  80539. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  80540. /**
  80541. * candela (lm/sr)
  80542. */
  80543. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  80544. /**
  80545. * lux (lm/m^2)
  80546. */
  80547. static readonly INTENSITYMODE_ILLUMINANCE: number;
  80548. /**
  80549. * nit (cd/m^2)
  80550. */
  80551. static readonly INTENSITYMODE_LUMINANCE: number;
  80552. /**
  80553. * Light type const id of the point light.
  80554. */
  80555. static readonly LIGHTTYPEID_POINTLIGHT: number;
  80556. /**
  80557. * Light type const id of the directional light.
  80558. */
  80559. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  80560. /**
  80561. * Light type const id of the spot light.
  80562. */
  80563. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  80564. /**
  80565. * Light type const id of the hemispheric light.
  80566. */
  80567. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  80568. /**
  80569. * Diffuse gives the basic color to an object.
  80570. */
  80571. diffuse: Color3;
  80572. /**
  80573. * Specular produces a highlight color on an object.
  80574. * Note: This is note affecting PBR materials.
  80575. */
  80576. specular: Color3;
  80577. /**
  80578. * Defines the falloff type for this light. This lets overrriding how punctual light are
  80579. * falling off base on range or angle.
  80580. * This can be set to any values in Light.FALLOFF_x.
  80581. *
  80582. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  80583. * other types of materials.
  80584. */
  80585. falloffType: number;
  80586. /**
  80587. * Strength of the light.
  80588. * Note: By default it is define in the framework own unit.
  80589. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  80590. */
  80591. intensity: number;
  80592. private _range;
  80593. protected _inverseSquaredRange: number;
  80594. /**
  80595. * Defines how far from the source the light is impacting in scene units.
  80596. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80597. */
  80598. get range(): number;
  80599. /**
  80600. * Defines how far from the source the light is impacting in scene units.
  80601. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80602. */
  80603. set range(value: number);
  80604. /**
  80605. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  80606. * of light.
  80607. */
  80608. private _photometricScale;
  80609. private _intensityMode;
  80610. /**
  80611. * Gets the photometric scale used to interpret the intensity.
  80612. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80613. */
  80614. get intensityMode(): number;
  80615. /**
  80616. * Sets the photometric scale used to interpret the intensity.
  80617. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80618. */
  80619. set intensityMode(value: number);
  80620. private _radius;
  80621. /**
  80622. * Gets the light radius used by PBR Materials to simulate soft area lights.
  80623. */
  80624. get radius(): number;
  80625. /**
  80626. * sets the light radius used by PBR Materials to simulate soft area lights.
  80627. */
  80628. set radius(value: number);
  80629. private _renderPriority;
  80630. /**
  80631. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  80632. * exceeding the number allowed of the materials.
  80633. */
  80634. renderPriority: number;
  80635. private _shadowEnabled;
  80636. /**
  80637. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80638. * the current shadow generator.
  80639. */
  80640. get shadowEnabled(): boolean;
  80641. /**
  80642. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80643. * the current shadow generator.
  80644. */
  80645. set shadowEnabled(value: boolean);
  80646. private _includedOnlyMeshes;
  80647. /**
  80648. * Gets the only meshes impacted by this light.
  80649. */
  80650. get includedOnlyMeshes(): AbstractMesh[];
  80651. /**
  80652. * Sets the only meshes impacted by this light.
  80653. */
  80654. set includedOnlyMeshes(value: AbstractMesh[]);
  80655. private _excludedMeshes;
  80656. /**
  80657. * Gets the meshes not impacted by this light.
  80658. */
  80659. get excludedMeshes(): AbstractMesh[];
  80660. /**
  80661. * Sets the meshes not impacted by this light.
  80662. */
  80663. set excludedMeshes(value: AbstractMesh[]);
  80664. private _excludeWithLayerMask;
  80665. /**
  80666. * Gets the layer id use to find what meshes are not impacted by the light.
  80667. * Inactive if 0
  80668. */
  80669. get excludeWithLayerMask(): number;
  80670. /**
  80671. * Sets the layer id use to find what meshes are not impacted by the light.
  80672. * Inactive if 0
  80673. */
  80674. set excludeWithLayerMask(value: number);
  80675. private _includeOnlyWithLayerMask;
  80676. /**
  80677. * Gets the layer id use to find what meshes are impacted by the light.
  80678. * Inactive if 0
  80679. */
  80680. get includeOnlyWithLayerMask(): number;
  80681. /**
  80682. * Sets the layer id use to find what meshes are impacted by the light.
  80683. * Inactive if 0
  80684. */
  80685. set includeOnlyWithLayerMask(value: number);
  80686. private _lightmapMode;
  80687. /**
  80688. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80689. */
  80690. get lightmapMode(): number;
  80691. /**
  80692. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80693. */
  80694. set lightmapMode(value: number);
  80695. /**
  80696. * Shadow generator associted to the light.
  80697. * @hidden Internal use only.
  80698. */
  80699. _shadowGenerator: Nullable<IShadowGenerator>;
  80700. /**
  80701. * @hidden Internal use only.
  80702. */
  80703. _excludedMeshesIds: string[];
  80704. /**
  80705. * @hidden Internal use only.
  80706. */
  80707. _includedOnlyMeshesIds: string[];
  80708. /**
  80709. * The current light unifom buffer.
  80710. * @hidden Internal use only.
  80711. */
  80712. _uniformBuffer: UniformBuffer;
  80713. /** @hidden */
  80714. _renderId: number;
  80715. /**
  80716. * Creates a Light object in the scene.
  80717. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80718. * @param name The firendly name of the light
  80719. * @param scene The scene the light belongs too
  80720. */
  80721. constructor(name: string, scene: Scene);
  80722. protected abstract _buildUniformLayout(): void;
  80723. /**
  80724. * Sets the passed Effect "effect" with the Light information.
  80725. * @param effect The effect to update
  80726. * @param lightIndex The index of the light in the effect to update
  80727. * @returns The light
  80728. */
  80729. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  80730. /**
  80731. * Sets the passed Effect "effect" with the Light textures.
  80732. * @param effect The effect to update
  80733. * @param lightIndex The index of the light in the effect to update
  80734. * @returns The light
  80735. */
  80736. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  80737. /**
  80738. * Binds the lights information from the scene to the effect for the given mesh.
  80739. * @param lightIndex Light index
  80740. * @param scene The scene where the light belongs to
  80741. * @param effect The effect we are binding the data to
  80742. * @param useSpecular Defines if specular is supported
  80743. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  80744. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80745. */
  80746. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  80747. /**
  80748. * Sets the passed Effect "effect" with the Light information.
  80749. * @param effect The effect to update
  80750. * @param lightDataUniformName The uniform used to store light data (position or direction)
  80751. * @returns The light
  80752. */
  80753. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  80754. /**
  80755. * Returns the string "Light".
  80756. * @returns the class name
  80757. */
  80758. getClassName(): string;
  80759. /** @hidden */
  80760. readonly _isLight: boolean;
  80761. /**
  80762. * Converts the light information to a readable string for debug purpose.
  80763. * @param fullDetails Supports for multiple levels of logging within scene loading
  80764. * @returns the human readable light info
  80765. */
  80766. toString(fullDetails?: boolean): string;
  80767. /** @hidden */
  80768. protected _syncParentEnabledState(): void;
  80769. /**
  80770. * Set the enabled state of this node.
  80771. * @param value - the new enabled state
  80772. */
  80773. setEnabled(value: boolean): void;
  80774. /**
  80775. * Returns the Light associated shadow generator if any.
  80776. * @return the associated shadow generator.
  80777. */
  80778. getShadowGenerator(): Nullable<IShadowGenerator>;
  80779. /**
  80780. * Returns a Vector3, the absolute light position in the World.
  80781. * @returns the world space position of the light
  80782. */
  80783. getAbsolutePosition(): Vector3;
  80784. /**
  80785. * Specifies if the light will affect the passed mesh.
  80786. * @param mesh The mesh to test against the light
  80787. * @return true the mesh is affected otherwise, false.
  80788. */
  80789. canAffectMesh(mesh: AbstractMesh): boolean;
  80790. /**
  80791. * Sort function to order lights for rendering.
  80792. * @param a First Light object to compare to second.
  80793. * @param b Second Light object to compare first.
  80794. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  80795. */
  80796. static CompareLightsPriority(a: Light, b: Light): number;
  80797. /**
  80798. * Releases resources associated with this node.
  80799. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80800. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80801. */
  80802. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80803. /**
  80804. * Returns the light type ID (integer).
  80805. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80806. */
  80807. getTypeID(): number;
  80808. /**
  80809. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  80810. * @returns the scaled intensity in intensity mode unit
  80811. */
  80812. getScaledIntensity(): number;
  80813. /**
  80814. * Returns a new Light object, named "name", from the current one.
  80815. * @param name The name of the cloned light
  80816. * @returns the new created light
  80817. */
  80818. clone(name: string): Nullable<Light>;
  80819. /**
  80820. * Serializes the current light into a Serialization object.
  80821. * @returns the serialized object.
  80822. */
  80823. serialize(): any;
  80824. /**
  80825. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  80826. * This new light is named "name" and added to the passed scene.
  80827. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  80828. * @param name The friendly name of the light
  80829. * @param scene The scene the new light will belong to
  80830. * @returns the constructor function
  80831. */
  80832. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  80833. /**
  80834. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  80835. * @param parsedLight The JSON representation of the light
  80836. * @param scene The scene to create the parsed light in
  80837. * @returns the created light after parsing
  80838. */
  80839. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  80840. private _hookArrayForExcluded;
  80841. private _hookArrayForIncludedOnly;
  80842. private _resyncMeshes;
  80843. /**
  80844. * Forces the meshes to update their light related information in their rendering used effects
  80845. * @hidden Internal Use Only
  80846. */
  80847. _markMeshesAsLightDirty(): void;
  80848. /**
  80849. * Recomputes the cached photometric scale if needed.
  80850. */
  80851. private _computePhotometricScale;
  80852. /**
  80853. * Returns the Photometric Scale according to the light type and intensity mode.
  80854. */
  80855. private _getPhotometricScale;
  80856. /**
  80857. * Reorder the light in the scene according to their defined priority.
  80858. * @hidden Internal Use Only
  80859. */
  80860. _reorderLightsInScene(): void;
  80861. /**
  80862. * Prepares the list of defines specific to the light type.
  80863. * @param defines the list of defines
  80864. * @param lightIndex defines the index of the light for the effect
  80865. */
  80866. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80867. }
  80868. }
  80869. declare module BABYLON {
  80870. /**
  80871. * Interface used to define Action
  80872. */
  80873. export interface IAction {
  80874. /**
  80875. * Trigger for the action
  80876. */
  80877. trigger: number;
  80878. /** Options of the trigger */
  80879. triggerOptions: any;
  80880. /**
  80881. * Gets the trigger parameters
  80882. * @returns the trigger parameters
  80883. */
  80884. getTriggerParameter(): any;
  80885. /**
  80886. * Internal only - executes current action event
  80887. * @hidden
  80888. */
  80889. _executeCurrent(evt?: ActionEvent): void;
  80890. /**
  80891. * Serialize placeholder for child classes
  80892. * @param parent of child
  80893. * @returns the serialized object
  80894. */
  80895. serialize(parent: any): any;
  80896. /**
  80897. * Internal only
  80898. * @hidden
  80899. */
  80900. _prepare(): void;
  80901. /**
  80902. * Internal only - manager for action
  80903. * @hidden
  80904. */
  80905. _actionManager: AbstractActionManager;
  80906. /**
  80907. * Adds action to chain of actions, may be a DoNothingAction
  80908. * @param action defines the next action to execute
  80909. * @returns The action passed in
  80910. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80911. */
  80912. then(action: IAction): IAction;
  80913. }
  80914. /**
  80915. * The action to be carried out following a trigger
  80916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  80917. */
  80918. export class Action implements IAction {
  80919. /** the trigger, with or without parameters, for the action */
  80920. triggerOptions: any;
  80921. /**
  80922. * Trigger for the action
  80923. */
  80924. trigger: number;
  80925. /**
  80926. * Internal only - manager for action
  80927. * @hidden
  80928. */
  80929. _actionManager: ActionManager;
  80930. private _nextActiveAction;
  80931. private _child;
  80932. private _condition?;
  80933. private _triggerParameter;
  80934. /**
  80935. * An event triggered prior to action being executed.
  80936. */
  80937. onBeforeExecuteObservable: Observable<Action>;
  80938. /**
  80939. * Creates a new Action
  80940. * @param triggerOptions the trigger, with or without parameters, for the action
  80941. * @param condition an optional determinant of action
  80942. */
  80943. constructor(
  80944. /** the trigger, with or without parameters, for the action */
  80945. triggerOptions: any, condition?: Condition);
  80946. /**
  80947. * Internal only
  80948. * @hidden
  80949. */
  80950. _prepare(): void;
  80951. /**
  80952. * Gets the trigger parameters
  80953. * @returns the trigger parameters
  80954. */
  80955. getTriggerParameter(): any;
  80956. /**
  80957. * Internal only - executes current action event
  80958. * @hidden
  80959. */
  80960. _executeCurrent(evt?: ActionEvent): void;
  80961. /**
  80962. * Execute placeholder for child classes
  80963. * @param evt optional action event
  80964. */
  80965. execute(evt?: ActionEvent): void;
  80966. /**
  80967. * Skips to next active action
  80968. */
  80969. skipToNextActiveAction(): void;
  80970. /**
  80971. * Adds action to chain of actions, may be a DoNothingAction
  80972. * @param action defines the next action to execute
  80973. * @returns The action passed in
  80974. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80975. */
  80976. then(action: Action): Action;
  80977. /**
  80978. * Internal only
  80979. * @hidden
  80980. */
  80981. _getProperty(propertyPath: string): string;
  80982. /**
  80983. * Internal only
  80984. * @hidden
  80985. */
  80986. _getEffectiveTarget(target: any, propertyPath: string): any;
  80987. /**
  80988. * Serialize placeholder for child classes
  80989. * @param parent of child
  80990. * @returns the serialized object
  80991. */
  80992. serialize(parent: any): any;
  80993. /**
  80994. * Internal only called by serialize
  80995. * @hidden
  80996. */
  80997. protected _serialize(serializedAction: any, parent?: any): any;
  80998. /**
  80999. * Internal only
  81000. * @hidden
  81001. */
  81002. static _SerializeValueAsString: (value: any) => string;
  81003. /**
  81004. * Internal only
  81005. * @hidden
  81006. */
  81007. static _GetTargetProperty: (target: Node | Scene) => {
  81008. name: string;
  81009. targetType: string;
  81010. value: string;
  81011. };
  81012. }
  81013. }
  81014. declare module BABYLON {
  81015. /**
  81016. * A Condition applied to an Action
  81017. */
  81018. export class Condition {
  81019. /**
  81020. * Internal only - manager for action
  81021. * @hidden
  81022. */
  81023. _actionManager: ActionManager;
  81024. /**
  81025. * Internal only
  81026. * @hidden
  81027. */
  81028. _evaluationId: number;
  81029. /**
  81030. * Internal only
  81031. * @hidden
  81032. */
  81033. _currentResult: boolean;
  81034. /**
  81035. * Creates a new Condition
  81036. * @param actionManager the manager of the action the condition is applied to
  81037. */
  81038. constructor(actionManager: ActionManager);
  81039. /**
  81040. * Check if the current condition is valid
  81041. * @returns a boolean
  81042. */
  81043. isValid(): boolean;
  81044. /**
  81045. * Internal only
  81046. * @hidden
  81047. */
  81048. _getProperty(propertyPath: string): string;
  81049. /**
  81050. * Internal only
  81051. * @hidden
  81052. */
  81053. _getEffectiveTarget(target: any, propertyPath: string): any;
  81054. /**
  81055. * Serialize placeholder for child classes
  81056. * @returns the serialized object
  81057. */
  81058. serialize(): any;
  81059. /**
  81060. * Internal only
  81061. * @hidden
  81062. */
  81063. protected _serialize(serializedCondition: any): any;
  81064. }
  81065. /**
  81066. * Defines specific conditional operators as extensions of Condition
  81067. */
  81068. export class ValueCondition extends Condition {
  81069. /** path to specify the property of the target the conditional operator uses */
  81070. propertyPath: string;
  81071. /** the value compared by the conditional operator against the current value of the property */
  81072. value: any;
  81073. /** the conditional operator, default ValueCondition.IsEqual */
  81074. operator: number;
  81075. /**
  81076. * Internal only
  81077. * @hidden
  81078. */
  81079. private static _IsEqual;
  81080. /**
  81081. * Internal only
  81082. * @hidden
  81083. */
  81084. private static _IsDifferent;
  81085. /**
  81086. * Internal only
  81087. * @hidden
  81088. */
  81089. private static _IsGreater;
  81090. /**
  81091. * Internal only
  81092. * @hidden
  81093. */
  81094. private static _IsLesser;
  81095. /**
  81096. * returns the number for IsEqual
  81097. */
  81098. static get IsEqual(): number;
  81099. /**
  81100. * Returns the number for IsDifferent
  81101. */
  81102. static get IsDifferent(): number;
  81103. /**
  81104. * Returns the number for IsGreater
  81105. */
  81106. static get IsGreater(): number;
  81107. /**
  81108. * Returns the number for IsLesser
  81109. */
  81110. static get IsLesser(): number;
  81111. /**
  81112. * Internal only The action manager for the condition
  81113. * @hidden
  81114. */
  81115. _actionManager: ActionManager;
  81116. /**
  81117. * Internal only
  81118. * @hidden
  81119. */
  81120. private _target;
  81121. /**
  81122. * Internal only
  81123. * @hidden
  81124. */
  81125. private _effectiveTarget;
  81126. /**
  81127. * Internal only
  81128. * @hidden
  81129. */
  81130. private _property;
  81131. /**
  81132. * Creates a new ValueCondition
  81133. * @param actionManager manager for the action the condition applies to
  81134. * @param target for the action
  81135. * @param propertyPath path to specify the property of the target the conditional operator uses
  81136. * @param value the value compared by the conditional operator against the current value of the property
  81137. * @param operator the conditional operator, default ValueCondition.IsEqual
  81138. */
  81139. constructor(actionManager: ActionManager, target: any,
  81140. /** path to specify the property of the target the conditional operator uses */
  81141. propertyPath: string,
  81142. /** the value compared by the conditional operator against the current value of the property */
  81143. value: any,
  81144. /** the conditional operator, default ValueCondition.IsEqual */
  81145. operator?: number);
  81146. /**
  81147. * Compares the given value with the property value for the specified conditional operator
  81148. * @returns the result of the comparison
  81149. */
  81150. isValid(): boolean;
  81151. /**
  81152. * Serialize the ValueCondition into a JSON compatible object
  81153. * @returns serialization object
  81154. */
  81155. serialize(): any;
  81156. /**
  81157. * Gets the name of the conditional operator for the ValueCondition
  81158. * @param operator the conditional operator
  81159. * @returns the name
  81160. */
  81161. static GetOperatorName(operator: number): string;
  81162. }
  81163. /**
  81164. * Defines a predicate condition as an extension of Condition
  81165. */
  81166. export class PredicateCondition extends Condition {
  81167. /** defines the predicate function used to validate the condition */
  81168. predicate: () => boolean;
  81169. /**
  81170. * Internal only - manager for action
  81171. * @hidden
  81172. */
  81173. _actionManager: ActionManager;
  81174. /**
  81175. * Creates a new PredicateCondition
  81176. * @param actionManager manager for the action the condition applies to
  81177. * @param predicate defines the predicate function used to validate the condition
  81178. */
  81179. constructor(actionManager: ActionManager,
  81180. /** defines the predicate function used to validate the condition */
  81181. predicate: () => boolean);
  81182. /**
  81183. * @returns the validity of the predicate condition
  81184. */
  81185. isValid(): boolean;
  81186. }
  81187. /**
  81188. * Defines a state condition as an extension of Condition
  81189. */
  81190. export class StateCondition extends Condition {
  81191. /** Value to compare with target state */
  81192. value: string;
  81193. /**
  81194. * Internal only - manager for action
  81195. * @hidden
  81196. */
  81197. _actionManager: ActionManager;
  81198. /**
  81199. * Internal only
  81200. * @hidden
  81201. */
  81202. private _target;
  81203. /**
  81204. * Creates a new StateCondition
  81205. * @param actionManager manager for the action the condition applies to
  81206. * @param target of the condition
  81207. * @param value to compare with target state
  81208. */
  81209. constructor(actionManager: ActionManager, target: any,
  81210. /** Value to compare with target state */
  81211. value: string);
  81212. /**
  81213. * Gets a boolean indicating if the current condition is met
  81214. * @returns the validity of the state
  81215. */
  81216. isValid(): boolean;
  81217. /**
  81218. * Serialize the StateCondition into a JSON compatible object
  81219. * @returns serialization object
  81220. */
  81221. serialize(): any;
  81222. }
  81223. }
  81224. declare module BABYLON {
  81225. /**
  81226. * This defines an action responsible to toggle a boolean once triggered.
  81227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81228. */
  81229. export class SwitchBooleanAction extends Action {
  81230. /**
  81231. * The path to the boolean property in the target object
  81232. */
  81233. propertyPath: string;
  81234. private _target;
  81235. private _effectiveTarget;
  81236. private _property;
  81237. /**
  81238. * Instantiate the action
  81239. * @param triggerOptions defines the trigger options
  81240. * @param target defines the object containing the boolean
  81241. * @param propertyPath defines the path to the boolean property in the target object
  81242. * @param condition defines the trigger related conditions
  81243. */
  81244. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  81245. /** @hidden */
  81246. _prepare(): void;
  81247. /**
  81248. * Execute the action toggle the boolean value.
  81249. */
  81250. execute(): void;
  81251. /**
  81252. * Serializes the actions and its related information.
  81253. * @param parent defines the object to serialize in
  81254. * @returns the serialized object
  81255. */
  81256. serialize(parent: any): any;
  81257. }
  81258. /**
  81259. * This defines an action responsible to set a the state field of the target
  81260. * to a desired value once triggered.
  81261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81262. */
  81263. export class SetStateAction extends Action {
  81264. /**
  81265. * The value to store in the state field.
  81266. */
  81267. value: string;
  81268. private _target;
  81269. /**
  81270. * Instantiate the action
  81271. * @param triggerOptions defines the trigger options
  81272. * @param target defines the object containing the state property
  81273. * @param value defines the value to store in the state field
  81274. * @param condition defines the trigger related conditions
  81275. */
  81276. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  81277. /**
  81278. * Execute the action and store the value on the target state property.
  81279. */
  81280. execute(): void;
  81281. /**
  81282. * Serializes the actions and its related information.
  81283. * @param parent defines the object to serialize in
  81284. * @returns the serialized object
  81285. */
  81286. serialize(parent: any): any;
  81287. }
  81288. /**
  81289. * This defines an action responsible to set a property of the target
  81290. * to a desired value once triggered.
  81291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81292. */
  81293. export class SetValueAction extends Action {
  81294. /**
  81295. * The path of the property to set in the target.
  81296. */
  81297. propertyPath: string;
  81298. /**
  81299. * The value to set in the property
  81300. */
  81301. value: any;
  81302. private _target;
  81303. private _effectiveTarget;
  81304. private _property;
  81305. /**
  81306. * Instantiate the action
  81307. * @param triggerOptions defines the trigger options
  81308. * @param target defines the object containing the property
  81309. * @param propertyPath defines the path of the property to set in the target
  81310. * @param value defines the value to set in the property
  81311. * @param condition defines the trigger related conditions
  81312. */
  81313. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81314. /** @hidden */
  81315. _prepare(): void;
  81316. /**
  81317. * Execute the action and set the targetted property to the desired value.
  81318. */
  81319. execute(): void;
  81320. /**
  81321. * Serializes the actions and its related information.
  81322. * @param parent defines the object to serialize in
  81323. * @returns the serialized object
  81324. */
  81325. serialize(parent: any): any;
  81326. }
  81327. /**
  81328. * This defines an action responsible to increment the target value
  81329. * to a desired value once triggered.
  81330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81331. */
  81332. export class IncrementValueAction extends Action {
  81333. /**
  81334. * The path of the property to increment in the target.
  81335. */
  81336. propertyPath: string;
  81337. /**
  81338. * The value we should increment the property by.
  81339. */
  81340. value: any;
  81341. private _target;
  81342. private _effectiveTarget;
  81343. private _property;
  81344. /**
  81345. * Instantiate the action
  81346. * @param triggerOptions defines the trigger options
  81347. * @param target defines the object containing the property
  81348. * @param propertyPath defines the path of the property to increment in the target
  81349. * @param value defines the value value we should increment the property by
  81350. * @param condition defines the trigger related conditions
  81351. */
  81352. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81353. /** @hidden */
  81354. _prepare(): void;
  81355. /**
  81356. * Execute the action and increment the target of the value amount.
  81357. */
  81358. execute(): void;
  81359. /**
  81360. * Serializes the actions and its related information.
  81361. * @param parent defines the object to serialize in
  81362. * @returns the serialized object
  81363. */
  81364. serialize(parent: any): any;
  81365. }
  81366. /**
  81367. * This defines an action responsible to start an animation once triggered.
  81368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81369. */
  81370. export class PlayAnimationAction extends Action {
  81371. /**
  81372. * Where the animation should start (animation frame)
  81373. */
  81374. from: number;
  81375. /**
  81376. * Where the animation should stop (animation frame)
  81377. */
  81378. to: number;
  81379. /**
  81380. * Define if the animation should loop or stop after the first play.
  81381. */
  81382. loop?: boolean;
  81383. private _target;
  81384. /**
  81385. * Instantiate the action
  81386. * @param triggerOptions defines the trigger options
  81387. * @param target defines the target animation or animation name
  81388. * @param from defines from where the animation should start (animation frame)
  81389. * @param end defines where the animation should stop (animation frame)
  81390. * @param loop defines if the animation should loop or stop after the first play
  81391. * @param condition defines the trigger related conditions
  81392. */
  81393. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  81394. /** @hidden */
  81395. _prepare(): void;
  81396. /**
  81397. * Execute the action and play the animation.
  81398. */
  81399. execute(): void;
  81400. /**
  81401. * Serializes the actions and its related information.
  81402. * @param parent defines the object to serialize in
  81403. * @returns the serialized object
  81404. */
  81405. serialize(parent: any): any;
  81406. }
  81407. /**
  81408. * This defines an action responsible to stop an animation once triggered.
  81409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81410. */
  81411. export class StopAnimationAction extends Action {
  81412. private _target;
  81413. /**
  81414. * Instantiate the action
  81415. * @param triggerOptions defines the trigger options
  81416. * @param target defines the target animation or animation name
  81417. * @param condition defines the trigger related conditions
  81418. */
  81419. constructor(triggerOptions: any, target: any, condition?: Condition);
  81420. /** @hidden */
  81421. _prepare(): void;
  81422. /**
  81423. * Execute the action and stop the animation.
  81424. */
  81425. execute(): void;
  81426. /**
  81427. * Serializes the actions and its related information.
  81428. * @param parent defines the object to serialize in
  81429. * @returns the serialized object
  81430. */
  81431. serialize(parent: any): any;
  81432. }
  81433. /**
  81434. * This defines an action responsible that does nothing once triggered.
  81435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81436. */
  81437. export class DoNothingAction extends Action {
  81438. /**
  81439. * Instantiate the action
  81440. * @param triggerOptions defines the trigger options
  81441. * @param condition defines the trigger related conditions
  81442. */
  81443. constructor(triggerOptions?: any, condition?: Condition);
  81444. /**
  81445. * Execute the action and do nothing.
  81446. */
  81447. execute(): void;
  81448. /**
  81449. * Serializes the actions and its related information.
  81450. * @param parent defines the object to serialize in
  81451. * @returns the serialized object
  81452. */
  81453. serialize(parent: any): any;
  81454. }
  81455. /**
  81456. * This defines an action responsible to trigger several actions once triggered.
  81457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81458. */
  81459. export class CombineAction extends Action {
  81460. /**
  81461. * The list of aggregated animations to run.
  81462. */
  81463. children: Action[];
  81464. /**
  81465. * Instantiate the action
  81466. * @param triggerOptions defines the trigger options
  81467. * @param children defines the list of aggregated animations to run
  81468. * @param condition defines the trigger related conditions
  81469. */
  81470. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  81471. /** @hidden */
  81472. _prepare(): void;
  81473. /**
  81474. * Execute the action and executes all the aggregated actions.
  81475. */
  81476. execute(evt: ActionEvent): void;
  81477. /**
  81478. * Serializes the actions and its related information.
  81479. * @param parent defines the object to serialize in
  81480. * @returns the serialized object
  81481. */
  81482. serialize(parent: any): any;
  81483. }
  81484. /**
  81485. * This defines an action responsible to run code (external event) once triggered.
  81486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81487. */
  81488. export class ExecuteCodeAction extends Action {
  81489. /**
  81490. * The callback function to run.
  81491. */
  81492. func: (evt: ActionEvent) => void;
  81493. /**
  81494. * Instantiate the action
  81495. * @param triggerOptions defines the trigger options
  81496. * @param func defines the callback function to run
  81497. * @param condition defines the trigger related conditions
  81498. */
  81499. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  81500. /**
  81501. * Execute the action and run the attached code.
  81502. */
  81503. execute(evt: ActionEvent): void;
  81504. }
  81505. /**
  81506. * This defines an action responsible to set the parent property of the target once triggered.
  81507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81508. */
  81509. export class SetParentAction extends Action {
  81510. private _parent;
  81511. private _target;
  81512. /**
  81513. * Instantiate the action
  81514. * @param triggerOptions defines the trigger options
  81515. * @param target defines the target containing the parent property
  81516. * @param parent defines from where the animation should start (animation frame)
  81517. * @param condition defines the trigger related conditions
  81518. */
  81519. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  81520. /** @hidden */
  81521. _prepare(): void;
  81522. /**
  81523. * Execute the action and set the parent property.
  81524. */
  81525. execute(): void;
  81526. /**
  81527. * Serializes the actions and its related information.
  81528. * @param parent defines the object to serialize in
  81529. * @returns the serialized object
  81530. */
  81531. serialize(parent: any): any;
  81532. }
  81533. }
  81534. declare module BABYLON {
  81535. /**
  81536. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  81537. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  81538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81539. */
  81540. export class ActionManager extends AbstractActionManager {
  81541. /**
  81542. * Nothing
  81543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81544. */
  81545. static readonly NothingTrigger: number;
  81546. /**
  81547. * On pick
  81548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81549. */
  81550. static readonly OnPickTrigger: number;
  81551. /**
  81552. * On left pick
  81553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81554. */
  81555. static readonly OnLeftPickTrigger: number;
  81556. /**
  81557. * On right pick
  81558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81559. */
  81560. static readonly OnRightPickTrigger: number;
  81561. /**
  81562. * On center pick
  81563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81564. */
  81565. static readonly OnCenterPickTrigger: number;
  81566. /**
  81567. * On pick down
  81568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81569. */
  81570. static readonly OnPickDownTrigger: number;
  81571. /**
  81572. * On double pick
  81573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81574. */
  81575. static readonly OnDoublePickTrigger: number;
  81576. /**
  81577. * On pick up
  81578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81579. */
  81580. static readonly OnPickUpTrigger: number;
  81581. /**
  81582. * On pick out.
  81583. * This trigger will only be raised if you also declared a OnPickDown
  81584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81585. */
  81586. static readonly OnPickOutTrigger: number;
  81587. /**
  81588. * On long press
  81589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81590. */
  81591. static readonly OnLongPressTrigger: number;
  81592. /**
  81593. * On pointer over
  81594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81595. */
  81596. static readonly OnPointerOverTrigger: number;
  81597. /**
  81598. * On pointer out
  81599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81600. */
  81601. static readonly OnPointerOutTrigger: number;
  81602. /**
  81603. * On every frame
  81604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81605. */
  81606. static readonly OnEveryFrameTrigger: number;
  81607. /**
  81608. * On intersection enter
  81609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81610. */
  81611. static readonly OnIntersectionEnterTrigger: number;
  81612. /**
  81613. * On intersection exit
  81614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81615. */
  81616. static readonly OnIntersectionExitTrigger: number;
  81617. /**
  81618. * On key down
  81619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81620. */
  81621. static readonly OnKeyDownTrigger: number;
  81622. /**
  81623. * On key up
  81624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81625. */
  81626. static readonly OnKeyUpTrigger: number;
  81627. private _scene;
  81628. /**
  81629. * Creates a new action manager
  81630. * @param scene defines the hosting scene
  81631. */
  81632. constructor(scene: Scene);
  81633. /**
  81634. * Releases all associated resources
  81635. */
  81636. dispose(): void;
  81637. /**
  81638. * Gets hosting scene
  81639. * @returns the hosting scene
  81640. */
  81641. getScene(): Scene;
  81642. /**
  81643. * Does this action manager handles actions of any of the given triggers
  81644. * @param triggers defines the triggers to be tested
  81645. * @return a boolean indicating whether one (or more) of the triggers is handled
  81646. */
  81647. hasSpecificTriggers(triggers: number[]): boolean;
  81648. /**
  81649. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81650. * speed.
  81651. * @param triggerA defines the trigger to be tested
  81652. * @param triggerB defines the trigger to be tested
  81653. * @return a boolean indicating whether one (or more) of the triggers is handled
  81654. */
  81655. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81656. /**
  81657. * Does this action manager handles actions of a given trigger
  81658. * @param trigger defines the trigger to be tested
  81659. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81660. * @return whether the trigger is handled
  81661. */
  81662. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81663. /**
  81664. * Does this action manager has pointer triggers
  81665. */
  81666. get hasPointerTriggers(): boolean;
  81667. /**
  81668. * Does this action manager has pick triggers
  81669. */
  81670. get hasPickTriggers(): boolean;
  81671. /**
  81672. * Registers an action to this action manager
  81673. * @param action defines the action to be registered
  81674. * @return the action amended (prepared) after registration
  81675. */
  81676. registerAction(action: IAction): Nullable<IAction>;
  81677. /**
  81678. * Unregisters an action to this action manager
  81679. * @param action defines the action to be unregistered
  81680. * @return a boolean indicating whether the action has been unregistered
  81681. */
  81682. unregisterAction(action: IAction): Boolean;
  81683. /**
  81684. * Process a specific trigger
  81685. * @param trigger defines the trigger to process
  81686. * @param evt defines the event details to be processed
  81687. */
  81688. processTrigger(trigger: number, evt?: IActionEvent): void;
  81689. /** @hidden */
  81690. _getEffectiveTarget(target: any, propertyPath: string): any;
  81691. /** @hidden */
  81692. _getProperty(propertyPath: string): string;
  81693. /**
  81694. * Serialize this manager to a JSON object
  81695. * @param name defines the property name to store this manager
  81696. * @returns a JSON representation of this manager
  81697. */
  81698. serialize(name: string): any;
  81699. /**
  81700. * Creates a new ActionManager from a JSON data
  81701. * @param parsedActions defines the JSON data to read from
  81702. * @param object defines the hosting mesh
  81703. * @param scene defines the hosting scene
  81704. */
  81705. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  81706. /**
  81707. * Get a trigger name by index
  81708. * @param trigger defines the trigger index
  81709. * @returns a trigger name
  81710. */
  81711. static GetTriggerName(trigger: number): string;
  81712. }
  81713. }
  81714. declare module BABYLON {
  81715. /**
  81716. * Class representing a ray with position and direction
  81717. */
  81718. export class Ray {
  81719. /** origin point */
  81720. origin: Vector3;
  81721. /** direction */
  81722. direction: Vector3;
  81723. /** length of the ray */
  81724. length: number;
  81725. private static readonly TmpVector3;
  81726. private _tmpRay;
  81727. /**
  81728. * Creates a new ray
  81729. * @param origin origin point
  81730. * @param direction direction
  81731. * @param length length of the ray
  81732. */
  81733. constructor(
  81734. /** origin point */
  81735. origin: Vector3,
  81736. /** direction */
  81737. direction: Vector3,
  81738. /** length of the ray */
  81739. length?: number);
  81740. /**
  81741. * Checks if the ray intersects a box
  81742. * @param minimum bound of the box
  81743. * @param maximum bound of the box
  81744. * @param intersectionTreshold extra extend to be added to the box in all direction
  81745. * @returns if the box was hit
  81746. */
  81747. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  81748. /**
  81749. * Checks if the ray intersects a box
  81750. * @param box the bounding box to check
  81751. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  81752. * @returns if the box was hit
  81753. */
  81754. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  81755. /**
  81756. * If the ray hits a sphere
  81757. * @param sphere the bounding sphere to check
  81758. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  81759. * @returns true if it hits the sphere
  81760. */
  81761. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  81762. /**
  81763. * If the ray hits a triange
  81764. * @param vertex0 triangle vertex
  81765. * @param vertex1 triangle vertex
  81766. * @param vertex2 triangle vertex
  81767. * @returns intersection information if hit
  81768. */
  81769. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  81770. /**
  81771. * Checks if ray intersects a plane
  81772. * @param plane the plane to check
  81773. * @returns the distance away it was hit
  81774. */
  81775. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  81776. /**
  81777. * Calculate the intercept of a ray on a given axis
  81778. * @param axis to check 'x' | 'y' | 'z'
  81779. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  81780. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  81781. */
  81782. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  81783. /**
  81784. * Checks if ray intersects a mesh
  81785. * @param mesh the mesh to check
  81786. * @param fastCheck if only the bounding box should checked
  81787. * @returns picking info of the intersecton
  81788. */
  81789. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  81790. /**
  81791. * Checks if ray intersects a mesh
  81792. * @param meshes the meshes to check
  81793. * @param fastCheck if only the bounding box should checked
  81794. * @param results array to store result in
  81795. * @returns Array of picking infos
  81796. */
  81797. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  81798. private _comparePickingInfo;
  81799. private static smallnum;
  81800. private static rayl;
  81801. /**
  81802. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  81803. * @param sega the first point of the segment to test the intersection against
  81804. * @param segb the second point of the segment to test the intersection against
  81805. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  81806. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  81807. */
  81808. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  81809. /**
  81810. * Update the ray from viewport position
  81811. * @param x position
  81812. * @param y y position
  81813. * @param viewportWidth viewport width
  81814. * @param viewportHeight viewport height
  81815. * @param world world matrix
  81816. * @param view view matrix
  81817. * @param projection projection matrix
  81818. * @returns this ray updated
  81819. */
  81820. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81821. /**
  81822. * Creates a ray with origin and direction of 0,0,0
  81823. * @returns the new ray
  81824. */
  81825. static Zero(): Ray;
  81826. /**
  81827. * Creates a new ray from screen space and viewport
  81828. * @param x position
  81829. * @param y y position
  81830. * @param viewportWidth viewport width
  81831. * @param viewportHeight viewport height
  81832. * @param world world matrix
  81833. * @param view view matrix
  81834. * @param projection projection matrix
  81835. * @returns new ray
  81836. */
  81837. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81838. /**
  81839. * 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
  81840. * transformed to the given world matrix.
  81841. * @param origin The origin point
  81842. * @param end The end point
  81843. * @param world a matrix to transform the ray to. Default is the identity matrix.
  81844. * @returns the new ray
  81845. */
  81846. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  81847. /**
  81848. * Transforms a ray by a matrix
  81849. * @param ray ray to transform
  81850. * @param matrix matrix to apply
  81851. * @returns the resulting new ray
  81852. */
  81853. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  81854. /**
  81855. * Transforms a ray by a matrix
  81856. * @param ray ray to transform
  81857. * @param matrix matrix to apply
  81858. * @param result ray to store result in
  81859. */
  81860. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  81861. /**
  81862. * Unproject a ray from screen space to object space
  81863. * @param sourceX defines the screen space x coordinate to use
  81864. * @param sourceY defines the screen space y coordinate to use
  81865. * @param viewportWidth defines the current width of the viewport
  81866. * @param viewportHeight defines the current height of the viewport
  81867. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81868. * @param view defines the view matrix to use
  81869. * @param projection defines the projection matrix to use
  81870. */
  81871. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  81872. }
  81873. /**
  81874. * Type used to define predicate used to select faces when a mesh intersection is detected
  81875. */
  81876. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  81877. interface Scene {
  81878. /** @hidden */
  81879. _tempPickingRay: Nullable<Ray>;
  81880. /** @hidden */
  81881. _cachedRayForTransform: Ray;
  81882. /** @hidden */
  81883. _pickWithRayInverseMatrix: Matrix;
  81884. /** @hidden */
  81885. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  81886. /** @hidden */
  81887. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  81888. }
  81889. }
  81890. declare module BABYLON {
  81891. /**
  81892. * Groups all the scene component constants in one place to ease maintenance.
  81893. * @hidden
  81894. */
  81895. export class SceneComponentConstants {
  81896. static readonly NAME_EFFECTLAYER: string;
  81897. static readonly NAME_LAYER: string;
  81898. static readonly NAME_LENSFLARESYSTEM: string;
  81899. static readonly NAME_BOUNDINGBOXRENDERER: string;
  81900. static readonly NAME_PARTICLESYSTEM: string;
  81901. static readonly NAME_GAMEPAD: string;
  81902. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  81903. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  81904. static readonly NAME_DEPTHRENDERER: string;
  81905. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  81906. static readonly NAME_SPRITE: string;
  81907. static readonly NAME_OUTLINERENDERER: string;
  81908. static readonly NAME_PROCEDURALTEXTURE: string;
  81909. static readonly NAME_SHADOWGENERATOR: string;
  81910. static readonly NAME_OCTREE: string;
  81911. static readonly NAME_PHYSICSENGINE: string;
  81912. static readonly NAME_AUDIO: string;
  81913. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  81914. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81915. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  81916. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81917. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  81918. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  81919. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  81920. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  81921. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  81922. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  81923. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  81924. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  81925. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  81926. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  81927. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  81928. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  81929. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  81930. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  81931. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  81932. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  81933. static readonly STEP_AFTERRENDER_AUDIO: number;
  81934. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  81935. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  81936. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  81937. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  81938. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  81939. static readonly STEP_POINTERMOVE_SPRITE: number;
  81940. static readonly STEP_POINTERDOWN_SPRITE: number;
  81941. static readonly STEP_POINTERUP_SPRITE: number;
  81942. }
  81943. /**
  81944. * This represents a scene component.
  81945. *
  81946. * This is used to decouple the dependency the scene is having on the different workloads like
  81947. * layers, post processes...
  81948. */
  81949. export interface ISceneComponent {
  81950. /**
  81951. * The name of the component. Each component must have a unique name.
  81952. */
  81953. name: string;
  81954. /**
  81955. * The scene the component belongs to.
  81956. */
  81957. scene: Scene;
  81958. /**
  81959. * Register the component to one instance of a scene.
  81960. */
  81961. register(): void;
  81962. /**
  81963. * Rebuilds the elements related to this component in case of
  81964. * context lost for instance.
  81965. */
  81966. rebuild(): void;
  81967. /**
  81968. * Disposes the component and the associated ressources.
  81969. */
  81970. dispose(): void;
  81971. }
  81972. /**
  81973. * This represents a SERIALIZABLE scene component.
  81974. *
  81975. * This extends Scene Component to add Serialization methods on top.
  81976. */
  81977. export interface ISceneSerializableComponent extends ISceneComponent {
  81978. /**
  81979. * Adds all the elements from the container to the scene
  81980. * @param container the container holding the elements
  81981. */
  81982. addFromContainer(container: AbstractScene): void;
  81983. /**
  81984. * Removes all the elements in the container from the scene
  81985. * @param container contains the elements to remove
  81986. * @param dispose if the removed element should be disposed (default: false)
  81987. */
  81988. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  81989. /**
  81990. * Serializes the component data to the specified json object
  81991. * @param serializationObject The object to serialize to
  81992. */
  81993. serialize(serializationObject: any): void;
  81994. }
  81995. /**
  81996. * Strong typing of a Mesh related stage step action
  81997. */
  81998. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  81999. /**
  82000. * Strong typing of a Evaluate Sub Mesh related stage step action
  82001. */
  82002. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82003. /**
  82004. * Strong typing of a Active Mesh related stage step action
  82005. */
  82006. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82007. /**
  82008. * Strong typing of a Camera related stage step action
  82009. */
  82010. export type CameraStageAction = (camera: Camera) => void;
  82011. /**
  82012. * Strong typing of a Camera Frame buffer related stage step action
  82013. */
  82014. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82015. /**
  82016. * Strong typing of a Render Target related stage step action
  82017. */
  82018. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82019. /**
  82020. * Strong typing of a RenderingGroup related stage step action
  82021. */
  82022. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82023. /**
  82024. * Strong typing of a Mesh Render related stage step action
  82025. */
  82026. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82027. /**
  82028. * Strong typing of a simple stage step action
  82029. */
  82030. export type SimpleStageAction = () => void;
  82031. /**
  82032. * Strong typing of a render target action.
  82033. */
  82034. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82035. /**
  82036. * Strong typing of a pointer move action.
  82037. */
  82038. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82039. /**
  82040. * Strong typing of a pointer up/down action.
  82041. */
  82042. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82043. /**
  82044. * Representation of a stage in the scene (Basically a list of ordered steps)
  82045. * @hidden
  82046. */
  82047. export class Stage<T extends Function> extends Array<{
  82048. index: number;
  82049. component: ISceneComponent;
  82050. action: T;
  82051. }> {
  82052. /**
  82053. * Hide ctor from the rest of the world.
  82054. * @param items The items to add.
  82055. */
  82056. private constructor();
  82057. /**
  82058. * Creates a new Stage.
  82059. * @returns A new instance of a Stage
  82060. */
  82061. static Create<T extends Function>(): Stage<T>;
  82062. /**
  82063. * Registers a step in an ordered way in the targeted stage.
  82064. * @param index Defines the position to register the step in
  82065. * @param component Defines the component attached to the step
  82066. * @param action Defines the action to launch during the step
  82067. */
  82068. registerStep(index: number, component: ISceneComponent, action: T): void;
  82069. /**
  82070. * Clears all the steps from the stage.
  82071. */
  82072. clear(): void;
  82073. }
  82074. }
  82075. declare module BABYLON {
  82076. interface Scene {
  82077. /** @hidden */
  82078. _pointerOverSprite: Nullable<Sprite>;
  82079. /** @hidden */
  82080. _pickedDownSprite: Nullable<Sprite>;
  82081. /** @hidden */
  82082. _tempSpritePickingRay: Nullable<Ray>;
  82083. /**
  82084. * All of the sprite managers added to this scene
  82085. * @see http://doc.babylonjs.com/babylon101/sprites
  82086. */
  82087. spriteManagers: Array<ISpriteManager>;
  82088. /**
  82089. * An event triggered when sprites rendering is about to start
  82090. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82091. */
  82092. onBeforeSpritesRenderingObservable: Observable<Scene>;
  82093. /**
  82094. * An event triggered when sprites rendering is done
  82095. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82096. */
  82097. onAfterSpritesRenderingObservable: Observable<Scene>;
  82098. /** @hidden */
  82099. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82100. /** Launch a ray to try to pick a sprite in the scene
  82101. * @param x position on screen
  82102. * @param y position on screen
  82103. * @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
  82104. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82105. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82106. * @returns a PickingInfo
  82107. */
  82108. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82109. /** Use the given ray to pick a sprite in the scene
  82110. * @param ray The ray (in world space) to use to pick meshes
  82111. * @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
  82112. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82113. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82114. * @returns a PickingInfo
  82115. */
  82116. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82117. /** @hidden */
  82118. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82119. /** Launch a ray to try to pick sprites in the scene
  82120. * @param x position on screen
  82121. * @param y position on screen
  82122. * @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
  82123. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82124. * @returns a PickingInfo array
  82125. */
  82126. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82127. /** Use the given ray to pick sprites in the scene
  82128. * @param ray The ray (in world space) to use to pick meshes
  82129. * @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
  82130. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82131. * @returns a PickingInfo array
  82132. */
  82133. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82134. /**
  82135. * Force the sprite under the pointer
  82136. * @param sprite defines the sprite to use
  82137. */
  82138. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  82139. /**
  82140. * Gets the sprite under the pointer
  82141. * @returns a Sprite or null if no sprite is under the pointer
  82142. */
  82143. getPointerOverSprite(): Nullable<Sprite>;
  82144. }
  82145. /**
  82146. * Defines the sprite scene component responsible to manage sprites
  82147. * in a given scene.
  82148. */
  82149. export class SpriteSceneComponent implements ISceneComponent {
  82150. /**
  82151. * The component name helpfull to identify the component in the list of scene components.
  82152. */
  82153. readonly name: string;
  82154. /**
  82155. * The scene the component belongs to.
  82156. */
  82157. scene: Scene;
  82158. /** @hidden */
  82159. private _spritePredicate;
  82160. /**
  82161. * Creates a new instance of the component for the given scene
  82162. * @param scene Defines the scene to register the component in
  82163. */
  82164. constructor(scene: Scene);
  82165. /**
  82166. * Registers the component in a given scene
  82167. */
  82168. register(): void;
  82169. /**
  82170. * Rebuilds the elements related to this component in case of
  82171. * context lost for instance.
  82172. */
  82173. rebuild(): void;
  82174. /**
  82175. * Disposes the component and the associated ressources.
  82176. */
  82177. dispose(): void;
  82178. private _pickSpriteButKeepRay;
  82179. private _pointerMove;
  82180. private _pointerDown;
  82181. private _pointerUp;
  82182. }
  82183. }
  82184. declare module BABYLON {
  82185. /** @hidden */
  82186. export var fogFragmentDeclaration: {
  82187. name: string;
  82188. shader: string;
  82189. };
  82190. }
  82191. declare module BABYLON {
  82192. /** @hidden */
  82193. export var fogFragment: {
  82194. name: string;
  82195. shader: string;
  82196. };
  82197. }
  82198. declare module BABYLON {
  82199. /** @hidden */
  82200. export var spritesPixelShader: {
  82201. name: string;
  82202. shader: string;
  82203. };
  82204. }
  82205. declare module BABYLON {
  82206. /** @hidden */
  82207. export var fogVertexDeclaration: {
  82208. name: string;
  82209. shader: string;
  82210. };
  82211. }
  82212. declare module BABYLON {
  82213. /** @hidden */
  82214. export var spritesVertexShader: {
  82215. name: string;
  82216. shader: string;
  82217. };
  82218. }
  82219. declare module BABYLON {
  82220. /**
  82221. * Defines the minimum interface to fullfil in order to be a sprite manager.
  82222. */
  82223. export interface ISpriteManager extends IDisposable {
  82224. /**
  82225. * Restricts the camera to viewing objects with the same layerMask.
  82226. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  82227. */
  82228. layerMask: number;
  82229. /**
  82230. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82231. */
  82232. isPickable: boolean;
  82233. /**
  82234. * Specifies the rendering group id for this mesh (0 by default)
  82235. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82236. */
  82237. renderingGroupId: number;
  82238. /**
  82239. * Defines the list of sprites managed by the manager.
  82240. */
  82241. sprites: Array<Sprite>;
  82242. /**
  82243. * Tests the intersection of a sprite with a specific ray.
  82244. * @param ray The ray we are sending to test the collision
  82245. * @param camera The camera space we are sending rays in
  82246. * @param predicate A predicate allowing excluding sprites from the list of object to test
  82247. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  82248. * @returns picking info or null.
  82249. */
  82250. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82251. /**
  82252. * Intersects the sprites with a ray
  82253. * @param ray defines the ray to intersect with
  82254. * @param camera defines the current active camera
  82255. * @param predicate defines a predicate used to select candidate sprites
  82256. * @returns null if no hit or a PickingInfo array
  82257. */
  82258. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82259. /**
  82260. * Renders the list of sprites on screen.
  82261. */
  82262. render(): void;
  82263. }
  82264. /**
  82265. * Class used to manage multiple sprites on the same spritesheet
  82266. * @see http://doc.babylonjs.com/babylon101/sprites
  82267. */
  82268. export class SpriteManager implements ISpriteManager {
  82269. /** defines the manager's name */
  82270. name: string;
  82271. /** Gets the list of sprites */
  82272. sprites: Sprite[];
  82273. /** Gets or sets the rendering group id (0 by default) */
  82274. renderingGroupId: number;
  82275. /** Gets or sets camera layer mask */
  82276. layerMask: number;
  82277. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  82278. fogEnabled: boolean;
  82279. /** Gets or sets a boolean indicating if the sprites are pickable */
  82280. isPickable: boolean;
  82281. /** Defines the default width of a cell in the spritesheet */
  82282. cellWidth: number;
  82283. /** Defines the default height of a cell in the spritesheet */
  82284. cellHeight: number;
  82285. /** Associative array from JSON sprite data file */
  82286. private _cellData;
  82287. /** Array of sprite names from JSON sprite data file */
  82288. private _spriteMap;
  82289. /** True when packed cell data from JSON file is ready*/
  82290. private _packedAndReady;
  82291. /**
  82292. * An event triggered when the manager is disposed.
  82293. */
  82294. onDisposeObservable: Observable<SpriteManager>;
  82295. private _onDisposeObserver;
  82296. /**
  82297. * Callback called when the manager is disposed
  82298. */
  82299. set onDispose(callback: () => void);
  82300. private _capacity;
  82301. private _fromPacked;
  82302. private _spriteTexture;
  82303. private _epsilon;
  82304. private _scene;
  82305. private _vertexData;
  82306. private _buffer;
  82307. private _vertexBuffers;
  82308. private _indexBuffer;
  82309. private _effectBase;
  82310. private _effectFog;
  82311. /**
  82312. * Gets or sets the spritesheet texture
  82313. */
  82314. get texture(): Texture;
  82315. set texture(value: Texture);
  82316. /**
  82317. * Creates a new sprite manager
  82318. * @param name defines the manager's name
  82319. * @param imgUrl defines the sprite sheet url
  82320. * @param capacity defines the maximum allowed number of sprites
  82321. * @param cellSize defines the size of a sprite cell
  82322. * @param scene defines the hosting scene
  82323. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  82324. * @param samplingMode defines the smapling mode to use with spritesheet
  82325. * @param fromPacked set to false; do not alter
  82326. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  82327. */
  82328. constructor(
  82329. /** defines the manager's name */
  82330. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  82331. private _makePacked;
  82332. private _appendSpriteVertex;
  82333. /**
  82334. * Intersects the sprites with a ray
  82335. * @param ray defines the ray to intersect with
  82336. * @param camera defines the current active camera
  82337. * @param predicate defines a predicate used to select candidate sprites
  82338. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  82339. * @returns null if no hit or a PickingInfo
  82340. */
  82341. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82342. /**
  82343. * Intersects the sprites with a ray
  82344. * @param ray defines the ray to intersect with
  82345. * @param camera defines the current active camera
  82346. * @param predicate defines a predicate used to select candidate sprites
  82347. * @returns null if no hit or a PickingInfo array
  82348. */
  82349. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82350. /**
  82351. * Render all child sprites
  82352. */
  82353. render(): void;
  82354. /**
  82355. * Release associated resources
  82356. */
  82357. dispose(): void;
  82358. }
  82359. }
  82360. declare module BABYLON {
  82361. /**
  82362. * Class used to represent a sprite
  82363. * @see http://doc.babylonjs.com/babylon101/sprites
  82364. */
  82365. export class Sprite {
  82366. /** defines the name */
  82367. name: string;
  82368. /** Gets or sets the current world position */
  82369. position: Vector3;
  82370. /** Gets or sets the main color */
  82371. color: Color4;
  82372. /** Gets or sets the width */
  82373. width: number;
  82374. /** Gets or sets the height */
  82375. height: number;
  82376. /** Gets or sets rotation angle */
  82377. angle: number;
  82378. /** Gets or sets the cell index in the sprite sheet */
  82379. cellIndex: number;
  82380. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  82381. cellRef: string;
  82382. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  82383. invertU: number;
  82384. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  82385. invertV: number;
  82386. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  82387. disposeWhenFinishedAnimating: boolean;
  82388. /** Gets the list of attached animations */
  82389. animations: Animation[];
  82390. /** Gets or sets a boolean indicating if the sprite can be picked */
  82391. isPickable: boolean;
  82392. /**
  82393. * Gets or sets the associated action manager
  82394. */
  82395. actionManager: Nullable<ActionManager>;
  82396. private _animationStarted;
  82397. private _loopAnimation;
  82398. private _fromIndex;
  82399. private _toIndex;
  82400. private _delay;
  82401. private _direction;
  82402. private _manager;
  82403. private _time;
  82404. private _onAnimationEnd;
  82405. /**
  82406. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  82407. */
  82408. isVisible: boolean;
  82409. /**
  82410. * Gets or sets the sprite size
  82411. */
  82412. get size(): number;
  82413. set size(value: number);
  82414. /**
  82415. * Creates a new Sprite
  82416. * @param name defines the name
  82417. * @param manager defines the manager
  82418. */
  82419. constructor(
  82420. /** defines the name */
  82421. name: string, manager: ISpriteManager);
  82422. /**
  82423. * Starts an animation
  82424. * @param from defines the initial key
  82425. * @param to defines the end key
  82426. * @param loop defines if the animation must loop
  82427. * @param delay defines the start delay (in ms)
  82428. * @param onAnimationEnd defines a callback to call when animation ends
  82429. */
  82430. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  82431. /** Stops current animation (if any) */
  82432. stopAnimation(): void;
  82433. /** @hidden */
  82434. _animate(deltaTime: number): void;
  82435. /** Release associated resources */
  82436. dispose(): void;
  82437. }
  82438. }
  82439. declare module BABYLON {
  82440. /**
  82441. * Information about the result of picking within a scene
  82442. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  82443. */
  82444. export class PickingInfo {
  82445. /** @hidden */
  82446. _pickingUnavailable: boolean;
  82447. /**
  82448. * If the pick collided with an object
  82449. */
  82450. hit: boolean;
  82451. /**
  82452. * Distance away where the pick collided
  82453. */
  82454. distance: number;
  82455. /**
  82456. * The location of pick collision
  82457. */
  82458. pickedPoint: Nullable<Vector3>;
  82459. /**
  82460. * The mesh corresponding the the pick collision
  82461. */
  82462. pickedMesh: Nullable<AbstractMesh>;
  82463. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  82464. bu: number;
  82465. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  82466. bv: number;
  82467. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  82468. faceId: number;
  82469. /** Id of the the submesh that was picked */
  82470. subMeshId: number;
  82471. /** If a sprite was picked, this will be the sprite the pick collided with */
  82472. pickedSprite: Nullable<Sprite>;
  82473. /**
  82474. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  82475. */
  82476. originMesh: Nullable<AbstractMesh>;
  82477. /**
  82478. * The ray that was used to perform the picking.
  82479. */
  82480. ray: Nullable<Ray>;
  82481. /**
  82482. * Gets the normal correspodning to the face the pick collided with
  82483. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  82484. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  82485. * @returns The normal correspodning to the face the pick collided with
  82486. */
  82487. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  82488. /**
  82489. * Gets the texture coordinates of where the pick occured
  82490. * @returns the vector containing the coordnates of the texture
  82491. */
  82492. getTextureCoordinates(): Nullable<Vector2>;
  82493. }
  82494. }
  82495. declare module BABYLON {
  82496. /**
  82497. * Gather the list of pointer event types as constants.
  82498. */
  82499. export class PointerEventTypes {
  82500. /**
  82501. * 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.
  82502. */
  82503. static readonly POINTERDOWN: number;
  82504. /**
  82505. * The pointerup event is fired when a pointer is no longer active.
  82506. */
  82507. static readonly POINTERUP: number;
  82508. /**
  82509. * The pointermove event is fired when a pointer changes coordinates.
  82510. */
  82511. static readonly POINTERMOVE: number;
  82512. /**
  82513. * The pointerwheel event is fired when a mouse wheel has been rotated.
  82514. */
  82515. static readonly POINTERWHEEL: number;
  82516. /**
  82517. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  82518. */
  82519. static readonly POINTERPICK: number;
  82520. /**
  82521. * The pointertap event is fired when a the object has been touched and released without drag.
  82522. */
  82523. static readonly POINTERTAP: number;
  82524. /**
  82525. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  82526. */
  82527. static readonly POINTERDOUBLETAP: number;
  82528. }
  82529. /**
  82530. * Base class of pointer info types.
  82531. */
  82532. export class PointerInfoBase {
  82533. /**
  82534. * Defines the type of event (PointerEventTypes)
  82535. */
  82536. type: number;
  82537. /**
  82538. * Defines the related dom event
  82539. */
  82540. event: PointerEvent | MouseWheelEvent;
  82541. /**
  82542. * Instantiates the base class of pointers info.
  82543. * @param type Defines the type of event (PointerEventTypes)
  82544. * @param event Defines the related dom event
  82545. */
  82546. constructor(
  82547. /**
  82548. * Defines the type of event (PointerEventTypes)
  82549. */
  82550. type: number,
  82551. /**
  82552. * Defines the related dom event
  82553. */
  82554. event: PointerEvent | MouseWheelEvent);
  82555. }
  82556. /**
  82557. * This class is used to store pointer related info for the onPrePointerObservable event.
  82558. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  82559. */
  82560. export class PointerInfoPre extends PointerInfoBase {
  82561. /**
  82562. * Ray from a pointer if availible (eg. 6dof controller)
  82563. */
  82564. ray: Nullable<Ray>;
  82565. /**
  82566. * Defines the local position of the pointer on the canvas.
  82567. */
  82568. localPosition: Vector2;
  82569. /**
  82570. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  82571. */
  82572. skipOnPointerObservable: boolean;
  82573. /**
  82574. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  82575. * @param type Defines the type of event (PointerEventTypes)
  82576. * @param event Defines the related dom event
  82577. * @param localX Defines the local x coordinates of the pointer when the event occured
  82578. * @param localY Defines the local y coordinates of the pointer when the event occured
  82579. */
  82580. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  82581. }
  82582. /**
  82583. * This type contains all the data related to a pointer event in Babylon.js.
  82584. * 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.
  82585. */
  82586. export class PointerInfo extends PointerInfoBase {
  82587. /**
  82588. * Defines the picking info associated to the info (if any)\
  82589. */
  82590. pickInfo: Nullable<PickingInfo>;
  82591. /**
  82592. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  82593. * @param type Defines the type of event (PointerEventTypes)
  82594. * @param event Defines the related dom event
  82595. * @param pickInfo Defines the picking info associated to the info (if any)\
  82596. */
  82597. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  82598. /**
  82599. * Defines the picking info associated to the info (if any)\
  82600. */
  82601. pickInfo: Nullable<PickingInfo>);
  82602. }
  82603. /**
  82604. * Data relating to a touch event on the screen.
  82605. */
  82606. export interface PointerTouch {
  82607. /**
  82608. * X coordinate of touch.
  82609. */
  82610. x: number;
  82611. /**
  82612. * Y coordinate of touch.
  82613. */
  82614. y: number;
  82615. /**
  82616. * Id of touch. Unique for each finger.
  82617. */
  82618. pointerId: number;
  82619. /**
  82620. * Event type passed from DOM.
  82621. */
  82622. type: any;
  82623. }
  82624. }
  82625. declare module BABYLON {
  82626. /**
  82627. * Manage the mouse inputs to control the movement of a free camera.
  82628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82629. */
  82630. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  82631. /**
  82632. * Define if touch is enabled in the mouse input
  82633. */
  82634. touchEnabled: boolean;
  82635. /**
  82636. * Defines the camera the input is attached to.
  82637. */
  82638. camera: FreeCamera;
  82639. /**
  82640. * Defines the buttons associated with the input to handle camera move.
  82641. */
  82642. buttons: number[];
  82643. /**
  82644. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  82645. */
  82646. angularSensibility: number;
  82647. private _pointerInput;
  82648. private _onMouseMove;
  82649. private _observer;
  82650. private previousPosition;
  82651. /**
  82652. * Observable for when a pointer move event occurs containing the move offset
  82653. */
  82654. onPointerMovedObservable: Observable<{
  82655. offsetX: number;
  82656. offsetY: number;
  82657. }>;
  82658. /**
  82659. * @hidden
  82660. * If the camera should be rotated automatically based on pointer movement
  82661. */
  82662. _allowCameraRotation: boolean;
  82663. /**
  82664. * Manage the mouse inputs to control the movement of a free camera.
  82665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82666. * @param touchEnabled Defines if touch is enabled or not
  82667. */
  82668. constructor(
  82669. /**
  82670. * Define if touch is enabled in the mouse input
  82671. */
  82672. touchEnabled?: boolean);
  82673. /**
  82674. * Attach the input controls to a specific dom element to get the input from.
  82675. * @param element Defines the element the controls should be listened from
  82676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82677. */
  82678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82679. /**
  82680. * Called on JS contextmenu event.
  82681. * Override this method to provide functionality.
  82682. */
  82683. protected onContextMenu(evt: PointerEvent): void;
  82684. /**
  82685. * Detach the current controls from the specified dom element.
  82686. * @param element Defines the element to stop listening the inputs from
  82687. */
  82688. detachControl(element: Nullable<HTMLElement>): void;
  82689. /**
  82690. * Gets the class name of the current intput.
  82691. * @returns the class name
  82692. */
  82693. getClassName(): string;
  82694. /**
  82695. * Get the friendly name associated with the input class.
  82696. * @returns the input friendly name
  82697. */
  82698. getSimpleName(): string;
  82699. }
  82700. }
  82701. declare module BABYLON {
  82702. /**
  82703. * Manage the touch inputs to control the movement of a free camera.
  82704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82705. */
  82706. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  82707. /**
  82708. * Defines the camera the input is attached to.
  82709. */
  82710. camera: FreeCamera;
  82711. /**
  82712. * Defines the touch sensibility for rotation.
  82713. * The higher the faster.
  82714. */
  82715. touchAngularSensibility: number;
  82716. /**
  82717. * Defines the touch sensibility for move.
  82718. * The higher the faster.
  82719. */
  82720. touchMoveSensibility: number;
  82721. private _offsetX;
  82722. private _offsetY;
  82723. private _pointerPressed;
  82724. private _pointerInput;
  82725. private _observer;
  82726. private _onLostFocus;
  82727. /**
  82728. * Attach the input controls to a specific dom element to get the input from.
  82729. * @param element Defines the element the controls should be listened from
  82730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82731. */
  82732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82733. /**
  82734. * Detach the current controls from the specified dom element.
  82735. * @param element Defines the element to stop listening the inputs from
  82736. */
  82737. detachControl(element: Nullable<HTMLElement>): void;
  82738. /**
  82739. * Update the current camera state depending on the inputs that have been used this frame.
  82740. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82741. */
  82742. checkInputs(): void;
  82743. /**
  82744. * Gets the class name of the current intput.
  82745. * @returns the class name
  82746. */
  82747. getClassName(): string;
  82748. /**
  82749. * Get the friendly name associated with the input class.
  82750. * @returns the input friendly name
  82751. */
  82752. getSimpleName(): string;
  82753. }
  82754. }
  82755. declare module BABYLON {
  82756. /**
  82757. * Default Inputs manager for the FreeCamera.
  82758. * It groups all the default supported inputs for ease of use.
  82759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82760. */
  82761. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  82762. /**
  82763. * @hidden
  82764. */
  82765. _mouseInput: Nullable<FreeCameraMouseInput>;
  82766. /**
  82767. * Instantiates a new FreeCameraInputsManager.
  82768. * @param camera Defines the camera the inputs belong to
  82769. */
  82770. constructor(camera: FreeCamera);
  82771. /**
  82772. * Add keyboard input support to the input manager.
  82773. * @returns the current input manager
  82774. */
  82775. addKeyboard(): FreeCameraInputsManager;
  82776. /**
  82777. * Add mouse input support to the input manager.
  82778. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  82779. * @returns the current input manager
  82780. */
  82781. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  82782. /**
  82783. * Removes the mouse input support from the manager
  82784. * @returns the current input manager
  82785. */
  82786. removeMouse(): FreeCameraInputsManager;
  82787. /**
  82788. * Add touch input support to the input manager.
  82789. * @returns the current input manager
  82790. */
  82791. addTouch(): FreeCameraInputsManager;
  82792. /**
  82793. * Remove all attached input methods from a camera
  82794. */
  82795. clear(): void;
  82796. }
  82797. }
  82798. declare module BABYLON {
  82799. /**
  82800. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82801. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  82802. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82803. */
  82804. export class FreeCamera extends TargetCamera {
  82805. /**
  82806. * Define the collision ellipsoid of the camera.
  82807. * This is helpful to simulate a camera body like the player body around the camera
  82808. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  82809. */
  82810. ellipsoid: Vector3;
  82811. /**
  82812. * Define an offset for the position of the ellipsoid around the camera.
  82813. * This can be helpful to determine the center of the body near the gravity center of the body
  82814. * instead of its head.
  82815. */
  82816. ellipsoidOffset: Vector3;
  82817. /**
  82818. * Enable or disable collisions of the camera with the rest of the scene objects.
  82819. */
  82820. checkCollisions: boolean;
  82821. /**
  82822. * Enable or disable gravity on the camera.
  82823. */
  82824. applyGravity: boolean;
  82825. /**
  82826. * Define the input manager associated to the camera.
  82827. */
  82828. inputs: FreeCameraInputsManager;
  82829. /**
  82830. * Gets the input sensibility for a mouse input. (default is 2000.0)
  82831. * Higher values reduce sensitivity.
  82832. */
  82833. get angularSensibility(): number;
  82834. /**
  82835. * Sets the input sensibility for a mouse input. (default is 2000.0)
  82836. * Higher values reduce sensitivity.
  82837. */
  82838. set angularSensibility(value: number);
  82839. /**
  82840. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82841. */
  82842. get keysUp(): number[];
  82843. set keysUp(value: number[]);
  82844. /**
  82845. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82846. */
  82847. get keysDown(): number[];
  82848. set keysDown(value: number[]);
  82849. /**
  82850. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82851. */
  82852. get keysLeft(): number[];
  82853. set keysLeft(value: number[]);
  82854. /**
  82855. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82856. */
  82857. get keysRight(): number[];
  82858. set keysRight(value: number[]);
  82859. /**
  82860. * Event raised when the camera collide with a mesh in the scene.
  82861. */
  82862. onCollide: (collidedMesh: AbstractMesh) => void;
  82863. private _collider;
  82864. private _needMoveForGravity;
  82865. private _oldPosition;
  82866. private _diffPosition;
  82867. private _newPosition;
  82868. /** @hidden */
  82869. _localDirection: Vector3;
  82870. /** @hidden */
  82871. _transformedDirection: Vector3;
  82872. /**
  82873. * Instantiates a Free Camera.
  82874. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82875. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  82876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82877. * @param name Define the name of the camera in the scene
  82878. * @param position Define the start position of the camera in the scene
  82879. * @param scene Define the scene the camera belongs to
  82880. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82881. */
  82882. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82883. /**
  82884. * Attached controls to the current camera.
  82885. * @param element Defines the element the controls should be listened from
  82886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82887. */
  82888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82889. /**
  82890. * Detach the current controls from the camera.
  82891. * The camera will stop reacting to inputs.
  82892. * @param element Defines the element to stop listening the inputs from
  82893. */
  82894. detachControl(element: HTMLElement): void;
  82895. private _collisionMask;
  82896. /**
  82897. * Define a collision mask to limit the list of object the camera can collide with
  82898. */
  82899. get collisionMask(): number;
  82900. set collisionMask(mask: number);
  82901. /** @hidden */
  82902. _collideWithWorld(displacement: Vector3): void;
  82903. private _onCollisionPositionChange;
  82904. /** @hidden */
  82905. _checkInputs(): void;
  82906. /** @hidden */
  82907. _decideIfNeedsToMove(): boolean;
  82908. /** @hidden */
  82909. _updatePosition(): void;
  82910. /**
  82911. * Destroy the camera and release the current resources hold by it.
  82912. */
  82913. dispose(): void;
  82914. /**
  82915. * Gets the current object class name.
  82916. * @return the class name
  82917. */
  82918. getClassName(): string;
  82919. }
  82920. }
  82921. declare module BABYLON {
  82922. /**
  82923. * Represents a gamepad control stick position
  82924. */
  82925. export class StickValues {
  82926. /**
  82927. * The x component of the control stick
  82928. */
  82929. x: number;
  82930. /**
  82931. * The y component of the control stick
  82932. */
  82933. y: number;
  82934. /**
  82935. * Initializes the gamepad x and y control stick values
  82936. * @param x The x component of the gamepad control stick value
  82937. * @param y The y component of the gamepad control stick value
  82938. */
  82939. constructor(
  82940. /**
  82941. * The x component of the control stick
  82942. */
  82943. x: number,
  82944. /**
  82945. * The y component of the control stick
  82946. */
  82947. y: number);
  82948. }
  82949. /**
  82950. * An interface which manages callbacks for gamepad button changes
  82951. */
  82952. export interface GamepadButtonChanges {
  82953. /**
  82954. * Called when a gamepad has been changed
  82955. */
  82956. changed: boolean;
  82957. /**
  82958. * Called when a gamepad press event has been triggered
  82959. */
  82960. pressChanged: boolean;
  82961. /**
  82962. * Called when a touch event has been triggered
  82963. */
  82964. touchChanged: boolean;
  82965. /**
  82966. * Called when a value has changed
  82967. */
  82968. valueChanged: boolean;
  82969. }
  82970. /**
  82971. * Represents a gamepad
  82972. */
  82973. export class Gamepad {
  82974. /**
  82975. * The id of the gamepad
  82976. */
  82977. id: string;
  82978. /**
  82979. * The index of the gamepad
  82980. */
  82981. index: number;
  82982. /**
  82983. * The browser gamepad
  82984. */
  82985. browserGamepad: any;
  82986. /**
  82987. * Specifies what type of gamepad this represents
  82988. */
  82989. type: number;
  82990. private _leftStick;
  82991. private _rightStick;
  82992. /** @hidden */
  82993. _isConnected: boolean;
  82994. private _leftStickAxisX;
  82995. private _leftStickAxisY;
  82996. private _rightStickAxisX;
  82997. private _rightStickAxisY;
  82998. /**
  82999. * Triggered when the left control stick has been changed
  83000. */
  83001. private _onleftstickchanged;
  83002. /**
  83003. * Triggered when the right control stick has been changed
  83004. */
  83005. private _onrightstickchanged;
  83006. /**
  83007. * Represents a gamepad controller
  83008. */
  83009. static GAMEPAD: number;
  83010. /**
  83011. * Represents a generic controller
  83012. */
  83013. static GENERIC: number;
  83014. /**
  83015. * Represents an XBox controller
  83016. */
  83017. static XBOX: number;
  83018. /**
  83019. * Represents a pose-enabled controller
  83020. */
  83021. static POSE_ENABLED: number;
  83022. /**
  83023. * Represents an Dual Shock controller
  83024. */
  83025. static DUALSHOCK: number;
  83026. /**
  83027. * Specifies whether the left control stick should be Y-inverted
  83028. */
  83029. protected _invertLeftStickY: boolean;
  83030. /**
  83031. * Specifies if the gamepad has been connected
  83032. */
  83033. get isConnected(): boolean;
  83034. /**
  83035. * Initializes the gamepad
  83036. * @param id The id of the gamepad
  83037. * @param index The index of the gamepad
  83038. * @param browserGamepad The browser gamepad
  83039. * @param leftStickX The x component of the left joystick
  83040. * @param leftStickY The y component of the left joystick
  83041. * @param rightStickX The x component of the right joystick
  83042. * @param rightStickY The y component of the right joystick
  83043. */
  83044. constructor(
  83045. /**
  83046. * The id of the gamepad
  83047. */
  83048. id: string,
  83049. /**
  83050. * The index of the gamepad
  83051. */
  83052. index: number,
  83053. /**
  83054. * The browser gamepad
  83055. */
  83056. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  83057. /**
  83058. * Callback triggered when the left joystick has changed
  83059. * @param callback
  83060. */
  83061. onleftstickchanged(callback: (values: StickValues) => void): void;
  83062. /**
  83063. * Callback triggered when the right joystick has changed
  83064. * @param callback
  83065. */
  83066. onrightstickchanged(callback: (values: StickValues) => void): void;
  83067. /**
  83068. * Gets the left joystick
  83069. */
  83070. get leftStick(): StickValues;
  83071. /**
  83072. * Sets the left joystick values
  83073. */
  83074. set leftStick(newValues: StickValues);
  83075. /**
  83076. * Gets the right joystick
  83077. */
  83078. get rightStick(): StickValues;
  83079. /**
  83080. * Sets the right joystick value
  83081. */
  83082. set rightStick(newValues: StickValues);
  83083. /**
  83084. * Updates the gamepad joystick positions
  83085. */
  83086. update(): void;
  83087. /**
  83088. * Disposes the gamepad
  83089. */
  83090. dispose(): void;
  83091. }
  83092. /**
  83093. * Represents a generic gamepad
  83094. */
  83095. export class GenericPad extends Gamepad {
  83096. private _buttons;
  83097. private _onbuttondown;
  83098. private _onbuttonup;
  83099. /**
  83100. * Observable triggered when a button has been pressed
  83101. */
  83102. onButtonDownObservable: Observable<number>;
  83103. /**
  83104. * Observable triggered when a button has been released
  83105. */
  83106. onButtonUpObservable: Observable<number>;
  83107. /**
  83108. * Callback triggered when a button has been pressed
  83109. * @param callback Called when a button has been pressed
  83110. */
  83111. onbuttondown(callback: (buttonPressed: number) => void): void;
  83112. /**
  83113. * Callback triggered when a button has been released
  83114. * @param callback Called when a button has been released
  83115. */
  83116. onbuttonup(callback: (buttonReleased: number) => void): void;
  83117. /**
  83118. * Initializes the generic gamepad
  83119. * @param id The id of the generic gamepad
  83120. * @param index The index of the generic gamepad
  83121. * @param browserGamepad The browser gamepad
  83122. */
  83123. constructor(id: string, index: number, browserGamepad: any);
  83124. private _setButtonValue;
  83125. /**
  83126. * Updates the generic gamepad
  83127. */
  83128. update(): void;
  83129. /**
  83130. * Disposes the generic gamepad
  83131. */
  83132. dispose(): void;
  83133. }
  83134. }
  83135. declare module BABYLON {
  83136. interface Engine {
  83137. /**
  83138. * Creates a raw texture
  83139. * @param data defines the data to store in the texture
  83140. * @param width defines the width of the texture
  83141. * @param height defines the height of the texture
  83142. * @param format defines the format of the data
  83143. * @param generateMipMaps defines if the engine should generate the mip levels
  83144. * @param invertY defines if data must be stored with Y axis inverted
  83145. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83146. * @param compression defines the compression used (null by default)
  83147. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83148. * @returns the raw texture inside an InternalTexture
  83149. */
  83150. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83151. /**
  83152. * Update a raw texture
  83153. * @param texture defines the texture to update
  83154. * @param data defines the data to store in the texture
  83155. * @param format defines the format of the data
  83156. * @param invertY defines if data must be stored with Y axis inverted
  83157. */
  83158. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83159. /**
  83160. * Update a raw texture
  83161. * @param texture defines the texture to update
  83162. * @param data defines the data to store in the texture
  83163. * @param format defines the format of the data
  83164. * @param invertY defines if data must be stored with Y axis inverted
  83165. * @param compression defines the compression used (null by default)
  83166. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83167. */
  83168. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83169. /**
  83170. * Creates a new raw cube texture
  83171. * @param data defines the array of data to use to create each face
  83172. * @param size defines the size of the textures
  83173. * @param format defines the format of the data
  83174. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83175. * @param generateMipMaps defines if the engine should generate the mip levels
  83176. * @param invertY defines if data must be stored with Y axis inverted
  83177. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83178. * @param compression defines the compression used (null by default)
  83179. * @returns the cube texture as an InternalTexture
  83180. */
  83181. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83182. /**
  83183. * Update a raw cube texture
  83184. * @param texture defines the texture to udpdate
  83185. * @param data defines the data to store
  83186. * @param format defines the data format
  83187. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83188. * @param invertY defines if data must be stored with Y axis inverted
  83189. */
  83190. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83191. /**
  83192. * Update a raw cube texture
  83193. * @param texture defines the texture to udpdate
  83194. * @param data defines the data to store
  83195. * @param format defines the data format
  83196. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83197. * @param invertY defines if data must be stored with Y axis inverted
  83198. * @param compression defines the compression used (null by default)
  83199. */
  83200. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83201. /**
  83202. * Update a raw cube texture
  83203. * @param texture defines the texture to udpdate
  83204. * @param data defines the data to store
  83205. * @param format defines the data format
  83206. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83207. * @param invertY defines if data must be stored with Y axis inverted
  83208. * @param compression defines the compression used (null by default)
  83209. * @param level defines which level of the texture to update
  83210. */
  83211. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83212. /**
  83213. * Creates a new raw cube texture from a specified url
  83214. * @param url defines the url where the data is located
  83215. * @param scene defines the current scene
  83216. * @param size defines the size of the textures
  83217. * @param format defines the format of the data
  83218. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83219. * @param noMipmap defines if the engine should avoid generating the mip levels
  83220. * @param callback defines a callback used to extract texture data from loaded data
  83221. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83222. * @param onLoad defines a callback called when texture is loaded
  83223. * @param onError defines a callback called if there is an error
  83224. * @returns the cube texture as an InternalTexture
  83225. */
  83226. 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;
  83227. /**
  83228. * Creates a new raw cube texture from a specified url
  83229. * @param url defines the url where the data is located
  83230. * @param scene defines the current scene
  83231. * @param size defines the size of the textures
  83232. * @param format defines the format of the data
  83233. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83234. * @param noMipmap defines if the engine should avoid generating the mip levels
  83235. * @param callback defines a callback used to extract texture data from loaded data
  83236. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83237. * @param onLoad defines a callback called when texture is loaded
  83238. * @param onError defines a callback called if there is an error
  83239. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83240. * @param invertY defines if data must be stored with Y axis inverted
  83241. * @returns the cube texture as an InternalTexture
  83242. */
  83243. 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;
  83244. /**
  83245. * Creates a new raw 3D texture
  83246. * @param data defines the data used to create the texture
  83247. * @param width defines the width of the texture
  83248. * @param height defines the height of the texture
  83249. * @param depth defines the depth of the texture
  83250. * @param format defines the format of the texture
  83251. * @param generateMipMaps defines if the engine must generate mip levels
  83252. * @param invertY defines if data must be stored with Y axis inverted
  83253. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83254. * @param compression defines the compressed used (can be null)
  83255. * @param textureType defines the compressed used (can be null)
  83256. * @returns a new raw 3D texture (stored in an InternalTexture)
  83257. */
  83258. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83259. /**
  83260. * Update a raw 3D texture
  83261. * @param texture defines the texture to update
  83262. * @param data defines the data to store
  83263. * @param format defines the data format
  83264. * @param invertY defines if data must be stored with Y axis inverted
  83265. */
  83266. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83267. /**
  83268. * Update a raw 3D texture
  83269. * @param texture defines the texture to update
  83270. * @param data defines the data to store
  83271. * @param format defines the data format
  83272. * @param invertY defines if data must be stored with Y axis inverted
  83273. * @param compression defines the used compression (can be null)
  83274. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83275. */
  83276. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83277. /**
  83278. * Creates a new raw 2D array texture
  83279. * @param data defines the data used to create the texture
  83280. * @param width defines the width of the texture
  83281. * @param height defines the height of the texture
  83282. * @param depth defines the number of layers of the texture
  83283. * @param format defines the format of the texture
  83284. * @param generateMipMaps defines if the engine must generate mip levels
  83285. * @param invertY defines if data must be stored with Y axis inverted
  83286. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83287. * @param compression defines the compressed used (can be null)
  83288. * @param textureType defines the compressed used (can be null)
  83289. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83290. */
  83291. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83292. /**
  83293. * Update a raw 2D array texture
  83294. * @param texture defines the texture to update
  83295. * @param data defines the data to store
  83296. * @param format defines the data format
  83297. * @param invertY defines if data must be stored with Y axis inverted
  83298. */
  83299. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83300. /**
  83301. * Update a raw 2D array texture
  83302. * @param texture defines the texture to update
  83303. * @param data defines the data to store
  83304. * @param format defines the data format
  83305. * @param invertY defines if data must be stored with Y axis inverted
  83306. * @param compression defines the used compression (can be null)
  83307. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83308. */
  83309. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83310. }
  83311. }
  83312. declare module BABYLON {
  83313. /**
  83314. * Raw texture can help creating a texture directly from an array of data.
  83315. * This can be super useful if you either get the data from an uncompressed source or
  83316. * if you wish to create your texture pixel by pixel.
  83317. */
  83318. export class RawTexture extends Texture {
  83319. /**
  83320. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83321. */
  83322. format: number;
  83323. private _engine;
  83324. /**
  83325. * Instantiates a new RawTexture.
  83326. * Raw texture can help creating a texture directly from an array of data.
  83327. * This can be super useful if you either get the data from an uncompressed source or
  83328. * if you wish to create your texture pixel by pixel.
  83329. * @param data define the array of data to use to create the texture
  83330. * @param width define the width of the texture
  83331. * @param height define the height of the texture
  83332. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83333. * @param scene define the scene the texture belongs to
  83334. * @param generateMipMaps define whether mip maps should be generated or not
  83335. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83336. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83337. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83338. */
  83339. constructor(data: ArrayBufferView, width: number, height: number,
  83340. /**
  83341. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83342. */
  83343. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83344. /**
  83345. * Updates the texture underlying data.
  83346. * @param data Define the new data of the texture
  83347. */
  83348. update(data: ArrayBufferView): void;
  83349. /**
  83350. * Creates a luminance texture from some data.
  83351. * @param data Define the texture data
  83352. * @param width Define the width of the texture
  83353. * @param height Define the height of the texture
  83354. * @param scene Define the scene the texture belongs to
  83355. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83356. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83357. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83358. * @returns the luminance texture
  83359. */
  83360. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83361. /**
  83362. * Creates a luminance alpha texture from some data.
  83363. * @param data Define the texture data
  83364. * @param width Define the width of the texture
  83365. * @param height Define the height of the texture
  83366. * @param scene Define the scene the texture belongs to
  83367. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83368. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83369. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83370. * @returns the luminance alpha texture
  83371. */
  83372. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83373. /**
  83374. * Creates an alpha texture from some data.
  83375. * @param data Define the texture data
  83376. * @param width Define the width of the texture
  83377. * @param height Define the height of the texture
  83378. * @param scene Define the scene the texture belongs to
  83379. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83380. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83381. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83382. * @returns the alpha texture
  83383. */
  83384. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83385. /**
  83386. * Creates a RGB texture from some data.
  83387. * @param data Define the texture data
  83388. * @param width Define the width of the texture
  83389. * @param height Define the height of the texture
  83390. * @param scene Define the scene the texture belongs to
  83391. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83392. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83393. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83394. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83395. * @returns the RGB alpha texture
  83396. */
  83397. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83398. /**
  83399. * Creates a RGBA texture from some data.
  83400. * @param data Define the texture data
  83401. * @param width Define the width of the texture
  83402. * @param height Define the height of the texture
  83403. * @param scene Define the scene the texture belongs to
  83404. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83405. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83406. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83407. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83408. * @returns the RGBA texture
  83409. */
  83410. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83411. /**
  83412. * Creates a R texture from some data.
  83413. * @param data Define the texture data
  83414. * @param width Define the width of the texture
  83415. * @param height Define the height of the texture
  83416. * @param scene Define the scene the texture belongs to
  83417. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83418. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83419. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83420. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83421. * @returns the R texture
  83422. */
  83423. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83424. }
  83425. }
  83426. declare module BABYLON {
  83427. /**
  83428. * Interface for the size containing width and height
  83429. */
  83430. export interface ISize {
  83431. /**
  83432. * Width
  83433. */
  83434. width: number;
  83435. /**
  83436. * Heighht
  83437. */
  83438. height: number;
  83439. }
  83440. /**
  83441. * Size containing widht and height
  83442. */
  83443. export class Size implements ISize {
  83444. /**
  83445. * Width
  83446. */
  83447. width: number;
  83448. /**
  83449. * Height
  83450. */
  83451. height: number;
  83452. /**
  83453. * Creates a Size object from the given width and height (floats).
  83454. * @param width width of the new size
  83455. * @param height height of the new size
  83456. */
  83457. constructor(width: number, height: number);
  83458. /**
  83459. * Returns a string with the Size width and height
  83460. * @returns a string with the Size width and height
  83461. */
  83462. toString(): string;
  83463. /**
  83464. * "Size"
  83465. * @returns the string "Size"
  83466. */
  83467. getClassName(): string;
  83468. /**
  83469. * Returns the Size hash code.
  83470. * @returns a hash code for a unique width and height
  83471. */
  83472. getHashCode(): number;
  83473. /**
  83474. * Updates the current size from the given one.
  83475. * @param src the given size
  83476. */
  83477. copyFrom(src: Size): void;
  83478. /**
  83479. * Updates in place the current Size from the given floats.
  83480. * @param width width of the new size
  83481. * @param height height of the new size
  83482. * @returns the updated Size.
  83483. */
  83484. copyFromFloats(width: number, height: number): Size;
  83485. /**
  83486. * Updates in place the current Size from the given floats.
  83487. * @param width width to set
  83488. * @param height height to set
  83489. * @returns the updated Size.
  83490. */
  83491. set(width: number, height: number): Size;
  83492. /**
  83493. * Multiplies the width and height by numbers
  83494. * @param w factor to multiple the width by
  83495. * @param h factor to multiple the height by
  83496. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83497. */
  83498. multiplyByFloats(w: number, h: number): Size;
  83499. /**
  83500. * Clones the size
  83501. * @returns a new Size copied from the given one.
  83502. */
  83503. clone(): Size;
  83504. /**
  83505. * True if the current Size and the given one width and height are strictly equal.
  83506. * @param other the other size to compare against
  83507. * @returns True if the current Size and the given one width and height are strictly equal.
  83508. */
  83509. equals(other: Size): boolean;
  83510. /**
  83511. * The surface of the Size : width * height (float).
  83512. */
  83513. get surface(): number;
  83514. /**
  83515. * Create a new size of zero
  83516. * @returns a new Size set to (0.0, 0.0)
  83517. */
  83518. static Zero(): Size;
  83519. /**
  83520. * Sums the width and height of two sizes
  83521. * @param otherSize size to add to this size
  83522. * @returns a new Size set as the addition result of the current Size and the given one.
  83523. */
  83524. add(otherSize: Size): Size;
  83525. /**
  83526. * Subtracts the width and height of two
  83527. * @param otherSize size to subtract to this size
  83528. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83529. */
  83530. subtract(otherSize: Size): Size;
  83531. /**
  83532. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83533. * @param start starting size to lerp between
  83534. * @param end end size to lerp between
  83535. * @param amount amount to lerp between the start and end values
  83536. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83537. */
  83538. static Lerp(start: Size, end: Size, amount: number): Size;
  83539. }
  83540. }
  83541. declare module BABYLON {
  83542. /**
  83543. * Defines a runtime animation
  83544. */
  83545. export class RuntimeAnimation {
  83546. private _events;
  83547. /**
  83548. * The current frame of the runtime animation
  83549. */
  83550. private _currentFrame;
  83551. /**
  83552. * The animation used by the runtime animation
  83553. */
  83554. private _animation;
  83555. /**
  83556. * The target of the runtime animation
  83557. */
  83558. private _target;
  83559. /**
  83560. * The initiating animatable
  83561. */
  83562. private _host;
  83563. /**
  83564. * The original value of the runtime animation
  83565. */
  83566. private _originalValue;
  83567. /**
  83568. * The original blend value of the runtime animation
  83569. */
  83570. private _originalBlendValue;
  83571. /**
  83572. * The offsets cache of the runtime animation
  83573. */
  83574. private _offsetsCache;
  83575. /**
  83576. * The high limits cache of the runtime animation
  83577. */
  83578. private _highLimitsCache;
  83579. /**
  83580. * Specifies if the runtime animation has been stopped
  83581. */
  83582. private _stopped;
  83583. /**
  83584. * The blending factor of the runtime animation
  83585. */
  83586. private _blendingFactor;
  83587. /**
  83588. * The BabylonJS scene
  83589. */
  83590. private _scene;
  83591. /**
  83592. * The current value of the runtime animation
  83593. */
  83594. private _currentValue;
  83595. /** @hidden */
  83596. _animationState: _IAnimationState;
  83597. /**
  83598. * The active target of the runtime animation
  83599. */
  83600. private _activeTargets;
  83601. private _currentActiveTarget;
  83602. private _directTarget;
  83603. /**
  83604. * The target path of the runtime animation
  83605. */
  83606. private _targetPath;
  83607. /**
  83608. * The weight of the runtime animation
  83609. */
  83610. private _weight;
  83611. /**
  83612. * The ratio offset of the runtime animation
  83613. */
  83614. private _ratioOffset;
  83615. /**
  83616. * The previous delay of the runtime animation
  83617. */
  83618. private _previousDelay;
  83619. /**
  83620. * The previous ratio of the runtime animation
  83621. */
  83622. private _previousRatio;
  83623. private _enableBlending;
  83624. private _keys;
  83625. private _minFrame;
  83626. private _maxFrame;
  83627. private _minValue;
  83628. private _maxValue;
  83629. private _targetIsArray;
  83630. /**
  83631. * Gets the current frame of the runtime animation
  83632. */
  83633. get currentFrame(): number;
  83634. /**
  83635. * Gets the weight of the runtime animation
  83636. */
  83637. get weight(): number;
  83638. /**
  83639. * Gets the current value of the runtime animation
  83640. */
  83641. get currentValue(): any;
  83642. /**
  83643. * Gets the target path of the runtime animation
  83644. */
  83645. get targetPath(): string;
  83646. /**
  83647. * Gets the actual target of the runtime animation
  83648. */
  83649. get target(): any;
  83650. /** @hidden */
  83651. _onLoop: () => void;
  83652. /**
  83653. * Create a new RuntimeAnimation object
  83654. * @param target defines the target of the animation
  83655. * @param animation defines the source animation object
  83656. * @param scene defines the hosting scene
  83657. * @param host defines the initiating Animatable
  83658. */
  83659. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  83660. private _preparePath;
  83661. /**
  83662. * Gets the animation from the runtime animation
  83663. */
  83664. get animation(): Animation;
  83665. /**
  83666. * Resets the runtime animation to the beginning
  83667. * @param restoreOriginal defines whether to restore the target property to the original value
  83668. */
  83669. reset(restoreOriginal?: boolean): void;
  83670. /**
  83671. * Specifies if the runtime animation is stopped
  83672. * @returns Boolean specifying if the runtime animation is stopped
  83673. */
  83674. isStopped(): boolean;
  83675. /**
  83676. * Disposes of the runtime animation
  83677. */
  83678. dispose(): void;
  83679. /**
  83680. * Apply the interpolated value to the target
  83681. * @param currentValue defines the value computed by the animation
  83682. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  83683. */
  83684. setValue(currentValue: any, weight: number): void;
  83685. private _getOriginalValues;
  83686. private _setValue;
  83687. /**
  83688. * Gets the loop pmode of the runtime animation
  83689. * @returns Loop Mode
  83690. */
  83691. private _getCorrectLoopMode;
  83692. /**
  83693. * Move the current animation to a given frame
  83694. * @param frame defines the frame to move to
  83695. */
  83696. goToFrame(frame: number): void;
  83697. /**
  83698. * @hidden Internal use only
  83699. */
  83700. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  83701. /**
  83702. * Execute the current animation
  83703. * @param delay defines the delay to add to the current frame
  83704. * @param from defines the lower bound of the animation range
  83705. * @param to defines the upper bound of the animation range
  83706. * @param loop defines if the current animation must loop
  83707. * @param speedRatio defines the current speed ratio
  83708. * @param weight defines the weight of the animation (default is -1 so no weight)
  83709. * @param onLoop optional callback called when animation loops
  83710. * @returns a boolean indicating if the animation is running
  83711. */
  83712. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  83713. }
  83714. }
  83715. declare module BABYLON {
  83716. /**
  83717. * Class used to store an actual running animation
  83718. */
  83719. export class Animatable {
  83720. /** defines the target object */
  83721. target: any;
  83722. /** defines the starting frame number (default is 0) */
  83723. fromFrame: number;
  83724. /** defines the ending frame number (default is 100) */
  83725. toFrame: number;
  83726. /** defines if the animation must loop (default is false) */
  83727. loopAnimation: boolean;
  83728. /** defines a callback to call when animation ends if it is not looping */
  83729. onAnimationEnd?: (() => void) | null | undefined;
  83730. /** defines a callback to call when animation loops */
  83731. onAnimationLoop?: (() => void) | null | undefined;
  83732. private _localDelayOffset;
  83733. private _pausedDelay;
  83734. private _runtimeAnimations;
  83735. private _paused;
  83736. private _scene;
  83737. private _speedRatio;
  83738. private _weight;
  83739. private _syncRoot;
  83740. /**
  83741. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  83742. * This will only apply for non looping animation (default is true)
  83743. */
  83744. disposeOnEnd: boolean;
  83745. /**
  83746. * Gets a boolean indicating if the animation has started
  83747. */
  83748. animationStarted: boolean;
  83749. /**
  83750. * Observer raised when the animation ends
  83751. */
  83752. onAnimationEndObservable: Observable<Animatable>;
  83753. /**
  83754. * Observer raised when the animation loops
  83755. */
  83756. onAnimationLoopObservable: Observable<Animatable>;
  83757. /**
  83758. * Gets the root Animatable used to synchronize and normalize animations
  83759. */
  83760. get syncRoot(): Nullable<Animatable>;
  83761. /**
  83762. * Gets the current frame of the first RuntimeAnimation
  83763. * Used to synchronize Animatables
  83764. */
  83765. get masterFrame(): number;
  83766. /**
  83767. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  83768. */
  83769. get weight(): number;
  83770. set weight(value: number);
  83771. /**
  83772. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  83773. */
  83774. get speedRatio(): number;
  83775. set speedRatio(value: number);
  83776. /**
  83777. * Creates a new Animatable
  83778. * @param scene defines the hosting scene
  83779. * @param target defines the target object
  83780. * @param fromFrame defines the starting frame number (default is 0)
  83781. * @param toFrame defines the ending frame number (default is 100)
  83782. * @param loopAnimation defines if the animation must loop (default is false)
  83783. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  83784. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  83785. * @param animations defines a group of animation to add to the new Animatable
  83786. * @param onAnimationLoop defines a callback to call when animation loops
  83787. */
  83788. constructor(scene: Scene,
  83789. /** defines the target object */
  83790. target: any,
  83791. /** defines the starting frame number (default is 0) */
  83792. fromFrame?: number,
  83793. /** defines the ending frame number (default is 100) */
  83794. toFrame?: number,
  83795. /** defines if the animation must loop (default is false) */
  83796. loopAnimation?: boolean, speedRatio?: number,
  83797. /** defines a callback to call when animation ends if it is not looping */
  83798. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  83799. /** defines a callback to call when animation loops */
  83800. onAnimationLoop?: (() => void) | null | undefined);
  83801. /**
  83802. * Synchronize and normalize current Animatable with a source Animatable
  83803. * This is useful when using animation weights and when animations are not of the same length
  83804. * @param root defines the root Animatable to synchronize with
  83805. * @returns the current Animatable
  83806. */
  83807. syncWith(root: Animatable): Animatable;
  83808. /**
  83809. * Gets the list of runtime animations
  83810. * @returns an array of RuntimeAnimation
  83811. */
  83812. getAnimations(): RuntimeAnimation[];
  83813. /**
  83814. * Adds more animations to the current animatable
  83815. * @param target defines the target of the animations
  83816. * @param animations defines the new animations to add
  83817. */
  83818. appendAnimations(target: any, animations: Animation[]): void;
  83819. /**
  83820. * Gets the source animation for a specific property
  83821. * @param property defines the propertyu to look for
  83822. * @returns null or the source animation for the given property
  83823. */
  83824. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  83825. /**
  83826. * Gets the runtime animation for a specific property
  83827. * @param property defines the propertyu to look for
  83828. * @returns null or the runtime animation for the given property
  83829. */
  83830. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  83831. /**
  83832. * Resets the animatable to its original state
  83833. */
  83834. reset(): void;
  83835. /**
  83836. * Allows the animatable to blend with current running animations
  83837. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83838. * @param blendingSpeed defines the blending speed to use
  83839. */
  83840. enableBlending(blendingSpeed: number): void;
  83841. /**
  83842. * Disable animation blending
  83843. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83844. */
  83845. disableBlending(): void;
  83846. /**
  83847. * Jump directly to a given frame
  83848. * @param frame defines the frame to jump to
  83849. */
  83850. goToFrame(frame: number): void;
  83851. /**
  83852. * Pause the animation
  83853. */
  83854. pause(): void;
  83855. /**
  83856. * Restart the animation
  83857. */
  83858. restart(): void;
  83859. private _raiseOnAnimationEnd;
  83860. /**
  83861. * Stop and delete the current animation
  83862. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  83863. * @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)
  83864. */
  83865. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  83866. /**
  83867. * Wait asynchronously for the animation to end
  83868. * @returns a promise which will be fullfilled when the animation ends
  83869. */
  83870. waitAsync(): Promise<Animatable>;
  83871. /** @hidden */
  83872. _animate(delay: number): boolean;
  83873. }
  83874. interface Scene {
  83875. /** @hidden */
  83876. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  83877. /** @hidden */
  83878. _processLateAnimationBindingsForMatrices(holder: {
  83879. totalWeight: number;
  83880. animations: RuntimeAnimation[];
  83881. originalValue: Matrix;
  83882. }): any;
  83883. /** @hidden */
  83884. _processLateAnimationBindingsForQuaternions(holder: {
  83885. totalWeight: number;
  83886. animations: RuntimeAnimation[];
  83887. originalValue: Quaternion;
  83888. }, refQuaternion: Quaternion): Quaternion;
  83889. /** @hidden */
  83890. _processLateAnimationBindings(): void;
  83891. /**
  83892. * Will start the animation sequence of a given target
  83893. * @param target defines the target
  83894. * @param from defines from which frame should animation start
  83895. * @param to defines until which frame should animation run.
  83896. * @param weight defines the weight to apply to the animation (1.0 by default)
  83897. * @param loop defines if the animation loops
  83898. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83899. * @param onAnimationEnd defines the function to be executed when the animation ends
  83900. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83901. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83902. * @param onAnimationLoop defines the callback to call when an animation loops
  83903. * @returns the animatable object created for this animation
  83904. */
  83905. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83906. /**
  83907. * Will start the animation sequence of a given target
  83908. * @param target defines the target
  83909. * @param from defines from which frame should animation start
  83910. * @param to defines until which frame should animation run.
  83911. * @param loop defines if the animation loops
  83912. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83913. * @param onAnimationEnd defines the function to be executed when the animation ends
  83914. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83915. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83916. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  83917. * @param onAnimationLoop defines the callback to call when an animation loops
  83918. * @returns the animatable object created for this animation
  83919. */
  83920. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83921. /**
  83922. * Will start the animation sequence of a given target and its hierarchy
  83923. * @param target defines the target
  83924. * @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.
  83925. * @param from defines from which frame should animation start
  83926. * @param to defines until which frame should animation run.
  83927. * @param loop defines if the animation loops
  83928. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83929. * @param onAnimationEnd defines the function to be executed when the animation ends
  83930. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83931. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83932. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83933. * @param onAnimationLoop defines the callback to call when an animation loops
  83934. * @returns the list of created animatables
  83935. */
  83936. 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[];
  83937. /**
  83938. * Begin a new animation on a given node
  83939. * @param target defines the target where the animation will take place
  83940. * @param animations defines the list of animations to start
  83941. * @param from defines the initial value
  83942. * @param to defines the final value
  83943. * @param loop defines if you want animation to loop (off by default)
  83944. * @param speedRatio defines the speed ratio to apply to all animations
  83945. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83946. * @param onAnimationLoop defines the callback to call when an animation loops
  83947. * @returns the list of created animatables
  83948. */
  83949. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  83950. /**
  83951. * Begin a new animation on a given node and its hierarchy
  83952. * @param target defines the root node where the animation will take place
  83953. * @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.
  83954. * @param animations defines the list of animations to start
  83955. * @param from defines the initial value
  83956. * @param to defines the final value
  83957. * @param loop defines if you want animation to loop (off by default)
  83958. * @param speedRatio defines the speed ratio to apply to all animations
  83959. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83960. * @param onAnimationLoop defines the callback to call when an animation loops
  83961. * @returns the list of animatables created for all nodes
  83962. */
  83963. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  83964. /**
  83965. * Gets the animatable associated with a specific target
  83966. * @param target defines the target of the animatable
  83967. * @returns the required animatable if found
  83968. */
  83969. getAnimatableByTarget(target: any): Nullable<Animatable>;
  83970. /**
  83971. * Gets all animatables associated with a given target
  83972. * @param target defines the target to look animatables for
  83973. * @returns an array of Animatables
  83974. */
  83975. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  83976. /**
  83977. * Stops and removes all animations that have been applied to the scene
  83978. */
  83979. stopAllAnimations(): void;
  83980. /**
  83981. * Gets the current delta time used by animation engine
  83982. */
  83983. deltaTime: number;
  83984. }
  83985. interface Bone {
  83986. /**
  83987. * Copy an animation range from another bone
  83988. * @param source defines the source bone
  83989. * @param rangeName defines the range name to copy
  83990. * @param frameOffset defines the frame offset
  83991. * @param rescaleAsRequired defines if rescaling must be applied if required
  83992. * @param skelDimensionsRatio defines the scaling ratio
  83993. * @returns true if operation was successful
  83994. */
  83995. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  83996. }
  83997. }
  83998. declare module BABYLON {
  83999. /**
  84000. * Class used to override all child animations of a given target
  84001. */
  84002. export class AnimationPropertiesOverride {
  84003. /**
  84004. * Gets or sets a value indicating if animation blending must be used
  84005. */
  84006. enableBlending: boolean;
  84007. /**
  84008. * Gets or sets the blending speed to use when enableBlending is true
  84009. */
  84010. blendingSpeed: number;
  84011. /**
  84012. * Gets or sets the default loop mode to use
  84013. */
  84014. loopMode: number;
  84015. }
  84016. }
  84017. declare module BABYLON {
  84018. /**
  84019. * Class used to handle skinning animations
  84020. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84021. */
  84022. export class Skeleton implements IAnimatable {
  84023. /** defines the skeleton name */
  84024. name: string;
  84025. /** defines the skeleton Id */
  84026. id: string;
  84027. /**
  84028. * Defines the list of child bones
  84029. */
  84030. bones: Bone[];
  84031. /**
  84032. * Defines an estimate of the dimension of the skeleton at rest
  84033. */
  84034. dimensionsAtRest: Vector3;
  84035. /**
  84036. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  84037. */
  84038. needInitialSkinMatrix: boolean;
  84039. /**
  84040. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  84041. */
  84042. overrideMesh: Nullable<AbstractMesh>;
  84043. /**
  84044. * Gets the list of animations attached to this skeleton
  84045. */
  84046. animations: Array<Animation>;
  84047. private _scene;
  84048. private _isDirty;
  84049. private _transformMatrices;
  84050. private _transformMatrixTexture;
  84051. private _meshesWithPoseMatrix;
  84052. private _animatables;
  84053. private _identity;
  84054. private _synchronizedWithMesh;
  84055. private _ranges;
  84056. private _lastAbsoluteTransformsUpdateId;
  84057. private _canUseTextureForBones;
  84058. private _uniqueId;
  84059. /** @hidden */
  84060. _numBonesWithLinkedTransformNode: number;
  84061. /** @hidden */
  84062. _hasWaitingData: Nullable<boolean>;
  84063. /**
  84064. * Specifies if the skeleton should be serialized
  84065. */
  84066. doNotSerialize: boolean;
  84067. private _useTextureToStoreBoneMatrices;
  84068. /**
  84069. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  84070. * Please note that this option is not available if the hardware does not support it
  84071. */
  84072. get useTextureToStoreBoneMatrices(): boolean;
  84073. set useTextureToStoreBoneMatrices(value: boolean);
  84074. private _animationPropertiesOverride;
  84075. /**
  84076. * Gets or sets the animation properties override
  84077. */
  84078. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84079. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  84080. /**
  84081. * List of inspectable custom properties (used by the Inspector)
  84082. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84083. */
  84084. inspectableCustomProperties: IInspectable[];
  84085. /**
  84086. * An observable triggered before computing the skeleton's matrices
  84087. */
  84088. onBeforeComputeObservable: Observable<Skeleton>;
  84089. /**
  84090. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  84091. */
  84092. get isUsingTextureForMatrices(): boolean;
  84093. /**
  84094. * Gets the unique ID of this skeleton
  84095. */
  84096. get uniqueId(): number;
  84097. /**
  84098. * Creates a new skeleton
  84099. * @param name defines the skeleton name
  84100. * @param id defines the skeleton Id
  84101. * @param scene defines the hosting scene
  84102. */
  84103. constructor(
  84104. /** defines the skeleton name */
  84105. name: string,
  84106. /** defines the skeleton Id */
  84107. id: string, scene: Scene);
  84108. /**
  84109. * Gets the current object class name.
  84110. * @return the class name
  84111. */
  84112. getClassName(): string;
  84113. /**
  84114. * Returns an array containing the root bones
  84115. * @returns an array containing the root bones
  84116. */
  84117. getChildren(): Array<Bone>;
  84118. /**
  84119. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  84120. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84121. * @returns a Float32Array containing matrices data
  84122. */
  84123. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  84124. /**
  84125. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  84126. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84127. * @returns a raw texture containing the data
  84128. */
  84129. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  84130. /**
  84131. * Gets the current hosting scene
  84132. * @returns a scene object
  84133. */
  84134. getScene(): Scene;
  84135. /**
  84136. * Gets a string representing the current skeleton data
  84137. * @param fullDetails defines a boolean indicating if we want a verbose version
  84138. * @returns a string representing the current skeleton data
  84139. */
  84140. toString(fullDetails?: boolean): string;
  84141. /**
  84142. * Get bone's index searching by name
  84143. * @param name defines bone's name to search for
  84144. * @return the indice of the bone. Returns -1 if not found
  84145. */
  84146. getBoneIndexByName(name: string): number;
  84147. /**
  84148. * Creater a new animation range
  84149. * @param name defines the name of the range
  84150. * @param from defines the start key
  84151. * @param to defines the end key
  84152. */
  84153. createAnimationRange(name: string, from: number, to: number): void;
  84154. /**
  84155. * Delete a specific animation range
  84156. * @param name defines the name of the range
  84157. * @param deleteFrames defines if frames must be removed as well
  84158. */
  84159. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84160. /**
  84161. * Gets a specific animation range
  84162. * @param name defines the name of the range to look for
  84163. * @returns the requested animation range or null if not found
  84164. */
  84165. getAnimationRange(name: string): Nullable<AnimationRange>;
  84166. /**
  84167. * Gets the list of all animation ranges defined on this skeleton
  84168. * @returns an array
  84169. */
  84170. getAnimationRanges(): Nullable<AnimationRange>[];
  84171. /**
  84172. * Copy animation range from a source skeleton.
  84173. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  84174. * @param source defines the source skeleton
  84175. * @param name defines the name of the range to copy
  84176. * @param rescaleAsRequired defines if rescaling must be applied if required
  84177. * @returns true if operation was successful
  84178. */
  84179. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  84180. /**
  84181. * Forces the skeleton to go to rest pose
  84182. */
  84183. returnToRest(): void;
  84184. private _getHighestAnimationFrame;
  84185. /**
  84186. * Begin a specific animation range
  84187. * @param name defines the name of the range to start
  84188. * @param loop defines if looping must be turned on (false by default)
  84189. * @param speedRatio defines the speed ratio to apply (1 by default)
  84190. * @param onAnimationEnd defines a callback which will be called when animation will end
  84191. * @returns a new animatable
  84192. */
  84193. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84194. /** @hidden */
  84195. _markAsDirty(): void;
  84196. /** @hidden */
  84197. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84198. /** @hidden */
  84199. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84200. private _computeTransformMatrices;
  84201. /**
  84202. * Build all resources required to render a skeleton
  84203. */
  84204. prepare(): void;
  84205. /**
  84206. * Gets the list of animatables currently running for this skeleton
  84207. * @returns an array of animatables
  84208. */
  84209. getAnimatables(): IAnimatable[];
  84210. /**
  84211. * Clone the current skeleton
  84212. * @param name defines the name of the new skeleton
  84213. * @param id defines the id of the new skeleton
  84214. * @returns the new skeleton
  84215. */
  84216. clone(name: string, id?: string): Skeleton;
  84217. /**
  84218. * Enable animation blending for this skeleton
  84219. * @param blendingSpeed defines the blending speed to apply
  84220. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84221. */
  84222. enableBlending(blendingSpeed?: number): void;
  84223. /**
  84224. * Releases all resources associated with the current skeleton
  84225. */
  84226. dispose(): void;
  84227. /**
  84228. * Serialize the skeleton in a JSON object
  84229. * @returns a JSON object
  84230. */
  84231. serialize(): any;
  84232. /**
  84233. * Creates a new skeleton from serialized data
  84234. * @param parsedSkeleton defines the serialized data
  84235. * @param scene defines the hosting scene
  84236. * @returns a new skeleton
  84237. */
  84238. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  84239. /**
  84240. * Compute all node absolute transforms
  84241. * @param forceUpdate defines if computation must be done even if cache is up to date
  84242. */
  84243. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  84244. /**
  84245. * Gets the root pose matrix
  84246. * @returns a matrix
  84247. */
  84248. getPoseMatrix(): Nullable<Matrix>;
  84249. /**
  84250. * Sorts bones per internal index
  84251. */
  84252. sortBones(): void;
  84253. private _sortBones;
  84254. }
  84255. }
  84256. declare module BABYLON {
  84257. /**
  84258. * Class used to store bone information
  84259. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84260. */
  84261. export class Bone extends Node {
  84262. /**
  84263. * defines the bone name
  84264. */
  84265. name: string;
  84266. private static _tmpVecs;
  84267. private static _tmpQuat;
  84268. private static _tmpMats;
  84269. /**
  84270. * Gets the list of child bones
  84271. */
  84272. children: Bone[];
  84273. /** Gets the animations associated with this bone */
  84274. animations: Animation[];
  84275. /**
  84276. * Gets or sets bone length
  84277. */
  84278. length: number;
  84279. /**
  84280. * @hidden Internal only
  84281. * Set this value to map this bone to a different index in the transform matrices
  84282. * Set this value to -1 to exclude the bone from the transform matrices
  84283. */
  84284. _index: Nullable<number>;
  84285. private _skeleton;
  84286. private _localMatrix;
  84287. private _restPose;
  84288. private _baseMatrix;
  84289. private _absoluteTransform;
  84290. private _invertedAbsoluteTransform;
  84291. private _parent;
  84292. private _scalingDeterminant;
  84293. private _worldTransform;
  84294. private _localScaling;
  84295. private _localRotation;
  84296. private _localPosition;
  84297. private _needToDecompose;
  84298. private _needToCompose;
  84299. /** @hidden */
  84300. _linkedTransformNode: Nullable<TransformNode>;
  84301. /** @hidden */
  84302. _waitingTransformNodeId: Nullable<string>;
  84303. /** @hidden */
  84304. get _matrix(): Matrix;
  84305. /** @hidden */
  84306. set _matrix(value: Matrix);
  84307. /**
  84308. * Create a new bone
  84309. * @param name defines the bone name
  84310. * @param skeleton defines the parent skeleton
  84311. * @param parentBone defines the parent (can be null if the bone is the root)
  84312. * @param localMatrix defines the local matrix
  84313. * @param restPose defines the rest pose matrix
  84314. * @param baseMatrix defines the base matrix
  84315. * @param index defines index of the bone in the hiearchy
  84316. */
  84317. constructor(
  84318. /**
  84319. * defines the bone name
  84320. */
  84321. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  84322. /**
  84323. * Gets the current object class name.
  84324. * @return the class name
  84325. */
  84326. getClassName(): string;
  84327. /**
  84328. * Gets the parent skeleton
  84329. * @returns a skeleton
  84330. */
  84331. getSkeleton(): Skeleton;
  84332. /**
  84333. * Gets parent bone
  84334. * @returns a bone or null if the bone is the root of the bone hierarchy
  84335. */
  84336. getParent(): Nullable<Bone>;
  84337. /**
  84338. * Returns an array containing the root bones
  84339. * @returns an array containing the root bones
  84340. */
  84341. getChildren(): Array<Bone>;
  84342. /**
  84343. * Gets the node index in matrix array generated for rendering
  84344. * @returns the node index
  84345. */
  84346. getIndex(): number;
  84347. /**
  84348. * Sets the parent bone
  84349. * @param parent defines the parent (can be null if the bone is the root)
  84350. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84351. */
  84352. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  84353. /**
  84354. * Gets the local matrix
  84355. * @returns a matrix
  84356. */
  84357. getLocalMatrix(): Matrix;
  84358. /**
  84359. * Gets the base matrix (initial matrix which remains unchanged)
  84360. * @returns a matrix
  84361. */
  84362. getBaseMatrix(): Matrix;
  84363. /**
  84364. * Gets the rest pose matrix
  84365. * @returns a matrix
  84366. */
  84367. getRestPose(): Matrix;
  84368. /**
  84369. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  84370. */
  84371. getWorldMatrix(): Matrix;
  84372. /**
  84373. * Sets the local matrix to rest pose matrix
  84374. */
  84375. returnToRest(): void;
  84376. /**
  84377. * Gets the inverse of the absolute transform matrix.
  84378. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  84379. * @returns a matrix
  84380. */
  84381. getInvertedAbsoluteTransform(): Matrix;
  84382. /**
  84383. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  84384. * @returns a matrix
  84385. */
  84386. getAbsoluteTransform(): Matrix;
  84387. /**
  84388. * Links with the given transform node.
  84389. * The local matrix of this bone is copied from the transform node every frame.
  84390. * @param transformNode defines the transform node to link to
  84391. */
  84392. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  84393. /**
  84394. * Gets the node used to drive the bone's transformation
  84395. * @returns a transform node or null
  84396. */
  84397. getTransformNode(): Nullable<TransformNode>;
  84398. /** Gets or sets current position (in local space) */
  84399. get position(): Vector3;
  84400. set position(newPosition: Vector3);
  84401. /** Gets or sets current rotation (in local space) */
  84402. get rotation(): Vector3;
  84403. set rotation(newRotation: Vector3);
  84404. /** Gets or sets current rotation quaternion (in local space) */
  84405. get rotationQuaternion(): Quaternion;
  84406. set rotationQuaternion(newRotation: Quaternion);
  84407. /** Gets or sets current scaling (in local space) */
  84408. get scaling(): Vector3;
  84409. set scaling(newScaling: Vector3);
  84410. /**
  84411. * Gets the animation properties override
  84412. */
  84413. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84414. private _decompose;
  84415. private _compose;
  84416. /**
  84417. * Update the base and local matrices
  84418. * @param matrix defines the new base or local matrix
  84419. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84420. * @param updateLocalMatrix defines if the local matrix should be updated
  84421. */
  84422. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  84423. /** @hidden */
  84424. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  84425. /**
  84426. * Flag the bone as dirty (Forcing it to update everything)
  84427. */
  84428. markAsDirty(): void;
  84429. /** @hidden */
  84430. _markAsDirtyAndCompose(): void;
  84431. private _markAsDirtyAndDecompose;
  84432. /**
  84433. * Translate the bone in local or world space
  84434. * @param vec The amount to translate the bone
  84435. * @param space The space that the translation is in
  84436. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84437. */
  84438. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84439. /**
  84440. * Set the postion of the bone in local or world space
  84441. * @param position The position to set the bone
  84442. * @param space The space that the position is in
  84443. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84444. */
  84445. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84446. /**
  84447. * Set the absolute position of the bone (world space)
  84448. * @param position The position to set the bone
  84449. * @param mesh The mesh that this bone is attached to
  84450. */
  84451. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  84452. /**
  84453. * Scale the bone on the x, y and z axes (in local space)
  84454. * @param x The amount to scale the bone on the x axis
  84455. * @param y The amount to scale the bone on the y axis
  84456. * @param z The amount to scale the bone on the z axis
  84457. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  84458. */
  84459. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  84460. /**
  84461. * Set the bone scaling in local space
  84462. * @param scale defines the scaling vector
  84463. */
  84464. setScale(scale: Vector3): void;
  84465. /**
  84466. * Gets the current scaling in local space
  84467. * @returns the current scaling vector
  84468. */
  84469. getScale(): Vector3;
  84470. /**
  84471. * Gets the current scaling in local space and stores it in a target vector
  84472. * @param result defines the target vector
  84473. */
  84474. getScaleToRef(result: Vector3): void;
  84475. /**
  84476. * Set the yaw, pitch, and roll of the bone in local or world space
  84477. * @param yaw The rotation of the bone on the y axis
  84478. * @param pitch The rotation of the bone on the x axis
  84479. * @param roll The rotation of the bone on the z axis
  84480. * @param space The space that the axes of rotation are in
  84481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84482. */
  84483. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  84484. /**
  84485. * Add a rotation to the bone on an axis in local or world space
  84486. * @param axis The axis to rotate the bone on
  84487. * @param amount The amount to rotate the bone
  84488. * @param space The space that the axis is in
  84489. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84490. */
  84491. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  84492. /**
  84493. * Set the rotation of the bone to a particular axis angle in local or world space
  84494. * @param axis The axis to rotate the bone on
  84495. * @param angle The angle that the bone should be rotated to
  84496. * @param space The space that the axis is in
  84497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84498. */
  84499. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  84500. /**
  84501. * Set the euler rotation of the bone in local of world space
  84502. * @param rotation The euler rotation that the bone should be set to
  84503. * @param space The space that the rotation is in
  84504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84505. */
  84506. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84507. /**
  84508. * Set the quaternion rotation of the bone in local of world space
  84509. * @param quat The quaternion rotation that the bone should be set to
  84510. * @param space The space that the rotation is in
  84511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84512. */
  84513. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  84514. /**
  84515. * Set the rotation matrix of the bone in local of world space
  84516. * @param rotMat The rotation matrix that the bone should be set to
  84517. * @param space The space that the rotation is in
  84518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84519. */
  84520. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  84521. private _rotateWithMatrix;
  84522. private _getNegativeRotationToRef;
  84523. /**
  84524. * Get the position of the bone in local or world space
  84525. * @param space The space that the returned position is in
  84526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84527. * @returns The position of the bone
  84528. */
  84529. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84530. /**
  84531. * Copy the position of the bone to a vector3 in local or world space
  84532. * @param space The space that the returned position is in
  84533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84534. * @param result The vector3 to copy the position to
  84535. */
  84536. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  84537. /**
  84538. * Get the absolute position of the bone (world space)
  84539. * @param mesh The mesh that this bone is attached to
  84540. * @returns The absolute position of the bone
  84541. */
  84542. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  84543. /**
  84544. * Copy the absolute position of the bone (world space) to the result param
  84545. * @param mesh The mesh that this bone is attached to
  84546. * @param result The vector3 to copy the absolute position to
  84547. */
  84548. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  84549. /**
  84550. * Compute the absolute transforms of this bone and its children
  84551. */
  84552. computeAbsoluteTransforms(): void;
  84553. /**
  84554. * Get the world direction from an axis that is in the local space of the bone
  84555. * @param localAxis The local direction that is used to compute the world direction
  84556. * @param mesh The mesh that this bone is attached to
  84557. * @returns The world direction
  84558. */
  84559. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84560. /**
  84561. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  84562. * @param localAxis The local direction that is used to compute the world direction
  84563. * @param mesh The mesh that this bone is attached to
  84564. * @param result The vector3 that the world direction will be copied to
  84565. */
  84566. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84567. /**
  84568. * Get the euler rotation of the bone in local or world space
  84569. * @param space The space that the rotation should be in
  84570. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84571. * @returns The euler rotation
  84572. */
  84573. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84574. /**
  84575. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  84576. * @param space The space that the rotation should be in
  84577. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84578. * @param result The vector3 that the rotation should be copied to
  84579. */
  84580. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84581. /**
  84582. * Get the quaternion rotation of the bone in either local or world space
  84583. * @param space The space that the rotation should be in
  84584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84585. * @returns The quaternion rotation
  84586. */
  84587. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  84588. /**
  84589. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  84590. * @param space The space that the rotation should be in
  84591. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84592. * @param result The quaternion that the rotation should be copied to
  84593. */
  84594. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  84595. /**
  84596. * Get the rotation matrix of the bone in local or world space
  84597. * @param space The space that the rotation should be in
  84598. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84599. * @returns The rotation matrix
  84600. */
  84601. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  84602. /**
  84603. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  84604. * @param space The space that the rotation should be in
  84605. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84606. * @param result The quaternion that the rotation should be copied to
  84607. */
  84608. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  84609. /**
  84610. * Get the world position of a point that is in the local space of the bone
  84611. * @param position The local position
  84612. * @param mesh The mesh that this bone is attached to
  84613. * @returns The world position
  84614. */
  84615. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84616. /**
  84617. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  84618. * @param position The local position
  84619. * @param mesh The mesh that this bone is attached to
  84620. * @param result The vector3 that the world position should be copied to
  84621. */
  84622. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84623. /**
  84624. * Get the local position of a point that is in world space
  84625. * @param position The world position
  84626. * @param mesh The mesh that this bone is attached to
  84627. * @returns The local position
  84628. */
  84629. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84630. /**
  84631. * Get the local position of a point that is in world space and copy it to the result param
  84632. * @param position The world position
  84633. * @param mesh The mesh that this bone is attached to
  84634. * @param result The vector3 that the local position should be copied to
  84635. */
  84636. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84637. }
  84638. }
  84639. declare module BABYLON {
  84640. /**
  84641. * 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.
  84642. * @see https://doc.babylonjs.com/how_to/transformnode
  84643. */
  84644. export class TransformNode extends Node {
  84645. /**
  84646. * Object will not rotate to face the camera
  84647. */
  84648. static BILLBOARDMODE_NONE: number;
  84649. /**
  84650. * Object will rotate to face the camera but only on the x axis
  84651. */
  84652. static BILLBOARDMODE_X: number;
  84653. /**
  84654. * Object will rotate to face the camera but only on the y axis
  84655. */
  84656. static BILLBOARDMODE_Y: number;
  84657. /**
  84658. * Object will rotate to face the camera but only on the z axis
  84659. */
  84660. static BILLBOARDMODE_Z: number;
  84661. /**
  84662. * Object will rotate to face the camera
  84663. */
  84664. static BILLBOARDMODE_ALL: number;
  84665. /**
  84666. * Object will rotate to face the camera's position instead of orientation
  84667. */
  84668. static BILLBOARDMODE_USE_POSITION: number;
  84669. private _forward;
  84670. private _forwardInverted;
  84671. private _up;
  84672. private _right;
  84673. private _rightInverted;
  84674. private _position;
  84675. private _rotation;
  84676. private _rotationQuaternion;
  84677. protected _scaling: Vector3;
  84678. protected _isDirty: boolean;
  84679. private _transformToBoneReferal;
  84680. private _isAbsoluteSynced;
  84681. private _billboardMode;
  84682. /**
  84683. * Gets or sets the billboard mode. Default is 0.
  84684. *
  84685. * | Value | Type | Description |
  84686. * | --- | --- | --- |
  84687. * | 0 | BILLBOARDMODE_NONE | |
  84688. * | 1 | BILLBOARDMODE_X | |
  84689. * | 2 | BILLBOARDMODE_Y | |
  84690. * | 4 | BILLBOARDMODE_Z | |
  84691. * | 7 | BILLBOARDMODE_ALL | |
  84692. *
  84693. */
  84694. get billboardMode(): number;
  84695. set billboardMode(value: number);
  84696. private _preserveParentRotationForBillboard;
  84697. /**
  84698. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  84699. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  84700. */
  84701. get preserveParentRotationForBillboard(): boolean;
  84702. set preserveParentRotationForBillboard(value: boolean);
  84703. /**
  84704. * 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
  84705. */
  84706. scalingDeterminant: number;
  84707. private _infiniteDistance;
  84708. /**
  84709. * Gets or sets the distance of the object to max, often used by skybox
  84710. */
  84711. get infiniteDistance(): boolean;
  84712. set infiniteDistance(value: boolean);
  84713. /**
  84714. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  84715. * By default the system will update normals to compensate
  84716. */
  84717. ignoreNonUniformScaling: boolean;
  84718. /**
  84719. * 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
  84720. */
  84721. reIntegrateRotationIntoRotationQuaternion: boolean;
  84722. /** @hidden */
  84723. _poseMatrix: Nullable<Matrix>;
  84724. /** @hidden */
  84725. _localMatrix: Matrix;
  84726. private _usePivotMatrix;
  84727. private _absolutePosition;
  84728. private _absoluteScaling;
  84729. private _absoluteRotationQuaternion;
  84730. private _pivotMatrix;
  84731. private _pivotMatrixInverse;
  84732. protected _postMultiplyPivotMatrix: boolean;
  84733. protected _isWorldMatrixFrozen: boolean;
  84734. /** @hidden */
  84735. _indexInSceneTransformNodesArray: number;
  84736. /**
  84737. * An event triggered after the world matrix is updated
  84738. */
  84739. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  84740. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  84741. /**
  84742. * Gets a string identifying the name of the class
  84743. * @returns "TransformNode" string
  84744. */
  84745. getClassName(): string;
  84746. /**
  84747. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  84748. */
  84749. get position(): Vector3;
  84750. set position(newPosition: Vector3);
  84751. /**
  84752. * 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)).
  84753. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  84754. */
  84755. get rotation(): Vector3;
  84756. set rotation(newRotation: Vector3);
  84757. /**
  84758. * 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)).
  84759. */
  84760. get scaling(): Vector3;
  84761. set scaling(newScaling: Vector3);
  84762. /**
  84763. * 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).
  84764. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  84765. */
  84766. get rotationQuaternion(): Nullable<Quaternion>;
  84767. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  84768. /**
  84769. * The forward direction of that transform in world space.
  84770. */
  84771. get forward(): Vector3;
  84772. /**
  84773. * The up direction of that transform in world space.
  84774. */
  84775. get up(): Vector3;
  84776. /**
  84777. * The right direction of that transform in world space.
  84778. */
  84779. get right(): Vector3;
  84780. /**
  84781. * Copies the parameter passed Matrix into the mesh Pose matrix.
  84782. * @param matrix the matrix to copy the pose from
  84783. * @returns this TransformNode.
  84784. */
  84785. updatePoseMatrix(matrix: Matrix): TransformNode;
  84786. /**
  84787. * Returns the mesh Pose matrix.
  84788. * @returns the pose matrix
  84789. */
  84790. getPoseMatrix(): Matrix;
  84791. /** @hidden */
  84792. _isSynchronized(): boolean;
  84793. /** @hidden */
  84794. _initCache(): void;
  84795. /**
  84796. * Flag the transform node as dirty (Forcing it to update everything)
  84797. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  84798. * @returns this transform node
  84799. */
  84800. markAsDirty(property: string): TransformNode;
  84801. /**
  84802. * Returns the current mesh absolute position.
  84803. * Returns a Vector3.
  84804. */
  84805. get absolutePosition(): Vector3;
  84806. /**
  84807. * Returns the current mesh absolute scaling.
  84808. * Returns a Vector3.
  84809. */
  84810. get absoluteScaling(): Vector3;
  84811. /**
  84812. * Returns the current mesh absolute rotation.
  84813. * Returns a Quaternion.
  84814. */
  84815. get absoluteRotationQuaternion(): Quaternion;
  84816. /**
  84817. * Sets a new matrix to apply before all other transformation
  84818. * @param matrix defines the transform matrix
  84819. * @returns the current TransformNode
  84820. */
  84821. setPreTransformMatrix(matrix: Matrix): TransformNode;
  84822. /**
  84823. * Sets a new pivot matrix to the current node
  84824. * @param matrix defines the new pivot matrix to use
  84825. * @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
  84826. * @returns the current TransformNode
  84827. */
  84828. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  84829. /**
  84830. * Returns the mesh pivot matrix.
  84831. * Default : Identity.
  84832. * @returns the matrix
  84833. */
  84834. getPivotMatrix(): Matrix;
  84835. /**
  84836. * Instantiate (when possible) or clone that node with its hierarchy
  84837. * @param newParent defines the new parent to use for the instance (or clone)
  84838. * @param options defines options to configure how copy is done
  84839. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  84840. * @returns an instance (or a clone) of the current node with its hiearchy
  84841. */
  84842. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  84843. doNotInstantiate: boolean;
  84844. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  84845. /**
  84846. * Prevents the World matrix to be computed any longer
  84847. * @param newWorldMatrix defines an optional matrix to use as world matrix
  84848. * @returns the TransformNode.
  84849. */
  84850. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  84851. /**
  84852. * Allows back the World matrix computation.
  84853. * @returns the TransformNode.
  84854. */
  84855. unfreezeWorldMatrix(): this;
  84856. /**
  84857. * True if the World matrix has been frozen.
  84858. */
  84859. get isWorldMatrixFrozen(): boolean;
  84860. /**
  84861. * Retuns the mesh absolute position in the World.
  84862. * @returns a Vector3.
  84863. */
  84864. getAbsolutePosition(): Vector3;
  84865. /**
  84866. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  84867. * @param absolutePosition the absolute position to set
  84868. * @returns the TransformNode.
  84869. */
  84870. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  84871. /**
  84872. * Sets the mesh position in its local space.
  84873. * @param vector3 the position to set in localspace
  84874. * @returns the TransformNode.
  84875. */
  84876. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  84877. /**
  84878. * Returns the mesh position in the local space from the current World matrix values.
  84879. * @returns a new Vector3.
  84880. */
  84881. getPositionExpressedInLocalSpace(): Vector3;
  84882. /**
  84883. * Translates the mesh along the passed Vector3 in its local space.
  84884. * @param vector3 the distance to translate in localspace
  84885. * @returns the TransformNode.
  84886. */
  84887. locallyTranslate(vector3: Vector3): TransformNode;
  84888. private static _lookAtVectorCache;
  84889. /**
  84890. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  84891. * @param targetPoint the position (must be in same space as current mesh) to look at
  84892. * @param yawCor optional yaw (y-axis) correction in radians
  84893. * @param pitchCor optional pitch (x-axis) correction in radians
  84894. * @param rollCor optional roll (z-axis) correction in radians
  84895. * @param space the choosen space of the target
  84896. * @returns the TransformNode.
  84897. */
  84898. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  84899. /**
  84900. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84901. * This Vector3 is expressed in the World space.
  84902. * @param localAxis axis to rotate
  84903. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84904. */
  84905. getDirection(localAxis: Vector3): Vector3;
  84906. /**
  84907. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  84908. * localAxis is expressed in the mesh local space.
  84909. * result is computed in the Wordl space from the mesh World matrix.
  84910. * @param localAxis axis to rotate
  84911. * @param result the resulting transformnode
  84912. * @returns this TransformNode.
  84913. */
  84914. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  84915. /**
  84916. * Sets this transform node rotation to the given local axis.
  84917. * @param localAxis the axis in local space
  84918. * @param yawCor optional yaw (y-axis) correction in radians
  84919. * @param pitchCor optional pitch (x-axis) correction in radians
  84920. * @param rollCor optional roll (z-axis) correction in radians
  84921. * @returns this TransformNode
  84922. */
  84923. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  84924. /**
  84925. * Sets a new pivot point to the current node
  84926. * @param point defines the new pivot point to use
  84927. * @param space defines if the point is in world or local space (local by default)
  84928. * @returns the current TransformNode
  84929. */
  84930. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  84931. /**
  84932. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  84933. * @returns the pivot point
  84934. */
  84935. getPivotPoint(): Vector3;
  84936. /**
  84937. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  84938. * @param result the vector3 to store the result
  84939. * @returns this TransformNode.
  84940. */
  84941. getPivotPointToRef(result: Vector3): TransformNode;
  84942. /**
  84943. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  84944. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  84945. */
  84946. getAbsolutePivotPoint(): Vector3;
  84947. /**
  84948. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  84949. * @param result vector3 to store the result
  84950. * @returns this TransformNode.
  84951. */
  84952. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  84953. /**
  84954. * Defines the passed node as the parent of the current node.
  84955. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  84956. * @see https://doc.babylonjs.com/how_to/parenting
  84957. * @param node the node ot set as the parent
  84958. * @returns this TransformNode.
  84959. */
  84960. setParent(node: Nullable<Node>): TransformNode;
  84961. private _nonUniformScaling;
  84962. /**
  84963. * True if the scaling property of this object is non uniform eg. (1,2,1)
  84964. */
  84965. get nonUniformScaling(): boolean;
  84966. /** @hidden */
  84967. _updateNonUniformScalingState(value: boolean): boolean;
  84968. /**
  84969. * Attach the current TransformNode to another TransformNode associated with a bone
  84970. * @param bone Bone affecting the TransformNode
  84971. * @param affectedTransformNode TransformNode associated with the bone
  84972. * @returns this object
  84973. */
  84974. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  84975. /**
  84976. * Detach the transform node if its associated with a bone
  84977. * @returns this object
  84978. */
  84979. detachFromBone(): TransformNode;
  84980. private static _rotationAxisCache;
  84981. /**
  84982. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  84983. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  84984. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  84985. * The passed axis is also normalized.
  84986. * @param axis the axis to rotate around
  84987. * @param amount the amount to rotate in radians
  84988. * @param space Space to rotate in (Default: local)
  84989. * @returns the TransformNode.
  84990. */
  84991. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  84992. /**
  84993. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  84994. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  84995. * The passed axis is also normalized. .
  84996. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  84997. * @param point the point to rotate around
  84998. * @param axis the axis to rotate around
  84999. * @param amount the amount to rotate in radians
  85000. * @returns the TransformNode
  85001. */
  85002. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  85003. /**
  85004. * Translates the mesh along the axis vector for the passed distance in the given space.
  85005. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85006. * @param axis the axis to translate in
  85007. * @param distance the distance to translate
  85008. * @param space Space to rotate in (Default: local)
  85009. * @returns the TransformNode.
  85010. */
  85011. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  85012. /**
  85013. * Adds a rotation step to the mesh current rotation.
  85014. * x, y, z are Euler angles expressed in radians.
  85015. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  85016. * This means this rotation is made in the mesh local space only.
  85017. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  85018. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  85019. * ```javascript
  85020. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  85021. * ```
  85022. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  85023. * 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.
  85024. * @param x Rotation to add
  85025. * @param y Rotation to add
  85026. * @param z Rotation to add
  85027. * @returns the TransformNode.
  85028. */
  85029. addRotation(x: number, y: number, z: number): TransformNode;
  85030. /**
  85031. * @hidden
  85032. */
  85033. protected _getEffectiveParent(): Nullable<Node>;
  85034. /**
  85035. * Computes the world matrix of the node
  85036. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85037. * @returns the world matrix
  85038. */
  85039. computeWorldMatrix(force?: boolean): Matrix;
  85040. protected _afterComputeWorldMatrix(): void;
  85041. /**
  85042. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  85043. * @param func callback function to add
  85044. *
  85045. * @returns the TransformNode.
  85046. */
  85047. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85048. /**
  85049. * Removes a registered callback function.
  85050. * @param func callback function to remove
  85051. * @returns the TransformNode.
  85052. */
  85053. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85054. /**
  85055. * Gets the position of the current mesh in camera space
  85056. * @param camera defines the camera to use
  85057. * @returns a position
  85058. */
  85059. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  85060. /**
  85061. * Returns the distance from the mesh to the active camera
  85062. * @param camera defines the camera to use
  85063. * @returns the distance
  85064. */
  85065. getDistanceToCamera(camera?: Nullable<Camera>): number;
  85066. /**
  85067. * Clone the current transform node
  85068. * @param name Name of the new clone
  85069. * @param newParent New parent for the clone
  85070. * @param doNotCloneChildren Do not clone children hierarchy
  85071. * @returns the new transform node
  85072. */
  85073. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  85074. /**
  85075. * Serializes the objects information.
  85076. * @param currentSerializationObject defines the object to serialize in
  85077. * @returns the serialized object
  85078. */
  85079. serialize(currentSerializationObject?: any): any;
  85080. /**
  85081. * Returns a new TransformNode object parsed from the source provided.
  85082. * @param parsedTransformNode is the source.
  85083. * @param scene the scne the object belongs to
  85084. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  85085. * @returns a new TransformNode object parsed from the source provided.
  85086. */
  85087. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  85088. /**
  85089. * Get all child-transformNodes of this node
  85090. * @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
  85091. * @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
  85092. * @returns an array of TransformNode
  85093. */
  85094. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  85095. /**
  85096. * Releases resources associated with this transform node.
  85097. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85098. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85099. */
  85100. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85101. /**
  85102. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  85103. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  85104. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  85105. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  85106. * @returns the current mesh
  85107. */
  85108. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  85109. private _syncAbsoluteScalingAndRotation;
  85110. }
  85111. }
  85112. declare module BABYLON {
  85113. /**
  85114. * Defines the types of pose enabled controllers that are supported
  85115. */
  85116. export enum PoseEnabledControllerType {
  85117. /**
  85118. * HTC Vive
  85119. */
  85120. VIVE = 0,
  85121. /**
  85122. * Oculus Rift
  85123. */
  85124. OCULUS = 1,
  85125. /**
  85126. * Windows mixed reality
  85127. */
  85128. WINDOWS = 2,
  85129. /**
  85130. * Samsung gear VR
  85131. */
  85132. GEAR_VR = 3,
  85133. /**
  85134. * Google Daydream
  85135. */
  85136. DAYDREAM = 4,
  85137. /**
  85138. * Generic
  85139. */
  85140. GENERIC = 5
  85141. }
  85142. /**
  85143. * Defines the MutableGamepadButton interface for the state of a gamepad button
  85144. */
  85145. export interface MutableGamepadButton {
  85146. /**
  85147. * Value of the button/trigger
  85148. */
  85149. value: number;
  85150. /**
  85151. * If the button/trigger is currently touched
  85152. */
  85153. touched: boolean;
  85154. /**
  85155. * If the button/trigger is currently pressed
  85156. */
  85157. pressed: boolean;
  85158. }
  85159. /**
  85160. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  85161. * @hidden
  85162. */
  85163. export interface ExtendedGamepadButton extends GamepadButton {
  85164. /**
  85165. * If the button/trigger is currently pressed
  85166. */
  85167. readonly pressed: boolean;
  85168. /**
  85169. * If the button/trigger is currently touched
  85170. */
  85171. readonly touched: boolean;
  85172. /**
  85173. * Value of the button/trigger
  85174. */
  85175. readonly value: number;
  85176. }
  85177. /** @hidden */
  85178. export interface _GamePadFactory {
  85179. /**
  85180. * Returns wether or not the current gamepad can be created for this type of controller.
  85181. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85182. * @returns true if it can be created, otherwise false
  85183. */
  85184. canCreate(gamepadInfo: any): boolean;
  85185. /**
  85186. * Creates a new instance of the Gamepad.
  85187. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85188. * @returns the new gamepad instance
  85189. */
  85190. create(gamepadInfo: any): Gamepad;
  85191. }
  85192. /**
  85193. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85194. */
  85195. export class PoseEnabledControllerHelper {
  85196. /** @hidden */
  85197. static _ControllerFactories: _GamePadFactory[];
  85198. /** @hidden */
  85199. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  85200. /**
  85201. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85202. * @param vrGamepad the gamepad to initialized
  85203. * @returns a vr controller of the type the gamepad identified as
  85204. */
  85205. static InitiateController(vrGamepad: any): Gamepad;
  85206. }
  85207. /**
  85208. * Defines the PoseEnabledController object that contains state of a vr capable controller
  85209. */
  85210. export class PoseEnabledController extends Gamepad implements PoseControlled {
  85211. /**
  85212. * If the controller is used in a webXR session
  85213. */
  85214. isXR: boolean;
  85215. private _deviceRoomPosition;
  85216. private _deviceRoomRotationQuaternion;
  85217. /**
  85218. * The device position in babylon space
  85219. */
  85220. devicePosition: Vector3;
  85221. /**
  85222. * The device rotation in babylon space
  85223. */
  85224. deviceRotationQuaternion: Quaternion;
  85225. /**
  85226. * The scale factor of the device in babylon space
  85227. */
  85228. deviceScaleFactor: number;
  85229. /**
  85230. * (Likely devicePosition should be used instead) The device position in its room space
  85231. */
  85232. position: Vector3;
  85233. /**
  85234. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  85235. */
  85236. rotationQuaternion: Quaternion;
  85237. /**
  85238. * The type of controller (Eg. Windows mixed reality)
  85239. */
  85240. controllerType: PoseEnabledControllerType;
  85241. protected _calculatedPosition: Vector3;
  85242. private _calculatedRotation;
  85243. /**
  85244. * The raw pose from the device
  85245. */
  85246. rawPose: DevicePose;
  85247. private _trackPosition;
  85248. private _maxRotationDistFromHeadset;
  85249. private _draggedRoomRotation;
  85250. /**
  85251. * @hidden
  85252. */
  85253. _disableTrackPosition(fixedPosition: Vector3): void;
  85254. /**
  85255. * Internal, the mesh attached to the controller
  85256. * @hidden
  85257. */
  85258. _mesh: Nullable<AbstractMesh>;
  85259. private _poseControlledCamera;
  85260. private _leftHandSystemQuaternion;
  85261. /**
  85262. * Internal, matrix used to convert room space to babylon space
  85263. * @hidden
  85264. */
  85265. _deviceToWorld: Matrix;
  85266. /**
  85267. * Node to be used when casting a ray from the controller
  85268. * @hidden
  85269. */
  85270. _pointingPoseNode: Nullable<TransformNode>;
  85271. /**
  85272. * Name of the child mesh that can be used to cast a ray from the controller
  85273. */
  85274. static readonly POINTING_POSE: string;
  85275. /**
  85276. * Creates a new PoseEnabledController from a gamepad
  85277. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  85278. */
  85279. constructor(browserGamepad: any);
  85280. private _workingMatrix;
  85281. /**
  85282. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  85283. */
  85284. update(): void;
  85285. /**
  85286. * Updates only the pose device and mesh without doing any button event checking
  85287. */
  85288. protected _updatePoseAndMesh(): void;
  85289. /**
  85290. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  85291. * @param poseData raw pose fromthe device
  85292. */
  85293. updateFromDevice(poseData: DevicePose): void;
  85294. /**
  85295. * @hidden
  85296. */
  85297. _meshAttachedObservable: Observable<AbstractMesh>;
  85298. /**
  85299. * Attaches a mesh to the controller
  85300. * @param mesh the mesh to be attached
  85301. */
  85302. attachToMesh(mesh: AbstractMesh): void;
  85303. /**
  85304. * Attaches the controllers mesh to a camera
  85305. * @param camera the camera the mesh should be attached to
  85306. */
  85307. attachToPoseControlledCamera(camera: TargetCamera): void;
  85308. /**
  85309. * Disposes of the controller
  85310. */
  85311. dispose(): void;
  85312. /**
  85313. * The mesh that is attached to the controller
  85314. */
  85315. get mesh(): Nullable<AbstractMesh>;
  85316. /**
  85317. * Gets the ray of the controller in the direction the controller is pointing
  85318. * @param length the length the resulting ray should be
  85319. * @returns a ray in the direction the controller is pointing
  85320. */
  85321. getForwardRay(length?: number): Ray;
  85322. }
  85323. }
  85324. declare module BABYLON {
  85325. /**
  85326. * Defines the WebVRController object that represents controllers tracked in 3D space
  85327. */
  85328. export abstract class WebVRController extends PoseEnabledController {
  85329. /**
  85330. * Internal, the default controller model for the controller
  85331. */
  85332. protected _defaultModel: Nullable<AbstractMesh>;
  85333. /**
  85334. * Fired when the trigger state has changed
  85335. */
  85336. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  85337. /**
  85338. * Fired when the main button state has changed
  85339. */
  85340. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85341. /**
  85342. * Fired when the secondary button state has changed
  85343. */
  85344. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85345. /**
  85346. * Fired when the pad state has changed
  85347. */
  85348. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  85349. /**
  85350. * Fired when controllers stick values have changed
  85351. */
  85352. onPadValuesChangedObservable: Observable<StickValues>;
  85353. /**
  85354. * Array of button availible on the controller
  85355. */
  85356. protected _buttons: Array<MutableGamepadButton>;
  85357. private _onButtonStateChange;
  85358. /**
  85359. * Fired when a controller button's state has changed
  85360. * @param callback the callback containing the button that was modified
  85361. */
  85362. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  85363. /**
  85364. * X and Y axis corresponding to the controllers joystick
  85365. */
  85366. pad: StickValues;
  85367. /**
  85368. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  85369. */
  85370. hand: string;
  85371. /**
  85372. * The default controller model for the controller
  85373. */
  85374. get defaultModel(): Nullable<AbstractMesh>;
  85375. /**
  85376. * Creates a new WebVRController from a gamepad
  85377. * @param vrGamepad the gamepad that the WebVRController should be created from
  85378. */
  85379. constructor(vrGamepad: any);
  85380. /**
  85381. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  85382. */
  85383. update(): void;
  85384. /**
  85385. * Function to be called when a button is modified
  85386. */
  85387. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  85388. /**
  85389. * Loads a mesh and attaches it to the controller
  85390. * @param scene the scene the mesh should be added to
  85391. * @param meshLoaded callback for when the mesh has been loaded
  85392. */
  85393. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  85394. private _setButtonValue;
  85395. private _changes;
  85396. private _checkChanges;
  85397. /**
  85398. * Disposes of th webVRCOntroller
  85399. */
  85400. dispose(): void;
  85401. }
  85402. }
  85403. declare module BABYLON {
  85404. /**
  85405. * The HemisphericLight simulates the ambient environment light,
  85406. * so the passed direction is the light reflection direction, not the incoming direction.
  85407. */
  85408. export class HemisphericLight extends Light {
  85409. /**
  85410. * The groundColor is the light in the opposite direction to the one specified during creation.
  85411. * 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.
  85412. */
  85413. groundColor: Color3;
  85414. /**
  85415. * The light reflection direction, not the incoming direction.
  85416. */
  85417. direction: Vector3;
  85418. /**
  85419. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  85420. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  85421. * The HemisphericLight can't cast shadows.
  85422. * Documentation : https://doc.babylonjs.com/babylon101/lights
  85423. * @param name The friendly name of the light
  85424. * @param direction The direction of the light reflection
  85425. * @param scene The scene the light belongs to
  85426. */
  85427. constructor(name: string, direction: Vector3, scene: Scene);
  85428. protected _buildUniformLayout(): void;
  85429. /**
  85430. * Returns the string "HemisphericLight".
  85431. * @return The class name
  85432. */
  85433. getClassName(): string;
  85434. /**
  85435. * Sets the HemisphericLight direction towards the passed target (Vector3).
  85436. * Returns the updated direction.
  85437. * @param target The target the direction should point to
  85438. * @return The computed direction
  85439. */
  85440. setDirectionToTarget(target: Vector3): Vector3;
  85441. /**
  85442. * Returns the shadow generator associated to the light.
  85443. * @returns Always null for hemispheric lights because it does not support shadows.
  85444. */
  85445. getShadowGenerator(): Nullable<IShadowGenerator>;
  85446. /**
  85447. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  85448. * @param effect The effect to update
  85449. * @param lightIndex The index of the light in the effect to update
  85450. * @returns The hemispheric light
  85451. */
  85452. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  85453. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  85454. /**
  85455. * Computes the world matrix of the node
  85456. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85457. * @param useWasUpdatedFlag defines a reserved property
  85458. * @returns the world matrix
  85459. */
  85460. computeWorldMatrix(): Matrix;
  85461. /**
  85462. * Returns the integer 3.
  85463. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  85464. */
  85465. getTypeID(): number;
  85466. /**
  85467. * Prepares the list of defines specific to the light type.
  85468. * @param defines the list of defines
  85469. * @param lightIndex defines the index of the light for the effect
  85470. */
  85471. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  85472. }
  85473. }
  85474. declare module BABYLON {
  85475. /** @hidden */
  85476. export var vrMultiviewToSingleviewPixelShader: {
  85477. name: string;
  85478. shader: string;
  85479. };
  85480. }
  85481. declare module BABYLON {
  85482. /**
  85483. * Renders to multiple views with a single draw call
  85484. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  85485. */
  85486. export class MultiviewRenderTarget extends RenderTargetTexture {
  85487. /**
  85488. * Creates a multiview render target
  85489. * @param scene scene used with the render target
  85490. * @param size the size of the render target (used for each view)
  85491. */
  85492. constructor(scene: Scene, size?: number | {
  85493. width: number;
  85494. height: number;
  85495. } | {
  85496. ratio: number;
  85497. });
  85498. /**
  85499. * @hidden
  85500. * @param faceIndex the face index, if its a cube texture
  85501. */
  85502. _bindFrameBuffer(faceIndex?: number): void;
  85503. /**
  85504. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85505. * @returns the view count
  85506. */
  85507. getViewCount(): number;
  85508. }
  85509. }
  85510. declare module BABYLON {
  85511. /**
  85512. * Represents a camera frustum
  85513. */
  85514. export class Frustum {
  85515. /**
  85516. * Gets the planes representing the frustum
  85517. * @param transform matrix to be applied to the returned planes
  85518. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85519. */
  85520. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85521. /**
  85522. * Gets the near frustum plane transformed by the transform matrix
  85523. * @param transform transformation matrix to be applied to the resulting frustum plane
  85524. * @param frustumPlane the resuling frustum plane
  85525. */
  85526. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85527. /**
  85528. * Gets the far frustum plane transformed by the transform matrix
  85529. * @param transform transformation matrix to be applied to the resulting frustum plane
  85530. * @param frustumPlane the resuling frustum plane
  85531. */
  85532. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85533. /**
  85534. * Gets the left frustum plane transformed by the transform matrix
  85535. * @param transform transformation matrix to be applied to the resulting frustum plane
  85536. * @param frustumPlane the resuling frustum plane
  85537. */
  85538. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85539. /**
  85540. * Gets the right frustum plane transformed by the transform matrix
  85541. * @param transform transformation matrix to be applied to the resulting frustum plane
  85542. * @param frustumPlane the resuling frustum plane
  85543. */
  85544. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85545. /**
  85546. * Gets the top frustum plane transformed by the transform matrix
  85547. * @param transform transformation matrix to be applied to the resulting frustum plane
  85548. * @param frustumPlane the resuling frustum plane
  85549. */
  85550. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85551. /**
  85552. * Gets the bottom frustum plane transformed by the transform matrix
  85553. * @param transform transformation matrix to be applied to the resulting frustum plane
  85554. * @param frustumPlane the resuling frustum plane
  85555. */
  85556. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85557. /**
  85558. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85559. * @param transform transformation matrix to be applied to the resulting frustum planes
  85560. * @param frustumPlanes the resuling frustum planes
  85561. */
  85562. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85563. }
  85564. }
  85565. declare module BABYLON {
  85566. interface Engine {
  85567. /**
  85568. * Creates a new multiview render target
  85569. * @param width defines the width of the texture
  85570. * @param height defines the height of the texture
  85571. * @returns the created multiview texture
  85572. */
  85573. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  85574. /**
  85575. * Binds a multiview framebuffer to be drawn to
  85576. * @param multiviewTexture texture to bind
  85577. */
  85578. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  85579. }
  85580. interface Camera {
  85581. /**
  85582. * @hidden
  85583. * 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)
  85584. */
  85585. _useMultiviewToSingleView: boolean;
  85586. /**
  85587. * @hidden
  85588. * 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)
  85589. */
  85590. _multiviewTexture: Nullable<RenderTargetTexture>;
  85591. /**
  85592. * @hidden
  85593. * ensures the multiview texture of the camera exists and has the specified width/height
  85594. * @param width height to set on the multiview texture
  85595. * @param height width to set on the multiview texture
  85596. */
  85597. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  85598. }
  85599. interface Scene {
  85600. /** @hidden */
  85601. _transformMatrixR: Matrix;
  85602. /** @hidden */
  85603. _multiviewSceneUbo: Nullable<UniformBuffer>;
  85604. /** @hidden */
  85605. _createMultiviewUbo(): void;
  85606. /** @hidden */
  85607. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  85608. /** @hidden */
  85609. _renderMultiviewToSingleView(camera: Camera): void;
  85610. }
  85611. }
  85612. declare module BABYLON {
  85613. /**
  85614. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  85615. * This will not be used for webXR as it supports displaying texture arrays directly
  85616. */
  85617. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  85618. /**
  85619. * Initializes a VRMultiviewToSingleview
  85620. * @param name name of the post process
  85621. * @param camera camera to be applied to
  85622. * @param scaleFactor scaling factor to the size of the output texture
  85623. */
  85624. constructor(name: string, camera: Camera, scaleFactor: number);
  85625. }
  85626. }
  85627. declare module BABYLON {
  85628. /**
  85629. * Interface used to define additional presentation attributes
  85630. */
  85631. export interface IVRPresentationAttributes {
  85632. /**
  85633. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  85634. */
  85635. highRefreshRate: boolean;
  85636. /**
  85637. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  85638. */
  85639. foveationLevel: number;
  85640. }
  85641. interface Engine {
  85642. /** @hidden */
  85643. _vrDisplay: any;
  85644. /** @hidden */
  85645. _vrSupported: boolean;
  85646. /** @hidden */
  85647. _oldSize: Size;
  85648. /** @hidden */
  85649. _oldHardwareScaleFactor: number;
  85650. /** @hidden */
  85651. _vrExclusivePointerMode: boolean;
  85652. /** @hidden */
  85653. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  85654. /** @hidden */
  85655. _onVRDisplayPointerRestricted: () => void;
  85656. /** @hidden */
  85657. _onVRDisplayPointerUnrestricted: () => void;
  85658. /** @hidden */
  85659. _onVrDisplayConnect: Nullable<(display: any) => void>;
  85660. /** @hidden */
  85661. _onVrDisplayDisconnect: Nullable<() => void>;
  85662. /** @hidden */
  85663. _onVrDisplayPresentChange: Nullable<() => void>;
  85664. /**
  85665. * Observable signaled when VR display mode changes
  85666. */
  85667. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85668. /**
  85669. * Observable signaled when VR request present is complete
  85670. */
  85671. onVRRequestPresentComplete: Observable<boolean>;
  85672. /**
  85673. * Observable signaled when VR request present starts
  85674. */
  85675. onVRRequestPresentStart: Observable<Engine>;
  85676. /**
  85677. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85678. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85679. */
  85680. isInVRExclusivePointerMode: boolean;
  85681. /**
  85682. * Gets a boolean indicating if a webVR device was detected
  85683. * @returns true if a webVR device was detected
  85684. */
  85685. isVRDevicePresent(): boolean;
  85686. /**
  85687. * Gets the current webVR device
  85688. * @returns the current webVR device (or null)
  85689. */
  85690. getVRDevice(): any;
  85691. /**
  85692. * Initializes a webVR display and starts listening to display change events
  85693. * The onVRDisplayChangedObservable will be notified upon these changes
  85694. * @returns A promise containing a VRDisplay and if vr is supported
  85695. */
  85696. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85697. /** @hidden */
  85698. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  85699. /**
  85700. * Gets or sets the presentation attributes used to configure VR rendering
  85701. */
  85702. vrPresentationAttributes?: IVRPresentationAttributes;
  85703. /**
  85704. * Call this function to switch to webVR mode
  85705. * Will do nothing if webVR is not supported or if there is no webVR device
  85706. * @param options the webvr options provided to the camera. mainly used for multiview
  85707. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85708. */
  85709. enableVR(options: WebVROptions): void;
  85710. /** @hidden */
  85711. _onVRFullScreenTriggered(): void;
  85712. }
  85713. }
  85714. declare module BABYLON {
  85715. /**
  85716. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  85717. * IMPORTANT!! The data is right-hand data.
  85718. * @export
  85719. * @interface DevicePose
  85720. */
  85721. export interface DevicePose {
  85722. /**
  85723. * The position of the device, values in array are [x,y,z].
  85724. */
  85725. readonly position: Nullable<Float32Array>;
  85726. /**
  85727. * The linearVelocity of the device, values in array are [x,y,z].
  85728. */
  85729. readonly linearVelocity: Nullable<Float32Array>;
  85730. /**
  85731. * The linearAcceleration of the device, values in array are [x,y,z].
  85732. */
  85733. readonly linearAcceleration: Nullable<Float32Array>;
  85734. /**
  85735. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  85736. */
  85737. readonly orientation: Nullable<Float32Array>;
  85738. /**
  85739. * The angularVelocity of the device, values in array are [x,y,z].
  85740. */
  85741. readonly angularVelocity: Nullable<Float32Array>;
  85742. /**
  85743. * The angularAcceleration of the device, values in array are [x,y,z].
  85744. */
  85745. readonly angularAcceleration: Nullable<Float32Array>;
  85746. }
  85747. /**
  85748. * Interface representing a pose controlled object in Babylon.
  85749. * A pose controlled object has both regular pose values as well as pose values
  85750. * from an external device such as a VR head mounted display
  85751. */
  85752. export interface PoseControlled {
  85753. /**
  85754. * The position of the object in babylon space.
  85755. */
  85756. position: Vector3;
  85757. /**
  85758. * The rotation quaternion of the object in babylon space.
  85759. */
  85760. rotationQuaternion: Quaternion;
  85761. /**
  85762. * The position of the device in babylon space.
  85763. */
  85764. devicePosition?: Vector3;
  85765. /**
  85766. * The rotation quaternion of the device in babylon space.
  85767. */
  85768. deviceRotationQuaternion: Quaternion;
  85769. /**
  85770. * The raw pose coming from the device.
  85771. */
  85772. rawPose: Nullable<DevicePose>;
  85773. /**
  85774. * The scale of the device to be used when translating from device space to babylon space.
  85775. */
  85776. deviceScaleFactor: number;
  85777. /**
  85778. * Updates the poseControlled values based on the input device pose.
  85779. * @param poseData the pose data to update the object with
  85780. */
  85781. updateFromDevice(poseData: DevicePose): void;
  85782. }
  85783. /**
  85784. * Set of options to customize the webVRCamera
  85785. */
  85786. export interface WebVROptions {
  85787. /**
  85788. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  85789. */
  85790. trackPosition?: boolean;
  85791. /**
  85792. * Sets the scale of the vrDevice in babylon space. (default: 1)
  85793. */
  85794. positionScale?: number;
  85795. /**
  85796. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  85797. */
  85798. displayName?: string;
  85799. /**
  85800. * Should the native controller meshes be initialized. (default: true)
  85801. */
  85802. controllerMeshes?: boolean;
  85803. /**
  85804. * Creating a default HemiLight only on controllers. (default: true)
  85805. */
  85806. defaultLightingOnControllers?: boolean;
  85807. /**
  85808. * If you don't want to use the default VR button of the helper. (default: false)
  85809. */
  85810. useCustomVRButton?: boolean;
  85811. /**
  85812. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  85813. */
  85814. customVRButton?: HTMLButtonElement;
  85815. /**
  85816. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  85817. */
  85818. rayLength?: number;
  85819. /**
  85820. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  85821. */
  85822. defaultHeight?: number;
  85823. /**
  85824. * If multiview should be used if availible (default: false)
  85825. */
  85826. useMultiview?: boolean;
  85827. }
  85828. /**
  85829. * This represents a WebVR camera.
  85830. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  85831. * @example http://doc.babylonjs.com/how_to/webvr_camera
  85832. */
  85833. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  85834. private webVROptions;
  85835. /**
  85836. * @hidden
  85837. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  85838. */
  85839. _vrDevice: any;
  85840. /**
  85841. * The rawPose of the vrDevice.
  85842. */
  85843. rawPose: Nullable<DevicePose>;
  85844. private _onVREnabled;
  85845. private _specsVersion;
  85846. private _attached;
  85847. private _frameData;
  85848. protected _descendants: Array<Node>;
  85849. private _deviceRoomPosition;
  85850. /** @hidden */
  85851. _deviceRoomRotationQuaternion: Quaternion;
  85852. private _standingMatrix;
  85853. /**
  85854. * Represents device position in babylon space.
  85855. */
  85856. devicePosition: Vector3;
  85857. /**
  85858. * Represents device rotation in babylon space.
  85859. */
  85860. deviceRotationQuaternion: Quaternion;
  85861. /**
  85862. * The scale of the device to be used when translating from device space to babylon space.
  85863. */
  85864. deviceScaleFactor: number;
  85865. private _deviceToWorld;
  85866. private _worldToDevice;
  85867. /**
  85868. * References to the webVR controllers for the vrDevice.
  85869. */
  85870. controllers: Array<WebVRController>;
  85871. /**
  85872. * Emits an event when a controller is attached.
  85873. */
  85874. onControllersAttachedObservable: Observable<WebVRController[]>;
  85875. /**
  85876. * Emits an event when a controller's mesh has been loaded;
  85877. */
  85878. onControllerMeshLoadedObservable: Observable<WebVRController>;
  85879. /**
  85880. * Emits an event when the HMD's pose has been updated.
  85881. */
  85882. onPoseUpdatedFromDeviceObservable: Observable<any>;
  85883. private _poseSet;
  85884. /**
  85885. * If the rig cameras be used as parent instead of this camera.
  85886. */
  85887. rigParenting: boolean;
  85888. private _lightOnControllers;
  85889. private _defaultHeight?;
  85890. /**
  85891. * Instantiates a WebVRFreeCamera.
  85892. * @param name The name of the WebVRFreeCamera
  85893. * @param position The starting anchor position for the camera
  85894. * @param scene The scene the camera belongs to
  85895. * @param webVROptions a set of customizable options for the webVRCamera
  85896. */
  85897. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  85898. /**
  85899. * Gets the device distance from the ground in meters.
  85900. * @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.
  85901. */
  85902. deviceDistanceToRoomGround(): number;
  85903. /**
  85904. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85905. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  85906. */
  85907. useStandingMatrix(callback?: (bool: boolean) => void): void;
  85908. /**
  85909. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85910. * @returns A promise with a boolean set to if the standing matrix is supported.
  85911. */
  85912. useStandingMatrixAsync(): Promise<boolean>;
  85913. /**
  85914. * Disposes the camera
  85915. */
  85916. dispose(): void;
  85917. /**
  85918. * Gets a vrController by name.
  85919. * @param name The name of the controller to retreive
  85920. * @returns the controller matching the name specified or null if not found
  85921. */
  85922. getControllerByName(name: string): Nullable<WebVRController>;
  85923. private _leftController;
  85924. /**
  85925. * The controller corresponding to the users left hand.
  85926. */
  85927. get leftController(): Nullable<WebVRController>;
  85928. private _rightController;
  85929. /**
  85930. * The controller corresponding to the users right hand.
  85931. */
  85932. get rightController(): Nullable<WebVRController>;
  85933. /**
  85934. * Casts a ray forward from the vrCamera's gaze.
  85935. * @param length Length of the ray (default: 100)
  85936. * @returns the ray corresponding to the gaze
  85937. */
  85938. getForwardRay(length?: number): Ray;
  85939. /**
  85940. * @hidden
  85941. * Updates the camera based on device's frame data
  85942. */
  85943. _checkInputs(): void;
  85944. /**
  85945. * Updates the poseControlled values based on the input device pose.
  85946. * @param poseData Pose coming from the device
  85947. */
  85948. updateFromDevice(poseData: DevicePose): void;
  85949. private _htmlElementAttached;
  85950. private _detachIfAttached;
  85951. /**
  85952. * WebVR's attach control will start broadcasting frames to the device.
  85953. * Note that in certain browsers (chrome for example) this function must be called
  85954. * within a user-interaction callback. Example:
  85955. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  85956. *
  85957. * @param element html element to attach the vrDevice to
  85958. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  85959. */
  85960. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85961. /**
  85962. * Detaches the camera from the html element and disables VR
  85963. *
  85964. * @param element html element to detach from
  85965. */
  85966. detachControl(element: HTMLElement): void;
  85967. /**
  85968. * @returns the name of this class
  85969. */
  85970. getClassName(): string;
  85971. /**
  85972. * Calls resetPose on the vrDisplay
  85973. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  85974. */
  85975. resetToCurrentRotation(): void;
  85976. /**
  85977. * @hidden
  85978. * Updates the rig cameras (left and right eye)
  85979. */
  85980. _updateRigCameras(): void;
  85981. private _workingVector;
  85982. private _oneVector;
  85983. private _workingMatrix;
  85984. private updateCacheCalled;
  85985. private _correctPositionIfNotTrackPosition;
  85986. /**
  85987. * @hidden
  85988. * Updates the cached values of the camera
  85989. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  85990. */
  85991. _updateCache(ignoreParentClass?: boolean): void;
  85992. /**
  85993. * @hidden
  85994. * Get current device position in babylon world
  85995. */
  85996. _computeDevicePosition(): void;
  85997. /**
  85998. * Updates the current device position and rotation in the babylon world
  85999. */
  86000. update(): void;
  86001. /**
  86002. * @hidden
  86003. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  86004. * @returns an identity matrix
  86005. */
  86006. _getViewMatrix(): Matrix;
  86007. private _tmpMatrix;
  86008. /**
  86009. * This function is called by the two RIG cameras.
  86010. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  86011. * @hidden
  86012. */
  86013. _getWebVRViewMatrix(): Matrix;
  86014. /** @hidden */
  86015. _getWebVRProjectionMatrix(): Matrix;
  86016. private _onGamepadConnectedObserver;
  86017. private _onGamepadDisconnectedObserver;
  86018. private _updateCacheWhenTrackingDisabledObserver;
  86019. /**
  86020. * Initializes the controllers and their meshes
  86021. */
  86022. initControllers(): void;
  86023. }
  86024. }
  86025. declare module BABYLON {
  86026. /**
  86027. * Size options for a post process
  86028. */
  86029. export type PostProcessOptions = {
  86030. width: number;
  86031. height: number;
  86032. };
  86033. /**
  86034. * PostProcess can be used to apply a shader to a texture after it has been rendered
  86035. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86036. */
  86037. export class PostProcess {
  86038. /** Name of the PostProcess. */
  86039. name: string;
  86040. /**
  86041. * Gets or sets the unique id of the post process
  86042. */
  86043. uniqueId: number;
  86044. /**
  86045. * Width of the texture to apply the post process on
  86046. */
  86047. width: number;
  86048. /**
  86049. * Height of the texture to apply the post process on
  86050. */
  86051. height: number;
  86052. /**
  86053. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  86054. * @hidden
  86055. */
  86056. _outputTexture: Nullable<InternalTexture>;
  86057. /**
  86058. * Sampling mode used by the shader
  86059. * See https://doc.babylonjs.com/classes/3.1/texture
  86060. */
  86061. renderTargetSamplingMode: number;
  86062. /**
  86063. * Clear color to use when screen clearing
  86064. */
  86065. clearColor: Color4;
  86066. /**
  86067. * If the buffer needs to be cleared before applying the post process. (default: true)
  86068. * Should be set to false if shader will overwrite all previous pixels.
  86069. */
  86070. autoClear: boolean;
  86071. /**
  86072. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  86073. */
  86074. alphaMode: number;
  86075. /**
  86076. * Sets the setAlphaBlendConstants of the babylon engine
  86077. */
  86078. alphaConstants: Color4;
  86079. /**
  86080. * Animations to be used for the post processing
  86081. */
  86082. animations: Animation[];
  86083. /**
  86084. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  86085. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  86086. */
  86087. enablePixelPerfectMode: boolean;
  86088. /**
  86089. * Force the postprocess to be applied without taking in account viewport
  86090. */
  86091. forceFullscreenViewport: boolean;
  86092. /**
  86093. * List of inspectable custom properties (used by the Inspector)
  86094. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86095. */
  86096. inspectableCustomProperties: IInspectable[];
  86097. /**
  86098. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  86099. *
  86100. * | Value | Type | Description |
  86101. * | ----- | ----------------------------------- | ----------- |
  86102. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  86103. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  86104. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  86105. *
  86106. */
  86107. scaleMode: number;
  86108. /**
  86109. * Force textures to be a power of two (default: false)
  86110. */
  86111. alwaysForcePOT: boolean;
  86112. private _samples;
  86113. /**
  86114. * Number of sample textures (default: 1)
  86115. */
  86116. get samples(): number;
  86117. set samples(n: number);
  86118. /**
  86119. * Modify the scale of the post process to be the same as the viewport (default: false)
  86120. */
  86121. adaptScaleToCurrentViewport: boolean;
  86122. private _camera;
  86123. private _scene;
  86124. private _engine;
  86125. private _options;
  86126. private _reusable;
  86127. private _textureType;
  86128. /**
  86129. * Smart array of input and output textures for the post process.
  86130. * @hidden
  86131. */
  86132. _textures: SmartArray<InternalTexture>;
  86133. /**
  86134. * The index in _textures that corresponds to the output texture.
  86135. * @hidden
  86136. */
  86137. _currentRenderTextureInd: number;
  86138. private _effect;
  86139. private _samplers;
  86140. private _fragmentUrl;
  86141. private _vertexUrl;
  86142. private _parameters;
  86143. private _scaleRatio;
  86144. protected _indexParameters: any;
  86145. private _shareOutputWithPostProcess;
  86146. private _texelSize;
  86147. private _forcedOutputTexture;
  86148. /**
  86149. * Returns the fragment url or shader name used in the post process.
  86150. * @returns the fragment url or name in the shader store.
  86151. */
  86152. getEffectName(): string;
  86153. /**
  86154. * An event triggered when the postprocess is activated.
  86155. */
  86156. onActivateObservable: Observable<Camera>;
  86157. private _onActivateObserver;
  86158. /**
  86159. * A function that is added to the onActivateObservable
  86160. */
  86161. set onActivate(callback: Nullable<(camera: Camera) => void>);
  86162. /**
  86163. * An event triggered when the postprocess changes its size.
  86164. */
  86165. onSizeChangedObservable: Observable<PostProcess>;
  86166. private _onSizeChangedObserver;
  86167. /**
  86168. * A function that is added to the onSizeChangedObservable
  86169. */
  86170. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  86171. /**
  86172. * An event triggered when the postprocess applies its effect.
  86173. */
  86174. onApplyObservable: Observable<Effect>;
  86175. private _onApplyObserver;
  86176. /**
  86177. * A function that is added to the onApplyObservable
  86178. */
  86179. set onApply(callback: (effect: Effect) => void);
  86180. /**
  86181. * An event triggered before rendering the postprocess
  86182. */
  86183. onBeforeRenderObservable: Observable<Effect>;
  86184. private _onBeforeRenderObserver;
  86185. /**
  86186. * A function that is added to the onBeforeRenderObservable
  86187. */
  86188. set onBeforeRender(callback: (effect: Effect) => void);
  86189. /**
  86190. * An event triggered after rendering the postprocess
  86191. */
  86192. onAfterRenderObservable: Observable<Effect>;
  86193. private _onAfterRenderObserver;
  86194. /**
  86195. * A function that is added to the onAfterRenderObservable
  86196. */
  86197. set onAfterRender(callback: (efect: Effect) => void);
  86198. /**
  86199. * 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
  86200. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  86201. */
  86202. get inputTexture(): InternalTexture;
  86203. set inputTexture(value: InternalTexture);
  86204. /**
  86205. * Gets the camera which post process is applied to.
  86206. * @returns The camera the post process is applied to.
  86207. */
  86208. getCamera(): Camera;
  86209. /**
  86210. * Gets the texel size of the postprocess.
  86211. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  86212. */
  86213. get texelSize(): Vector2;
  86214. /**
  86215. * Creates a new instance PostProcess
  86216. * @param name The name of the PostProcess.
  86217. * @param fragmentUrl The url of the fragment shader to be used.
  86218. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  86219. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  86220. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86221. * @param camera The camera to apply the render pass to.
  86222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86223. * @param engine The engine which the post process will be applied. (default: current engine)
  86224. * @param reusable If the post process can be reused on the same frame. (default: false)
  86225. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  86226. * @param textureType Type of textures used when performing the post process. (default: 0)
  86227. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  86228. * @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
  86229. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  86230. */
  86231. constructor(
  86232. /** Name of the PostProcess. */
  86233. 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);
  86234. /**
  86235. * Gets a string idenfifying the name of the class
  86236. * @returns "PostProcess" string
  86237. */
  86238. getClassName(): string;
  86239. /**
  86240. * Gets the engine which this post process belongs to.
  86241. * @returns The engine the post process was enabled with.
  86242. */
  86243. getEngine(): Engine;
  86244. /**
  86245. * The effect that is created when initializing the post process.
  86246. * @returns The created effect corresponding the the postprocess.
  86247. */
  86248. getEffect(): Effect;
  86249. /**
  86250. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  86251. * @param postProcess The post process to share the output with.
  86252. * @returns This post process.
  86253. */
  86254. shareOutputWith(postProcess: PostProcess): PostProcess;
  86255. /**
  86256. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  86257. * This should be called if the post process that shares output with this post process is disabled/disposed.
  86258. */
  86259. useOwnOutput(): void;
  86260. /**
  86261. * Updates the effect with the current post process compile time values and recompiles the shader.
  86262. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86263. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86264. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86265. * @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
  86266. * @param onCompiled Called when the shader has been compiled.
  86267. * @param onError Called if there is an error when compiling a shader.
  86268. */
  86269. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86270. /**
  86271. * The post process is reusable if it can be used multiple times within one frame.
  86272. * @returns If the post process is reusable
  86273. */
  86274. isReusable(): boolean;
  86275. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  86276. markTextureDirty(): void;
  86277. /**
  86278. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  86279. * 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.
  86280. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  86281. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  86282. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  86283. * @returns The target texture that was bound to be written to.
  86284. */
  86285. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  86286. /**
  86287. * If the post process is supported.
  86288. */
  86289. get isSupported(): boolean;
  86290. /**
  86291. * The aspect ratio of the output texture.
  86292. */
  86293. get aspectRatio(): number;
  86294. /**
  86295. * Get a value indicating if the post-process is ready to be used
  86296. * @returns true if the post-process is ready (shader is compiled)
  86297. */
  86298. isReady(): boolean;
  86299. /**
  86300. * Binds all textures and uniforms to the shader, this will be run on every pass.
  86301. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  86302. */
  86303. apply(): Nullable<Effect>;
  86304. private _disposeTextures;
  86305. /**
  86306. * Disposes the post process.
  86307. * @param camera The camera to dispose the post process on.
  86308. */
  86309. dispose(camera?: Camera): void;
  86310. }
  86311. }
  86312. declare module BABYLON {
  86313. /** @hidden */
  86314. export var kernelBlurVaryingDeclaration: {
  86315. name: string;
  86316. shader: string;
  86317. };
  86318. }
  86319. declare module BABYLON {
  86320. /** @hidden */
  86321. export var kernelBlurFragment: {
  86322. name: string;
  86323. shader: string;
  86324. };
  86325. }
  86326. declare module BABYLON {
  86327. /** @hidden */
  86328. export var kernelBlurFragment2: {
  86329. name: string;
  86330. shader: string;
  86331. };
  86332. }
  86333. declare module BABYLON {
  86334. /** @hidden */
  86335. export var kernelBlurPixelShader: {
  86336. name: string;
  86337. shader: string;
  86338. };
  86339. }
  86340. declare module BABYLON {
  86341. /** @hidden */
  86342. export var kernelBlurVertex: {
  86343. name: string;
  86344. shader: string;
  86345. };
  86346. }
  86347. declare module BABYLON {
  86348. /** @hidden */
  86349. export var kernelBlurVertexShader: {
  86350. name: string;
  86351. shader: string;
  86352. };
  86353. }
  86354. declare module BABYLON {
  86355. /**
  86356. * The Blur Post Process which blurs an image based on a kernel and direction.
  86357. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  86358. */
  86359. export class BlurPostProcess extends PostProcess {
  86360. /** The direction in which to blur the image. */
  86361. direction: Vector2;
  86362. private blockCompilation;
  86363. protected _kernel: number;
  86364. protected _idealKernel: number;
  86365. protected _packedFloat: boolean;
  86366. private _staticDefines;
  86367. /**
  86368. * Sets the length in pixels of the blur sample region
  86369. */
  86370. set kernel(v: number);
  86371. /**
  86372. * Gets the length in pixels of the blur sample region
  86373. */
  86374. get kernel(): number;
  86375. /**
  86376. * Sets wether or not the blur needs to unpack/repack floats
  86377. */
  86378. set packedFloat(v: boolean);
  86379. /**
  86380. * Gets wether or not the blur is unpacking/repacking floats
  86381. */
  86382. get packedFloat(): boolean;
  86383. /**
  86384. * Creates a new instance BlurPostProcess
  86385. * @param name The name of the effect.
  86386. * @param direction The direction in which to blur the image.
  86387. * @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.
  86388. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86389. * @param camera The camera to apply the render pass to.
  86390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86391. * @param engine The engine which the post process will be applied. (default: current engine)
  86392. * @param reusable If the post process can be reused on the same frame. (default: false)
  86393. * @param textureType Type of textures used when performing the post process. (default: 0)
  86394. * @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)
  86395. */
  86396. constructor(name: string,
  86397. /** The direction in which to blur the image. */
  86398. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  86399. /**
  86400. * Updates the effect with the current post process compile time values and recompiles the shader.
  86401. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86402. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86403. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86404. * @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
  86405. * @param onCompiled Called when the shader has been compiled.
  86406. * @param onError Called if there is an error when compiling a shader.
  86407. */
  86408. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86409. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86410. /**
  86411. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  86412. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  86413. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  86414. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  86415. * The gaps between physical kernels are compensated for in the weighting of the samples
  86416. * @param idealKernel Ideal blur kernel.
  86417. * @return Nearest best kernel.
  86418. */
  86419. protected _nearestBestKernel(idealKernel: number): number;
  86420. /**
  86421. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  86422. * @param x The point on the Gaussian distribution to sample.
  86423. * @return the value of the Gaussian function at x.
  86424. */
  86425. protected _gaussianWeight(x: number): number;
  86426. /**
  86427. * Generates a string that can be used as a floating point number in GLSL.
  86428. * @param x Value to print.
  86429. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  86430. * @return GLSL float string.
  86431. */
  86432. protected _glslFloat(x: number, decimalFigures?: number): string;
  86433. }
  86434. }
  86435. declare module BABYLON {
  86436. /**
  86437. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86438. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86439. * You can then easily use it as a reflectionTexture on a flat surface.
  86440. * In case the surface is not a plane, please consider relying on reflection probes.
  86441. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86442. */
  86443. export class MirrorTexture extends RenderTargetTexture {
  86444. private scene;
  86445. /**
  86446. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  86447. * 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.
  86448. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86449. */
  86450. mirrorPlane: Plane;
  86451. /**
  86452. * Define the blur ratio used to blur the reflection if needed.
  86453. */
  86454. set blurRatio(value: number);
  86455. get blurRatio(): number;
  86456. /**
  86457. * Define the adaptive blur kernel used to blur the reflection if needed.
  86458. * This will autocompute the closest best match for the `blurKernel`
  86459. */
  86460. set adaptiveBlurKernel(value: number);
  86461. /**
  86462. * Define the blur kernel used to blur the reflection if needed.
  86463. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86464. */
  86465. set blurKernel(value: number);
  86466. /**
  86467. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  86468. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86469. */
  86470. set blurKernelX(value: number);
  86471. get blurKernelX(): number;
  86472. /**
  86473. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  86474. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86475. */
  86476. set blurKernelY(value: number);
  86477. get blurKernelY(): number;
  86478. private _autoComputeBlurKernel;
  86479. protected _onRatioRescale(): void;
  86480. private _updateGammaSpace;
  86481. private _imageProcessingConfigChangeObserver;
  86482. private _transformMatrix;
  86483. private _mirrorMatrix;
  86484. private _savedViewMatrix;
  86485. private _blurX;
  86486. private _blurY;
  86487. private _adaptiveBlurKernel;
  86488. private _blurKernelX;
  86489. private _blurKernelY;
  86490. private _blurRatio;
  86491. /**
  86492. * Instantiates a Mirror Texture.
  86493. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86494. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86495. * You can then easily use it as a reflectionTexture on a flat surface.
  86496. * In case the surface is not a plane, please consider relying on reflection probes.
  86497. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86498. * @param name
  86499. * @param size
  86500. * @param scene
  86501. * @param generateMipMaps
  86502. * @param type
  86503. * @param samplingMode
  86504. * @param generateDepthBuffer
  86505. */
  86506. constructor(name: string, size: number | {
  86507. width: number;
  86508. height: number;
  86509. } | {
  86510. ratio: number;
  86511. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  86512. private _preparePostProcesses;
  86513. /**
  86514. * Clone the mirror texture.
  86515. * @returns the cloned texture
  86516. */
  86517. clone(): MirrorTexture;
  86518. /**
  86519. * Serialize the texture to a JSON representation you could use in Parse later on
  86520. * @returns the serialized JSON representation
  86521. */
  86522. serialize(): any;
  86523. /**
  86524. * Dispose the texture and release its associated resources.
  86525. */
  86526. dispose(): void;
  86527. }
  86528. }
  86529. declare module BABYLON {
  86530. /**
  86531. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86532. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86533. */
  86534. export class Texture extends BaseTexture {
  86535. /**
  86536. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  86537. */
  86538. static SerializeBuffers: boolean;
  86539. /** @hidden */
  86540. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  86541. /** @hidden */
  86542. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  86543. /** @hidden */
  86544. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  86545. /** nearest is mag = nearest and min = nearest and mip = linear */
  86546. static readonly NEAREST_SAMPLINGMODE: number;
  86547. /** nearest is mag = nearest and min = nearest and mip = linear */
  86548. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  86549. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86550. static readonly BILINEAR_SAMPLINGMODE: number;
  86551. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86552. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  86553. /** Trilinear is mag = linear and min = linear and mip = linear */
  86554. static readonly TRILINEAR_SAMPLINGMODE: number;
  86555. /** Trilinear is mag = linear and min = linear and mip = linear */
  86556. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  86557. /** mag = nearest and min = nearest and mip = nearest */
  86558. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  86559. /** mag = nearest and min = linear and mip = nearest */
  86560. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  86561. /** mag = nearest and min = linear and mip = linear */
  86562. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  86563. /** mag = nearest and min = linear and mip = none */
  86564. static readonly NEAREST_LINEAR: number;
  86565. /** mag = nearest and min = nearest and mip = none */
  86566. static readonly NEAREST_NEAREST: number;
  86567. /** mag = linear and min = nearest and mip = nearest */
  86568. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  86569. /** mag = linear and min = nearest and mip = linear */
  86570. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  86571. /** mag = linear and min = linear and mip = none */
  86572. static readonly LINEAR_LINEAR: number;
  86573. /** mag = linear and min = nearest and mip = none */
  86574. static readonly LINEAR_NEAREST: number;
  86575. /** Explicit coordinates mode */
  86576. static readonly EXPLICIT_MODE: number;
  86577. /** Spherical coordinates mode */
  86578. static readonly SPHERICAL_MODE: number;
  86579. /** Planar coordinates mode */
  86580. static readonly PLANAR_MODE: number;
  86581. /** Cubic coordinates mode */
  86582. static readonly CUBIC_MODE: number;
  86583. /** Projection coordinates mode */
  86584. static readonly PROJECTION_MODE: number;
  86585. /** Inverse Cubic coordinates mode */
  86586. static readonly SKYBOX_MODE: number;
  86587. /** Inverse Cubic coordinates mode */
  86588. static readonly INVCUBIC_MODE: number;
  86589. /** Equirectangular coordinates mode */
  86590. static readonly EQUIRECTANGULAR_MODE: number;
  86591. /** Equirectangular Fixed coordinates mode */
  86592. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  86593. /** Equirectangular Fixed Mirrored coordinates mode */
  86594. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86595. /** Texture is not repeating outside of 0..1 UVs */
  86596. static readonly CLAMP_ADDRESSMODE: number;
  86597. /** Texture is repeating outside of 0..1 UVs */
  86598. static readonly WRAP_ADDRESSMODE: number;
  86599. /** Texture is repeating and mirrored */
  86600. static readonly MIRROR_ADDRESSMODE: number;
  86601. /**
  86602. * 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
  86603. */
  86604. static UseSerializedUrlIfAny: boolean;
  86605. /**
  86606. * Define the url of the texture.
  86607. */
  86608. url: Nullable<string>;
  86609. /**
  86610. * Define an offset on the texture to offset the u coordinates of the UVs
  86611. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86612. */
  86613. uOffset: number;
  86614. /**
  86615. * Define an offset on the texture to offset the v coordinates of the UVs
  86616. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86617. */
  86618. vOffset: number;
  86619. /**
  86620. * Define an offset on the texture to scale the u coordinates of the UVs
  86621. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86622. */
  86623. uScale: number;
  86624. /**
  86625. * Define an offset on the texture to scale the v coordinates of the UVs
  86626. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86627. */
  86628. vScale: number;
  86629. /**
  86630. * Define an offset on the texture to rotate around the u coordinates of the UVs
  86631. * @see http://doc.babylonjs.com/how_to/more_materials
  86632. */
  86633. uAng: number;
  86634. /**
  86635. * Define an offset on the texture to rotate around the v coordinates of the UVs
  86636. * @see http://doc.babylonjs.com/how_to/more_materials
  86637. */
  86638. vAng: number;
  86639. /**
  86640. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  86641. * @see http://doc.babylonjs.com/how_to/more_materials
  86642. */
  86643. wAng: number;
  86644. /**
  86645. * Defines the center of rotation (U)
  86646. */
  86647. uRotationCenter: number;
  86648. /**
  86649. * Defines the center of rotation (V)
  86650. */
  86651. vRotationCenter: number;
  86652. /**
  86653. * Defines the center of rotation (W)
  86654. */
  86655. wRotationCenter: number;
  86656. /**
  86657. * Are mip maps generated for this texture or not.
  86658. */
  86659. get noMipmap(): boolean;
  86660. /**
  86661. * List of inspectable custom properties (used by the Inspector)
  86662. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86663. */
  86664. inspectableCustomProperties: Nullable<IInspectable[]>;
  86665. private _noMipmap;
  86666. /** @hidden */
  86667. _invertY: boolean;
  86668. private _rowGenerationMatrix;
  86669. private _cachedTextureMatrix;
  86670. private _projectionModeMatrix;
  86671. private _t0;
  86672. private _t1;
  86673. private _t2;
  86674. private _cachedUOffset;
  86675. private _cachedVOffset;
  86676. private _cachedUScale;
  86677. private _cachedVScale;
  86678. private _cachedUAng;
  86679. private _cachedVAng;
  86680. private _cachedWAng;
  86681. private _cachedProjectionMatrixId;
  86682. private _cachedCoordinatesMode;
  86683. /** @hidden */
  86684. protected _initialSamplingMode: number;
  86685. /** @hidden */
  86686. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  86687. private _deleteBuffer;
  86688. protected _format: Nullable<number>;
  86689. private _delayedOnLoad;
  86690. private _delayedOnError;
  86691. private _mimeType?;
  86692. /**
  86693. * Observable triggered once the texture has been loaded.
  86694. */
  86695. onLoadObservable: Observable<Texture>;
  86696. protected _isBlocking: boolean;
  86697. /**
  86698. * Is the texture preventing material to render while loading.
  86699. * If false, a default texture will be used instead of the loading one during the preparation step.
  86700. */
  86701. set isBlocking(value: boolean);
  86702. get isBlocking(): boolean;
  86703. /**
  86704. * Get the current sampling mode associated with the texture.
  86705. */
  86706. get samplingMode(): number;
  86707. /**
  86708. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  86709. */
  86710. get invertY(): boolean;
  86711. /**
  86712. * Instantiates a new texture.
  86713. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86714. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86715. * @param url defines the url of the picture to load as a texture
  86716. * @param scene defines the scene or engine the texture will belong to
  86717. * @param noMipmap defines if the texture will require mip maps or not
  86718. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  86719. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86720. * @param onLoad defines a callback triggered when the texture has been loaded
  86721. * @param onError defines a callback triggered when an error occurred during the loading session
  86722. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  86723. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  86724. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86725. * @param mimeType defines an optional mime type information
  86726. */
  86727. 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);
  86728. /**
  86729. * Update the url (and optional buffer) of this texture if url was null during construction.
  86730. * @param url the url of the texture
  86731. * @param buffer the buffer of the texture (defaults to null)
  86732. * @param onLoad callback called when the texture is loaded (defaults to null)
  86733. */
  86734. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  86735. /**
  86736. * Finish the loading sequence of a texture flagged as delayed load.
  86737. * @hidden
  86738. */
  86739. delayLoad(): void;
  86740. private _prepareRowForTextureGeneration;
  86741. /**
  86742. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  86743. * @returns the transform matrix of the texture.
  86744. */
  86745. getTextureMatrix(uBase?: number): Matrix;
  86746. /**
  86747. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  86748. * @returns The reflection texture transform
  86749. */
  86750. getReflectionTextureMatrix(): Matrix;
  86751. /**
  86752. * Clones the texture.
  86753. * @returns the cloned texture
  86754. */
  86755. clone(): Texture;
  86756. /**
  86757. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86758. * @returns The JSON representation of the texture
  86759. */
  86760. serialize(): any;
  86761. /**
  86762. * Get the current class name of the texture useful for serialization or dynamic coding.
  86763. * @returns "Texture"
  86764. */
  86765. getClassName(): string;
  86766. /**
  86767. * Dispose the texture and release its associated resources.
  86768. */
  86769. dispose(): void;
  86770. /**
  86771. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  86772. * @param parsedTexture Define the JSON representation of the texture
  86773. * @param scene Define the scene the parsed texture should be instantiated in
  86774. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  86775. * @returns The parsed texture if successful
  86776. */
  86777. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  86778. /**
  86779. * Creates a texture from its base 64 representation.
  86780. * @param data Define the base64 payload without the data: prefix
  86781. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86782. * @param scene Define the scene the texture should belong to
  86783. * @param noMipmap Forces the texture to not create mip map information if true
  86784. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86785. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86786. * @param onLoad define a callback triggered when the texture has been loaded
  86787. * @param onError define a callback triggered when an error occurred during the loading session
  86788. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86789. * @returns the created texture
  86790. */
  86791. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  86792. /**
  86793. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  86794. * @param data Define the base64 payload without the data: prefix
  86795. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86796. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  86797. * @param scene Define the scene the texture should belong to
  86798. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  86799. * @param noMipmap Forces the texture to not create mip map information if true
  86800. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86801. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86802. * @param onLoad define a callback triggered when the texture has been loaded
  86803. * @param onError define a callback triggered when an error occurred during the loading session
  86804. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86805. * @returns the created texture
  86806. */
  86807. 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;
  86808. }
  86809. }
  86810. declare module BABYLON {
  86811. /**
  86812. * PostProcessManager is used to manage one or more post processes or post process pipelines
  86813. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86814. */
  86815. export class PostProcessManager {
  86816. private _scene;
  86817. private _indexBuffer;
  86818. private _vertexBuffers;
  86819. /**
  86820. * Creates a new instance PostProcess
  86821. * @param scene The scene that the post process is associated with.
  86822. */
  86823. constructor(scene: Scene);
  86824. private _prepareBuffers;
  86825. private _buildIndexBuffer;
  86826. /**
  86827. * Rebuilds the vertex buffers of the manager.
  86828. * @hidden
  86829. */
  86830. _rebuild(): void;
  86831. /**
  86832. * Prepares a frame to be run through a post process.
  86833. * @param sourceTexture The input texture to the post procesess. (default: null)
  86834. * @param postProcesses An array of post processes to be run. (default: null)
  86835. * @returns True if the post processes were able to be run.
  86836. * @hidden
  86837. */
  86838. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  86839. /**
  86840. * Manually render a set of post processes to a texture.
  86841. * @param postProcesses An array of post processes to be run.
  86842. * @param targetTexture The target texture to render to.
  86843. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  86844. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  86845. * @param lodLevel defines which lod of the texture to render to
  86846. */
  86847. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  86848. /**
  86849. * Finalize the result of the output of the postprocesses.
  86850. * @param doNotPresent If true the result will not be displayed to the screen.
  86851. * @param targetTexture The target texture to render to.
  86852. * @param faceIndex The index of the face to bind the target texture to.
  86853. * @param postProcesses The array of post processes to render.
  86854. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  86855. * @hidden
  86856. */
  86857. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  86858. /**
  86859. * Disposes of the post process manager.
  86860. */
  86861. dispose(): void;
  86862. }
  86863. }
  86864. declare module BABYLON {
  86865. /** Interface used by value gradients (color, factor, ...) */
  86866. export interface IValueGradient {
  86867. /**
  86868. * Gets or sets the gradient value (between 0 and 1)
  86869. */
  86870. gradient: number;
  86871. }
  86872. /** Class used to store color4 gradient */
  86873. export class ColorGradient implements IValueGradient {
  86874. /**
  86875. * Gets or sets the gradient value (between 0 and 1)
  86876. */
  86877. gradient: number;
  86878. /**
  86879. * Gets or sets first associated color
  86880. */
  86881. color1: Color4;
  86882. /**
  86883. * Gets or sets second associated color
  86884. */
  86885. color2?: Color4;
  86886. /**
  86887. * Will get a color picked randomly between color1 and color2.
  86888. * If color2 is undefined then color1 will be used
  86889. * @param result defines the target Color4 to store the result in
  86890. */
  86891. getColorToRef(result: Color4): void;
  86892. }
  86893. /** Class used to store color 3 gradient */
  86894. export class Color3Gradient implements IValueGradient {
  86895. /**
  86896. * Gets or sets the gradient value (between 0 and 1)
  86897. */
  86898. gradient: number;
  86899. /**
  86900. * Gets or sets the associated color
  86901. */
  86902. color: Color3;
  86903. }
  86904. /** Class used to store factor gradient */
  86905. export class FactorGradient implements IValueGradient {
  86906. /**
  86907. * Gets or sets the gradient value (between 0 and 1)
  86908. */
  86909. gradient: number;
  86910. /**
  86911. * Gets or sets first associated factor
  86912. */
  86913. factor1: number;
  86914. /**
  86915. * Gets or sets second associated factor
  86916. */
  86917. factor2?: number;
  86918. /**
  86919. * Will get a number picked randomly between factor1 and factor2.
  86920. * If factor2 is undefined then factor1 will be used
  86921. * @returns the picked number
  86922. */
  86923. getFactor(): number;
  86924. }
  86925. /**
  86926. * Helper used to simplify some generic gradient tasks
  86927. */
  86928. export class GradientHelper {
  86929. /**
  86930. * Gets the current gradient from an array of IValueGradient
  86931. * @param ratio defines the current ratio to get
  86932. * @param gradients defines the array of IValueGradient
  86933. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86934. */
  86935. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86936. }
  86937. }
  86938. declare module BABYLON {
  86939. interface ThinEngine {
  86940. /**
  86941. * Creates a dynamic texture
  86942. * @param width defines the width of the texture
  86943. * @param height defines the height of the texture
  86944. * @param generateMipMaps defines if the engine should generate the mip levels
  86945. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86946. * @returns the dynamic texture inside an InternalTexture
  86947. */
  86948. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86949. /**
  86950. * Update the content of a dynamic texture
  86951. * @param texture defines the texture to update
  86952. * @param canvas defines the canvas containing the source
  86953. * @param invertY defines if data must be stored with Y axis inverted
  86954. * @param premulAlpha defines if alpha is stored as premultiplied
  86955. * @param format defines the format of the data
  86956. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86957. */
  86958. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86959. }
  86960. }
  86961. declare module BABYLON {
  86962. /**
  86963. * Helper class used to generate a canvas to manipulate images
  86964. */
  86965. export class CanvasGenerator {
  86966. /**
  86967. * Create a new canvas (or offscreen canvas depending on the context)
  86968. * @param width defines the expected width
  86969. * @param height defines the expected height
  86970. * @return a new canvas or offscreen canvas
  86971. */
  86972. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  86973. }
  86974. }
  86975. declare module BABYLON {
  86976. /**
  86977. * A class extending Texture allowing drawing on a texture
  86978. * @see http://doc.babylonjs.com/how_to/dynamictexture
  86979. */
  86980. export class DynamicTexture extends Texture {
  86981. private _generateMipMaps;
  86982. private _canvas;
  86983. private _context;
  86984. private _engine;
  86985. /**
  86986. * Creates a DynamicTexture
  86987. * @param name defines the name of the texture
  86988. * @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
  86989. * @param scene defines the scene where you want the texture
  86990. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  86991. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  86992. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  86993. */
  86994. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  86995. /**
  86996. * Get the current class name of the texture useful for serialization or dynamic coding.
  86997. * @returns "DynamicTexture"
  86998. */
  86999. getClassName(): string;
  87000. /**
  87001. * Gets the current state of canRescale
  87002. */
  87003. get canRescale(): boolean;
  87004. private _recreate;
  87005. /**
  87006. * Scales the texture
  87007. * @param ratio the scale factor to apply to both width and height
  87008. */
  87009. scale(ratio: number): void;
  87010. /**
  87011. * Resizes the texture
  87012. * @param width the new width
  87013. * @param height the new height
  87014. */
  87015. scaleTo(width: number, height: number): void;
  87016. /**
  87017. * Gets the context of the canvas used by the texture
  87018. * @returns the canvas context of the dynamic texture
  87019. */
  87020. getContext(): CanvasRenderingContext2D;
  87021. /**
  87022. * Clears the texture
  87023. */
  87024. clear(): void;
  87025. /**
  87026. * Updates the texture
  87027. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87028. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  87029. */
  87030. update(invertY?: boolean, premulAlpha?: boolean): void;
  87031. /**
  87032. * Draws text onto the texture
  87033. * @param text defines the text to be drawn
  87034. * @param x defines the placement of the text from the left
  87035. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  87036. * @param font defines the font to be used with font-style, font-size, font-name
  87037. * @param color defines the color used for the text
  87038. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  87039. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87040. * @param update defines whether texture is immediately update (default is true)
  87041. */
  87042. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  87043. /**
  87044. * Clones the texture
  87045. * @returns the clone of the texture.
  87046. */
  87047. clone(): DynamicTexture;
  87048. /**
  87049. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  87050. * @returns a serialized dynamic texture object
  87051. */
  87052. serialize(): any;
  87053. /** @hidden */
  87054. _rebuild(): void;
  87055. }
  87056. }
  87057. declare module BABYLON {
  87058. interface AbstractScene {
  87059. /**
  87060. * The list of procedural textures added to the scene
  87061. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87062. */
  87063. proceduralTextures: Array<ProceduralTexture>;
  87064. }
  87065. /**
  87066. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  87067. * in a given scene.
  87068. */
  87069. export class ProceduralTextureSceneComponent implements ISceneComponent {
  87070. /**
  87071. * The component name helpfull to identify the component in the list of scene components.
  87072. */
  87073. readonly name: string;
  87074. /**
  87075. * The scene the component belongs to.
  87076. */
  87077. scene: Scene;
  87078. /**
  87079. * Creates a new instance of the component for the given scene
  87080. * @param scene Defines the scene to register the component in
  87081. */
  87082. constructor(scene: Scene);
  87083. /**
  87084. * Registers the component in a given scene
  87085. */
  87086. register(): void;
  87087. /**
  87088. * Rebuilds the elements related to this component in case of
  87089. * context lost for instance.
  87090. */
  87091. rebuild(): void;
  87092. /**
  87093. * Disposes the component and the associated ressources.
  87094. */
  87095. dispose(): void;
  87096. private _beforeClear;
  87097. }
  87098. }
  87099. declare module BABYLON {
  87100. interface ThinEngine {
  87101. /**
  87102. * Creates a new render target cube texture
  87103. * @param size defines the size of the texture
  87104. * @param options defines the options used to create the texture
  87105. * @returns a new render target cube texture stored in an InternalTexture
  87106. */
  87107. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87108. }
  87109. }
  87110. declare module BABYLON {
  87111. /** @hidden */
  87112. export var proceduralVertexShader: {
  87113. name: string;
  87114. shader: string;
  87115. };
  87116. }
  87117. declare module BABYLON {
  87118. /**
  87119. * 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.
  87120. * This is the base class of any Procedural texture and contains most of the shareable code.
  87121. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87122. */
  87123. export class ProceduralTexture extends Texture {
  87124. isCube: boolean;
  87125. /**
  87126. * Define if the texture is enabled or not (disabled texture will not render)
  87127. */
  87128. isEnabled: boolean;
  87129. /**
  87130. * Define if the texture must be cleared before rendering (default is true)
  87131. */
  87132. autoClear: boolean;
  87133. /**
  87134. * Callback called when the texture is generated
  87135. */
  87136. onGenerated: () => void;
  87137. /**
  87138. * Event raised when the texture is generated
  87139. */
  87140. onGeneratedObservable: Observable<ProceduralTexture>;
  87141. /** @hidden */
  87142. _generateMipMaps: boolean;
  87143. /** @hidden **/
  87144. _effect: Effect;
  87145. /** @hidden */
  87146. _textures: {
  87147. [key: string]: Texture;
  87148. };
  87149. private _size;
  87150. private _currentRefreshId;
  87151. private _frameId;
  87152. private _refreshRate;
  87153. private _vertexBuffers;
  87154. private _indexBuffer;
  87155. private _uniforms;
  87156. private _samplers;
  87157. private _fragment;
  87158. private _floats;
  87159. private _ints;
  87160. private _floatsArrays;
  87161. private _colors3;
  87162. private _colors4;
  87163. private _vectors2;
  87164. private _vectors3;
  87165. private _matrices;
  87166. private _fallbackTexture;
  87167. private _fallbackTextureUsed;
  87168. private _engine;
  87169. private _cachedDefines;
  87170. private _contentUpdateId;
  87171. private _contentData;
  87172. /**
  87173. * Instantiates a new procedural texture.
  87174. * 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.
  87175. * This is the base class of any Procedural texture and contains most of the shareable code.
  87176. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87177. * @param name Define the name of the texture
  87178. * @param size Define the size of the texture to create
  87179. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  87180. * @param scene Define the scene the texture belongs to
  87181. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  87182. * @param generateMipMaps Define if the texture should creates mip maps or not
  87183. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  87184. */
  87185. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  87186. /**
  87187. * The effect that is created when initializing the post process.
  87188. * @returns The created effect corresponding the the postprocess.
  87189. */
  87190. getEffect(): Effect;
  87191. /**
  87192. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  87193. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  87194. */
  87195. getContent(): Nullable<ArrayBufferView>;
  87196. private _createIndexBuffer;
  87197. /** @hidden */
  87198. _rebuild(): void;
  87199. /**
  87200. * Resets the texture in order to recreate its associated resources.
  87201. * This can be called in case of context loss
  87202. */
  87203. reset(): void;
  87204. protected _getDefines(): string;
  87205. /**
  87206. * Is the texture ready to be used ? (rendered at least once)
  87207. * @returns true if ready, otherwise, false.
  87208. */
  87209. isReady(): boolean;
  87210. /**
  87211. * Resets the refresh counter of the texture and start bak from scratch.
  87212. * Could be useful to regenerate the texture if it is setup to render only once.
  87213. */
  87214. resetRefreshCounter(): void;
  87215. /**
  87216. * Set the fragment shader to use in order to render the texture.
  87217. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  87218. */
  87219. setFragment(fragment: any): void;
  87220. /**
  87221. * Define the refresh rate of the texture or the rendering frequency.
  87222. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87223. */
  87224. get refreshRate(): number;
  87225. set refreshRate(value: number);
  87226. /** @hidden */
  87227. _shouldRender(): boolean;
  87228. /**
  87229. * Get the size the texture is rendering at.
  87230. * @returns the size (texture is always squared)
  87231. */
  87232. getRenderSize(): number;
  87233. /**
  87234. * Resize the texture to new value.
  87235. * @param size Define the new size the texture should have
  87236. * @param generateMipMaps Define whether the new texture should create mip maps
  87237. */
  87238. resize(size: number, generateMipMaps: boolean): void;
  87239. private _checkUniform;
  87240. /**
  87241. * Set a texture in the shader program used to render.
  87242. * @param name Define the name of the uniform samplers as defined in the shader
  87243. * @param texture Define the texture to bind to this sampler
  87244. * @return the texture itself allowing "fluent" like uniform updates
  87245. */
  87246. setTexture(name: string, texture: Texture): ProceduralTexture;
  87247. /**
  87248. * Set a float in the shader.
  87249. * @param name Define the name of the uniform as defined in the shader
  87250. * @param value Define the value to give to the uniform
  87251. * @return the texture itself allowing "fluent" like uniform updates
  87252. */
  87253. setFloat(name: string, value: number): ProceduralTexture;
  87254. /**
  87255. * Set a int in the shader.
  87256. * @param name Define the name of the uniform as defined in the shader
  87257. * @param value Define the value to give to the uniform
  87258. * @return the texture itself allowing "fluent" like uniform updates
  87259. */
  87260. setInt(name: string, value: number): ProceduralTexture;
  87261. /**
  87262. * Set an array of floats in the shader.
  87263. * @param name Define the name of the uniform as defined in the shader
  87264. * @param value Define the value to give to the uniform
  87265. * @return the texture itself allowing "fluent" like uniform updates
  87266. */
  87267. setFloats(name: string, value: number[]): ProceduralTexture;
  87268. /**
  87269. * Set a vec3 in the shader from a Color3.
  87270. * @param name Define the name of the uniform as defined in the shader
  87271. * @param value Define the value to give to the uniform
  87272. * @return the texture itself allowing "fluent" like uniform updates
  87273. */
  87274. setColor3(name: string, value: Color3): ProceduralTexture;
  87275. /**
  87276. * Set a vec4 in the shader from a Color4.
  87277. * @param name Define the name of the uniform as defined in the shader
  87278. * @param value Define the value to give to the uniform
  87279. * @return the texture itself allowing "fluent" like uniform updates
  87280. */
  87281. setColor4(name: string, value: Color4): ProceduralTexture;
  87282. /**
  87283. * Set a vec2 in the shader from a Vector2.
  87284. * @param name Define the name of the uniform as defined in the shader
  87285. * @param value Define the value to give to the uniform
  87286. * @return the texture itself allowing "fluent" like uniform updates
  87287. */
  87288. setVector2(name: string, value: Vector2): ProceduralTexture;
  87289. /**
  87290. * Set a vec3 in the shader from a Vector3.
  87291. * @param name Define the name of the uniform as defined in the shader
  87292. * @param value Define the value to give to the uniform
  87293. * @return the texture itself allowing "fluent" like uniform updates
  87294. */
  87295. setVector3(name: string, value: Vector3): ProceduralTexture;
  87296. /**
  87297. * Set a mat4 in the shader from a MAtrix.
  87298. * @param name Define the name of the uniform as defined in the shader
  87299. * @param value Define the value to give to the uniform
  87300. * @return the texture itself allowing "fluent" like uniform updates
  87301. */
  87302. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87303. /**
  87304. * Render the texture to its associated render target.
  87305. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87306. */
  87307. render(useCameraPostProcess?: boolean): void;
  87308. /**
  87309. * Clone the texture.
  87310. * @returns the cloned texture
  87311. */
  87312. clone(): ProceduralTexture;
  87313. /**
  87314. * Dispose the texture and release its asoociated resources.
  87315. */
  87316. dispose(): void;
  87317. }
  87318. }
  87319. declare module BABYLON {
  87320. /**
  87321. * This represents the base class for particle system in Babylon.
  87322. * 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.
  87323. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87324. * @example https://doc.babylonjs.com/babylon101/particles
  87325. */
  87326. export class BaseParticleSystem {
  87327. /**
  87328. * Source color is added to the destination color without alpha affecting the result
  87329. */
  87330. static BLENDMODE_ONEONE: number;
  87331. /**
  87332. * Blend current color and particle color using particle’s alpha
  87333. */
  87334. static BLENDMODE_STANDARD: number;
  87335. /**
  87336. * Add current color and particle color multiplied by particle’s alpha
  87337. */
  87338. static BLENDMODE_ADD: number;
  87339. /**
  87340. * Multiply current color with particle color
  87341. */
  87342. static BLENDMODE_MULTIPLY: number;
  87343. /**
  87344. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87345. */
  87346. static BLENDMODE_MULTIPLYADD: number;
  87347. /**
  87348. * List of animations used by the particle system.
  87349. */
  87350. animations: Animation[];
  87351. /**
  87352. * The id of the Particle system.
  87353. */
  87354. id: string;
  87355. /**
  87356. * The friendly name of the Particle system.
  87357. */
  87358. name: string;
  87359. /**
  87360. * The rendering group used by the Particle system to chose when to render.
  87361. */
  87362. renderingGroupId: number;
  87363. /**
  87364. * The emitter represents the Mesh or position we are attaching the particle system to.
  87365. */
  87366. emitter: Nullable<AbstractMesh | Vector3>;
  87367. /**
  87368. * The maximum number of particles to emit per frame
  87369. */
  87370. emitRate: number;
  87371. /**
  87372. * If you want to launch only a few particles at once, that can be done, as well.
  87373. */
  87374. manualEmitCount: number;
  87375. /**
  87376. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87377. */
  87378. updateSpeed: number;
  87379. /**
  87380. * The amount of time the particle system is running (depends of the overall update speed).
  87381. */
  87382. targetStopDuration: number;
  87383. /**
  87384. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87385. */
  87386. disposeOnStop: boolean;
  87387. /**
  87388. * Minimum power of emitting particles.
  87389. */
  87390. minEmitPower: number;
  87391. /**
  87392. * Maximum power of emitting particles.
  87393. */
  87394. maxEmitPower: number;
  87395. /**
  87396. * Minimum life time of emitting particles.
  87397. */
  87398. minLifeTime: number;
  87399. /**
  87400. * Maximum life time of emitting particles.
  87401. */
  87402. maxLifeTime: number;
  87403. /**
  87404. * Minimum Size of emitting particles.
  87405. */
  87406. minSize: number;
  87407. /**
  87408. * Maximum Size of emitting particles.
  87409. */
  87410. maxSize: number;
  87411. /**
  87412. * Minimum scale of emitting particles on X axis.
  87413. */
  87414. minScaleX: number;
  87415. /**
  87416. * Maximum scale of emitting particles on X axis.
  87417. */
  87418. maxScaleX: number;
  87419. /**
  87420. * Minimum scale of emitting particles on Y axis.
  87421. */
  87422. minScaleY: number;
  87423. /**
  87424. * Maximum scale of emitting particles on Y axis.
  87425. */
  87426. maxScaleY: number;
  87427. /**
  87428. * Gets or sets the minimal initial rotation in radians.
  87429. */
  87430. minInitialRotation: number;
  87431. /**
  87432. * Gets or sets the maximal initial rotation in radians.
  87433. */
  87434. maxInitialRotation: number;
  87435. /**
  87436. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87437. */
  87438. minAngularSpeed: number;
  87439. /**
  87440. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87441. */
  87442. maxAngularSpeed: number;
  87443. /**
  87444. * The texture used to render each particle. (this can be a spritesheet)
  87445. */
  87446. particleTexture: Nullable<Texture>;
  87447. /**
  87448. * The layer mask we are rendering the particles through.
  87449. */
  87450. layerMask: number;
  87451. /**
  87452. * This can help using your own shader to render the particle system.
  87453. * The according effect will be created
  87454. */
  87455. customShader: any;
  87456. /**
  87457. * By default particle system starts as soon as they are created. This prevents the
  87458. * automatic start to happen and let you decide when to start emitting particles.
  87459. */
  87460. preventAutoStart: boolean;
  87461. private _noiseTexture;
  87462. /**
  87463. * Gets or sets a texture used to add random noise to particle positions
  87464. */
  87465. get noiseTexture(): Nullable<ProceduralTexture>;
  87466. set noiseTexture(value: Nullable<ProceduralTexture>);
  87467. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87468. noiseStrength: Vector3;
  87469. /**
  87470. * Callback triggered when the particle animation is ending.
  87471. */
  87472. onAnimationEnd: Nullable<() => void>;
  87473. /**
  87474. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87475. */
  87476. blendMode: number;
  87477. /**
  87478. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87479. * to override the particles.
  87480. */
  87481. forceDepthWrite: boolean;
  87482. /** 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 */
  87483. preWarmCycles: number;
  87484. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87485. preWarmStepOffset: number;
  87486. /**
  87487. * 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)
  87488. */
  87489. spriteCellChangeSpeed: number;
  87490. /**
  87491. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87492. */
  87493. startSpriteCellID: number;
  87494. /**
  87495. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87496. */
  87497. endSpriteCellID: number;
  87498. /**
  87499. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87500. */
  87501. spriteCellWidth: number;
  87502. /**
  87503. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87504. */
  87505. spriteCellHeight: number;
  87506. /**
  87507. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87508. */
  87509. spriteRandomStartCell: boolean;
  87510. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87511. translationPivot: Vector2;
  87512. /** @hidden */
  87513. protected _isAnimationSheetEnabled: boolean;
  87514. /**
  87515. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87516. */
  87517. beginAnimationOnStart: boolean;
  87518. /**
  87519. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87520. */
  87521. beginAnimationFrom: number;
  87522. /**
  87523. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87524. */
  87525. beginAnimationTo: number;
  87526. /**
  87527. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87528. */
  87529. beginAnimationLoop: boolean;
  87530. /**
  87531. * Gets or sets a world offset applied to all particles
  87532. */
  87533. worldOffset: Vector3;
  87534. /**
  87535. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87536. */
  87537. get isAnimationSheetEnabled(): boolean;
  87538. set isAnimationSheetEnabled(value: boolean);
  87539. /**
  87540. * Get hosting scene
  87541. * @returns the scene
  87542. */
  87543. getScene(): Scene;
  87544. /**
  87545. * You can use gravity if you want to give an orientation to your particles.
  87546. */
  87547. gravity: Vector3;
  87548. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87549. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87550. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87551. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87552. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87553. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87554. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87555. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87556. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87557. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87558. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87559. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87560. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87561. /**
  87562. * Defines the delay in milliseconds before starting the system (0 by default)
  87563. */
  87564. startDelay: number;
  87565. /**
  87566. * Gets the current list of drag gradients.
  87567. * You must use addDragGradient and removeDragGradient to udpate this list
  87568. * @returns the list of drag gradients
  87569. */
  87570. getDragGradients(): Nullable<Array<FactorGradient>>;
  87571. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87572. limitVelocityDamping: number;
  87573. /**
  87574. * Gets the current list of limit velocity gradients.
  87575. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87576. * @returns the list of limit velocity gradients
  87577. */
  87578. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87579. /**
  87580. * Gets the current list of color gradients.
  87581. * You must use addColorGradient and removeColorGradient to udpate this list
  87582. * @returns the list of color gradients
  87583. */
  87584. getColorGradients(): Nullable<Array<ColorGradient>>;
  87585. /**
  87586. * Gets the current list of size gradients.
  87587. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87588. * @returns the list of size gradients
  87589. */
  87590. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87591. /**
  87592. * Gets the current list of color remap gradients.
  87593. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87594. * @returns the list of color remap gradients
  87595. */
  87596. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87597. /**
  87598. * Gets the current list of alpha remap gradients.
  87599. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87600. * @returns the list of alpha remap gradients
  87601. */
  87602. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87603. /**
  87604. * Gets the current list of life time gradients.
  87605. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87606. * @returns the list of life time gradients
  87607. */
  87608. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87609. /**
  87610. * Gets the current list of angular speed gradients.
  87611. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87612. * @returns the list of angular speed gradients
  87613. */
  87614. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87615. /**
  87616. * Gets the current list of velocity gradients.
  87617. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87618. * @returns the list of velocity gradients
  87619. */
  87620. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87621. /**
  87622. * Gets the current list of start size gradients.
  87623. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87624. * @returns the list of start size gradients
  87625. */
  87626. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87627. /**
  87628. * Gets the current list of emit rate gradients.
  87629. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87630. * @returns the list of emit rate gradients
  87631. */
  87632. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87633. /**
  87634. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87635. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87636. */
  87637. get direction1(): Vector3;
  87638. set direction1(value: Vector3);
  87639. /**
  87640. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87641. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87642. */
  87643. get direction2(): Vector3;
  87644. set direction2(value: Vector3);
  87645. /**
  87646. * 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.
  87647. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87648. */
  87649. get minEmitBox(): Vector3;
  87650. set minEmitBox(value: Vector3);
  87651. /**
  87652. * 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.
  87653. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87654. */
  87655. get maxEmitBox(): Vector3;
  87656. set maxEmitBox(value: Vector3);
  87657. /**
  87658. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87659. */
  87660. color1: Color4;
  87661. /**
  87662. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87663. */
  87664. color2: Color4;
  87665. /**
  87666. * Color the particle will have at the end of its lifetime
  87667. */
  87668. colorDead: Color4;
  87669. /**
  87670. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87671. */
  87672. textureMask: Color4;
  87673. /**
  87674. * The particle emitter type defines the emitter used by the particle system.
  87675. * It can be for example box, sphere, or cone...
  87676. */
  87677. particleEmitterType: IParticleEmitterType;
  87678. /** @hidden */
  87679. _isSubEmitter: boolean;
  87680. /**
  87681. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87682. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87683. */
  87684. billboardMode: number;
  87685. protected _isBillboardBased: boolean;
  87686. /**
  87687. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87688. */
  87689. get isBillboardBased(): boolean;
  87690. set isBillboardBased(value: boolean);
  87691. /**
  87692. * The scene the particle system belongs to.
  87693. */
  87694. protected _scene: Scene;
  87695. /**
  87696. * Local cache of defines for image processing.
  87697. */
  87698. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87699. /**
  87700. * Default configuration related to image processing available in the standard Material.
  87701. */
  87702. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87703. /**
  87704. * Gets the image processing configuration used either in this material.
  87705. */
  87706. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87707. /**
  87708. * Sets the Default image processing configuration used either in the this material.
  87709. *
  87710. * If sets to null, the scene one is in use.
  87711. */
  87712. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87713. /**
  87714. * Attaches a new image processing configuration to the Standard Material.
  87715. * @param configuration
  87716. */
  87717. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87718. /** @hidden */
  87719. protected _reset(): void;
  87720. /** @hidden */
  87721. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87722. /**
  87723. * Instantiates a particle system.
  87724. * 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.
  87725. * @param name The name of the particle system
  87726. */
  87727. constructor(name: string);
  87728. /**
  87729. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87730. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87731. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87732. * @returns the emitter
  87733. */
  87734. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87735. /**
  87736. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87737. * @param radius The radius of the hemisphere to emit from
  87738. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87739. * @returns the emitter
  87740. */
  87741. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87742. /**
  87743. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87744. * @param radius The radius of the sphere to emit from
  87745. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87746. * @returns the emitter
  87747. */
  87748. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87749. /**
  87750. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87751. * @param radius The radius of the sphere to emit from
  87752. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87753. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87754. * @returns the emitter
  87755. */
  87756. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87757. /**
  87758. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87759. * @param radius The radius of the emission cylinder
  87760. * @param height The height of the emission cylinder
  87761. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87762. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87763. * @returns the emitter
  87764. */
  87765. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87766. /**
  87767. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87768. * @param radius The radius of the cylinder to emit from
  87769. * @param height The height of the emission cylinder
  87770. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87771. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87772. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87773. * @returns the emitter
  87774. */
  87775. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87776. /**
  87777. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87778. * @param radius The radius of the cone to emit from
  87779. * @param angle The base angle of the cone
  87780. * @returns the emitter
  87781. */
  87782. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87783. /**
  87784. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87785. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87786. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87787. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87788. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87789. * @returns the emitter
  87790. */
  87791. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87792. }
  87793. }
  87794. declare module BABYLON {
  87795. /**
  87796. * Type of sub emitter
  87797. */
  87798. export enum SubEmitterType {
  87799. /**
  87800. * Attached to the particle over it's lifetime
  87801. */
  87802. ATTACHED = 0,
  87803. /**
  87804. * Created when the particle dies
  87805. */
  87806. END = 1
  87807. }
  87808. /**
  87809. * Sub emitter class used to emit particles from an existing particle
  87810. */
  87811. export class SubEmitter {
  87812. /**
  87813. * the particle system to be used by the sub emitter
  87814. */
  87815. particleSystem: ParticleSystem;
  87816. /**
  87817. * Type of the submitter (Default: END)
  87818. */
  87819. type: SubEmitterType;
  87820. /**
  87821. * 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)
  87822. * Note: This only is supported when using an emitter of type Mesh
  87823. */
  87824. inheritDirection: boolean;
  87825. /**
  87826. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87827. */
  87828. inheritedVelocityAmount: number;
  87829. /**
  87830. * Creates a sub emitter
  87831. * @param particleSystem the particle system to be used by the sub emitter
  87832. */
  87833. constructor(
  87834. /**
  87835. * the particle system to be used by the sub emitter
  87836. */
  87837. particleSystem: ParticleSystem);
  87838. /**
  87839. * Clones the sub emitter
  87840. * @returns the cloned sub emitter
  87841. */
  87842. clone(): SubEmitter;
  87843. /**
  87844. * Serialize current object to a JSON object
  87845. * @returns the serialized object
  87846. */
  87847. serialize(): any;
  87848. /** @hidden */
  87849. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87850. /**
  87851. * Creates a new SubEmitter from a serialized JSON version
  87852. * @param serializationObject defines the JSON object to read from
  87853. * @param scene defines the hosting scene
  87854. * @param rootUrl defines the rootUrl for data loading
  87855. * @returns a new SubEmitter
  87856. */
  87857. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87858. /** Release associated resources */
  87859. dispose(): void;
  87860. }
  87861. }
  87862. declare module BABYLON {
  87863. /** @hidden */
  87864. export var clipPlaneFragmentDeclaration: {
  87865. name: string;
  87866. shader: string;
  87867. };
  87868. }
  87869. declare module BABYLON {
  87870. /** @hidden */
  87871. export var imageProcessingDeclaration: {
  87872. name: string;
  87873. shader: string;
  87874. };
  87875. }
  87876. declare module BABYLON {
  87877. /** @hidden */
  87878. export var imageProcessingFunctions: {
  87879. name: string;
  87880. shader: string;
  87881. };
  87882. }
  87883. declare module BABYLON {
  87884. /** @hidden */
  87885. export var clipPlaneFragment: {
  87886. name: string;
  87887. shader: string;
  87888. };
  87889. }
  87890. declare module BABYLON {
  87891. /** @hidden */
  87892. export var particlesPixelShader: {
  87893. name: string;
  87894. shader: string;
  87895. };
  87896. }
  87897. declare module BABYLON {
  87898. /** @hidden */
  87899. export var clipPlaneVertexDeclaration: {
  87900. name: string;
  87901. shader: string;
  87902. };
  87903. }
  87904. declare module BABYLON {
  87905. /** @hidden */
  87906. export var clipPlaneVertex: {
  87907. name: string;
  87908. shader: string;
  87909. };
  87910. }
  87911. declare module BABYLON {
  87912. /** @hidden */
  87913. export var particlesVertexShader: {
  87914. name: string;
  87915. shader: string;
  87916. };
  87917. }
  87918. declare module BABYLON {
  87919. /**
  87920. * This represents a particle system in Babylon.
  87921. * 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.
  87922. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87923. * @example https://doc.babylonjs.com/babylon101/particles
  87924. */
  87925. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  87926. /**
  87927. * Billboard mode will only apply to Y axis
  87928. */
  87929. static readonly BILLBOARDMODE_Y: number;
  87930. /**
  87931. * Billboard mode will apply to all axes
  87932. */
  87933. static readonly BILLBOARDMODE_ALL: number;
  87934. /**
  87935. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  87936. */
  87937. static readonly BILLBOARDMODE_STRETCHED: number;
  87938. /**
  87939. * This function can be defined to provide custom update for active particles.
  87940. * This function will be called instead of regular update (age, position, color, etc.).
  87941. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  87942. */
  87943. updateFunction: (particles: Particle[]) => void;
  87944. private _emitterWorldMatrix;
  87945. /**
  87946. * This function can be defined to specify initial direction for every new particle.
  87947. * It by default use the emitterType defined function
  87948. */
  87949. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  87950. /**
  87951. * This function can be defined to specify initial position for every new particle.
  87952. * It by default use the emitterType defined function
  87953. */
  87954. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  87955. /**
  87956. * @hidden
  87957. */
  87958. _inheritedVelocityOffset: Vector3;
  87959. /**
  87960. * An event triggered when the system is disposed
  87961. */
  87962. onDisposeObservable: Observable<ParticleSystem>;
  87963. private _onDisposeObserver;
  87964. /**
  87965. * Sets a callback that will be triggered when the system is disposed
  87966. */
  87967. set onDispose(callback: () => void);
  87968. private _particles;
  87969. private _epsilon;
  87970. private _capacity;
  87971. private _stockParticles;
  87972. private _newPartsExcess;
  87973. private _vertexData;
  87974. private _vertexBuffer;
  87975. private _vertexBuffers;
  87976. private _spriteBuffer;
  87977. private _indexBuffer;
  87978. private _effect;
  87979. private _customEffect;
  87980. private _cachedDefines;
  87981. private _scaledColorStep;
  87982. private _colorDiff;
  87983. private _scaledDirection;
  87984. private _scaledGravity;
  87985. private _currentRenderId;
  87986. private _alive;
  87987. private _useInstancing;
  87988. private _started;
  87989. private _stopped;
  87990. private _actualFrame;
  87991. private _scaledUpdateSpeed;
  87992. private _vertexBufferSize;
  87993. /** @hidden */
  87994. _currentEmitRateGradient: Nullable<FactorGradient>;
  87995. /** @hidden */
  87996. _currentEmitRate1: number;
  87997. /** @hidden */
  87998. _currentEmitRate2: number;
  87999. /** @hidden */
  88000. _currentStartSizeGradient: Nullable<FactorGradient>;
  88001. /** @hidden */
  88002. _currentStartSize1: number;
  88003. /** @hidden */
  88004. _currentStartSize2: number;
  88005. private readonly _rawTextureWidth;
  88006. private _rampGradientsTexture;
  88007. private _useRampGradients;
  88008. /** Gets or sets a boolean indicating that ramp gradients must be used
  88009. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88010. */
  88011. get useRampGradients(): boolean;
  88012. set useRampGradients(value: boolean);
  88013. /**
  88014. * 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.
  88015. * 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: [])
  88016. */
  88017. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  88018. private _subEmitters;
  88019. /**
  88020. * @hidden
  88021. * If the particle systems emitter should be disposed when the particle system is disposed
  88022. */
  88023. _disposeEmitterOnDispose: boolean;
  88024. /**
  88025. * The current active Sub-systems, this property is used by the root particle system only.
  88026. */
  88027. activeSubSystems: Array<ParticleSystem>;
  88028. private _rootParticleSystem;
  88029. /**
  88030. * Gets the current list of active particles
  88031. */
  88032. get particles(): Particle[];
  88033. /**
  88034. * Returns the string "ParticleSystem"
  88035. * @returns a string containing the class name
  88036. */
  88037. getClassName(): string;
  88038. /**
  88039. * Instantiates a particle system.
  88040. * 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.
  88041. * @param name The name of the particle system
  88042. * @param capacity The max number of particles alive at the same time
  88043. * @param scene The scene the particle system belongs to
  88044. * @param customEffect a custom effect used to change the way particles are rendered by default
  88045. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  88046. * @param epsilon Offset used to render the particles
  88047. */
  88048. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  88049. private _addFactorGradient;
  88050. private _removeFactorGradient;
  88051. /**
  88052. * Adds a new life time gradient
  88053. * @param gradient defines the gradient to use (between 0 and 1)
  88054. * @param factor defines the life time factor to affect to the specified gradient
  88055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88056. * @returns the current particle system
  88057. */
  88058. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88059. /**
  88060. * Remove a specific life time gradient
  88061. * @param gradient defines the gradient to remove
  88062. * @returns the current particle system
  88063. */
  88064. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88065. /**
  88066. * Adds a new size gradient
  88067. * @param gradient defines the gradient to use (between 0 and 1)
  88068. * @param factor defines the size factor to affect to the specified gradient
  88069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88070. * @returns the current particle system
  88071. */
  88072. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88073. /**
  88074. * Remove a specific size gradient
  88075. * @param gradient defines the gradient to remove
  88076. * @returns the current particle system
  88077. */
  88078. removeSizeGradient(gradient: number): IParticleSystem;
  88079. /**
  88080. * Adds a new color remap gradient
  88081. * @param gradient defines the gradient to use (between 0 and 1)
  88082. * @param min defines the color remap minimal range
  88083. * @param max defines the color remap maximal range
  88084. * @returns the current particle system
  88085. */
  88086. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88087. /**
  88088. * Remove a specific color remap gradient
  88089. * @param gradient defines the gradient to remove
  88090. * @returns the current particle system
  88091. */
  88092. removeColorRemapGradient(gradient: number): IParticleSystem;
  88093. /**
  88094. * Adds a new alpha remap gradient
  88095. * @param gradient defines the gradient to use (between 0 and 1)
  88096. * @param min defines the alpha remap minimal range
  88097. * @param max defines the alpha remap maximal range
  88098. * @returns the current particle system
  88099. */
  88100. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88101. /**
  88102. * Remove a specific alpha remap gradient
  88103. * @param gradient defines the gradient to remove
  88104. * @returns the current particle system
  88105. */
  88106. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  88107. /**
  88108. * Adds a new angular speed gradient
  88109. * @param gradient defines the gradient to use (between 0 and 1)
  88110. * @param factor defines the angular speed to affect to the specified gradient
  88111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88112. * @returns the current particle system
  88113. */
  88114. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88115. /**
  88116. * Remove a specific angular speed gradient
  88117. * @param gradient defines the gradient to remove
  88118. * @returns the current particle system
  88119. */
  88120. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88121. /**
  88122. * Adds a new velocity gradient
  88123. * @param gradient defines the gradient to use (between 0 and 1)
  88124. * @param factor defines the velocity to affect to the specified gradient
  88125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88126. * @returns the current particle system
  88127. */
  88128. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88129. /**
  88130. * Remove a specific velocity gradient
  88131. * @param gradient defines the gradient to remove
  88132. * @returns the current particle system
  88133. */
  88134. removeVelocityGradient(gradient: number): IParticleSystem;
  88135. /**
  88136. * Adds a new limit velocity gradient
  88137. * @param gradient defines the gradient to use (between 0 and 1)
  88138. * @param factor defines the limit velocity value to affect to the specified gradient
  88139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88140. * @returns the current particle system
  88141. */
  88142. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88143. /**
  88144. * Remove a specific limit velocity gradient
  88145. * @param gradient defines the gradient to remove
  88146. * @returns the current particle system
  88147. */
  88148. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88149. /**
  88150. * Adds a new drag gradient
  88151. * @param gradient defines the gradient to use (between 0 and 1)
  88152. * @param factor defines the drag value to affect to the specified gradient
  88153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88154. * @returns the current particle system
  88155. */
  88156. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88157. /**
  88158. * Remove a specific drag gradient
  88159. * @param gradient defines the gradient to remove
  88160. * @returns the current particle system
  88161. */
  88162. removeDragGradient(gradient: number): IParticleSystem;
  88163. /**
  88164. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88165. * @param gradient defines the gradient to use (between 0 and 1)
  88166. * @param factor defines the emit rate value to affect to the specified gradient
  88167. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88168. * @returns the current particle system
  88169. */
  88170. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88171. /**
  88172. * Remove a specific emit rate gradient
  88173. * @param gradient defines the gradient to remove
  88174. * @returns the current particle system
  88175. */
  88176. removeEmitRateGradient(gradient: number): IParticleSystem;
  88177. /**
  88178. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88179. * @param gradient defines the gradient to use (between 0 and 1)
  88180. * @param factor defines the start size value to affect to the specified gradient
  88181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88182. * @returns the current particle system
  88183. */
  88184. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88185. /**
  88186. * Remove a specific start size gradient
  88187. * @param gradient defines the gradient to remove
  88188. * @returns the current particle system
  88189. */
  88190. removeStartSizeGradient(gradient: number): IParticleSystem;
  88191. private _createRampGradientTexture;
  88192. /**
  88193. * Gets the current list of ramp gradients.
  88194. * You must use addRampGradient and removeRampGradient to udpate this list
  88195. * @returns the list of ramp gradients
  88196. */
  88197. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88198. /**
  88199. * Adds a new ramp gradient used to remap particle colors
  88200. * @param gradient defines the gradient to use (between 0 and 1)
  88201. * @param color defines the color to affect to the specified gradient
  88202. * @returns the current particle system
  88203. */
  88204. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  88205. /**
  88206. * Remove a specific ramp gradient
  88207. * @param gradient defines the gradient to remove
  88208. * @returns the current particle system
  88209. */
  88210. removeRampGradient(gradient: number): ParticleSystem;
  88211. /**
  88212. * Adds a new color gradient
  88213. * @param gradient defines the gradient to use (between 0 and 1)
  88214. * @param color1 defines the color to affect to the specified gradient
  88215. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88216. * @returns this particle system
  88217. */
  88218. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88219. /**
  88220. * Remove a specific color gradient
  88221. * @param gradient defines the gradient to remove
  88222. * @returns this particle system
  88223. */
  88224. removeColorGradient(gradient: number): IParticleSystem;
  88225. private _fetchR;
  88226. protected _reset(): void;
  88227. private _resetEffect;
  88228. private _createVertexBuffers;
  88229. private _createIndexBuffer;
  88230. /**
  88231. * Gets the maximum number of particles active at the same time.
  88232. * @returns The max number of active particles.
  88233. */
  88234. getCapacity(): number;
  88235. /**
  88236. * Gets whether there are still active particles in the system.
  88237. * @returns True if it is alive, otherwise false.
  88238. */
  88239. isAlive(): boolean;
  88240. /**
  88241. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88242. * @returns True if it has been started, otherwise false.
  88243. */
  88244. isStarted(): boolean;
  88245. private _prepareSubEmitterInternalArray;
  88246. /**
  88247. * Starts the particle system and begins to emit
  88248. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  88249. */
  88250. start(delay?: number): void;
  88251. /**
  88252. * Stops the particle system.
  88253. * @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.
  88254. */
  88255. stop(stopSubEmitters?: boolean): void;
  88256. /**
  88257. * Remove all active particles
  88258. */
  88259. reset(): void;
  88260. /**
  88261. * @hidden (for internal use only)
  88262. */
  88263. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88264. /**
  88265. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88266. * Its lifetime will start back at 0.
  88267. */
  88268. recycleParticle: (particle: Particle) => void;
  88269. private _stopSubEmitters;
  88270. private _createParticle;
  88271. private _removeFromRoot;
  88272. private _emitFromParticle;
  88273. private _update;
  88274. /** @hidden */
  88275. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88276. /** @hidden */
  88277. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88278. /** @hidden */
  88279. private _getEffect;
  88280. /**
  88281. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88282. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88283. */
  88284. animate(preWarmOnly?: boolean): void;
  88285. private _appendParticleVertices;
  88286. /**
  88287. * Rebuilds the particle system.
  88288. */
  88289. rebuild(): void;
  88290. /**
  88291. * Is this system ready to be used/rendered
  88292. * @return true if the system is ready
  88293. */
  88294. isReady(): boolean;
  88295. private _render;
  88296. /**
  88297. * Renders the particle system in its current state.
  88298. * @returns the current number of particles
  88299. */
  88300. render(): number;
  88301. /**
  88302. * Disposes the particle system and free the associated resources
  88303. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88304. */
  88305. dispose(disposeTexture?: boolean): void;
  88306. /**
  88307. * Clones the particle system.
  88308. * @param name The name of the cloned object
  88309. * @param newEmitter The new emitter to use
  88310. * @returns the cloned particle system
  88311. */
  88312. clone(name: string, newEmitter: any): ParticleSystem;
  88313. /**
  88314. * Serializes the particle system to a JSON object.
  88315. * @returns the JSON object
  88316. */
  88317. serialize(): any;
  88318. /** @hidden */
  88319. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  88320. /** @hidden */
  88321. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88322. /**
  88323. * Parses a JSON object to create a particle system.
  88324. * @param parsedParticleSystem The JSON object to parse
  88325. * @param scene The scene to create the particle system in
  88326. * @param rootUrl The root url to use to load external dependencies like texture
  88327. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88328. * @returns the Parsed particle system
  88329. */
  88330. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88331. }
  88332. }
  88333. declare module BABYLON {
  88334. /**
  88335. * A particle represents one of the element emitted by a particle system.
  88336. * This is mainly define by its coordinates, direction, velocity and age.
  88337. */
  88338. export class Particle {
  88339. /**
  88340. * The particle system the particle belongs to.
  88341. */
  88342. particleSystem: ParticleSystem;
  88343. private static _Count;
  88344. /**
  88345. * Unique ID of the particle
  88346. */
  88347. id: number;
  88348. /**
  88349. * The world position of the particle in the scene.
  88350. */
  88351. position: Vector3;
  88352. /**
  88353. * The world direction of the particle in the scene.
  88354. */
  88355. direction: Vector3;
  88356. /**
  88357. * The color of the particle.
  88358. */
  88359. color: Color4;
  88360. /**
  88361. * The color change of the particle per step.
  88362. */
  88363. colorStep: Color4;
  88364. /**
  88365. * Defines how long will the life of the particle be.
  88366. */
  88367. lifeTime: number;
  88368. /**
  88369. * The current age of the particle.
  88370. */
  88371. age: number;
  88372. /**
  88373. * The current size of the particle.
  88374. */
  88375. size: number;
  88376. /**
  88377. * The current scale of the particle.
  88378. */
  88379. scale: Vector2;
  88380. /**
  88381. * The current angle of the particle.
  88382. */
  88383. angle: number;
  88384. /**
  88385. * Defines how fast is the angle changing.
  88386. */
  88387. angularSpeed: number;
  88388. /**
  88389. * Defines the cell index used by the particle to be rendered from a sprite.
  88390. */
  88391. cellIndex: number;
  88392. /**
  88393. * The information required to support color remapping
  88394. */
  88395. remapData: Vector4;
  88396. /** @hidden */
  88397. _randomCellOffset?: number;
  88398. /** @hidden */
  88399. _initialDirection: Nullable<Vector3>;
  88400. /** @hidden */
  88401. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88402. /** @hidden */
  88403. _initialStartSpriteCellID: number;
  88404. /** @hidden */
  88405. _initialEndSpriteCellID: number;
  88406. /** @hidden */
  88407. _currentColorGradient: Nullable<ColorGradient>;
  88408. /** @hidden */
  88409. _currentColor1: Color4;
  88410. /** @hidden */
  88411. _currentColor2: Color4;
  88412. /** @hidden */
  88413. _currentSizeGradient: Nullable<FactorGradient>;
  88414. /** @hidden */
  88415. _currentSize1: number;
  88416. /** @hidden */
  88417. _currentSize2: number;
  88418. /** @hidden */
  88419. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88420. /** @hidden */
  88421. _currentAngularSpeed1: number;
  88422. /** @hidden */
  88423. _currentAngularSpeed2: number;
  88424. /** @hidden */
  88425. _currentVelocityGradient: Nullable<FactorGradient>;
  88426. /** @hidden */
  88427. _currentVelocity1: number;
  88428. /** @hidden */
  88429. _currentVelocity2: number;
  88430. /** @hidden */
  88431. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88432. /** @hidden */
  88433. _currentLimitVelocity1: number;
  88434. /** @hidden */
  88435. _currentLimitVelocity2: number;
  88436. /** @hidden */
  88437. _currentDragGradient: Nullable<FactorGradient>;
  88438. /** @hidden */
  88439. _currentDrag1: number;
  88440. /** @hidden */
  88441. _currentDrag2: number;
  88442. /** @hidden */
  88443. _randomNoiseCoordinates1: Vector3;
  88444. /** @hidden */
  88445. _randomNoiseCoordinates2: Vector3;
  88446. /**
  88447. * Creates a new instance Particle
  88448. * @param particleSystem the particle system the particle belongs to
  88449. */
  88450. constructor(
  88451. /**
  88452. * The particle system the particle belongs to.
  88453. */
  88454. particleSystem: ParticleSystem);
  88455. private updateCellInfoFromSystem;
  88456. /**
  88457. * Defines how the sprite cell index is updated for the particle
  88458. */
  88459. updateCellIndex(): void;
  88460. /** @hidden */
  88461. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88462. /** @hidden */
  88463. _inheritParticleInfoToSubEmitters(): void;
  88464. /** @hidden */
  88465. _reset(): void;
  88466. /**
  88467. * Copy the properties of particle to another one.
  88468. * @param other the particle to copy the information to.
  88469. */
  88470. copyTo(other: Particle): void;
  88471. }
  88472. }
  88473. declare module BABYLON {
  88474. /**
  88475. * Particle emitter represents a volume emitting particles.
  88476. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88477. */
  88478. export interface IParticleEmitterType {
  88479. /**
  88480. * Called by the particle System when the direction is computed for the created particle.
  88481. * @param worldMatrix is the world matrix of the particle system
  88482. * @param directionToUpdate is the direction vector to update with the result
  88483. * @param particle is the particle we are computed the direction for
  88484. */
  88485. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88486. /**
  88487. * Called by the particle System when the position is computed for the created particle.
  88488. * @param worldMatrix is the world matrix of the particle system
  88489. * @param positionToUpdate is the position vector to update with the result
  88490. * @param particle is the particle we are computed the position for
  88491. */
  88492. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88493. /**
  88494. * Clones the current emitter and returns a copy of it
  88495. * @returns the new emitter
  88496. */
  88497. clone(): IParticleEmitterType;
  88498. /**
  88499. * Called by the GPUParticleSystem to setup the update shader
  88500. * @param effect defines the update shader
  88501. */
  88502. applyToShader(effect: Effect): void;
  88503. /**
  88504. * Returns a string to use to update the GPU particles update shader
  88505. * @returns the effect defines string
  88506. */
  88507. getEffectDefines(): string;
  88508. /**
  88509. * Returns a string representing the class name
  88510. * @returns a string containing the class name
  88511. */
  88512. getClassName(): string;
  88513. /**
  88514. * Serializes the particle system to a JSON object.
  88515. * @returns the JSON object
  88516. */
  88517. serialize(): any;
  88518. /**
  88519. * Parse properties from a JSON object
  88520. * @param serializationObject defines the JSON object
  88521. */
  88522. parse(serializationObject: any): void;
  88523. }
  88524. }
  88525. declare module BABYLON {
  88526. /**
  88527. * Particle emitter emitting particles from the inside of a box.
  88528. * It emits the particles randomly between 2 given directions.
  88529. */
  88530. export class BoxParticleEmitter implements IParticleEmitterType {
  88531. /**
  88532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88533. */
  88534. direction1: Vector3;
  88535. /**
  88536. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88537. */
  88538. direction2: Vector3;
  88539. /**
  88540. * 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.
  88541. */
  88542. minEmitBox: Vector3;
  88543. /**
  88544. * 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.
  88545. */
  88546. maxEmitBox: Vector3;
  88547. /**
  88548. * Creates a new instance BoxParticleEmitter
  88549. */
  88550. constructor();
  88551. /**
  88552. * Called by the particle System when the direction is computed for the created particle.
  88553. * @param worldMatrix is the world matrix of the particle system
  88554. * @param directionToUpdate is the direction vector to update with the result
  88555. * @param particle is the particle we are computed the direction for
  88556. */
  88557. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88558. /**
  88559. * Called by the particle System when the position is computed for the created particle.
  88560. * @param worldMatrix is the world matrix of the particle system
  88561. * @param positionToUpdate is the position vector to update with the result
  88562. * @param particle is the particle we are computed the position for
  88563. */
  88564. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88565. /**
  88566. * Clones the current emitter and returns a copy of it
  88567. * @returns the new emitter
  88568. */
  88569. clone(): BoxParticleEmitter;
  88570. /**
  88571. * Called by the GPUParticleSystem to setup the update shader
  88572. * @param effect defines the update shader
  88573. */
  88574. applyToShader(effect: Effect): void;
  88575. /**
  88576. * Returns a string to use to update the GPU particles update shader
  88577. * @returns a string containng the defines string
  88578. */
  88579. getEffectDefines(): string;
  88580. /**
  88581. * Returns the string "BoxParticleEmitter"
  88582. * @returns a string containing the class name
  88583. */
  88584. getClassName(): string;
  88585. /**
  88586. * Serializes the particle system to a JSON object.
  88587. * @returns the JSON object
  88588. */
  88589. serialize(): any;
  88590. /**
  88591. * Parse properties from a JSON object
  88592. * @param serializationObject defines the JSON object
  88593. */
  88594. parse(serializationObject: any): void;
  88595. }
  88596. }
  88597. declare module BABYLON {
  88598. /**
  88599. * Particle emitter emitting particles from the inside of a cone.
  88600. * It emits the particles alongside the cone volume from the base to the particle.
  88601. * The emission direction might be randomized.
  88602. */
  88603. export class ConeParticleEmitter implements IParticleEmitterType {
  88604. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88605. directionRandomizer: number;
  88606. private _radius;
  88607. private _angle;
  88608. private _height;
  88609. /**
  88610. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88611. */
  88612. radiusRange: number;
  88613. /**
  88614. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88615. */
  88616. heightRange: number;
  88617. /**
  88618. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88619. */
  88620. emitFromSpawnPointOnly: boolean;
  88621. /**
  88622. * Gets or sets the radius of the emission cone
  88623. */
  88624. get radius(): number;
  88625. set radius(value: number);
  88626. /**
  88627. * Gets or sets the angle of the emission cone
  88628. */
  88629. get angle(): number;
  88630. set angle(value: number);
  88631. private _buildHeight;
  88632. /**
  88633. * Creates a new instance ConeParticleEmitter
  88634. * @param radius the radius of the emission cone (1 by default)
  88635. * @param angle the cone base angle (PI by default)
  88636. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88637. */
  88638. constructor(radius?: number, angle?: number,
  88639. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88640. directionRandomizer?: number);
  88641. /**
  88642. * Called by the particle System when the direction is computed for the created particle.
  88643. * @param worldMatrix is the world matrix of the particle system
  88644. * @param directionToUpdate is the direction vector to update with the result
  88645. * @param particle is the particle we are computed the direction for
  88646. */
  88647. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88648. /**
  88649. * Called by the particle System when the position is computed for the created particle.
  88650. * @param worldMatrix is the world matrix of the particle system
  88651. * @param positionToUpdate is the position vector to update with the result
  88652. * @param particle is the particle we are computed the position for
  88653. */
  88654. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88655. /**
  88656. * Clones the current emitter and returns a copy of it
  88657. * @returns the new emitter
  88658. */
  88659. clone(): ConeParticleEmitter;
  88660. /**
  88661. * Called by the GPUParticleSystem to setup the update shader
  88662. * @param effect defines the update shader
  88663. */
  88664. applyToShader(effect: Effect): void;
  88665. /**
  88666. * Returns a string to use to update the GPU particles update shader
  88667. * @returns a string containng the defines string
  88668. */
  88669. getEffectDefines(): string;
  88670. /**
  88671. * Returns the string "ConeParticleEmitter"
  88672. * @returns a string containing the class name
  88673. */
  88674. getClassName(): string;
  88675. /**
  88676. * Serializes the particle system to a JSON object.
  88677. * @returns the JSON object
  88678. */
  88679. serialize(): any;
  88680. /**
  88681. * Parse properties from a JSON object
  88682. * @param serializationObject defines the JSON object
  88683. */
  88684. parse(serializationObject: any): void;
  88685. }
  88686. }
  88687. declare module BABYLON {
  88688. /**
  88689. * Particle emitter emitting particles from the inside of a cylinder.
  88690. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88691. */
  88692. export class CylinderParticleEmitter implements IParticleEmitterType {
  88693. /**
  88694. * The radius of the emission cylinder.
  88695. */
  88696. radius: number;
  88697. /**
  88698. * The height of the emission cylinder.
  88699. */
  88700. height: number;
  88701. /**
  88702. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88703. */
  88704. radiusRange: number;
  88705. /**
  88706. * How much to randomize the particle direction [0-1].
  88707. */
  88708. directionRandomizer: number;
  88709. /**
  88710. * Creates a new instance CylinderParticleEmitter
  88711. * @param radius the radius of the emission cylinder (1 by default)
  88712. * @param height the height of the emission cylinder (1 by default)
  88713. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88714. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88715. */
  88716. constructor(
  88717. /**
  88718. * The radius of the emission cylinder.
  88719. */
  88720. radius?: number,
  88721. /**
  88722. * The height of the emission cylinder.
  88723. */
  88724. height?: number,
  88725. /**
  88726. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88727. */
  88728. radiusRange?: number,
  88729. /**
  88730. * How much to randomize the particle direction [0-1].
  88731. */
  88732. directionRandomizer?: number);
  88733. /**
  88734. * Called by the particle System when the direction is computed for the created particle.
  88735. * @param worldMatrix is the world matrix of the particle system
  88736. * @param directionToUpdate is the direction vector to update with the result
  88737. * @param particle is the particle we are computed the direction for
  88738. */
  88739. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88740. /**
  88741. * Called by the particle System when the position is computed for the created particle.
  88742. * @param worldMatrix is the world matrix of the particle system
  88743. * @param positionToUpdate is the position vector to update with the result
  88744. * @param particle is the particle we are computed the position for
  88745. */
  88746. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88747. /**
  88748. * Clones the current emitter and returns a copy of it
  88749. * @returns the new emitter
  88750. */
  88751. clone(): CylinderParticleEmitter;
  88752. /**
  88753. * Called by the GPUParticleSystem to setup the update shader
  88754. * @param effect defines the update shader
  88755. */
  88756. applyToShader(effect: Effect): void;
  88757. /**
  88758. * Returns a string to use to update the GPU particles update shader
  88759. * @returns a string containng the defines string
  88760. */
  88761. getEffectDefines(): string;
  88762. /**
  88763. * Returns the string "CylinderParticleEmitter"
  88764. * @returns a string containing the class name
  88765. */
  88766. getClassName(): string;
  88767. /**
  88768. * Serializes the particle system to a JSON object.
  88769. * @returns the JSON object
  88770. */
  88771. serialize(): any;
  88772. /**
  88773. * Parse properties from a JSON object
  88774. * @param serializationObject defines the JSON object
  88775. */
  88776. parse(serializationObject: any): void;
  88777. }
  88778. /**
  88779. * Particle emitter emitting particles from the inside of a cylinder.
  88780. * It emits the particles randomly between two vectors.
  88781. */
  88782. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88783. /**
  88784. * The min limit of the emission direction.
  88785. */
  88786. direction1: Vector3;
  88787. /**
  88788. * The max limit of the emission direction.
  88789. */
  88790. direction2: Vector3;
  88791. /**
  88792. * Creates a new instance CylinderDirectedParticleEmitter
  88793. * @param radius the radius of the emission cylinder (1 by default)
  88794. * @param height the height of the emission cylinder (1 by default)
  88795. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88796. * @param direction1 the min limit of the emission direction (up vector by default)
  88797. * @param direction2 the max limit of the emission direction (up vector by default)
  88798. */
  88799. constructor(radius?: number, height?: number, radiusRange?: number,
  88800. /**
  88801. * The min limit of the emission direction.
  88802. */
  88803. direction1?: Vector3,
  88804. /**
  88805. * The max limit of the emission direction.
  88806. */
  88807. direction2?: Vector3);
  88808. /**
  88809. * Called by the particle System when the direction is computed for the created particle.
  88810. * @param worldMatrix is the world matrix of the particle system
  88811. * @param directionToUpdate is the direction vector to update with the result
  88812. * @param particle is the particle we are computed the direction for
  88813. */
  88814. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88815. /**
  88816. * Clones the current emitter and returns a copy of it
  88817. * @returns the new emitter
  88818. */
  88819. clone(): CylinderDirectedParticleEmitter;
  88820. /**
  88821. * Called by the GPUParticleSystem to setup the update shader
  88822. * @param effect defines the update shader
  88823. */
  88824. applyToShader(effect: Effect): void;
  88825. /**
  88826. * Returns a string to use to update the GPU particles update shader
  88827. * @returns a string containng the defines string
  88828. */
  88829. getEffectDefines(): string;
  88830. /**
  88831. * Returns the string "CylinderDirectedParticleEmitter"
  88832. * @returns a string containing the class name
  88833. */
  88834. getClassName(): string;
  88835. /**
  88836. * Serializes the particle system to a JSON object.
  88837. * @returns the JSON object
  88838. */
  88839. serialize(): any;
  88840. /**
  88841. * Parse properties from a JSON object
  88842. * @param serializationObject defines the JSON object
  88843. */
  88844. parse(serializationObject: any): void;
  88845. }
  88846. }
  88847. declare module BABYLON {
  88848. /**
  88849. * Particle emitter emitting particles from the inside of a hemisphere.
  88850. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88851. */
  88852. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88853. /**
  88854. * The radius of the emission hemisphere.
  88855. */
  88856. radius: number;
  88857. /**
  88858. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88859. */
  88860. radiusRange: number;
  88861. /**
  88862. * How much to randomize the particle direction [0-1].
  88863. */
  88864. directionRandomizer: number;
  88865. /**
  88866. * Creates a new instance HemisphericParticleEmitter
  88867. * @param radius the radius of the emission hemisphere (1 by default)
  88868. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88869. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88870. */
  88871. constructor(
  88872. /**
  88873. * The radius of the emission hemisphere.
  88874. */
  88875. radius?: number,
  88876. /**
  88877. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88878. */
  88879. radiusRange?: number,
  88880. /**
  88881. * How much to randomize the particle direction [0-1].
  88882. */
  88883. directionRandomizer?: number);
  88884. /**
  88885. * Called by the particle System when the direction is computed for the created particle.
  88886. * @param worldMatrix is the world matrix of the particle system
  88887. * @param directionToUpdate is the direction vector to update with the result
  88888. * @param particle is the particle we are computed the direction for
  88889. */
  88890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88891. /**
  88892. * Called by the particle System when the position is computed for the created particle.
  88893. * @param worldMatrix is the world matrix of the particle system
  88894. * @param positionToUpdate is the position vector to update with the result
  88895. * @param particle is the particle we are computed the position for
  88896. */
  88897. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88898. /**
  88899. * Clones the current emitter and returns a copy of it
  88900. * @returns the new emitter
  88901. */
  88902. clone(): HemisphericParticleEmitter;
  88903. /**
  88904. * Called by the GPUParticleSystem to setup the update shader
  88905. * @param effect defines the update shader
  88906. */
  88907. applyToShader(effect: Effect): void;
  88908. /**
  88909. * Returns a string to use to update the GPU particles update shader
  88910. * @returns a string containng the defines string
  88911. */
  88912. getEffectDefines(): string;
  88913. /**
  88914. * Returns the string "HemisphericParticleEmitter"
  88915. * @returns a string containing the class name
  88916. */
  88917. getClassName(): string;
  88918. /**
  88919. * Serializes the particle system to a JSON object.
  88920. * @returns the JSON object
  88921. */
  88922. serialize(): any;
  88923. /**
  88924. * Parse properties from a JSON object
  88925. * @param serializationObject defines the JSON object
  88926. */
  88927. parse(serializationObject: any): void;
  88928. }
  88929. }
  88930. declare module BABYLON {
  88931. /**
  88932. * Particle emitter emitting particles from a point.
  88933. * It emits the particles randomly between 2 given directions.
  88934. */
  88935. export class PointParticleEmitter implements IParticleEmitterType {
  88936. /**
  88937. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88938. */
  88939. direction1: Vector3;
  88940. /**
  88941. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88942. */
  88943. direction2: Vector3;
  88944. /**
  88945. * Creates a new instance PointParticleEmitter
  88946. */
  88947. constructor();
  88948. /**
  88949. * Called by the particle System when the direction is computed for the created particle.
  88950. * @param worldMatrix is the world matrix of the particle system
  88951. * @param directionToUpdate is the direction vector to update with the result
  88952. * @param particle is the particle we are computed the direction for
  88953. */
  88954. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88955. /**
  88956. * Called by the particle System when the position is computed for the created particle.
  88957. * @param worldMatrix is the world matrix of the particle system
  88958. * @param positionToUpdate is the position vector to update with the result
  88959. * @param particle is the particle we are computed the position for
  88960. */
  88961. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88962. /**
  88963. * Clones the current emitter and returns a copy of it
  88964. * @returns the new emitter
  88965. */
  88966. clone(): PointParticleEmitter;
  88967. /**
  88968. * Called by the GPUParticleSystem to setup the update shader
  88969. * @param effect defines the update shader
  88970. */
  88971. applyToShader(effect: Effect): void;
  88972. /**
  88973. * Returns a string to use to update the GPU particles update shader
  88974. * @returns a string containng the defines string
  88975. */
  88976. getEffectDefines(): string;
  88977. /**
  88978. * Returns the string "PointParticleEmitter"
  88979. * @returns a string containing the class name
  88980. */
  88981. getClassName(): string;
  88982. /**
  88983. * Serializes the particle system to a JSON object.
  88984. * @returns the JSON object
  88985. */
  88986. serialize(): any;
  88987. /**
  88988. * Parse properties from a JSON object
  88989. * @param serializationObject defines the JSON object
  88990. */
  88991. parse(serializationObject: any): void;
  88992. }
  88993. }
  88994. declare module BABYLON {
  88995. /**
  88996. * Particle emitter emitting particles from the inside of a sphere.
  88997. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  88998. */
  88999. export class SphereParticleEmitter implements IParticleEmitterType {
  89000. /**
  89001. * The radius of the emission sphere.
  89002. */
  89003. radius: number;
  89004. /**
  89005. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89006. */
  89007. radiusRange: number;
  89008. /**
  89009. * How much to randomize the particle direction [0-1].
  89010. */
  89011. directionRandomizer: number;
  89012. /**
  89013. * Creates a new instance SphereParticleEmitter
  89014. * @param radius the radius of the emission sphere (1 by default)
  89015. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89016. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89017. */
  89018. constructor(
  89019. /**
  89020. * The radius of the emission sphere.
  89021. */
  89022. radius?: number,
  89023. /**
  89024. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89025. */
  89026. radiusRange?: number,
  89027. /**
  89028. * How much to randomize the particle direction [0-1].
  89029. */
  89030. directionRandomizer?: number);
  89031. /**
  89032. * Called by the particle System when the direction is computed for the created particle.
  89033. * @param worldMatrix is the world matrix of the particle system
  89034. * @param directionToUpdate is the direction vector to update with the result
  89035. * @param particle is the particle we are computed the direction for
  89036. */
  89037. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89038. /**
  89039. * Called by the particle System when the position is computed for the created particle.
  89040. * @param worldMatrix is the world matrix of the particle system
  89041. * @param positionToUpdate is the position vector to update with the result
  89042. * @param particle is the particle we are computed the position for
  89043. */
  89044. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89045. /**
  89046. * Clones the current emitter and returns a copy of it
  89047. * @returns the new emitter
  89048. */
  89049. clone(): SphereParticleEmitter;
  89050. /**
  89051. * Called by the GPUParticleSystem to setup the update shader
  89052. * @param effect defines the update shader
  89053. */
  89054. applyToShader(effect: Effect): void;
  89055. /**
  89056. * Returns a string to use to update the GPU particles update shader
  89057. * @returns a string containng the defines string
  89058. */
  89059. getEffectDefines(): string;
  89060. /**
  89061. * Returns the string "SphereParticleEmitter"
  89062. * @returns a string containing the class name
  89063. */
  89064. getClassName(): string;
  89065. /**
  89066. * Serializes the particle system to a JSON object.
  89067. * @returns the JSON object
  89068. */
  89069. serialize(): any;
  89070. /**
  89071. * Parse properties from a JSON object
  89072. * @param serializationObject defines the JSON object
  89073. */
  89074. parse(serializationObject: any): void;
  89075. }
  89076. /**
  89077. * Particle emitter emitting particles from the inside of a sphere.
  89078. * It emits the particles randomly between two vectors.
  89079. */
  89080. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  89081. /**
  89082. * The min limit of the emission direction.
  89083. */
  89084. direction1: Vector3;
  89085. /**
  89086. * The max limit of the emission direction.
  89087. */
  89088. direction2: Vector3;
  89089. /**
  89090. * Creates a new instance SphereDirectedParticleEmitter
  89091. * @param radius the radius of the emission sphere (1 by default)
  89092. * @param direction1 the min limit of the emission direction (up vector by default)
  89093. * @param direction2 the max limit of the emission direction (up vector by default)
  89094. */
  89095. constructor(radius?: number,
  89096. /**
  89097. * The min limit of the emission direction.
  89098. */
  89099. direction1?: Vector3,
  89100. /**
  89101. * The max limit of the emission direction.
  89102. */
  89103. direction2?: Vector3);
  89104. /**
  89105. * Called by the particle System when the direction is computed for the created particle.
  89106. * @param worldMatrix is the world matrix of the particle system
  89107. * @param directionToUpdate is the direction vector to update with the result
  89108. * @param particle is the particle we are computed the direction for
  89109. */
  89110. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89111. /**
  89112. * Clones the current emitter and returns a copy of it
  89113. * @returns the new emitter
  89114. */
  89115. clone(): SphereDirectedParticleEmitter;
  89116. /**
  89117. * Called by the GPUParticleSystem to setup the update shader
  89118. * @param effect defines the update shader
  89119. */
  89120. applyToShader(effect: Effect): void;
  89121. /**
  89122. * Returns a string to use to update the GPU particles update shader
  89123. * @returns a string containng the defines string
  89124. */
  89125. getEffectDefines(): string;
  89126. /**
  89127. * Returns the string "SphereDirectedParticleEmitter"
  89128. * @returns a string containing the class name
  89129. */
  89130. getClassName(): string;
  89131. /**
  89132. * Serializes the particle system to a JSON object.
  89133. * @returns the JSON object
  89134. */
  89135. serialize(): any;
  89136. /**
  89137. * Parse properties from a JSON object
  89138. * @param serializationObject defines the JSON object
  89139. */
  89140. parse(serializationObject: any): void;
  89141. }
  89142. }
  89143. declare module BABYLON {
  89144. /**
  89145. * Interface representing a particle system in Babylon.js.
  89146. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89147. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89148. */
  89149. export interface IParticleSystem {
  89150. /**
  89151. * List of animations used by the particle system.
  89152. */
  89153. animations: Animation[];
  89154. /**
  89155. * The id of the Particle system.
  89156. */
  89157. id: string;
  89158. /**
  89159. * The name of the Particle system.
  89160. */
  89161. name: string;
  89162. /**
  89163. * The emitter represents the Mesh or position we are attaching the particle system to.
  89164. */
  89165. emitter: Nullable<AbstractMesh | Vector3>;
  89166. /**
  89167. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89168. */
  89169. isBillboardBased: boolean;
  89170. /**
  89171. * The rendering group used by the Particle system to chose when to render.
  89172. */
  89173. renderingGroupId: number;
  89174. /**
  89175. * The layer mask we are rendering the particles through.
  89176. */
  89177. layerMask: number;
  89178. /**
  89179. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89180. */
  89181. updateSpeed: number;
  89182. /**
  89183. * The amount of time the particle system is running (depends of the overall update speed).
  89184. */
  89185. targetStopDuration: number;
  89186. /**
  89187. * The texture used to render each particle. (this can be a spritesheet)
  89188. */
  89189. particleTexture: Nullable<Texture>;
  89190. /**
  89191. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89192. */
  89193. blendMode: number;
  89194. /**
  89195. * Minimum life time of emitting particles.
  89196. */
  89197. minLifeTime: number;
  89198. /**
  89199. * Maximum life time of emitting particles.
  89200. */
  89201. maxLifeTime: number;
  89202. /**
  89203. * Minimum Size of emitting particles.
  89204. */
  89205. minSize: number;
  89206. /**
  89207. * Maximum Size of emitting particles.
  89208. */
  89209. maxSize: number;
  89210. /**
  89211. * Minimum scale of emitting particles on X axis.
  89212. */
  89213. minScaleX: number;
  89214. /**
  89215. * Maximum scale of emitting particles on X axis.
  89216. */
  89217. maxScaleX: number;
  89218. /**
  89219. * Minimum scale of emitting particles on Y axis.
  89220. */
  89221. minScaleY: number;
  89222. /**
  89223. * Maximum scale of emitting particles on Y axis.
  89224. */
  89225. maxScaleY: number;
  89226. /**
  89227. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89228. */
  89229. color1: Color4;
  89230. /**
  89231. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89232. */
  89233. color2: Color4;
  89234. /**
  89235. * Color the particle will have at the end of its lifetime.
  89236. */
  89237. colorDead: Color4;
  89238. /**
  89239. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89240. */
  89241. emitRate: number;
  89242. /**
  89243. * You can use gravity if you want to give an orientation to your particles.
  89244. */
  89245. gravity: Vector3;
  89246. /**
  89247. * Minimum power of emitting particles.
  89248. */
  89249. minEmitPower: number;
  89250. /**
  89251. * Maximum power of emitting particles.
  89252. */
  89253. maxEmitPower: number;
  89254. /**
  89255. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89256. */
  89257. minAngularSpeed: number;
  89258. /**
  89259. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89260. */
  89261. maxAngularSpeed: number;
  89262. /**
  89263. * Gets or sets the minimal initial rotation in radians.
  89264. */
  89265. minInitialRotation: number;
  89266. /**
  89267. * Gets or sets the maximal initial rotation in radians.
  89268. */
  89269. maxInitialRotation: number;
  89270. /**
  89271. * The particle emitter type defines the emitter used by the particle system.
  89272. * It can be for example box, sphere, or cone...
  89273. */
  89274. particleEmitterType: Nullable<IParticleEmitterType>;
  89275. /**
  89276. * Defines the delay in milliseconds before starting the system (0 by default)
  89277. */
  89278. startDelay: number;
  89279. /**
  89280. * 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
  89281. */
  89282. preWarmCycles: number;
  89283. /**
  89284. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89285. */
  89286. preWarmStepOffset: number;
  89287. /**
  89288. * 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)
  89289. */
  89290. spriteCellChangeSpeed: number;
  89291. /**
  89292. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89293. */
  89294. startSpriteCellID: number;
  89295. /**
  89296. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89297. */
  89298. endSpriteCellID: number;
  89299. /**
  89300. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89301. */
  89302. spriteCellWidth: number;
  89303. /**
  89304. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89305. */
  89306. spriteCellHeight: number;
  89307. /**
  89308. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89309. */
  89310. spriteRandomStartCell: boolean;
  89311. /**
  89312. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89313. */
  89314. isAnimationSheetEnabled: boolean;
  89315. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89316. translationPivot: Vector2;
  89317. /**
  89318. * Gets or sets a texture used to add random noise to particle positions
  89319. */
  89320. noiseTexture: Nullable<BaseTexture>;
  89321. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89322. noiseStrength: Vector3;
  89323. /**
  89324. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89325. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89326. */
  89327. billboardMode: number;
  89328. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89329. limitVelocityDamping: number;
  89330. /**
  89331. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89332. */
  89333. beginAnimationOnStart: boolean;
  89334. /**
  89335. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89336. */
  89337. beginAnimationFrom: number;
  89338. /**
  89339. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89340. */
  89341. beginAnimationTo: number;
  89342. /**
  89343. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89344. */
  89345. beginAnimationLoop: boolean;
  89346. /**
  89347. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89348. */
  89349. disposeOnStop: boolean;
  89350. /**
  89351. * Gets the maximum number of particles active at the same time.
  89352. * @returns The max number of active particles.
  89353. */
  89354. getCapacity(): number;
  89355. /**
  89356. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89357. * @returns True if it has been started, otherwise false.
  89358. */
  89359. isStarted(): boolean;
  89360. /**
  89361. * Animates the particle system for this frame.
  89362. */
  89363. animate(): void;
  89364. /**
  89365. * Renders the particle system in its current state.
  89366. * @returns the current number of particles
  89367. */
  89368. render(): number;
  89369. /**
  89370. * Dispose the particle system and frees its associated resources.
  89371. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89372. */
  89373. dispose(disposeTexture?: boolean): void;
  89374. /**
  89375. * Clones the particle system.
  89376. * @param name The name of the cloned object
  89377. * @param newEmitter The new emitter to use
  89378. * @returns the cloned particle system
  89379. */
  89380. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89381. /**
  89382. * Serializes the particle system to a JSON object.
  89383. * @returns the JSON object
  89384. */
  89385. serialize(): any;
  89386. /**
  89387. * Rebuild the particle system
  89388. */
  89389. rebuild(): void;
  89390. /**
  89391. * Starts the particle system and begins to emit
  89392. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89393. */
  89394. start(delay?: number): void;
  89395. /**
  89396. * Stops the particle system.
  89397. */
  89398. stop(): void;
  89399. /**
  89400. * Remove all active particles
  89401. */
  89402. reset(): void;
  89403. /**
  89404. * Is this system ready to be used/rendered
  89405. * @return true if the system is ready
  89406. */
  89407. isReady(): boolean;
  89408. /**
  89409. * Adds a new color gradient
  89410. * @param gradient defines the gradient to use (between 0 and 1)
  89411. * @param color1 defines the color to affect to the specified gradient
  89412. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89413. * @returns the current particle system
  89414. */
  89415. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89416. /**
  89417. * Remove a specific color gradient
  89418. * @param gradient defines the gradient to remove
  89419. * @returns the current particle system
  89420. */
  89421. removeColorGradient(gradient: number): IParticleSystem;
  89422. /**
  89423. * Adds a new size gradient
  89424. * @param gradient defines the gradient to use (between 0 and 1)
  89425. * @param factor defines the size factor to affect to the specified gradient
  89426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89427. * @returns the current particle system
  89428. */
  89429. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89430. /**
  89431. * Remove a specific size gradient
  89432. * @param gradient defines the gradient to remove
  89433. * @returns the current particle system
  89434. */
  89435. removeSizeGradient(gradient: number): IParticleSystem;
  89436. /**
  89437. * Gets the current list of color gradients.
  89438. * You must use addColorGradient and removeColorGradient to udpate this list
  89439. * @returns the list of color gradients
  89440. */
  89441. getColorGradients(): Nullable<Array<ColorGradient>>;
  89442. /**
  89443. * Gets the current list of size gradients.
  89444. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89445. * @returns the list of size gradients
  89446. */
  89447. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89448. /**
  89449. * Gets the current list of angular speed gradients.
  89450. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89451. * @returns the list of angular speed gradients
  89452. */
  89453. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89454. /**
  89455. * Adds a new angular speed gradient
  89456. * @param gradient defines the gradient to use (between 0 and 1)
  89457. * @param factor defines the angular speed to affect to the specified gradient
  89458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89459. * @returns the current particle system
  89460. */
  89461. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89462. /**
  89463. * Remove a specific angular speed gradient
  89464. * @param gradient defines the gradient to remove
  89465. * @returns the current particle system
  89466. */
  89467. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89468. /**
  89469. * Gets the current list of velocity gradients.
  89470. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89471. * @returns the list of velocity gradients
  89472. */
  89473. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89474. /**
  89475. * Adds a new velocity gradient
  89476. * @param gradient defines the gradient to use (between 0 and 1)
  89477. * @param factor defines the velocity to affect to the specified gradient
  89478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89479. * @returns the current particle system
  89480. */
  89481. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89482. /**
  89483. * Remove a specific velocity gradient
  89484. * @param gradient defines the gradient to remove
  89485. * @returns the current particle system
  89486. */
  89487. removeVelocityGradient(gradient: number): IParticleSystem;
  89488. /**
  89489. * Gets the current list of limit velocity gradients.
  89490. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89491. * @returns the list of limit velocity gradients
  89492. */
  89493. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89494. /**
  89495. * Adds a new limit velocity gradient
  89496. * @param gradient defines the gradient to use (between 0 and 1)
  89497. * @param factor defines the limit velocity to affect to the specified gradient
  89498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89499. * @returns the current particle system
  89500. */
  89501. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89502. /**
  89503. * Remove a specific limit velocity gradient
  89504. * @param gradient defines the gradient to remove
  89505. * @returns the current particle system
  89506. */
  89507. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89508. /**
  89509. * Adds a new drag gradient
  89510. * @param gradient defines the gradient to use (between 0 and 1)
  89511. * @param factor defines the drag to affect to the specified gradient
  89512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89513. * @returns the current particle system
  89514. */
  89515. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89516. /**
  89517. * Remove a specific drag gradient
  89518. * @param gradient defines the gradient to remove
  89519. * @returns the current particle system
  89520. */
  89521. removeDragGradient(gradient: number): IParticleSystem;
  89522. /**
  89523. * Gets the current list of drag gradients.
  89524. * You must use addDragGradient and removeDragGradient to udpate this list
  89525. * @returns the list of drag gradients
  89526. */
  89527. getDragGradients(): Nullable<Array<FactorGradient>>;
  89528. /**
  89529. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89530. * @param gradient defines the gradient to use (between 0 and 1)
  89531. * @param factor defines the emit rate to affect to the specified gradient
  89532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89533. * @returns the current particle system
  89534. */
  89535. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89536. /**
  89537. * Remove a specific emit rate gradient
  89538. * @param gradient defines the gradient to remove
  89539. * @returns the current particle system
  89540. */
  89541. removeEmitRateGradient(gradient: number): IParticleSystem;
  89542. /**
  89543. * Gets the current list of emit rate gradients.
  89544. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89545. * @returns the list of emit rate gradients
  89546. */
  89547. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89548. /**
  89549. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89550. * @param gradient defines the gradient to use (between 0 and 1)
  89551. * @param factor defines the start size to affect to the specified gradient
  89552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89553. * @returns the current particle system
  89554. */
  89555. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89556. /**
  89557. * Remove a specific start size gradient
  89558. * @param gradient defines the gradient to remove
  89559. * @returns the current particle system
  89560. */
  89561. removeStartSizeGradient(gradient: number): IParticleSystem;
  89562. /**
  89563. * Gets the current list of start size gradients.
  89564. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89565. * @returns the list of start size gradients
  89566. */
  89567. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89568. /**
  89569. * Adds a new life time gradient
  89570. * @param gradient defines the gradient to use (between 0 and 1)
  89571. * @param factor defines the life time factor to affect to the specified gradient
  89572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89573. * @returns the current particle system
  89574. */
  89575. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89576. /**
  89577. * Remove a specific life time gradient
  89578. * @param gradient defines the gradient to remove
  89579. * @returns the current particle system
  89580. */
  89581. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89582. /**
  89583. * Gets the current list of life time gradients.
  89584. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89585. * @returns the list of life time gradients
  89586. */
  89587. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89588. /**
  89589. * Gets the current list of color gradients.
  89590. * You must use addColorGradient and removeColorGradient to udpate this list
  89591. * @returns the list of color gradients
  89592. */
  89593. getColorGradients(): Nullable<Array<ColorGradient>>;
  89594. /**
  89595. * Adds a new ramp gradient used to remap particle colors
  89596. * @param gradient defines the gradient to use (between 0 and 1)
  89597. * @param color defines the color to affect to the specified gradient
  89598. * @returns the current particle system
  89599. */
  89600. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89601. /**
  89602. * Gets the current list of ramp gradients.
  89603. * You must use addRampGradient and removeRampGradient to udpate this list
  89604. * @returns the list of ramp gradients
  89605. */
  89606. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89607. /** Gets or sets a boolean indicating that ramp gradients must be used
  89608. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89609. */
  89610. useRampGradients: boolean;
  89611. /**
  89612. * Adds a new color remap gradient
  89613. * @param gradient defines the gradient to use (between 0 and 1)
  89614. * @param min defines the color remap minimal range
  89615. * @param max defines the color remap maximal range
  89616. * @returns the current particle system
  89617. */
  89618. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89619. /**
  89620. * Gets the current list of color remap gradients.
  89621. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89622. * @returns the list of color remap gradients
  89623. */
  89624. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89625. /**
  89626. * Adds a new alpha remap gradient
  89627. * @param gradient defines the gradient to use (between 0 and 1)
  89628. * @param min defines the alpha remap minimal range
  89629. * @param max defines the alpha remap maximal range
  89630. * @returns the current particle system
  89631. */
  89632. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89633. /**
  89634. * Gets the current list of alpha remap gradients.
  89635. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89636. * @returns the list of alpha remap gradients
  89637. */
  89638. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89639. /**
  89640. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89643. * @returns the emitter
  89644. */
  89645. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89646. /**
  89647. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89648. * @param radius The radius of the hemisphere to emit from
  89649. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89650. * @returns the emitter
  89651. */
  89652. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89653. /**
  89654. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89655. * @param radius The radius of the sphere to emit from
  89656. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89657. * @returns the emitter
  89658. */
  89659. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89660. /**
  89661. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89662. * @param radius The radius of the sphere to emit from
  89663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89665. * @returns the emitter
  89666. */
  89667. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89668. /**
  89669. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89670. * @param radius The radius of the emission cylinder
  89671. * @param height The height of the emission cylinder
  89672. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89673. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89674. * @returns the emitter
  89675. */
  89676. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89677. /**
  89678. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89679. * @param radius The radius of the cylinder to emit from
  89680. * @param height The height of the emission cylinder
  89681. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89684. * @returns the emitter
  89685. */
  89686. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89687. /**
  89688. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89689. * @param radius The radius of the cone to emit from
  89690. * @param angle The base angle of the cone
  89691. * @returns the emitter
  89692. */
  89693. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89694. /**
  89695. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89696. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89697. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89698. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89699. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89700. * @returns the emitter
  89701. */
  89702. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89703. /**
  89704. * Get hosting scene
  89705. * @returns the scene
  89706. */
  89707. getScene(): Scene;
  89708. }
  89709. }
  89710. declare module BABYLON {
  89711. /**
  89712. * Creates an instance based on a source mesh.
  89713. */
  89714. export class InstancedMesh extends AbstractMesh {
  89715. private _sourceMesh;
  89716. private _currentLOD;
  89717. /** @hidden */
  89718. _indexInSourceMeshInstanceArray: number;
  89719. constructor(name: string, source: Mesh);
  89720. /**
  89721. * Returns the string "InstancedMesh".
  89722. */
  89723. getClassName(): string;
  89724. /** Gets the list of lights affecting that mesh */
  89725. get lightSources(): Light[];
  89726. _resyncLightSources(): void;
  89727. _resyncLightSource(light: Light): void;
  89728. _removeLightSource(light: Light, dispose: boolean): void;
  89729. /**
  89730. * If the source mesh receives shadows
  89731. */
  89732. get receiveShadows(): boolean;
  89733. /**
  89734. * The material of the source mesh
  89735. */
  89736. get material(): Nullable<Material>;
  89737. /**
  89738. * Visibility of the source mesh
  89739. */
  89740. get visibility(): number;
  89741. /**
  89742. * Skeleton of the source mesh
  89743. */
  89744. get skeleton(): Nullable<Skeleton>;
  89745. /**
  89746. * Rendering ground id of the source mesh
  89747. */
  89748. get renderingGroupId(): number;
  89749. set renderingGroupId(value: number);
  89750. /**
  89751. * Returns the total number of vertices (integer).
  89752. */
  89753. getTotalVertices(): number;
  89754. /**
  89755. * Returns a positive integer : the total number of indices in this mesh geometry.
  89756. * @returns the numner of indices or zero if the mesh has no geometry.
  89757. */
  89758. getTotalIndices(): number;
  89759. /**
  89760. * The source mesh of the instance
  89761. */
  89762. get sourceMesh(): Mesh;
  89763. /**
  89764. * Is this node ready to be used/rendered
  89765. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89766. * @return {boolean} is it ready
  89767. */
  89768. isReady(completeCheck?: boolean): boolean;
  89769. /**
  89770. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89771. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89772. * @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.
  89773. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89774. */
  89775. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89776. /**
  89777. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89778. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89779. * The `data` are either a numeric array either a Float32Array.
  89780. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89781. * 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).
  89782. * Note that a new underlying VertexBuffer object is created each call.
  89783. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89784. *
  89785. * Possible `kind` values :
  89786. * - VertexBuffer.PositionKind
  89787. * - VertexBuffer.UVKind
  89788. * - VertexBuffer.UV2Kind
  89789. * - VertexBuffer.UV3Kind
  89790. * - VertexBuffer.UV4Kind
  89791. * - VertexBuffer.UV5Kind
  89792. * - VertexBuffer.UV6Kind
  89793. * - VertexBuffer.ColorKind
  89794. * - VertexBuffer.MatricesIndicesKind
  89795. * - VertexBuffer.MatricesIndicesExtraKind
  89796. * - VertexBuffer.MatricesWeightsKind
  89797. * - VertexBuffer.MatricesWeightsExtraKind
  89798. *
  89799. * Returns the Mesh.
  89800. */
  89801. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89802. /**
  89803. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89804. * If the mesh has no geometry, it is simply returned as it is.
  89805. * The `data` are either a numeric array either a Float32Array.
  89806. * No new underlying VertexBuffer object is created.
  89807. * 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.
  89808. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89809. *
  89810. * Possible `kind` values :
  89811. * - VertexBuffer.PositionKind
  89812. * - VertexBuffer.UVKind
  89813. * - VertexBuffer.UV2Kind
  89814. * - VertexBuffer.UV3Kind
  89815. * - VertexBuffer.UV4Kind
  89816. * - VertexBuffer.UV5Kind
  89817. * - VertexBuffer.UV6Kind
  89818. * - VertexBuffer.ColorKind
  89819. * - VertexBuffer.MatricesIndicesKind
  89820. * - VertexBuffer.MatricesIndicesExtraKind
  89821. * - VertexBuffer.MatricesWeightsKind
  89822. * - VertexBuffer.MatricesWeightsExtraKind
  89823. *
  89824. * Returns the Mesh.
  89825. */
  89826. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89827. /**
  89828. * Sets the mesh indices.
  89829. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89830. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89831. * This method creates a new index buffer each call.
  89832. * Returns the Mesh.
  89833. */
  89834. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89835. /**
  89836. * Boolean : True if the mesh owns the requested kind of data.
  89837. */
  89838. isVerticesDataPresent(kind: string): boolean;
  89839. /**
  89840. * Returns an array of indices (IndicesArray).
  89841. */
  89842. getIndices(): Nullable<IndicesArray>;
  89843. get _positions(): Nullable<Vector3[]>;
  89844. /**
  89845. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89846. * This means the mesh underlying bounding box and sphere are recomputed.
  89847. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89848. * @returns the current mesh
  89849. */
  89850. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89851. /** @hidden */
  89852. _preActivate(): InstancedMesh;
  89853. /** @hidden */
  89854. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89855. /** @hidden */
  89856. _postActivate(): void;
  89857. getWorldMatrix(): Matrix;
  89858. get isAnInstance(): boolean;
  89859. /**
  89860. * Returns the current associated LOD AbstractMesh.
  89861. */
  89862. getLOD(camera: Camera): AbstractMesh;
  89863. /** @hidden */
  89864. _syncSubMeshes(): InstancedMesh;
  89865. /** @hidden */
  89866. _generatePointsArray(): boolean;
  89867. /**
  89868. * Creates a new InstancedMesh from the current mesh.
  89869. * - name (string) : the cloned mesh name
  89870. * - newParent (optional Node) : the optional Node to parent the clone to.
  89871. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89872. *
  89873. * Returns the clone.
  89874. */
  89875. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89876. /**
  89877. * Disposes the InstancedMesh.
  89878. * Returns nothing.
  89879. */
  89880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89881. }
  89882. interface Mesh {
  89883. /**
  89884. * Register a custom buffer that will be instanced
  89885. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89886. * @param kind defines the buffer kind
  89887. * @param stride defines the stride in floats
  89888. */
  89889. registerInstancedBuffer(kind: string, stride: number): void;
  89890. /** @hidden */
  89891. _userInstancedBuffersStorage: {
  89892. data: {
  89893. [key: string]: Float32Array;
  89894. };
  89895. sizes: {
  89896. [key: string]: number;
  89897. };
  89898. vertexBuffers: {
  89899. [key: string]: Nullable<VertexBuffer>;
  89900. };
  89901. strides: {
  89902. [key: string]: number;
  89903. };
  89904. };
  89905. }
  89906. interface AbstractMesh {
  89907. /**
  89908. * Object used to store instanced buffers defined by user
  89909. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89910. */
  89911. instancedBuffers: {
  89912. [key: string]: any;
  89913. };
  89914. }
  89915. }
  89916. declare module BABYLON {
  89917. /**
  89918. * Defines the options associated with the creation of a shader material.
  89919. */
  89920. export interface IShaderMaterialOptions {
  89921. /**
  89922. * Does the material work in alpha blend mode
  89923. */
  89924. needAlphaBlending: boolean;
  89925. /**
  89926. * Does the material work in alpha test mode
  89927. */
  89928. needAlphaTesting: boolean;
  89929. /**
  89930. * The list of attribute names used in the shader
  89931. */
  89932. attributes: string[];
  89933. /**
  89934. * The list of unifrom names used in the shader
  89935. */
  89936. uniforms: string[];
  89937. /**
  89938. * The list of UBO names used in the shader
  89939. */
  89940. uniformBuffers: string[];
  89941. /**
  89942. * The list of sampler names used in the shader
  89943. */
  89944. samplers: string[];
  89945. /**
  89946. * The list of defines used in the shader
  89947. */
  89948. defines: string[];
  89949. }
  89950. /**
  89951. * 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.
  89952. *
  89953. * This returned material effects how the mesh will look based on the code in the shaders.
  89954. *
  89955. * @see http://doc.babylonjs.com/how_to/shader_material
  89956. */
  89957. export class ShaderMaterial extends Material {
  89958. private _shaderPath;
  89959. private _options;
  89960. private _textures;
  89961. private _textureArrays;
  89962. private _floats;
  89963. private _ints;
  89964. private _floatsArrays;
  89965. private _colors3;
  89966. private _colors3Arrays;
  89967. private _colors4;
  89968. private _colors4Arrays;
  89969. private _vectors2;
  89970. private _vectors3;
  89971. private _vectors4;
  89972. private _matrices;
  89973. private _matrixArrays;
  89974. private _matrices3x3;
  89975. private _matrices2x2;
  89976. private _vectors2Arrays;
  89977. private _vectors3Arrays;
  89978. private _vectors4Arrays;
  89979. private _cachedWorldViewMatrix;
  89980. private _cachedWorldViewProjectionMatrix;
  89981. private _renderId;
  89982. private _multiview;
  89983. /**
  89984. * Instantiate a new shader material.
  89985. * 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.
  89986. * This returned material effects how the mesh will look based on the code in the shaders.
  89987. * @see http://doc.babylonjs.com/how_to/shader_material
  89988. * @param name Define the name of the material in the scene
  89989. * @param scene Define the scene the material belongs to
  89990. * @param shaderPath Defines the route to the shader code in one of three ways:
  89991. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89992. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89993. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89994. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89995. * @param options Define the options used to create the shader
  89996. */
  89997. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89998. /**
  89999. * Gets the shader path used to define the shader code
  90000. * It can be modified to trigger a new compilation
  90001. */
  90002. get shaderPath(): any;
  90003. /**
  90004. * Sets the shader path used to define the shader code
  90005. * It can be modified to trigger a new compilation
  90006. */
  90007. set shaderPath(shaderPath: any);
  90008. /**
  90009. * Gets the options used to compile the shader.
  90010. * They can be modified to trigger a new compilation
  90011. */
  90012. get options(): IShaderMaterialOptions;
  90013. /**
  90014. * Gets the current class name of the material e.g. "ShaderMaterial"
  90015. * Mainly use in serialization.
  90016. * @returns the class name
  90017. */
  90018. getClassName(): string;
  90019. /**
  90020. * Specifies if the material will require alpha blending
  90021. * @returns a boolean specifying if alpha blending is needed
  90022. */
  90023. needAlphaBlending(): boolean;
  90024. /**
  90025. * Specifies if this material should be rendered in alpha test mode
  90026. * @returns a boolean specifying if an alpha test is needed.
  90027. */
  90028. needAlphaTesting(): boolean;
  90029. private _checkUniform;
  90030. /**
  90031. * Set a texture in the shader.
  90032. * @param name Define the name of the uniform samplers as defined in the shader
  90033. * @param texture Define the texture to bind to this sampler
  90034. * @return the material itself allowing "fluent" like uniform updates
  90035. */
  90036. setTexture(name: string, texture: Texture): ShaderMaterial;
  90037. /**
  90038. * Set a texture array in the shader.
  90039. * @param name Define the name of the uniform sampler array as defined in the shader
  90040. * @param textures Define the list of textures to bind to this sampler
  90041. * @return the material itself allowing "fluent" like uniform updates
  90042. */
  90043. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  90044. /**
  90045. * Set a float in the shader.
  90046. * @param name Define the name of the uniform as defined in the shader
  90047. * @param value Define the value to give to the uniform
  90048. * @return the material itself allowing "fluent" like uniform updates
  90049. */
  90050. setFloat(name: string, value: number): ShaderMaterial;
  90051. /**
  90052. * Set a int in the shader.
  90053. * @param name Define the name of the uniform as defined in the shader
  90054. * @param value Define the value to give to the uniform
  90055. * @return the material itself allowing "fluent" like uniform updates
  90056. */
  90057. setInt(name: string, value: number): ShaderMaterial;
  90058. /**
  90059. * Set an array of floats in the shader.
  90060. * @param name Define the name of the uniform as defined in the shader
  90061. * @param value Define the value to give to the uniform
  90062. * @return the material itself allowing "fluent" like uniform updates
  90063. */
  90064. setFloats(name: string, value: number[]): ShaderMaterial;
  90065. /**
  90066. * Set a vec3 in the shader from a Color3.
  90067. * @param name Define the name of the uniform as defined in the shader
  90068. * @param value Define the value to give to the uniform
  90069. * @return the material itself allowing "fluent" like uniform updates
  90070. */
  90071. setColor3(name: string, value: Color3): ShaderMaterial;
  90072. /**
  90073. * Set a vec3 array in the shader from a Color3 array.
  90074. * @param name Define the name of the uniform as defined in the shader
  90075. * @param value Define the value to give to the uniform
  90076. * @return the material itself allowing "fluent" like uniform updates
  90077. */
  90078. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90079. /**
  90080. * Set a vec4 in the shader from a Color4.
  90081. * @param name Define the name of the uniform as defined in the shader
  90082. * @param value Define the value to give to the uniform
  90083. * @return the material itself allowing "fluent" like uniform updates
  90084. */
  90085. setColor4(name: string, value: Color4): ShaderMaterial;
  90086. /**
  90087. * Set a vec4 array in the shader from a Color4 array.
  90088. * @param name Define the name of the uniform as defined in the shader
  90089. * @param value Define the value to give to the uniform
  90090. * @return the material itself allowing "fluent" like uniform updates
  90091. */
  90092. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90093. /**
  90094. * Set a vec2 in the shader from a Vector2.
  90095. * @param name Define the name of the uniform as defined in the shader
  90096. * @param value Define the value to give to the uniform
  90097. * @return the material itself allowing "fluent" like uniform updates
  90098. */
  90099. setVector2(name: string, value: Vector2): ShaderMaterial;
  90100. /**
  90101. * Set a vec3 in the shader from a Vector3.
  90102. * @param name Define the name of the uniform as defined in the shader
  90103. * @param value Define the value to give to the uniform
  90104. * @return the material itself allowing "fluent" like uniform updates
  90105. */
  90106. setVector3(name: string, value: Vector3): ShaderMaterial;
  90107. /**
  90108. * Set a vec4 in the shader from a Vector4.
  90109. * @param name Define the name of the uniform as defined in the shader
  90110. * @param value Define the value to give to the uniform
  90111. * @return the material itself allowing "fluent" like uniform updates
  90112. */
  90113. setVector4(name: string, value: Vector4): ShaderMaterial;
  90114. /**
  90115. * Set a mat4 in the shader from a Matrix.
  90116. * @param name Define the name of the uniform as defined in the shader
  90117. * @param value Define the value to give to the uniform
  90118. * @return the material itself allowing "fluent" like uniform updates
  90119. */
  90120. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90121. /**
  90122. * Set a float32Array in the shader from a matrix array.
  90123. * @param name Define the name of the uniform as defined in the shader
  90124. * @param value Define the value to give to the uniform
  90125. * @return the material itself allowing "fluent" like uniform updates
  90126. */
  90127. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90128. /**
  90129. * Set a mat3 in the shader from a Float32Array.
  90130. * @param name Define the name of the uniform as defined in the shader
  90131. * @param value Define the value to give to the uniform
  90132. * @return the material itself allowing "fluent" like uniform updates
  90133. */
  90134. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90135. /**
  90136. * Set a mat2 in the shader from a Float32Array.
  90137. * @param name Define the name of the uniform as defined in the shader
  90138. * @param value Define the value to give to the uniform
  90139. * @return the material itself allowing "fluent" like uniform updates
  90140. */
  90141. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90142. /**
  90143. * Set a vec2 array in the shader from a number array.
  90144. * @param name Define the name of the uniform as defined in the shader
  90145. * @param value Define the value to give to the uniform
  90146. * @return the material itself allowing "fluent" like uniform updates
  90147. */
  90148. setArray2(name: string, value: number[]): ShaderMaterial;
  90149. /**
  90150. * Set a vec3 array in the shader from a number array.
  90151. * @param name Define the name of the uniform as defined in the shader
  90152. * @param value Define the value to give to the uniform
  90153. * @return the material itself allowing "fluent" like uniform updates
  90154. */
  90155. setArray3(name: string, value: number[]): ShaderMaterial;
  90156. /**
  90157. * Set a vec4 array in the shader from a number array.
  90158. * @param name Define the name of the uniform as defined in the shader
  90159. * @param value Define the value to give to the uniform
  90160. * @return the material itself allowing "fluent" like uniform updates
  90161. */
  90162. setArray4(name: string, value: number[]): ShaderMaterial;
  90163. private _checkCache;
  90164. /**
  90165. * Specifies that the submesh is ready to be used
  90166. * @param mesh defines the mesh to check
  90167. * @param subMesh defines which submesh to check
  90168. * @param useInstances specifies that instances should be used
  90169. * @returns a boolean indicating that the submesh is ready or not
  90170. */
  90171. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90172. /**
  90173. * Checks if the material is ready to render the requested mesh
  90174. * @param mesh Define the mesh to render
  90175. * @param useInstances Define whether or not the material is used with instances
  90176. * @returns true if ready, otherwise false
  90177. */
  90178. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90179. /**
  90180. * Binds the world matrix to the material
  90181. * @param world defines the world transformation matrix
  90182. */
  90183. bindOnlyWorldMatrix(world: Matrix): void;
  90184. /**
  90185. * Binds the material to the mesh
  90186. * @param world defines the world transformation matrix
  90187. * @param mesh defines the mesh to bind the material to
  90188. */
  90189. bind(world: Matrix, mesh?: Mesh): void;
  90190. /**
  90191. * Gets the active textures from the material
  90192. * @returns an array of textures
  90193. */
  90194. getActiveTextures(): BaseTexture[];
  90195. /**
  90196. * Specifies if the material uses a texture
  90197. * @param texture defines the texture to check against the material
  90198. * @returns a boolean specifying if the material uses the texture
  90199. */
  90200. hasTexture(texture: BaseTexture): boolean;
  90201. /**
  90202. * Makes a duplicate of the material, and gives it a new name
  90203. * @param name defines the new name for the duplicated material
  90204. * @returns the cloned material
  90205. */
  90206. clone(name: string): ShaderMaterial;
  90207. /**
  90208. * Disposes the material
  90209. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90210. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90211. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90212. */
  90213. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90214. /**
  90215. * Serializes this material in a JSON representation
  90216. * @returns the serialized material object
  90217. */
  90218. serialize(): any;
  90219. /**
  90220. * Creates a shader material from parsed shader material data
  90221. * @param source defines the JSON represnetation of the material
  90222. * @param scene defines the hosting scene
  90223. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90224. * @returns a new material
  90225. */
  90226. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90227. }
  90228. }
  90229. declare module BABYLON {
  90230. /** @hidden */
  90231. export var colorPixelShader: {
  90232. name: string;
  90233. shader: string;
  90234. };
  90235. }
  90236. declare module BABYLON {
  90237. /** @hidden */
  90238. export var colorVertexShader: {
  90239. name: string;
  90240. shader: string;
  90241. };
  90242. }
  90243. declare module BABYLON {
  90244. /**
  90245. * Line mesh
  90246. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90247. */
  90248. export class LinesMesh extends Mesh {
  90249. /**
  90250. * If vertex color should be applied to the mesh
  90251. */
  90252. readonly useVertexColor?: boolean | undefined;
  90253. /**
  90254. * If vertex alpha should be applied to the mesh
  90255. */
  90256. readonly useVertexAlpha?: boolean | undefined;
  90257. /**
  90258. * Color of the line (Default: White)
  90259. */
  90260. color: Color3;
  90261. /**
  90262. * Alpha of the line (Default: 1)
  90263. */
  90264. alpha: number;
  90265. /**
  90266. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90267. * This margin is expressed in world space coordinates, so its value may vary.
  90268. * Default value is 0.1
  90269. */
  90270. intersectionThreshold: number;
  90271. private _colorShader;
  90272. private color4;
  90273. /**
  90274. * Creates a new LinesMesh
  90275. * @param name defines the name
  90276. * @param scene defines the hosting scene
  90277. * @param parent defines the parent mesh if any
  90278. * @param source defines the optional source LinesMesh used to clone data from
  90279. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90280. * When false, achieved by calling a clone(), also passing False.
  90281. * This will make creation of children, recursive.
  90282. * @param useVertexColor defines if this LinesMesh supports vertex color
  90283. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90284. */
  90285. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90286. /**
  90287. * If vertex color should be applied to the mesh
  90288. */
  90289. useVertexColor?: boolean | undefined,
  90290. /**
  90291. * If vertex alpha should be applied to the mesh
  90292. */
  90293. useVertexAlpha?: boolean | undefined);
  90294. private _addClipPlaneDefine;
  90295. private _removeClipPlaneDefine;
  90296. isReady(): boolean;
  90297. /**
  90298. * Returns the string "LineMesh"
  90299. */
  90300. getClassName(): string;
  90301. /**
  90302. * @hidden
  90303. */
  90304. get material(): Material;
  90305. /**
  90306. * @hidden
  90307. */
  90308. set material(value: Material);
  90309. /**
  90310. * @hidden
  90311. */
  90312. get checkCollisions(): boolean;
  90313. /** @hidden */
  90314. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90315. /** @hidden */
  90316. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90317. /**
  90318. * Disposes of the line mesh
  90319. * @param doNotRecurse If children should be disposed
  90320. */
  90321. dispose(doNotRecurse?: boolean): void;
  90322. /**
  90323. * Returns a new LineMesh object cloned from the current one.
  90324. */
  90325. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90326. /**
  90327. * Creates a new InstancedLinesMesh object from the mesh model.
  90328. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90329. * @param name defines the name of the new instance
  90330. * @returns a new InstancedLinesMesh
  90331. */
  90332. createInstance(name: string): InstancedLinesMesh;
  90333. }
  90334. /**
  90335. * Creates an instance based on a source LinesMesh
  90336. */
  90337. export class InstancedLinesMesh extends InstancedMesh {
  90338. /**
  90339. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90340. * This margin is expressed in world space coordinates, so its value may vary.
  90341. * Initilized with the intersectionThreshold value of the source LinesMesh
  90342. */
  90343. intersectionThreshold: number;
  90344. constructor(name: string, source: LinesMesh);
  90345. /**
  90346. * Returns the string "InstancedLinesMesh".
  90347. */
  90348. getClassName(): string;
  90349. }
  90350. }
  90351. declare module BABYLON {
  90352. /** @hidden */
  90353. export var linePixelShader: {
  90354. name: string;
  90355. shader: string;
  90356. };
  90357. }
  90358. declare module BABYLON {
  90359. /** @hidden */
  90360. export var lineVertexShader: {
  90361. name: string;
  90362. shader: string;
  90363. };
  90364. }
  90365. declare module BABYLON {
  90366. interface AbstractMesh {
  90367. /**
  90368. * Gets the edgesRenderer associated with the mesh
  90369. */
  90370. edgesRenderer: Nullable<EdgesRenderer>;
  90371. }
  90372. interface LinesMesh {
  90373. /**
  90374. * Enables the edge rendering mode on the mesh.
  90375. * This mode makes the mesh edges visible
  90376. * @param epsilon defines the maximal distance between two angles to detect a face
  90377. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90378. * @returns the currentAbstractMesh
  90379. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90380. */
  90381. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90382. }
  90383. interface InstancedLinesMesh {
  90384. /**
  90385. * Enables the edge rendering mode on the mesh.
  90386. * This mode makes the mesh edges visible
  90387. * @param epsilon defines the maximal distance between two angles to detect a face
  90388. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90389. * @returns the current InstancedLinesMesh
  90390. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90391. */
  90392. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90393. }
  90394. /**
  90395. * Defines the minimum contract an Edges renderer should follow.
  90396. */
  90397. export interface IEdgesRenderer extends IDisposable {
  90398. /**
  90399. * Gets or sets a boolean indicating if the edgesRenderer is active
  90400. */
  90401. isEnabled: boolean;
  90402. /**
  90403. * Renders the edges of the attached mesh,
  90404. */
  90405. render(): void;
  90406. /**
  90407. * Checks wether or not the edges renderer is ready to render.
  90408. * @return true if ready, otherwise false.
  90409. */
  90410. isReady(): boolean;
  90411. }
  90412. /**
  90413. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90414. */
  90415. export class EdgesRenderer implements IEdgesRenderer {
  90416. /**
  90417. * Define the size of the edges with an orthographic camera
  90418. */
  90419. edgesWidthScalerForOrthographic: number;
  90420. /**
  90421. * Define the size of the edges with a perspective camera
  90422. */
  90423. edgesWidthScalerForPerspective: number;
  90424. protected _source: AbstractMesh;
  90425. protected _linesPositions: number[];
  90426. protected _linesNormals: number[];
  90427. protected _linesIndices: number[];
  90428. protected _epsilon: number;
  90429. protected _indicesCount: number;
  90430. protected _lineShader: ShaderMaterial;
  90431. protected _ib: DataBuffer;
  90432. protected _buffers: {
  90433. [key: string]: Nullable<VertexBuffer>;
  90434. };
  90435. protected _checkVerticesInsteadOfIndices: boolean;
  90436. private _meshRebuildObserver;
  90437. private _meshDisposeObserver;
  90438. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90439. isEnabled: boolean;
  90440. /**
  90441. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90442. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90443. * @param source Mesh used to create edges
  90444. * @param epsilon sum of angles in adjacency to check for edge
  90445. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90446. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90447. */
  90448. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90449. protected _prepareRessources(): void;
  90450. /** @hidden */
  90451. _rebuild(): void;
  90452. /**
  90453. * Releases the required resources for the edges renderer
  90454. */
  90455. dispose(): void;
  90456. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90457. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90458. /**
  90459. * Checks if the pair of p0 and p1 is en edge
  90460. * @param faceIndex
  90461. * @param edge
  90462. * @param faceNormals
  90463. * @param p0
  90464. * @param p1
  90465. * @private
  90466. */
  90467. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90468. /**
  90469. * push line into the position, normal and index buffer
  90470. * @protected
  90471. */
  90472. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90473. /**
  90474. * Generates lines edges from adjacencjes
  90475. * @private
  90476. */
  90477. _generateEdgesLines(): void;
  90478. /**
  90479. * Checks wether or not the edges renderer is ready to render.
  90480. * @return true if ready, otherwise false.
  90481. */
  90482. isReady(): boolean;
  90483. /**
  90484. * Renders the edges of the attached mesh,
  90485. */
  90486. render(): void;
  90487. }
  90488. /**
  90489. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90490. */
  90491. export class LineEdgesRenderer extends EdgesRenderer {
  90492. /**
  90493. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90494. * @param source LineMesh used to generate edges
  90495. * @param epsilon not important (specified angle for edge detection)
  90496. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90497. */
  90498. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90499. /**
  90500. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90501. */
  90502. _generateEdgesLines(): void;
  90503. }
  90504. }
  90505. declare module BABYLON {
  90506. /**
  90507. * This represents the object necessary to create a rendering group.
  90508. * This is exclusively used and created by the rendering manager.
  90509. * To modify the behavior, you use the available helpers in your scene or meshes.
  90510. * @hidden
  90511. */
  90512. export class RenderingGroup {
  90513. index: number;
  90514. private static _zeroVector;
  90515. private _scene;
  90516. private _opaqueSubMeshes;
  90517. private _transparentSubMeshes;
  90518. private _alphaTestSubMeshes;
  90519. private _depthOnlySubMeshes;
  90520. private _particleSystems;
  90521. private _spriteManagers;
  90522. private _opaqueSortCompareFn;
  90523. private _alphaTestSortCompareFn;
  90524. private _transparentSortCompareFn;
  90525. private _renderOpaque;
  90526. private _renderAlphaTest;
  90527. private _renderTransparent;
  90528. /** @hidden */
  90529. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90530. onBeforeTransparentRendering: () => void;
  90531. /**
  90532. * Set the opaque sort comparison function.
  90533. * If null the sub meshes will be render in the order they were created
  90534. */
  90535. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90536. /**
  90537. * Set the alpha test sort comparison function.
  90538. * If null the sub meshes will be render in the order they were created
  90539. */
  90540. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90541. /**
  90542. * Set the transparent sort comparison function.
  90543. * If null the sub meshes will be render in the order they were created
  90544. */
  90545. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90546. /**
  90547. * Creates a new rendering group.
  90548. * @param index The rendering group index
  90549. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90550. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90551. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90552. */
  90553. 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>);
  90554. /**
  90555. * Render all the sub meshes contained in the group.
  90556. * @param customRenderFunction Used to override the default render behaviour of the group.
  90557. * @returns true if rendered some submeshes.
  90558. */
  90559. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90560. /**
  90561. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90562. * @param subMeshes The submeshes to render
  90563. */
  90564. private renderOpaqueSorted;
  90565. /**
  90566. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90567. * @param subMeshes The submeshes to render
  90568. */
  90569. private renderAlphaTestSorted;
  90570. /**
  90571. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90572. * @param subMeshes The submeshes to render
  90573. */
  90574. private renderTransparentSorted;
  90575. /**
  90576. * Renders the submeshes in a specified order.
  90577. * @param subMeshes The submeshes to sort before render
  90578. * @param sortCompareFn The comparison function use to sort
  90579. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90580. * @param transparent Specifies to activate blending if true
  90581. */
  90582. private static renderSorted;
  90583. /**
  90584. * Renders the submeshes in the order they were dispatched (no sort applied).
  90585. * @param subMeshes The submeshes to render
  90586. */
  90587. private static renderUnsorted;
  90588. /**
  90589. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90590. * are rendered back to front if in the same alpha index.
  90591. *
  90592. * @param a The first submesh
  90593. * @param b The second submesh
  90594. * @returns The result of the comparison
  90595. */
  90596. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90597. /**
  90598. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90599. * are rendered back to front.
  90600. *
  90601. * @param a The first submesh
  90602. * @param b The second submesh
  90603. * @returns The result of the comparison
  90604. */
  90605. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90606. /**
  90607. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90608. * are rendered front to back (prevent overdraw).
  90609. *
  90610. * @param a The first submesh
  90611. * @param b The second submesh
  90612. * @returns The result of the comparison
  90613. */
  90614. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90615. /**
  90616. * Resets the different lists of submeshes to prepare a new frame.
  90617. */
  90618. prepare(): void;
  90619. dispose(): void;
  90620. /**
  90621. * Inserts the submesh in its correct queue depending on its material.
  90622. * @param subMesh The submesh to dispatch
  90623. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90624. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90625. */
  90626. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90627. dispatchSprites(spriteManager: ISpriteManager): void;
  90628. dispatchParticles(particleSystem: IParticleSystem): void;
  90629. private _renderParticles;
  90630. private _renderSprites;
  90631. }
  90632. }
  90633. declare module BABYLON {
  90634. /**
  90635. * Interface describing the different options available in the rendering manager
  90636. * regarding Auto Clear between groups.
  90637. */
  90638. export interface IRenderingManagerAutoClearSetup {
  90639. /**
  90640. * Defines whether or not autoclear is enable.
  90641. */
  90642. autoClear: boolean;
  90643. /**
  90644. * Defines whether or not to autoclear the depth buffer.
  90645. */
  90646. depth: boolean;
  90647. /**
  90648. * Defines whether or not to autoclear the stencil buffer.
  90649. */
  90650. stencil: boolean;
  90651. }
  90652. /**
  90653. * This class is used by the onRenderingGroupObservable
  90654. */
  90655. export class RenderingGroupInfo {
  90656. /**
  90657. * The Scene that being rendered
  90658. */
  90659. scene: Scene;
  90660. /**
  90661. * The camera currently used for the rendering pass
  90662. */
  90663. camera: Nullable<Camera>;
  90664. /**
  90665. * The ID of the renderingGroup being processed
  90666. */
  90667. renderingGroupId: number;
  90668. }
  90669. /**
  90670. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90671. * It is enable to manage the different groups as well as the different necessary sort functions.
  90672. * This should not be used directly aside of the few static configurations
  90673. */
  90674. export class RenderingManager {
  90675. /**
  90676. * The max id used for rendering groups (not included)
  90677. */
  90678. static MAX_RENDERINGGROUPS: number;
  90679. /**
  90680. * The min id used for rendering groups (included)
  90681. */
  90682. static MIN_RENDERINGGROUPS: number;
  90683. /**
  90684. * Used to globally prevent autoclearing scenes.
  90685. */
  90686. static AUTOCLEAR: boolean;
  90687. /**
  90688. * @hidden
  90689. */
  90690. _useSceneAutoClearSetup: boolean;
  90691. private _scene;
  90692. private _renderingGroups;
  90693. private _depthStencilBufferAlreadyCleaned;
  90694. private _autoClearDepthStencil;
  90695. private _customOpaqueSortCompareFn;
  90696. private _customAlphaTestSortCompareFn;
  90697. private _customTransparentSortCompareFn;
  90698. private _renderingGroupInfo;
  90699. /**
  90700. * Instantiates a new rendering group for a particular scene
  90701. * @param scene Defines the scene the groups belongs to
  90702. */
  90703. constructor(scene: Scene);
  90704. private _clearDepthStencilBuffer;
  90705. /**
  90706. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90707. * @hidden
  90708. */
  90709. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90710. /**
  90711. * Resets the different information of the group to prepare a new frame
  90712. * @hidden
  90713. */
  90714. reset(): void;
  90715. /**
  90716. * Dispose and release the group and its associated resources.
  90717. * @hidden
  90718. */
  90719. dispose(): void;
  90720. /**
  90721. * Clear the info related to rendering groups preventing retention points during dispose.
  90722. */
  90723. freeRenderingGroups(): void;
  90724. private _prepareRenderingGroup;
  90725. /**
  90726. * Add a sprite manager to the rendering manager in order to render it this frame.
  90727. * @param spriteManager Define the sprite manager to render
  90728. */
  90729. dispatchSprites(spriteManager: ISpriteManager): void;
  90730. /**
  90731. * Add a particle system to the rendering manager in order to render it this frame.
  90732. * @param particleSystem Define the particle system to render
  90733. */
  90734. dispatchParticles(particleSystem: IParticleSystem): void;
  90735. /**
  90736. * Add a submesh to the manager in order to render it this frame
  90737. * @param subMesh The submesh to dispatch
  90738. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90739. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90740. */
  90741. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90742. /**
  90743. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90744. * This allowed control for front to back rendering or reversly depending of the special needs.
  90745. *
  90746. * @param renderingGroupId The rendering group id corresponding to its index
  90747. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90748. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90749. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90750. */
  90751. 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;
  90752. /**
  90753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90754. *
  90755. * @param renderingGroupId The rendering group id corresponding to its index
  90756. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90757. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90758. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90759. */
  90760. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90761. /**
  90762. * Gets the current auto clear configuration for one rendering group of the rendering
  90763. * manager.
  90764. * @param index the rendering group index to get the information for
  90765. * @returns The auto clear setup for the requested rendering group
  90766. */
  90767. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90768. }
  90769. }
  90770. declare module BABYLON {
  90771. /**
  90772. * This Helps creating a texture that will be created from a camera in your scene.
  90773. * It is basically a dynamic texture that could be used to create special effects for instance.
  90774. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  90775. */
  90776. export class RenderTargetTexture extends Texture {
  90777. isCube: boolean;
  90778. /**
  90779. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  90780. */
  90781. static readonly REFRESHRATE_RENDER_ONCE: number;
  90782. /**
  90783. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  90784. */
  90785. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  90786. /**
  90787. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  90788. * the central point of your effect and can save a lot of performances.
  90789. */
  90790. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  90791. /**
  90792. * Use this predicate to dynamically define the list of mesh you want to render.
  90793. * If set, the renderList property will be overwritten.
  90794. */
  90795. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  90796. private _renderList;
  90797. /**
  90798. * Use this list to define the list of mesh you want to render.
  90799. */
  90800. get renderList(): Nullable<Array<AbstractMesh>>;
  90801. set renderList(value: Nullable<Array<AbstractMesh>>);
  90802. private _hookArray;
  90803. /**
  90804. * Define if particles should be rendered in your texture.
  90805. */
  90806. renderParticles: boolean;
  90807. /**
  90808. * Define if sprites should be rendered in your texture.
  90809. */
  90810. renderSprites: boolean;
  90811. /**
  90812. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  90813. */
  90814. coordinatesMode: number;
  90815. /**
  90816. * Define the camera used to render the texture.
  90817. */
  90818. activeCamera: Nullable<Camera>;
  90819. /**
  90820. * Override the render function of the texture with your own one.
  90821. */
  90822. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  90823. /**
  90824. * Define if camera post processes should be use while rendering the texture.
  90825. */
  90826. useCameraPostProcesses: boolean;
  90827. /**
  90828. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  90829. */
  90830. ignoreCameraViewport: boolean;
  90831. private _postProcessManager;
  90832. private _postProcesses;
  90833. private _resizeObserver;
  90834. /**
  90835. * An event triggered when the texture is unbind.
  90836. */
  90837. onBeforeBindObservable: Observable<RenderTargetTexture>;
  90838. /**
  90839. * An event triggered when the texture is unbind.
  90840. */
  90841. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  90842. private _onAfterUnbindObserver;
  90843. /**
  90844. * Set a after unbind callback in the texture.
  90845. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  90846. */
  90847. set onAfterUnbind(callback: () => void);
  90848. /**
  90849. * An event triggered before rendering the texture
  90850. */
  90851. onBeforeRenderObservable: Observable<number>;
  90852. private _onBeforeRenderObserver;
  90853. /**
  90854. * Set a before render callback in the texture.
  90855. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  90856. */
  90857. set onBeforeRender(callback: (faceIndex: number) => void);
  90858. /**
  90859. * An event triggered after rendering the texture
  90860. */
  90861. onAfterRenderObservable: Observable<number>;
  90862. private _onAfterRenderObserver;
  90863. /**
  90864. * Set a after render callback in the texture.
  90865. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  90866. */
  90867. set onAfterRender(callback: (faceIndex: number) => void);
  90868. /**
  90869. * An event triggered after the texture clear
  90870. */
  90871. onClearObservable: Observable<Engine>;
  90872. private _onClearObserver;
  90873. /**
  90874. * Set a clear callback in the texture.
  90875. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  90876. */
  90877. set onClear(callback: (Engine: Engine) => void);
  90878. /**
  90879. * An event triggered when the texture is resized.
  90880. */
  90881. onResizeObservable: Observable<RenderTargetTexture>;
  90882. /**
  90883. * Define the clear color of the Render Target if it should be different from the scene.
  90884. */
  90885. clearColor: Color4;
  90886. protected _size: number | {
  90887. width: number;
  90888. height: number;
  90889. };
  90890. protected _initialSizeParameter: number | {
  90891. width: number;
  90892. height: number;
  90893. } | {
  90894. ratio: number;
  90895. };
  90896. protected _sizeRatio: Nullable<number>;
  90897. /** @hidden */
  90898. _generateMipMaps: boolean;
  90899. protected _renderingManager: RenderingManager;
  90900. /** @hidden */
  90901. _waitingRenderList: string[];
  90902. protected _doNotChangeAspectRatio: boolean;
  90903. protected _currentRefreshId: number;
  90904. protected _refreshRate: number;
  90905. protected _textureMatrix: Matrix;
  90906. protected _samples: number;
  90907. protected _renderTargetOptions: RenderTargetCreationOptions;
  90908. /**
  90909. * Gets render target creation options that were used.
  90910. */
  90911. get renderTargetOptions(): RenderTargetCreationOptions;
  90912. protected _engine: Engine;
  90913. protected _onRatioRescale(): void;
  90914. /**
  90915. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  90916. * It must define where the camera used to render the texture is set
  90917. */
  90918. boundingBoxPosition: Vector3;
  90919. private _boundingBoxSize;
  90920. /**
  90921. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  90922. * When defined, the cubemap will switch to local mode
  90923. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  90924. * @example https://www.babylonjs-playground.com/#RNASML
  90925. */
  90926. set boundingBoxSize(value: Vector3);
  90927. get boundingBoxSize(): Vector3;
  90928. /**
  90929. * In case the RTT has been created with a depth texture, get the associated
  90930. * depth texture.
  90931. * Otherwise, return null.
  90932. */
  90933. depthStencilTexture: Nullable<InternalTexture>;
  90934. /**
  90935. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  90936. * or used a shadow, depth texture...
  90937. * @param name The friendly name of the texture
  90938. * @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)
  90939. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  90940. * @param generateMipMaps True if mip maps need to be generated after render.
  90941. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  90942. * @param type The type of the buffer in the RTT (int, half float, float...)
  90943. * @param isCube True if a cube texture needs to be created
  90944. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  90945. * @param generateDepthBuffer True to generate a depth buffer
  90946. * @param generateStencilBuffer True to generate a stencil buffer
  90947. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  90948. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  90949. * @param delayAllocation if the texture allocation should be delayed (default: false)
  90950. */
  90951. constructor(name: string, size: number | {
  90952. width: number;
  90953. height: number;
  90954. } | {
  90955. ratio: number;
  90956. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  90957. /**
  90958. * Creates a depth stencil texture.
  90959. * This is only available in WebGL 2 or with the depth texture extension available.
  90960. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  90961. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  90962. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  90963. */
  90964. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  90965. private _processSizeParameter;
  90966. /**
  90967. * Define the number of samples to use in case of MSAA.
  90968. * It defaults to one meaning no MSAA has been enabled.
  90969. */
  90970. get samples(): number;
  90971. set samples(value: number);
  90972. /**
  90973. * Resets the refresh counter of the texture and start bak from scratch.
  90974. * Could be useful to regenerate the texture if it is setup to render only once.
  90975. */
  90976. resetRefreshCounter(): void;
  90977. /**
  90978. * Define the refresh rate of the texture or the rendering frequency.
  90979. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90980. */
  90981. get refreshRate(): number;
  90982. set refreshRate(value: number);
  90983. /**
  90984. * Adds a post process to the render target rendering passes.
  90985. * @param postProcess define the post process to add
  90986. */
  90987. addPostProcess(postProcess: PostProcess): void;
  90988. /**
  90989. * Clear all the post processes attached to the render target
  90990. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  90991. */
  90992. clearPostProcesses(dispose?: boolean): void;
  90993. /**
  90994. * Remove one of the post process from the list of attached post processes to the texture
  90995. * @param postProcess define the post process to remove from the list
  90996. */
  90997. removePostProcess(postProcess: PostProcess): void;
  90998. /** @hidden */
  90999. _shouldRender(): boolean;
  91000. /**
  91001. * Gets the actual render size of the texture.
  91002. * @returns the width of the render size
  91003. */
  91004. getRenderSize(): number;
  91005. /**
  91006. * Gets the actual render width of the texture.
  91007. * @returns the width of the render size
  91008. */
  91009. getRenderWidth(): number;
  91010. /**
  91011. * Gets the actual render height of the texture.
  91012. * @returns the height of the render size
  91013. */
  91014. getRenderHeight(): number;
  91015. /**
  91016. * Get if the texture can be rescaled or not.
  91017. */
  91018. get canRescale(): boolean;
  91019. /**
  91020. * Resize the texture using a ratio.
  91021. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  91022. */
  91023. scale(ratio: number): void;
  91024. /**
  91025. * Get the texture reflection matrix used to rotate/transform the reflection.
  91026. * @returns the reflection matrix
  91027. */
  91028. getReflectionTextureMatrix(): Matrix;
  91029. /**
  91030. * Resize the texture to a new desired size.
  91031. * Be carrefull as it will recreate all the data in the new texture.
  91032. * @param size Define the new size. It can be:
  91033. * - a number for squared texture,
  91034. * - an object containing { width: number, height: number }
  91035. * - or an object containing a ratio { ratio: number }
  91036. */
  91037. resize(size: number | {
  91038. width: number;
  91039. height: number;
  91040. } | {
  91041. ratio: number;
  91042. }): void;
  91043. /**
  91044. * Renders all the objects from the render list into the texture.
  91045. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  91046. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  91047. */
  91048. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  91049. private _bestReflectionRenderTargetDimension;
  91050. /**
  91051. * @hidden
  91052. * @param faceIndex face index to bind to if this is a cubetexture
  91053. */
  91054. _bindFrameBuffer(faceIndex?: number): void;
  91055. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  91056. private renderToTarget;
  91057. /**
  91058. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91059. * This allowed control for front to back rendering or reversly depending of the special needs.
  91060. *
  91061. * @param renderingGroupId The rendering group id corresponding to its index
  91062. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91063. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91064. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91065. */
  91066. 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;
  91067. /**
  91068. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91069. *
  91070. * @param renderingGroupId The rendering group id corresponding to its index
  91071. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91072. */
  91073. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91074. /**
  91075. * Clones the texture.
  91076. * @returns the cloned texture
  91077. */
  91078. clone(): RenderTargetTexture;
  91079. /**
  91080. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  91081. * @returns The JSON representation of the texture
  91082. */
  91083. serialize(): any;
  91084. /**
  91085. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  91086. */
  91087. disposeFramebufferObjects(): void;
  91088. /**
  91089. * Dispose the texture and release its associated resources.
  91090. */
  91091. dispose(): void;
  91092. /** @hidden */
  91093. _rebuild(): void;
  91094. /**
  91095. * Clear the info related to rendering groups preventing retention point in material dispose.
  91096. */
  91097. freeRenderingGroups(): void;
  91098. /**
  91099. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  91100. * @returns the view count
  91101. */
  91102. getViewCount(): number;
  91103. }
  91104. }
  91105. declare module BABYLON {
  91106. /**
  91107. * Options for compiling materials.
  91108. */
  91109. export interface IMaterialCompilationOptions {
  91110. /**
  91111. * Defines whether clip planes are enabled.
  91112. */
  91113. clipPlane: boolean;
  91114. /**
  91115. * Defines whether instances are enabled.
  91116. */
  91117. useInstances: boolean;
  91118. }
  91119. /**
  91120. * Base class for the main features of a material in Babylon.js
  91121. */
  91122. export class Material implements IAnimatable {
  91123. /**
  91124. * Returns the triangle fill mode
  91125. */
  91126. static readonly TriangleFillMode: number;
  91127. /**
  91128. * Returns the wireframe mode
  91129. */
  91130. static readonly WireFrameFillMode: number;
  91131. /**
  91132. * Returns the point fill mode
  91133. */
  91134. static readonly PointFillMode: number;
  91135. /**
  91136. * Returns the point list draw mode
  91137. */
  91138. static readonly PointListDrawMode: number;
  91139. /**
  91140. * Returns the line list draw mode
  91141. */
  91142. static readonly LineListDrawMode: number;
  91143. /**
  91144. * Returns the line loop draw mode
  91145. */
  91146. static readonly LineLoopDrawMode: number;
  91147. /**
  91148. * Returns the line strip draw mode
  91149. */
  91150. static readonly LineStripDrawMode: number;
  91151. /**
  91152. * Returns the triangle strip draw mode
  91153. */
  91154. static readonly TriangleStripDrawMode: number;
  91155. /**
  91156. * Returns the triangle fan draw mode
  91157. */
  91158. static readonly TriangleFanDrawMode: number;
  91159. /**
  91160. * Stores the clock-wise side orientation
  91161. */
  91162. static readonly ClockWiseSideOrientation: number;
  91163. /**
  91164. * Stores the counter clock-wise side orientation
  91165. */
  91166. static readonly CounterClockWiseSideOrientation: number;
  91167. /**
  91168. * The dirty texture flag value
  91169. */
  91170. static readonly TextureDirtyFlag: number;
  91171. /**
  91172. * The dirty light flag value
  91173. */
  91174. static readonly LightDirtyFlag: number;
  91175. /**
  91176. * The dirty fresnel flag value
  91177. */
  91178. static readonly FresnelDirtyFlag: number;
  91179. /**
  91180. * The dirty attribute flag value
  91181. */
  91182. static readonly AttributesDirtyFlag: number;
  91183. /**
  91184. * The dirty misc flag value
  91185. */
  91186. static readonly MiscDirtyFlag: number;
  91187. /**
  91188. * The all dirty flag value
  91189. */
  91190. static readonly AllDirtyFlag: number;
  91191. /**
  91192. * The ID of the material
  91193. */
  91194. id: string;
  91195. /**
  91196. * Gets or sets the unique id of the material
  91197. */
  91198. uniqueId: number;
  91199. /**
  91200. * The name of the material
  91201. */
  91202. name: string;
  91203. /**
  91204. * Gets or sets user defined metadata
  91205. */
  91206. metadata: any;
  91207. /**
  91208. * For internal use only. Please do not use.
  91209. */
  91210. reservedDataStore: any;
  91211. /**
  91212. * Specifies if the ready state should be checked on each call
  91213. */
  91214. checkReadyOnEveryCall: boolean;
  91215. /**
  91216. * Specifies if the ready state should be checked once
  91217. */
  91218. checkReadyOnlyOnce: boolean;
  91219. /**
  91220. * The state of the material
  91221. */
  91222. state: string;
  91223. /**
  91224. * The alpha value of the material
  91225. */
  91226. protected _alpha: number;
  91227. /**
  91228. * List of inspectable custom properties (used by the Inspector)
  91229. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91230. */
  91231. inspectableCustomProperties: IInspectable[];
  91232. /**
  91233. * Sets the alpha value of the material
  91234. */
  91235. set alpha(value: number);
  91236. /**
  91237. * Gets the alpha value of the material
  91238. */
  91239. get alpha(): number;
  91240. /**
  91241. * Specifies if back face culling is enabled
  91242. */
  91243. protected _backFaceCulling: boolean;
  91244. /**
  91245. * Sets the back-face culling state
  91246. */
  91247. set backFaceCulling(value: boolean);
  91248. /**
  91249. * Gets the back-face culling state
  91250. */
  91251. get backFaceCulling(): boolean;
  91252. /**
  91253. * Stores the value for side orientation
  91254. */
  91255. sideOrientation: number;
  91256. /**
  91257. * Callback triggered when the material is compiled
  91258. */
  91259. onCompiled: Nullable<(effect: Effect) => void>;
  91260. /**
  91261. * Callback triggered when an error occurs
  91262. */
  91263. onError: Nullable<(effect: Effect, errors: string) => void>;
  91264. /**
  91265. * Callback triggered to get the render target textures
  91266. */
  91267. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  91268. /**
  91269. * Gets a boolean indicating that current material needs to register RTT
  91270. */
  91271. get hasRenderTargetTextures(): boolean;
  91272. /**
  91273. * Specifies if the material should be serialized
  91274. */
  91275. doNotSerialize: boolean;
  91276. /**
  91277. * @hidden
  91278. */
  91279. _storeEffectOnSubMeshes: boolean;
  91280. /**
  91281. * Stores the animations for the material
  91282. */
  91283. animations: Nullable<Array<Animation>>;
  91284. /**
  91285. * An event triggered when the material is disposed
  91286. */
  91287. onDisposeObservable: Observable<Material>;
  91288. /**
  91289. * An observer which watches for dispose events
  91290. */
  91291. private _onDisposeObserver;
  91292. private _onUnBindObservable;
  91293. /**
  91294. * Called during a dispose event
  91295. */
  91296. set onDispose(callback: () => void);
  91297. private _onBindObservable;
  91298. /**
  91299. * An event triggered when the material is bound
  91300. */
  91301. get onBindObservable(): Observable<AbstractMesh>;
  91302. /**
  91303. * An observer which watches for bind events
  91304. */
  91305. private _onBindObserver;
  91306. /**
  91307. * Called during a bind event
  91308. */
  91309. set onBind(callback: (Mesh: AbstractMesh) => void);
  91310. /**
  91311. * An event triggered when the material is unbound
  91312. */
  91313. get onUnBindObservable(): Observable<Material>;
  91314. /**
  91315. * Stores the value of the alpha mode
  91316. */
  91317. private _alphaMode;
  91318. /**
  91319. * Sets the value of the alpha mode.
  91320. *
  91321. * | Value | Type | Description |
  91322. * | --- | --- | --- |
  91323. * | 0 | ALPHA_DISABLE | |
  91324. * | 1 | ALPHA_ADD | |
  91325. * | 2 | ALPHA_COMBINE | |
  91326. * | 3 | ALPHA_SUBTRACT | |
  91327. * | 4 | ALPHA_MULTIPLY | |
  91328. * | 5 | ALPHA_MAXIMIZED | |
  91329. * | 6 | ALPHA_ONEONE | |
  91330. * | 7 | ALPHA_PREMULTIPLIED | |
  91331. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  91332. * | 9 | ALPHA_INTERPOLATE | |
  91333. * | 10 | ALPHA_SCREENMODE | |
  91334. *
  91335. */
  91336. set alphaMode(value: number);
  91337. /**
  91338. * Gets the value of the alpha mode
  91339. */
  91340. get alphaMode(): number;
  91341. /**
  91342. * Stores the state of the need depth pre-pass value
  91343. */
  91344. private _needDepthPrePass;
  91345. /**
  91346. * Sets the need depth pre-pass value
  91347. */
  91348. set needDepthPrePass(value: boolean);
  91349. /**
  91350. * Gets the depth pre-pass value
  91351. */
  91352. get needDepthPrePass(): boolean;
  91353. /**
  91354. * Specifies if depth writing should be disabled
  91355. */
  91356. disableDepthWrite: boolean;
  91357. /**
  91358. * Specifies if depth writing should be forced
  91359. */
  91360. forceDepthWrite: boolean;
  91361. /**
  91362. * Specifies the depth function that should be used. 0 means the default engine function
  91363. */
  91364. depthFunction: number;
  91365. /**
  91366. * Specifies if there should be a separate pass for culling
  91367. */
  91368. separateCullingPass: boolean;
  91369. /**
  91370. * Stores the state specifing if fog should be enabled
  91371. */
  91372. private _fogEnabled;
  91373. /**
  91374. * Sets the state for enabling fog
  91375. */
  91376. set fogEnabled(value: boolean);
  91377. /**
  91378. * Gets the value of the fog enabled state
  91379. */
  91380. get fogEnabled(): boolean;
  91381. /**
  91382. * Stores the size of points
  91383. */
  91384. pointSize: number;
  91385. /**
  91386. * Stores the z offset value
  91387. */
  91388. zOffset: number;
  91389. /**
  91390. * Gets a value specifying if wireframe mode is enabled
  91391. */
  91392. get wireframe(): boolean;
  91393. /**
  91394. * Sets the state of wireframe mode
  91395. */
  91396. set wireframe(value: boolean);
  91397. /**
  91398. * Gets the value specifying if point clouds are enabled
  91399. */
  91400. get pointsCloud(): boolean;
  91401. /**
  91402. * Sets the state of point cloud mode
  91403. */
  91404. set pointsCloud(value: boolean);
  91405. /**
  91406. * Gets the material fill mode
  91407. */
  91408. get fillMode(): number;
  91409. /**
  91410. * Sets the material fill mode
  91411. */
  91412. set fillMode(value: number);
  91413. /**
  91414. * @hidden
  91415. * Stores the effects for the material
  91416. */
  91417. _effect: Nullable<Effect>;
  91418. /**
  91419. * @hidden
  91420. * Specifies if the material was previously ready
  91421. */
  91422. _wasPreviouslyReady: boolean;
  91423. /**
  91424. * Specifies if uniform buffers should be used
  91425. */
  91426. private _useUBO;
  91427. /**
  91428. * Stores a reference to the scene
  91429. */
  91430. private _scene;
  91431. /**
  91432. * Stores the fill mode state
  91433. */
  91434. private _fillMode;
  91435. /**
  91436. * Specifies if the depth write state should be cached
  91437. */
  91438. private _cachedDepthWriteState;
  91439. /**
  91440. * Specifies if the depth function state should be cached
  91441. */
  91442. private _cachedDepthFunctionState;
  91443. /**
  91444. * Stores the uniform buffer
  91445. */
  91446. protected _uniformBuffer: UniformBuffer;
  91447. /** @hidden */
  91448. _indexInSceneMaterialArray: number;
  91449. /** @hidden */
  91450. meshMap: Nullable<{
  91451. [id: string]: AbstractMesh | undefined;
  91452. }>;
  91453. /**
  91454. * Creates a material instance
  91455. * @param name defines the name of the material
  91456. * @param scene defines the scene to reference
  91457. * @param doNotAdd specifies if the material should be added to the scene
  91458. */
  91459. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  91460. /**
  91461. * Returns a string representation of the current material
  91462. * @param fullDetails defines a boolean indicating which levels of logging is desired
  91463. * @returns a string with material information
  91464. */
  91465. toString(fullDetails?: boolean): string;
  91466. /**
  91467. * Gets the class name of the material
  91468. * @returns a string with the class name of the material
  91469. */
  91470. getClassName(): string;
  91471. /**
  91472. * Specifies if updates for the material been locked
  91473. */
  91474. get isFrozen(): boolean;
  91475. /**
  91476. * Locks updates for the material
  91477. */
  91478. freeze(): void;
  91479. /**
  91480. * Unlocks updates for the material
  91481. */
  91482. unfreeze(): void;
  91483. /**
  91484. * Specifies if the material is ready to be used
  91485. * @param mesh defines the mesh to check
  91486. * @param useInstances specifies if instances should be used
  91487. * @returns a boolean indicating if the material is ready to be used
  91488. */
  91489. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91490. /**
  91491. * Specifies that the submesh is ready to be used
  91492. * @param mesh defines the mesh to check
  91493. * @param subMesh defines which submesh to check
  91494. * @param useInstances specifies that instances should be used
  91495. * @returns a boolean indicating that the submesh is ready or not
  91496. */
  91497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91498. /**
  91499. * Returns the material effect
  91500. * @returns the effect associated with the material
  91501. */
  91502. getEffect(): Nullable<Effect>;
  91503. /**
  91504. * Returns the current scene
  91505. * @returns a Scene
  91506. */
  91507. getScene(): Scene;
  91508. /**
  91509. * Specifies if the material will require alpha blending
  91510. * @returns a boolean specifying if alpha blending is needed
  91511. */
  91512. needAlphaBlending(): boolean;
  91513. /**
  91514. * Specifies if the mesh will require alpha blending
  91515. * @param mesh defines the mesh to check
  91516. * @returns a boolean specifying if alpha blending is needed for the mesh
  91517. */
  91518. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  91519. /**
  91520. * Specifies if this material should be rendered in alpha test mode
  91521. * @returns a boolean specifying if an alpha test is needed.
  91522. */
  91523. needAlphaTesting(): boolean;
  91524. /**
  91525. * Gets the texture used for the alpha test
  91526. * @returns the texture to use for alpha testing
  91527. */
  91528. getAlphaTestTexture(): Nullable<BaseTexture>;
  91529. /**
  91530. * Marks the material to indicate that it needs to be re-calculated
  91531. */
  91532. markDirty(): void;
  91533. /** @hidden */
  91534. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  91535. /**
  91536. * Binds the material to the mesh
  91537. * @param world defines the world transformation matrix
  91538. * @param mesh defines the mesh to bind the material to
  91539. */
  91540. bind(world: Matrix, mesh?: Mesh): void;
  91541. /**
  91542. * Binds the submesh to the material
  91543. * @param world defines the world transformation matrix
  91544. * @param mesh defines the mesh containing the submesh
  91545. * @param subMesh defines the submesh to bind the material to
  91546. */
  91547. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91548. /**
  91549. * Binds the world matrix to the material
  91550. * @param world defines the world transformation matrix
  91551. */
  91552. bindOnlyWorldMatrix(world: Matrix): void;
  91553. /**
  91554. * Binds the scene's uniform buffer to the effect.
  91555. * @param effect defines the effect to bind to the scene uniform buffer
  91556. * @param sceneUbo defines the uniform buffer storing scene data
  91557. */
  91558. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  91559. /**
  91560. * Binds the view matrix to the effect
  91561. * @param effect defines the effect to bind the view matrix to
  91562. */
  91563. bindView(effect: Effect): void;
  91564. /**
  91565. * Binds the view projection matrix to the effect
  91566. * @param effect defines the effect to bind the view projection matrix to
  91567. */
  91568. bindViewProjection(effect: Effect): void;
  91569. /**
  91570. * Specifies if material alpha testing should be turned on for the mesh
  91571. * @param mesh defines the mesh to check
  91572. */
  91573. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  91574. /**
  91575. * Processes to execute after binding the material to a mesh
  91576. * @param mesh defines the rendered mesh
  91577. */
  91578. protected _afterBind(mesh?: Mesh): void;
  91579. /**
  91580. * Unbinds the material from the mesh
  91581. */
  91582. unbind(): void;
  91583. /**
  91584. * Gets the active textures from the material
  91585. * @returns an array of textures
  91586. */
  91587. getActiveTextures(): BaseTexture[];
  91588. /**
  91589. * Specifies if the material uses a texture
  91590. * @param texture defines the texture to check against the material
  91591. * @returns a boolean specifying if the material uses the texture
  91592. */
  91593. hasTexture(texture: BaseTexture): boolean;
  91594. /**
  91595. * Makes a duplicate of the material, and gives it a new name
  91596. * @param name defines the new name for the duplicated material
  91597. * @returns the cloned material
  91598. */
  91599. clone(name: string): Nullable<Material>;
  91600. /**
  91601. * Gets the meshes bound to the material
  91602. * @returns an array of meshes bound to the material
  91603. */
  91604. getBindedMeshes(): AbstractMesh[];
  91605. /**
  91606. * Force shader compilation
  91607. * @param mesh defines the mesh associated with this material
  91608. * @param onCompiled defines a function to execute once the material is compiled
  91609. * @param options defines the options to configure the compilation
  91610. * @param onError defines a function to execute if the material fails compiling
  91611. */
  91612. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  91613. /**
  91614. * Force shader compilation
  91615. * @param mesh defines the mesh that will use this material
  91616. * @param options defines additional options for compiling the shaders
  91617. * @returns a promise that resolves when the compilation completes
  91618. */
  91619. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  91620. private static readonly _AllDirtyCallBack;
  91621. private static readonly _ImageProcessingDirtyCallBack;
  91622. private static readonly _TextureDirtyCallBack;
  91623. private static readonly _FresnelDirtyCallBack;
  91624. private static readonly _MiscDirtyCallBack;
  91625. private static readonly _LightsDirtyCallBack;
  91626. private static readonly _AttributeDirtyCallBack;
  91627. private static _FresnelAndMiscDirtyCallBack;
  91628. private static _TextureAndMiscDirtyCallBack;
  91629. private static readonly _DirtyCallbackArray;
  91630. private static readonly _RunDirtyCallBacks;
  91631. /**
  91632. * Marks a define in the material to indicate that it needs to be re-computed
  91633. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  91634. */
  91635. markAsDirty(flag: number): void;
  91636. /**
  91637. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  91638. * @param func defines a function which checks material defines against the submeshes
  91639. */
  91640. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  91641. /**
  91642. * Indicates that we need to re-calculated for all submeshes
  91643. */
  91644. protected _markAllSubMeshesAsAllDirty(): void;
  91645. /**
  91646. * Indicates that image processing needs to be re-calculated for all submeshes
  91647. */
  91648. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  91649. /**
  91650. * Indicates that textures need to be re-calculated for all submeshes
  91651. */
  91652. protected _markAllSubMeshesAsTexturesDirty(): void;
  91653. /**
  91654. * Indicates that fresnel needs to be re-calculated for all submeshes
  91655. */
  91656. protected _markAllSubMeshesAsFresnelDirty(): void;
  91657. /**
  91658. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  91659. */
  91660. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  91661. /**
  91662. * Indicates that lights need to be re-calculated for all submeshes
  91663. */
  91664. protected _markAllSubMeshesAsLightsDirty(): void;
  91665. /**
  91666. * Indicates that attributes need to be re-calculated for all submeshes
  91667. */
  91668. protected _markAllSubMeshesAsAttributesDirty(): void;
  91669. /**
  91670. * Indicates that misc needs to be re-calculated for all submeshes
  91671. */
  91672. protected _markAllSubMeshesAsMiscDirty(): void;
  91673. /**
  91674. * Indicates that textures and misc need to be re-calculated for all submeshes
  91675. */
  91676. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  91677. /**
  91678. * Disposes the material
  91679. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91680. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91681. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91682. */
  91683. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91684. /** @hidden */
  91685. private releaseVertexArrayObject;
  91686. /**
  91687. * Serializes this material
  91688. * @returns the serialized material object
  91689. */
  91690. serialize(): any;
  91691. /**
  91692. * Creates a material from parsed material data
  91693. * @param parsedMaterial defines parsed material data
  91694. * @param scene defines the hosting scene
  91695. * @param rootUrl defines the root URL to use to load textures
  91696. * @returns a new material
  91697. */
  91698. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  91699. }
  91700. }
  91701. declare module BABYLON {
  91702. /**
  91703. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91704. * separate meshes. This can be use to improve performances.
  91705. * @see http://doc.babylonjs.com/how_to/multi_materials
  91706. */
  91707. export class MultiMaterial extends Material {
  91708. private _subMaterials;
  91709. /**
  91710. * Gets or Sets the list of Materials used within the multi material.
  91711. * They need to be ordered according to the submeshes order in the associated mesh
  91712. */
  91713. get subMaterials(): Nullable<Material>[];
  91714. set subMaterials(value: Nullable<Material>[]);
  91715. /**
  91716. * Function used to align with Node.getChildren()
  91717. * @returns the list of Materials used within the multi material
  91718. */
  91719. getChildren(): Nullable<Material>[];
  91720. /**
  91721. * Instantiates a new Multi Material
  91722. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91723. * separate meshes. This can be use to improve performances.
  91724. * @see http://doc.babylonjs.com/how_to/multi_materials
  91725. * @param name Define the name in the scene
  91726. * @param scene Define the scene the material belongs to
  91727. */
  91728. constructor(name: string, scene: Scene);
  91729. private _hookArray;
  91730. /**
  91731. * Get one of the submaterial by its index in the submaterials array
  91732. * @param index The index to look the sub material at
  91733. * @returns The Material if the index has been defined
  91734. */
  91735. getSubMaterial(index: number): Nullable<Material>;
  91736. /**
  91737. * Get the list of active textures for the whole sub materials list.
  91738. * @returns All the textures that will be used during the rendering
  91739. */
  91740. getActiveTextures(): BaseTexture[];
  91741. /**
  91742. * Gets the current class name of the material e.g. "MultiMaterial"
  91743. * Mainly use in serialization.
  91744. * @returns the class name
  91745. */
  91746. getClassName(): string;
  91747. /**
  91748. * Checks if the material is ready to render the requested sub mesh
  91749. * @param mesh Define the mesh the submesh belongs to
  91750. * @param subMesh Define the sub mesh to look readyness for
  91751. * @param useInstances Define whether or not the material is used with instances
  91752. * @returns true if ready, otherwise false
  91753. */
  91754. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91755. /**
  91756. * Clones the current material and its related sub materials
  91757. * @param name Define the name of the newly cloned material
  91758. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  91759. * @returns the cloned material
  91760. */
  91761. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  91762. /**
  91763. * Serializes the materials into a JSON representation.
  91764. * @returns the JSON representation
  91765. */
  91766. serialize(): any;
  91767. /**
  91768. * Dispose the material and release its associated resources
  91769. * @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)
  91770. * @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)
  91771. * @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)
  91772. */
  91773. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  91774. /**
  91775. * Creates a MultiMaterial from parsed MultiMaterial data.
  91776. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  91777. * @param scene defines the hosting scene
  91778. * @returns a new MultiMaterial
  91779. */
  91780. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  91781. }
  91782. }
  91783. declare module BABYLON {
  91784. /**
  91785. * Base class for submeshes
  91786. */
  91787. export class BaseSubMesh {
  91788. /** @hidden */
  91789. _materialDefines: Nullable<MaterialDefines>;
  91790. /** @hidden */
  91791. _materialEffect: Nullable<Effect>;
  91792. /**
  91793. * Gets material defines used by the effect associated to the sub mesh
  91794. */
  91795. get materialDefines(): Nullable<MaterialDefines>;
  91796. /**
  91797. * Sets material defines used by the effect associated to the sub mesh
  91798. */
  91799. set materialDefines(defines: Nullable<MaterialDefines>);
  91800. /**
  91801. * Gets associated effect
  91802. */
  91803. get effect(): Nullable<Effect>;
  91804. /**
  91805. * Sets associated effect (effect used to render this submesh)
  91806. * @param effect defines the effect to associate with
  91807. * @param defines defines the set of defines used to compile this effect
  91808. */
  91809. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  91810. }
  91811. /**
  91812. * Defines a subdivision inside a mesh
  91813. */
  91814. export class SubMesh extends BaseSubMesh implements ICullable {
  91815. /** the material index to use */
  91816. materialIndex: number;
  91817. /** vertex index start */
  91818. verticesStart: number;
  91819. /** vertices count */
  91820. verticesCount: number;
  91821. /** index start */
  91822. indexStart: number;
  91823. /** indices count */
  91824. indexCount: number;
  91825. /** @hidden */
  91826. _linesIndexCount: number;
  91827. private _mesh;
  91828. private _renderingMesh;
  91829. private _boundingInfo;
  91830. private _linesIndexBuffer;
  91831. /** @hidden */
  91832. _lastColliderWorldVertices: Nullable<Vector3[]>;
  91833. /** @hidden */
  91834. _trianglePlanes: Plane[];
  91835. /** @hidden */
  91836. _lastColliderTransformMatrix: Nullable<Matrix>;
  91837. /** @hidden */
  91838. _renderId: number;
  91839. /** @hidden */
  91840. _alphaIndex: number;
  91841. /** @hidden */
  91842. _distanceToCamera: number;
  91843. /** @hidden */
  91844. _id: number;
  91845. private _currentMaterial;
  91846. /**
  91847. * Add a new submesh to a mesh
  91848. * @param materialIndex defines the material index to use
  91849. * @param verticesStart defines vertex index start
  91850. * @param verticesCount defines vertices count
  91851. * @param indexStart defines index start
  91852. * @param indexCount defines indices count
  91853. * @param mesh defines the parent mesh
  91854. * @param renderingMesh defines an optional rendering mesh
  91855. * @param createBoundingBox defines if bounding box should be created for this submesh
  91856. * @returns the new submesh
  91857. */
  91858. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  91859. /**
  91860. * Creates a new submesh
  91861. * @param materialIndex defines the material index to use
  91862. * @param verticesStart defines vertex index start
  91863. * @param verticesCount defines vertices count
  91864. * @param indexStart defines index start
  91865. * @param indexCount defines indices count
  91866. * @param mesh defines the parent mesh
  91867. * @param renderingMesh defines an optional rendering mesh
  91868. * @param createBoundingBox defines if bounding box should be created for this submesh
  91869. */
  91870. constructor(
  91871. /** the material index to use */
  91872. materialIndex: number,
  91873. /** vertex index start */
  91874. verticesStart: number,
  91875. /** vertices count */
  91876. verticesCount: number,
  91877. /** index start */
  91878. indexStart: number,
  91879. /** indices count */
  91880. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  91881. /**
  91882. * Returns true if this submesh covers the entire parent mesh
  91883. * @ignorenaming
  91884. */
  91885. get IsGlobal(): boolean;
  91886. /**
  91887. * Returns the submesh BoudingInfo object
  91888. * @returns current bounding info (or mesh's one if the submesh is global)
  91889. */
  91890. getBoundingInfo(): BoundingInfo;
  91891. /**
  91892. * Sets the submesh BoundingInfo
  91893. * @param boundingInfo defines the new bounding info to use
  91894. * @returns the SubMesh
  91895. */
  91896. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  91897. /**
  91898. * Returns the mesh of the current submesh
  91899. * @return the parent mesh
  91900. */
  91901. getMesh(): AbstractMesh;
  91902. /**
  91903. * Returns the rendering mesh of the submesh
  91904. * @returns the rendering mesh (could be different from parent mesh)
  91905. */
  91906. getRenderingMesh(): Mesh;
  91907. /**
  91908. * Returns the submesh material
  91909. * @returns null or the current material
  91910. */
  91911. getMaterial(): Nullable<Material>;
  91912. /**
  91913. * Sets a new updated BoundingInfo object to the submesh
  91914. * @param data defines an optional position array to use to determine the bounding info
  91915. * @returns the SubMesh
  91916. */
  91917. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  91918. /** @hidden */
  91919. _checkCollision(collider: Collider): boolean;
  91920. /**
  91921. * Updates the submesh BoundingInfo
  91922. * @param world defines the world matrix to use to update the bounding info
  91923. * @returns the submesh
  91924. */
  91925. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  91926. /**
  91927. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  91928. * @param frustumPlanes defines the frustum planes
  91929. * @returns true if the submesh is intersecting with the frustum
  91930. */
  91931. isInFrustum(frustumPlanes: Plane[]): boolean;
  91932. /**
  91933. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  91934. * @param frustumPlanes defines the frustum planes
  91935. * @returns true if the submesh is inside the frustum
  91936. */
  91937. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91938. /**
  91939. * Renders the submesh
  91940. * @param enableAlphaMode defines if alpha needs to be used
  91941. * @returns the submesh
  91942. */
  91943. render(enableAlphaMode: boolean): SubMesh;
  91944. /**
  91945. * @hidden
  91946. */
  91947. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  91948. /**
  91949. * Checks if the submesh intersects with a ray
  91950. * @param ray defines the ray to test
  91951. * @returns true is the passed ray intersects the submesh bounding box
  91952. */
  91953. canIntersects(ray: Ray): boolean;
  91954. /**
  91955. * Intersects current submesh with a ray
  91956. * @param ray defines the ray to test
  91957. * @param positions defines mesh's positions array
  91958. * @param indices defines mesh's indices array
  91959. * @param fastCheck defines if only bounding info should be used
  91960. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91961. * @returns intersection info or null if no intersection
  91962. */
  91963. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  91964. /** @hidden */
  91965. private _intersectLines;
  91966. /** @hidden */
  91967. private _intersectUnIndexedLines;
  91968. /** @hidden */
  91969. private _intersectTriangles;
  91970. /** @hidden */
  91971. private _intersectUnIndexedTriangles;
  91972. /** @hidden */
  91973. _rebuild(): void;
  91974. /**
  91975. * Creates a new submesh from the passed mesh
  91976. * @param newMesh defines the new hosting mesh
  91977. * @param newRenderingMesh defines an optional rendering mesh
  91978. * @returns the new submesh
  91979. */
  91980. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  91981. /**
  91982. * Release associated resources
  91983. */
  91984. dispose(): void;
  91985. /**
  91986. * Gets the class name
  91987. * @returns the string "SubMesh".
  91988. */
  91989. getClassName(): string;
  91990. /**
  91991. * Creates a new submesh from indices data
  91992. * @param materialIndex the index of the main mesh material
  91993. * @param startIndex the index where to start the copy in the mesh indices array
  91994. * @param indexCount the number of indices to copy then from the startIndex
  91995. * @param mesh the main mesh to create the submesh from
  91996. * @param renderingMesh the optional rendering mesh
  91997. * @returns a new submesh
  91998. */
  91999. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  92000. }
  92001. }
  92002. declare module BABYLON {
  92003. /**
  92004. * Class used to represent data loading progression
  92005. */
  92006. export class SceneLoaderFlags {
  92007. private static _ForceFullSceneLoadingForIncremental;
  92008. private static _ShowLoadingScreen;
  92009. private static _CleanBoneMatrixWeights;
  92010. private static _loggingLevel;
  92011. /**
  92012. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  92013. */
  92014. static get ForceFullSceneLoadingForIncremental(): boolean;
  92015. static set ForceFullSceneLoadingForIncremental(value: boolean);
  92016. /**
  92017. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  92018. */
  92019. static get ShowLoadingScreen(): boolean;
  92020. static set ShowLoadingScreen(value: boolean);
  92021. /**
  92022. * Defines the current logging level (while loading the scene)
  92023. * @ignorenaming
  92024. */
  92025. static get loggingLevel(): number;
  92026. static set loggingLevel(value: number);
  92027. /**
  92028. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  92029. */
  92030. static get CleanBoneMatrixWeights(): boolean;
  92031. static set CleanBoneMatrixWeights(value: boolean);
  92032. }
  92033. }
  92034. declare module BABYLON {
  92035. /**
  92036. * Class used to store geometry data (vertex buffers + index buffer)
  92037. */
  92038. export class Geometry implements IGetSetVerticesData {
  92039. /**
  92040. * Gets or sets the ID of the geometry
  92041. */
  92042. id: string;
  92043. /**
  92044. * Gets or sets the unique ID of the geometry
  92045. */
  92046. uniqueId: number;
  92047. /**
  92048. * Gets the delay loading state of the geometry (none by default which means not delayed)
  92049. */
  92050. delayLoadState: number;
  92051. /**
  92052. * Gets the file containing the data to load when running in delay load state
  92053. */
  92054. delayLoadingFile: Nullable<string>;
  92055. /**
  92056. * Callback called when the geometry is updated
  92057. */
  92058. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  92059. private _scene;
  92060. private _engine;
  92061. private _meshes;
  92062. private _totalVertices;
  92063. /** @hidden */
  92064. _indices: IndicesArray;
  92065. /** @hidden */
  92066. _vertexBuffers: {
  92067. [key: string]: VertexBuffer;
  92068. };
  92069. private _isDisposed;
  92070. private _extend;
  92071. private _boundingBias;
  92072. /** @hidden */
  92073. _delayInfo: Array<string>;
  92074. private _indexBuffer;
  92075. private _indexBufferIsUpdatable;
  92076. /** @hidden */
  92077. _boundingInfo: Nullable<BoundingInfo>;
  92078. /** @hidden */
  92079. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  92080. /** @hidden */
  92081. _softwareSkinningFrameId: number;
  92082. private _vertexArrayObjects;
  92083. private _updatable;
  92084. /** @hidden */
  92085. _positions: Nullable<Vector3[]>;
  92086. /**
  92087. * 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
  92088. */
  92089. get boundingBias(): Vector2;
  92090. /**
  92091. * 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
  92092. */
  92093. set boundingBias(value: Vector2);
  92094. /**
  92095. * Static function used to attach a new empty geometry to a mesh
  92096. * @param mesh defines the mesh to attach the geometry to
  92097. * @returns the new Geometry
  92098. */
  92099. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  92100. /**
  92101. * Creates a new geometry
  92102. * @param id defines the unique ID
  92103. * @param scene defines the hosting scene
  92104. * @param vertexData defines the VertexData used to get geometry data
  92105. * @param updatable defines if geometry must be updatable (false by default)
  92106. * @param mesh defines the mesh that will be associated with the geometry
  92107. */
  92108. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  92109. /**
  92110. * Gets the current extend of the geometry
  92111. */
  92112. get extend(): {
  92113. minimum: Vector3;
  92114. maximum: Vector3;
  92115. };
  92116. /**
  92117. * Gets the hosting scene
  92118. * @returns the hosting Scene
  92119. */
  92120. getScene(): Scene;
  92121. /**
  92122. * Gets the hosting engine
  92123. * @returns the hosting Engine
  92124. */
  92125. getEngine(): Engine;
  92126. /**
  92127. * Defines if the geometry is ready to use
  92128. * @returns true if the geometry is ready to be used
  92129. */
  92130. isReady(): boolean;
  92131. /**
  92132. * Gets a value indicating that the geometry should not be serialized
  92133. */
  92134. get doNotSerialize(): boolean;
  92135. /** @hidden */
  92136. _rebuild(): void;
  92137. /**
  92138. * Affects all geometry data in one call
  92139. * @param vertexData defines the geometry data
  92140. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  92141. */
  92142. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  92143. /**
  92144. * Set specific vertex data
  92145. * @param kind defines the data kind (Position, normal, etc...)
  92146. * @param data defines the vertex data to use
  92147. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92148. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92149. */
  92150. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  92151. /**
  92152. * Removes a specific vertex data
  92153. * @param kind defines the data kind (Position, normal, etc...)
  92154. */
  92155. removeVerticesData(kind: string): void;
  92156. /**
  92157. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  92158. * @param buffer defines the vertex buffer to use
  92159. * @param totalVertices defines the total number of vertices for position kind (could be null)
  92160. */
  92161. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  92162. /**
  92163. * Update a specific vertex buffer
  92164. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  92165. * It will do nothing if the buffer is not updatable
  92166. * @param kind defines the data kind (Position, normal, etc...)
  92167. * @param data defines the data to use
  92168. * @param offset defines the offset in the target buffer where to store the data
  92169. * @param useBytes set to true if the offset is in bytes
  92170. */
  92171. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  92172. /**
  92173. * Update a specific vertex buffer
  92174. * This function will create a new buffer if the current one is not updatable
  92175. * @param kind defines the data kind (Position, normal, etc...)
  92176. * @param data defines the data to use
  92177. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  92178. */
  92179. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  92180. private _updateBoundingInfo;
  92181. /** @hidden */
  92182. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  92183. /**
  92184. * Gets total number of vertices
  92185. * @returns the total number of vertices
  92186. */
  92187. getTotalVertices(): number;
  92188. /**
  92189. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92190. * @param kind defines the data kind (Position, normal, etc...)
  92191. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92192. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92193. * @returns a float array containing vertex data
  92194. */
  92195. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92196. /**
  92197. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  92198. * @param kind defines the data kind (Position, normal, etc...)
  92199. * @returns true if the vertex buffer with the specified kind is updatable
  92200. */
  92201. isVertexBufferUpdatable(kind: string): boolean;
  92202. /**
  92203. * Gets a specific vertex buffer
  92204. * @param kind defines the data kind (Position, normal, etc...)
  92205. * @returns a VertexBuffer
  92206. */
  92207. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92208. /**
  92209. * Returns all vertex buffers
  92210. * @return an object holding all vertex buffers indexed by kind
  92211. */
  92212. getVertexBuffers(): Nullable<{
  92213. [key: string]: VertexBuffer;
  92214. }>;
  92215. /**
  92216. * Gets a boolean indicating if specific vertex buffer is present
  92217. * @param kind defines the data kind (Position, normal, etc...)
  92218. * @returns true if data is present
  92219. */
  92220. isVerticesDataPresent(kind: string): boolean;
  92221. /**
  92222. * Gets a list of all attached data kinds (Position, normal, etc...)
  92223. * @returns a list of string containing all kinds
  92224. */
  92225. getVerticesDataKinds(): string[];
  92226. /**
  92227. * Update index buffer
  92228. * @param indices defines the indices to store in the index buffer
  92229. * @param offset defines the offset in the target buffer where to store the data
  92230. * @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)
  92231. */
  92232. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  92233. /**
  92234. * Creates a new index buffer
  92235. * @param indices defines the indices to store in the index buffer
  92236. * @param totalVertices defines the total number of vertices (could be null)
  92237. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92238. */
  92239. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  92240. /**
  92241. * Return the total number of indices
  92242. * @returns the total number of indices
  92243. */
  92244. getTotalIndices(): number;
  92245. /**
  92246. * Gets the index buffer array
  92247. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92248. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92249. * @returns the index buffer array
  92250. */
  92251. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92252. /**
  92253. * Gets the index buffer
  92254. * @return the index buffer
  92255. */
  92256. getIndexBuffer(): Nullable<DataBuffer>;
  92257. /** @hidden */
  92258. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  92259. /**
  92260. * Release the associated resources for a specific mesh
  92261. * @param mesh defines the source mesh
  92262. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  92263. */
  92264. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  92265. /**
  92266. * Apply current geometry to a given mesh
  92267. * @param mesh defines the mesh to apply geometry to
  92268. */
  92269. applyToMesh(mesh: Mesh): void;
  92270. private _updateExtend;
  92271. private _applyToMesh;
  92272. private notifyUpdate;
  92273. /**
  92274. * Load the geometry if it was flagged as delay loaded
  92275. * @param scene defines the hosting scene
  92276. * @param onLoaded defines a callback called when the geometry is loaded
  92277. */
  92278. load(scene: Scene, onLoaded?: () => void): void;
  92279. private _queueLoad;
  92280. /**
  92281. * Invert the geometry to move from a right handed system to a left handed one.
  92282. */
  92283. toLeftHanded(): void;
  92284. /** @hidden */
  92285. _resetPointsArrayCache(): void;
  92286. /** @hidden */
  92287. _generatePointsArray(): boolean;
  92288. /**
  92289. * Gets a value indicating if the geometry is disposed
  92290. * @returns true if the geometry was disposed
  92291. */
  92292. isDisposed(): boolean;
  92293. private _disposeVertexArrayObjects;
  92294. /**
  92295. * Free all associated resources
  92296. */
  92297. dispose(): void;
  92298. /**
  92299. * Clone the current geometry into a new geometry
  92300. * @param id defines the unique ID of the new geometry
  92301. * @returns a new geometry object
  92302. */
  92303. copy(id: string): Geometry;
  92304. /**
  92305. * Serialize the current geometry info (and not the vertices data) into a JSON object
  92306. * @return a JSON representation of the current geometry data (without the vertices data)
  92307. */
  92308. serialize(): any;
  92309. private toNumberArray;
  92310. /**
  92311. * Serialize all vertices data into a JSON oject
  92312. * @returns a JSON representation of the current geometry data
  92313. */
  92314. serializeVerticeData(): any;
  92315. /**
  92316. * Extracts a clone of a mesh geometry
  92317. * @param mesh defines the source mesh
  92318. * @param id defines the unique ID of the new geometry object
  92319. * @returns the new geometry object
  92320. */
  92321. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  92322. /**
  92323. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  92324. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92325. * Be aware Math.random() could cause collisions, but:
  92326. * "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"
  92327. * @returns a string containing a new GUID
  92328. */
  92329. static RandomId(): string;
  92330. /** @hidden */
  92331. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  92332. private static _CleanMatricesWeights;
  92333. /**
  92334. * Create a new geometry from persisted data (Using .babylon file format)
  92335. * @param parsedVertexData defines the persisted data
  92336. * @param scene defines the hosting scene
  92337. * @param rootUrl defines the root url to use to load assets (like delayed data)
  92338. * @returns the new geometry object
  92339. */
  92340. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  92341. }
  92342. }
  92343. declare module BABYLON {
  92344. /**
  92345. * Define an interface for all classes that will get and set the data on vertices
  92346. */
  92347. export interface IGetSetVerticesData {
  92348. /**
  92349. * Gets a boolean indicating if specific vertex data is present
  92350. * @param kind defines the vertex data kind to use
  92351. * @returns true is data kind is present
  92352. */
  92353. isVerticesDataPresent(kind: string): boolean;
  92354. /**
  92355. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92356. * @param kind defines the data kind (Position, normal, etc...)
  92357. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92358. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92359. * @returns a float array containing vertex data
  92360. */
  92361. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92362. /**
  92363. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92364. * @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.
  92365. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92366. * @returns the indices array or an empty array if the mesh has no geometry
  92367. */
  92368. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92369. /**
  92370. * Set specific vertex data
  92371. * @param kind defines the data kind (Position, normal, etc...)
  92372. * @param data defines the vertex data to use
  92373. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92374. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92375. */
  92376. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  92377. /**
  92378. * Update a specific associated vertex buffer
  92379. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92380. * - VertexBuffer.PositionKind
  92381. * - VertexBuffer.UVKind
  92382. * - VertexBuffer.UV2Kind
  92383. * - VertexBuffer.UV3Kind
  92384. * - VertexBuffer.UV4Kind
  92385. * - VertexBuffer.UV5Kind
  92386. * - VertexBuffer.UV6Kind
  92387. * - VertexBuffer.ColorKind
  92388. * - VertexBuffer.MatricesIndicesKind
  92389. * - VertexBuffer.MatricesIndicesExtraKind
  92390. * - VertexBuffer.MatricesWeightsKind
  92391. * - VertexBuffer.MatricesWeightsExtraKind
  92392. * @param data defines the data source
  92393. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92394. * @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)
  92395. */
  92396. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  92397. /**
  92398. * Creates a new index buffer
  92399. * @param indices defines the indices to store in the index buffer
  92400. * @param totalVertices defines the total number of vertices (could be null)
  92401. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92402. */
  92403. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  92404. }
  92405. /**
  92406. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  92407. */
  92408. export class VertexData {
  92409. /**
  92410. * Mesh side orientation : usually the external or front surface
  92411. */
  92412. static readonly FRONTSIDE: number;
  92413. /**
  92414. * Mesh side orientation : usually the internal or back surface
  92415. */
  92416. static readonly BACKSIDE: number;
  92417. /**
  92418. * Mesh side orientation : both internal and external or front and back surfaces
  92419. */
  92420. static readonly DOUBLESIDE: number;
  92421. /**
  92422. * Mesh side orientation : by default, `FRONTSIDE`
  92423. */
  92424. static readonly DEFAULTSIDE: number;
  92425. /**
  92426. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  92427. */
  92428. positions: Nullable<FloatArray>;
  92429. /**
  92430. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  92431. */
  92432. normals: Nullable<FloatArray>;
  92433. /**
  92434. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  92435. */
  92436. tangents: Nullable<FloatArray>;
  92437. /**
  92438. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92439. */
  92440. uvs: Nullable<FloatArray>;
  92441. /**
  92442. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92443. */
  92444. uvs2: Nullable<FloatArray>;
  92445. /**
  92446. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92447. */
  92448. uvs3: Nullable<FloatArray>;
  92449. /**
  92450. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92451. */
  92452. uvs4: Nullable<FloatArray>;
  92453. /**
  92454. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92455. */
  92456. uvs5: Nullable<FloatArray>;
  92457. /**
  92458. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92459. */
  92460. uvs6: Nullable<FloatArray>;
  92461. /**
  92462. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  92463. */
  92464. colors: Nullable<FloatArray>;
  92465. /**
  92466. * 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).
  92467. */
  92468. matricesIndices: Nullable<FloatArray>;
  92469. /**
  92470. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  92471. */
  92472. matricesWeights: Nullable<FloatArray>;
  92473. /**
  92474. * An array extending the number of possible indices
  92475. */
  92476. matricesIndicesExtra: Nullable<FloatArray>;
  92477. /**
  92478. * An array extending the number of possible weights when the number of indices is extended
  92479. */
  92480. matricesWeightsExtra: Nullable<FloatArray>;
  92481. /**
  92482. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  92483. */
  92484. indices: Nullable<IndicesArray>;
  92485. /**
  92486. * Uses the passed data array to set the set the values for the specified kind of data
  92487. * @param data a linear array of floating numbers
  92488. * @param kind the type of data that is being set, eg positions, colors etc
  92489. */
  92490. set(data: FloatArray, kind: string): void;
  92491. /**
  92492. * Associates the vertexData to the passed Mesh.
  92493. * Sets it as updatable or not (default `false`)
  92494. * @param mesh the mesh the vertexData is applied to
  92495. * @param updatable when used and having the value true allows new data to update the vertexData
  92496. * @returns the VertexData
  92497. */
  92498. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  92499. /**
  92500. * Associates the vertexData to the passed Geometry.
  92501. * Sets it as updatable or not (default `false`)
  92502. * @param geometry the geometry the vertexData is applied to
  92503. * @param updatable when used and having the value true allows new data to update the vertexData
  92504. * @returns VertexData
  92505. */
  92506. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  92507. /**
  92508. * Updates the associated mesh
  92509. * @param mesh the mesh to be updated
  92510. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92511. * @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
  92512. * @returns VertexData
  92513. */
  92514. updateMesh(mesh: Mesh): VertexData;
  92515. /**
  92516. * Updates the associated geometry
  92517. * @param geometry the geometry to be updated
  92518. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92519. * @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
  92520. * @returns VertexData.
  92521. */
  92522. updateGeometry(geometry: Geometry): VertexData;
  92523. private _applyTo;
  92524. private _update;
  92525. /**
  92526. * Transforms each position and each normal of the vertexData according to the passed Matrix
  92527. * @param matrix the transforming matrix
  92528. * @returns the VertexData
  92529. */
  92530. transform(matrix: Matrix): VertexData;
  92531. /**
  92532. * Merges the passed VertexData into the current one
  92533. * @param other the VertexData to be merged into the current one
  92534. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  92535. * @returns the modified VertexData
  92536. */
  92537. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  92538. private _mergeElement;
  92539. private _validate;
  92540. /**
  92541. * Serializes the VertexData
  92542. * @returns a serialized object
  92543. */
  92544. serialize(): any;
  92545. /**
  92546. * Extracts the vertexData from a mesh
  92547. * @param mesh the mesh from which to extract the VertexData
  92548. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  92549. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92550. * @returns the object VertexData associated to the passed mesh
  92551. */
  92552. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92553. /**
  92554. * Extracts the vertexData from the geometry
  92555. * @param geometry the geometry from which to extract the VertexData
  92556. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  92557. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92558. * @returns the object VertexData associated to the passed mesh
  92559. */
  92560. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92561. private static _ExtractFrom;
  92562. /**
  92563. * Creates the VertexData for a Ribbon
  92564. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  92565. * * pathArray array of paths, each of which an array of successive Vector3
  92566. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  92567. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  92568. * * 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
  92569. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92570. * * 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)
  92571. * * 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)
  92572. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  92573. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  92574. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  92575. * @returns the VertexData of the ribbon
  92576. */
  92577. static CreateRibbon(options: {
  92578. pathArray: Vector3[][];
  92579. closeArray?: boolean;
  92580. closePath?: boolean;
  92581. offset?: number;
  92582. sideOrientation?: number;
  92583. frontUVs?: Vector4;
  92584. backUVs?: Vector4;
  92585. invertUV?: boolean;
  92586. uvs?: Vector2[];
  92587. colors?: Color4[];
  92588. }): VertexData;
  92589. /**
  92590. * Creates the VertexData for a box
  92591. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92592. * * size sets the width, height and depth of the box to the value of size, optional default 1
  92593. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  92594. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  92595. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  92596. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92597. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92598. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92599. * * 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)
  92600. * * 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)
  92601. * @returns the VertexData of the box
  92602. */
  92603. static CreateBox(options: {
  92604. size?: number;
  92605. width?: number;
  92606. height?: number;
  92607. depth?: number;
  92608. faceUV?: Vector4[];
  92609. faceColors?: Color4[];
  92610. sideOrientation?: number;
  92611. frontUVs?: Vector4;
  92612. backUVs?: Vector4;
  92613. }): VertexData;
  92614. /**
  92615. * Creates the VertexData for a tiled box
  92616. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92617. * * faceTiles sets the pattern, tile size and number of tiles for a face
  92618. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92619. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92620. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92621. * @returns the VertexData of the box
  92622. */
  92623. static CreateTiledBox(options: {
  92624. pattern?: number;
  92625. width?: number;
  92626. height?: number;
  92627. depth?: number;
  92628. tileSize?: number;
  92629. tileWidth?: number;
  92630. tileHeight?: number;
  92631. alignHorizontal?: number;
  92632. alignVertical?: number;
  92633. faceUV?: Vector4[];
  92634. faceColors?: Color4[];
  92635. sideOrientation?: number;
  92636. }): VertexData;
  92637. /**
  92638. * Creates the VertexData for a tiled plane
  92639. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92640. * * pattern a limited pattern arrangement depending on the number
  92641. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  92642. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  92643. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  92644. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92645. * * 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)
  92646. * * 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)
  92647. * @returns the VertexData of the tiled plane
  92648. */
  92649. static CreateTiledPlane(options: {
  92650. pattern?: number;
  92651. tileSize?: number;
  92652. tileWidth?: number;
  92653. tileHeight?: number;
  92654. size?: number;
  92655. width?: number;
  92656. height?: number;
  92657. alignHorizontal?: number;
  92658. alignVertical?: number;
  92659. sideOrientation?: number;
  92660. frontUVs?: Vector4;
  92661. backUVs?: Vector4;
  92662. }): VertexData;
  92663. /**
  92664. * Creates the VertexData for an ellipsoid, defaults to a sphere
  92665. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92666. * * segments sets the number of horizontal strips optional, default 32
  92667. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  92668. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  92669. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  92670. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  92671. * * 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
  92672. * * 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
  92673. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92674. * * 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)
  92675. * * 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)
  92676. * @returns the VertexData of the ellipsoid
  92677. */
  92678. static CreateSphere(options: {
  92679. segments?: number;
  92680. diameter?: number;
  92681. diameterX?: number;
  92682. diameterY?: number;
  92683. diameterZ?: number;
  92684. arc?: number;
  92685. slice?: number;
  92686. sideOrientation?: number;
  92687. frontUVs?: Vector4;
  92688. backUVs?: Vector4;
  92689. }): VertexData;
  92690. /**
  92691. * Creates the VertexData for a cylinder, cone or prism
  92692. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92693. * * height sets the height (y direction) of the cylinder, optional, default 2
  92694. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  92695. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  92696. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  92697. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92698. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  92699. * * 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
  92700. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92701. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92702. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  92703. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  92704. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92705. * * 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)
  92706. * * 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)
  92707. * @returns the VertexData of the cylinder, cone or prism
  92708. */
  92709. static CreateCylinder(options: {
  92710. height?: number;
  92711. diameterTop?: number;
  92712. diameterBottom?: number;
  92713. diameter?: number;
  92714. tessellation?: number;
  92715. subdivisions?: number;
  92716. arc?: number;
  92717. faceColors?: Color4[];
  92718. faceUV?: Vector4[];
  92719. hasRings?: boolean;
  92720. enclose?: boolean;
  92721. sideOrientation?: number;
  92722. frontUVs?: Vector4;
  92723. backUVs?: Vector4;
  92724. }): VertexData;
  92725. /**
  92726. * Creates the VertexData for a torus
  92727. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92728. * * diameter the diameter of the torus, optional default 1
  92729. * * thickness the diameter of the tube forming the torus, optional default 0.5
  92730. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92731. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92732. * * 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)
  92733. * * 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)
  92734. * @returns the VertexData of the torus
  92735. */
  92736. static CreateTorus(options: {
  92737. diameter?: number;
  92738. thickness?: number;
  92739. tessellation?: number;
  92740. sideOrientation?: number;
  92741. frontUVs?: Vector4;
  92742. backUVs?: Vector4;
  92743. }): VertexData;
  92744. /**
  92745. * Creates the VertexData of the LineSystem
  92746. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  92747. * - lines an array of lines, each line being an array of successive Vector3
  92748. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  92749. * @returns the VertexData of the LineSystem
  92750. */
  92751. static CreateLineSystem(options: {
  92752. lines: Vector3[][];
  92753. colors?: Nullable<Color4[][]>;
  92754. }): VertexData;
  92755. /**
  92756. * Create the VertexData for a DashedLines
  92757. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  92758. * - points an array successive Vector3
  92759. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  92760. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  92761. * - dashNb the intended total number of dashes, optional, default 200
  92762. * @returns the VertexData for the DashedLines
  92763. */
  92764. static CreateDashedLines(options: {
  92765. points: Vector3[];
  92766. dashSize?: number;
  92767. gapSize?: number;
  92768. dashNb?: number;
  92769. }): VertexData;
  92770. /**
  92771. * Creates the VertexData for a Ground
  92772. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92773. * - width the width (x direction) of the ground, optional, default 1
  92774. * - height the height (z direction) of the ground, optional, default 1
  92775. * - subdivisions the number of subdivisions per side, optional, default 1
  92776. * @returns the VertexData of the Ground
  92777. */
  92778. static CreateGround(options: {
  92779. width?: number;
  92780. height?: number;
  92781. subdivisions?: number;
  92782. subdivisionsX?: number;
  92783. subdivisionsY?: number;
  92784. }): VertexData;
  92785. /**
  92786. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  92787. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92788. * * xmin the ground minimum X coordinate, optional, default -1
  92789. * * zmin the ground minimum Z coordinate, optional, default -1
  92790. * * xmax the ground maximum X coordinate, optional, default 1
  92791. * * zmax the ground maximum Z coordinate, optional, default 1
  92792. * * 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}
  92793. * * 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}
  92794. * @returns the VertexData of the TiledGround
  92795. */
  92796. static CreateTiledGround(options: {
  92797. xmin: number;
  92798. zmin: number;
  92799. xmax: number;
  92800. zmax: number;
  92801. subdivisions?: {
  92802. w: number;
  92803. h: number;
  92804. };
  92805. precision?: {
  92806. w: number;
  92807. h: number;
  92808. };
  92809. }): VertexData;
  92810. /**
  92811. * Creates the VertexData of the Ground designed from a heightmap
  92812. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  92813. * * width the width (x direction) of the ground
  92814. * * height the height (z direction) of the ground
  92815. * * subdivisions the number of subdivisions per side
  92816. * * minHeight the minimum altitude on the ground, optional, default 0
  92817. * * maxHeight the maximum altitude on the ground, optional default 1
  92818. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  92819. * * buffer the array holding the image color data
  92820. * * bufferWidth the width of image
  92821. * * bufferHeight the height of image
  92822. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  92823. * @returns the VertexData of the Ground designed from a heightmap
  92824. */
  92825. static CreateGroundFromHeightMap(options: {
  92826. width: number;
  92827. height: number;
  92828. subdivisions: number;
  92829. minHeight: number;
  92830. maxHeight: number;
  92831. colorFilter: Color3;
  92832. buffer: Uint8Array;
  92833. bufferWidth: number;
  92834. bufferHeight: number;
  92835. alphaFilter: number;
  92836. }): VertexData;
  92837. /**
  92838. * Creates the VertexData for a Plane
  92839. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  92840. * * size sets the width and height of the plane to the value of size, optional default 1
  92841. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  92842. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  92843. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92844. * * 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)
  92845. * * 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)
  92846. * @returns the VertexData of the box
  92847. */
  92848. static CreatePlane(options: {
  92849. size?: number;
  92850. width?: number;
  92851. height?: number;
  92852. sideOrientation?: number;
  92853. frontUVs?: Vector4;
  92854. backUVs?: Vector4;
  92855. }): VertexData;
  92856. /**
  92857. * Creates the VertexData of the Disc or regular Polygon
  92858. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  92859. * * radius the radius of the disc, optional default 0.5
  92860. * * tessellation the number of polygon sides, optional, default 64
  92861. * * 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
  92862. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92863. * * 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)
  92864. * * 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)
  92865. * @returns the VertexData of the box
  92866. */
  92867. static CreateDisc(options: {
  92868. radius?: number;
  92869. tessellation?: number;
  92870. arc?: number;
  92871. sideOrientation?: number;
  92872. frontUVs?: Vector4;
  92873. backUVs?: Vector4;
  92874. }): VertexData;
  92875. /**
  92876. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  92877. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  92878. * @param polygon a mesh built from polygonTriangulation.build()
  92879. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92880. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92881. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92882. * @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)
  92883. * @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)
  92884. * @returns the VertexData of the Polygon
  92885. */
  92886. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  92887. /**
  92888. * Creates the VertexData of the IcoSphere
  92889. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  92890. * * radius the radius of the IcoSphere, optional default 1
  92891. * * radiusX allows stretching in the x direction, optional, default radius
  92892. * * radiusY allows stretching in the y direction, optional, default radius
  92893. * * radiusZ allows stretching in the z direction, optional, default radius
  92894. * * flat when true creates a flat shaded mesh, optional, default true
  92895. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92896. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92897. * * 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)
  92898. * * 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)
  92899. * @returns the VertexData of the IcoSphere
  92900. */
  92901. static CreateIcoSphere(options: {
  92902. radius?: number;
  92903. radiusX?: number;
  92904. radiusY?: number;
  92905. radiusZ?: number;
  92906. flat?: boolean;
  92907. subdivisions?: number;
  92908. sideOrientation?: number;
  92909. frontUVs?: Vector4;
  92910. backUVs?: Vector4;
  92911. }): VertexData;
  92912. /**
  92913. * Creates the VertexData for a Polyhedron
  92914. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  92915. * * type provided types are:
  92916. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  92917. * * 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)
  92918. * * size the size of the IcoSphere, optional default 1
  92919. * * sizeX allows stretching in the x direction, optional, default size
  92920. * * sizeY allows stretching in the y direction, optional, default size
  92921. * * sizeZ allows stretching in the z direction, optional, default size
  92922. * * 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
  92923. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92924. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92925. * * flat when true creates a flat shaded mesh, optional, default true
  92926. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92927. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92928. * * 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)
  92929. * * 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)
  92930. * @returns the VertexData of the Polyhedron
  92931. */
  92932. static CreatePolyhedron(options: {
  92933. type?: number;
  92934. size?: number;
  92935. sizeX?: number;
  92936. sizeY?: number;
  92937. sizeZ?: number;
  92938. custom?: any;
  92939. faceUV?: Vector4[];
  92940. faceColors?: Color4[];
  92941. flat?: boolean;
  92942. sideOrientation?: number;
  92943. frontUVs?: Vector4;
  92944. backUVs?: Vector4;
  92945. }): VertexData;
  92946. /**
  92947. * Creates the VertexData for a TorusKnot
  92948. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  92949. * * radius the radius of the torus knot, optional, default 2
  92950. * * tube the thickness of the tube, optional, default 0.5
  92951. * * radialSegments the number of sides on each tube segments, optional, default 32
  92952. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  92953. * * p the number of windings around the z axis, optional, default 2
  92954. * * q the number of windings around the x axis, optional, default 3
  92955. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92956. * * 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)
  92957. * * 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)
  92958. * @returns the VertexData of the Torus Knot
  92959. */
  92960. static CreateTorusKnot(options: {
  92961. radius?: number;
  92962. tube?: number;
  92963. radialSegments?: number;
  92964. tubularSegments?: number;
  92965. p?: number;
  92966. q?: number;
  92967. sideOrientation?: number;
  92968. frontUVs?: Vector4;
  92969. backUVs?: Vector4;
  92970. }): VertexData;
  92971. /**
  92972. * Compute normals for given positions and indices
  92973. * @param positions an array of vertex positions, [...., x, y, z, ......]
  92974. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  92975. * @param normals an array of vertex normals, [...., x, y, z, ......]
  92976. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  92977. * * facetNormals : optional array of facet normals (vector3)
  92978. * * facetPositions : optional array of facet positions (vector3)
  92979. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  92980. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  92981. * * bInfo : optional bounding info, required for facetPartitioning computation
  92982. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  92983. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  92984. * * useRightHandedSystem: optional boolean to for right handed system computation
  92985. * * depthSort : optional boolean to enable the facet depth sort computation
  92986. * * distanceTo : optional Vector3 to compute the facet depth from this location
  92987. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  92988. */
  92989. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  92990. facetNormals?: any;
  92991. facetPositions?: any;
  92992. facetPartitioning?: any;
  92993. ratio?: number;
  92994. bInfo?: any;
  92995. bbSize?: Vector3;
  92996. subDiv?: any;
  92997. useRightHandedSystem?: boolean;
  92998. depthSort?: boolean;
  92999. distanceTo?: Vector3;
  93000. depthSortedFacets?: any;
  93001. }): void;
  93002. /** @hidden */
  93003. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  93004. /**
  93005. * Applies VertexData created from the imported parameters to the geometry
  93006. * @param parsedVertexData the parsed data from an imported file
  93007. * @param geometry the geometry to apply the VertexData to
  93008. */
  93009. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  93010. }
  93011. }
  93012. declare module BABYLON {
  93013. /**
  93014. * Defines a target to use with MorphTargetManager
  93015. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93016. */
  93017. export class MorphTarget implements IAnimatable {
  93018. /** defines the name of the target */
  93019. name: string;
  93020. /**
  93021. * Gets or sets the list of animations
  93022. */
  93023. animations: Animation[];
  93024. private _scene;
  93025. private _positions;
  93026. private _normals;
  93027. private _tangents;
  93028. private _uvs;
  93029. private _influence;
  93030. private _uniqueId;
  93031. /**
  93032. * Observable raised when the influence changes
  93033. */
  93034. onInfluenceChanged: Observable<boolean>;
  93035. /** @hidden */
  93036. _onDataLayoutChanged: Observable<void>;
  93037. /**
  93038. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  93039. */
  93040. get influence(): number;
  93041. set influence(influence: number);
  93042. /**
  93043. * Gets or sets the id of the morph Target
  93044. */
  93045. id: string;
  93046. private _animationPropertiesOverride;
  93047. /**
  93048. * Gets or sets the animation properties override
  93049. */
  93050. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93051. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93052. /**
  93053. * Creates a new MorphTarget
  93054. * @param name defines the name of the target
  93055. * @param influence defines the influence to use
  93056. * @param scene defines the scene the morphtarget belongs to
  93057. */
  93058. constructor(
  93059. /** defines the name of the target */
  93060. name: string, influence?: number, scene?: Nullable<Scene>);
  93061. /**
  93062. * Gets the unique ID of this manager
  93063. */
  93064. get uniqueId(): number;
  93065. /**
  93066. * Gets a boolean defining if the target contains position data
  93067. */
  93068. get hasPositions(): boolean;
  93069. /**
  93070. * Gets a boolean defining if the target contains normal data
  93071. */
  93072. get hasNormals(): boolean;
  93073. /**
  93074. * Gets a boolean defining if the target contains tangent data
  93075. */
  93076. get hasTangents(): boolean;
  93077. /**
  93078. * Gets a boolean defining if the target contains texture coordinates data
  93079. */
  93080. get hasUVs(): boolean;
  93081. /**
  93082. * Affects position data to this target
  93083. * @param data defines the position data to use
  93084. */
  93085. setPositions(data: Nullable<FloatArray>): void;
  93086. /**
  93087. * Gets the position data stored in this target
  93088. * @returns a FloatArray containing the position data (or null if not present)
  93089. */
  93090. getPositions(): Nullable<FloatArray>;
  93091. /**
  93092. * Affects normal data to this target
  93093. * @param data defines the normal data to use
  93094. */
  93095. setNormals(data: Nullable<FloatArray>): void;
  93096. /**
  93097. * Gets the normal data stored in this target
  93098. * @returns a FloatArray containing the normal data (or null if not present)
  93099. */
  93100. getNormals(): Nullable<FloatArray>;
  93101. /**
  93102. * Affects tangent data to this target
  93103. * @param data defines the tangent data to use
  93104. */
  93105. setTangents(data: Nullable<FloatArray>): void;
  93106. /**
  93107. * Gets the tangent data stored in this target
  93108. * @returns a FloatArray containing the tangent data (or null if not present)
  93109. */
  93110. getTangents(): Nullable<FloatArray>;
  93111. /**
  93112. * Affects texture coordinates data to this target
  93113. * @param data defines the texture coordinates data to use
  93114. */
  93115. setUVs(data: Nullable<FloatArray>): void;
  93116. /**
  93117. * Gets the texture coordinates data stored in this target
  93118. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  93119. */
  93120. getUVs(): Nullable<FloatArray>;
  93121. /**
  93122. * Clone the current target
  93123. * @returns a new MorphTarget
  93124. */
  93125. clone(): MorphTarget;
  93126. /**
  93127. * Serializes the current target into a Serialization object
  93128. * @returns the serialized object
  93129. */
  93130. serialize(): any;
  93131. /**
  93132. * Returns the string "MorphTarget"
  93133. * @returns "MorphTarget"
  93134. */
  93135. getClassName(): string;
  93136. /**
  93137. * Creates a new target from serialized data
  93138. * @param serializationObject defines the serialized data to use
  93139. * @returns a new MorphTarget
  93140. */
  93141. static Parse(serializationObject: any): MorphTarget;
  93142. /**
  93143. * Creates a MorphTarget from mesh data
  93144. * @param mesh defines the source mesh
  93145. * @param name defines the name to use for the new target
  93146. * @param influence defines the influence to attach to the target
  93147. * @returns a new MorphTarget
  93148. */
  93149. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  93150. }
  93151. }
  93152. declare module BABYLON {
  93153. /**
  93154. * This class is used to deform meshes using morphing between different targets
  93155. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93156. */
  93157. export class MorphTargetManager {
  93158. private _targets;
  93159. private _targetInfluenceChangedObservers;
  93160. private _targetDataLayoutChangedObservers;
  93161. private _activeTargets;
  93162. private _scene;
  93163. private _influences;
  93164. private _supportsNormals;
  93165. private _supportsTangents;
  93166. private _supportsUVs;
  93167. private _vertexCount;
  93168. private _uniqueId;
  93169. private _tempInfluences;
  93170. /**
  93171. * Gets or sets a boolean indicating if normals must be morphed
  93172. */
  93173. enableNormalMorphing: boolean;
  93174. /**
  93175. * Gets or sets a boolean indicating if tangents must be morphed
  93176. */
  93177. enableTangentMorphing: boolean;
  93178. /**
  93179. * Gets or sets a boolean indicating if UV must be morphed
  93180. */
  93181. enableUVMorphing: boolean;
  93182. /**
  93183. * Creates a new MorphTargetManager
  93184. * @param scene defines the current scene
  93185. */
  93186. constructor(scene?: Nullable<Scene>);
  93187. /**
  93188. * Gets the unique ID of this manager
  93189. */
  93190. get uniqueId(): number;
  93191. /**
  93192. * Gets the number of vertices handled by this manager
  93193. */
  93194. get vertexCount(): number;
  93195. /**
  93196. * Gets a boolean indicating if this manager supports morphing of normals
  93197. */
  93198. get supportsNormals(): boolean;
  93199. /**
  93200. * Gets a boolean indicating if this manager supports morphing of tangents
  93201. */
  93202. get supportsTangents(): boolean;
  93203. /**
  93204. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  93205. */
  93206. get supportsUVs(): boolean;
  93207. /**
  93208. * Gets the number of targets stored in this manager
  93209. */
  93210. get numTargets(): number;
  93211. /**
  93212. * Gets the number of influencers (ie. the number of targets with influences > 0)
  93213. */
  93214. get numInfluencers(): number;
  93215. /**
  93216. * Gets the list of influences (one per target)
  93217. */
  93218. get influences(): Float32Array;
  93219. /**
  93220. * Gets the active target at specified index. An active target is a target with an influence > 0
  93221. * @param index defines the index to check
  93222. * @returns the requested target
  93223. */
  93224. getActiveTarget(index: number): MorphTarget;
  93225. /**
  93226. * Gets the target at specified index
  93227. * @param index defines the index to check
  93228. * @returns the requested target
  93229. */
  93230. getTarget(index: number): MorphTarget;
  93231. /**
  93232. * Add a new target to this manager
  93233. * @param target defines the target to add
  93234. */
  93235. addTarget(target: MorphTarget): void;
  93236. /**
  93237. * Removes a target from the manager
  93238. * @param target defines the target to remove
  93239. */
  93240. removeTarget(target: MorphTarget): void;
  93241. /**
  93242. * Clone the current manager
  93243. * @returns a new MorphTargetManager
  93244. */
  93245. clone(): MorphTargetManager;
  93246. /**
  93247. * Serializes the current manager into a Serialization object
  93248. * @returns the serialized object
  93249. */
  93250. serialize(): any;
  93251. private _syncActiveTargets;
  93252. /**
  93253. * Syncrhonize the targets with all the meshes using this morph target manager
  93254. */
  93255. synchronize(): void;
  93256. /**
  93257. * Creates a new MorphTargetManager from serialized data
  93258. * @param serializationObject defines the serialized data
  93259. * @param scene defines the hosting scene
  93260. * @returns the new MorphTargetManager
  93261. */
  93262. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  93263. }
  93264. }
  93265. declare module BABYLON {
  93266. /**
  93267. * Class used to represent a specific level of detail of a mesh
  93268. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93269. */
  93270. export class MeshLODLevel {
  93271. /** Defines the distance where this level should start being displayed */
  93272. distance: number;
  93273. /** Defines the mesh to use to render this level */
  93274. mesh: Nullable<Mesh>;
  93275. /**
  93276. * Creates a new LOD level
  93277. * @param distance defines the distance where this level should star being displayed
  93278. * @param mesh defines the mesh to use to render this level
  93279. */
  93280. constructor(
  93281. /** Defines the distance where this level should start being displayed */
  93282. distance: number,
  93283. /** Defines the mesh to use to render this level */
  93284. mesh: Nullable<Mesh>);
  93285. }
  93286. }
  93287. declare module BABYLON {
  93288. /**
  93289. * Mesh representing the gorund
  93290. */
  93291. export class GroundMesh extends Mesh {
  93292. /** If octree should be generated */
  93293. generateOctree: boolean;
  93294. private _heightQuads;
  93295. /** @hidden */
  93296. _subdivisionsX: number;
  93297. /** @hidden */
  93298. _subdivisionsY: number;
  93299. /** @hidden */
  93300. _width: number;
  93301. /** @hidden */
  93302. _height: number;
  93303. /** @hidden */
  93304. _minX: number;
  93305. /** @hidden */
  93306. _maxX: number;
  93307. /** @hidden */
  93308. _minZ: number;
  93309. /** @hidden */
  93310. _maxZ: number;
  93311. constructor(name: string, scene: Scene);
  93312. /**
  93313. * "GroundMesh"
  93314. * @returns "GroundMesh"
  93315. */
  93316. getClassName(): string;
  93317. /**
  93318. * The minimum of x and y subdivisions
  93319. */
  93320. get subdivisions(): number;
  93321. /**
  93322. * X subdivisions
  93323. */
  93324. get subdivisionsX(): number;
  93325. /**
  93326. * Y subdivisions
  93327. */
  93328. get subdivisionsY(): number;
  93329. /**
  93330. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  93331. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  93332. * @param chunksCount the number of subdivisions for x and y
  93333. * @param octreeBlocksSize (Default: 32)
  93334. */
  93335. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  93336. /**
  93337. * Returns a height (y) value in the Worl system :
  93338. * the ground altitude at the coordinates (x, z) expressed in the World system.
  93339. * @param x x coordinate
  93340. * @param z z coordinate
  93341. * @returns the ground y position if (x, z) are outside the ground surface.
  93342. */
  93343. getHeightAtCoordinates(x: number, z: number): number;
  93344. /**
  93345. * Returns a normalized vector (Vector3) orthogonal to the ground
  93346. * at the ground coordinates (x, z) expressed in the World system.
  93347. * @param x x coordinate
  93348. * @param z z coordinate
  93349. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  93350. */
  93351. getNormalAtCoordinates(x: number, z: number): Vector3;
  93352. /**
  93353. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  93354. * at the ground coordinates (x, z) expressed in the World system.
  93355. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  93356. * @param x x coordinate
  93357. * @param z z coordinate
  93358. * @param ref vector to store the result
  93359. * @returns the GroundMesh.
  93360. */
  93361. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  93362. /**
  93363. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  93364. * if the ground has been updated.
  93365. * This can be used in the render loop.
  93366. * @returns the GroundMesh.
  93367. */
  93368. updateCoordinateHeights(): GroundMesh;
  93369. private _getFacetAt;
  93370. private _initHeightQuads;
  93371. private _computeHeightQuads;
  93372. /**
  93373. * Serializes this ground mesh
  93374. * @param serializationObject object to write serialization to
  93375. */
  93376. serialize(serializationObject: any): void;
  93377. /**
  93378. * Parses a serialized ground mesh
  93379. * @param parsedMesh the serialized mesh
  93380. * @param scene the scene to create the ground mesh in
  93381. * @returns the created ground mesh
  93382. */
  93383. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  93384. }
  93385. }
  93386. declare module BABYLON {
  93387. /**
  93388. * Interface for Physics-Joint data
  93389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93390. */
  93391. export interface PhysicsJointData {
  93392. /**
  93393. * The main pivot of the joint
  93394. */
  93395. mainPivot?: Vector3;
  93396. /**
  93397. * The connected pivot of the joint
  93398. */
  93399. connectedPivot?: Vector3;
  93400. /**
  93401. * The main axis of the joint
  93402. */
  93403. mainAxis?: Vector3;
  93404. /**
  93405. * The connected axis of the joint
  93406. */
  93407. connectedAxis?: Vector3;
  93408. /**
  93409. * The collision of the joint
  93410. */
  93411. collision?: boolean;
  93412. /**
  93413. * Native Oimo/Cannon/Energy data
  93414. */
  93415. nativeParams?: any;
  93416. }
  93417. /**
  93418. * This is a holder class for the physics joint created by the physics plugin
  93419. * It holds a set of functions to control the underlying joint
  93420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93421. */
  93422. export class PhysicsJoint {
  93423. /**
  93424. * The type of the physics joint
  93425. */
  93426. type: number;
  93427. /**
  93428. * The data for the physics joint
  93429. */
  93430. jointData: PhysicsJointData;
  93431. private _physicsJoint;
  93432. protected _physicsPlugin: IPhysicsEnginePlugin;
  93433. /**
  93434. * Initializes the physics joint
  93435. * @param type The type of the physics joint
  93436. * @param jointData The data for the physics joint
  93437. */
  93438. constructor(
  93439. /**
  93440. * The type of the physics joint
  93441. */
  93442. type: number,
  93443. /**
  93444. * The data for the physics joint
  93445. */
  93446. jointData: PhysicsJointData);
  93447. /**
  93448. * Gets the physics joint
  93449. */
  93450. get physicsJoint(): any;
  93451. /**
  93452. * Sets the physics joint
  93453. */
  93454. set physicsJoint(newJoint: any);
  93455. /**
  93456. * Sets the physics plugin
  93457. */
  93458. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  93459. /**
  93460. * Execute a function that is physics-plugin specific.
  93461. * @param {Function} func the function that will be executed.
  93462. * It accepts two parameters: the physics world and the physics joint
  93463. */
  93464. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  93465. /**
  93466. * Distance-Joint type
  93467. */
  93468. static DistanceJoint: number;
  93469. /**
  93470. * Hinge-Joint type
  93471. */
  93472. static HingeJoint: number;
  93473. /**
  93474. * Ball-and-Socket joint type
  93475. */
  93476. static BallAndSocketJoint: number;
  93477. /**
  93478. * Wheel-Joint type
  93479. */
  93480. static WheelJoint: number;
  93481. /**
  93482. * Slider-Joint type
  93483. */
  93484. static SliderJoint: number;
  93485. /**
  93486. * Prismatic-Joint type
  93487. */
  93488. static PrismaticJoint: number;
  93489. /**
  93490. * Universal-Joint type
  93491. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  93492. */
  93493. static UniversalJoint: number;
  93494. /**
  93495. * Hinge-Joint 2 type
  93496. */
  93497. static Hinge2Joint: number;
  93498. /**
  93499. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  93500. */
  93501. static PointToPointJoint: number;
  93502. /**
  93503. * Spring-Joint type
  93504. */
  93505. static SpringJoint: number;
  93506. /**
  93507. * Lock-Joint type
  93508. */
  93509. static LockJoint: number;
  93510. }
  93511. /**
  93512. * A class representing a physics distance joint
  93513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93514. */
  93515. export class DistanceJoint extends PhysicsJoint {
  93516. /**
  93517. *
  93518. * @param jointData The data for the Distance-Joint
  93519. */
  93520. constructor(jointData: DistanceJointData);
  93521. /**
  93522. * Update the predefined distance.
  93523. * @param maxDistance The maximum preferred distance
  93524. * @param minDistance The minimum preferred distance
  93525. */
  93526. updateDistance(maxDistance: number, minDistance?: number): void;
  93527. }
  93528. /**
  93529. * Represents a Motor-Enabled Joint
  93530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93531. */
  93532. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  93533. /**
  93534. * Initializes the Motor-Enabled Joint
  93535. * @param type The type of the joint
  93536. * @param jointData The physica joint data for the joint
  93537. */
  93538. constructor(type: number, jointData: PhysicsJointData);
  93539. /**
  93540. * Set the motor values.
  93541. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93542. * @param force the force to apply
  93543. * @param maxForce max force for this motor.
  93544. */
  93545. setMotor(force?: number, maxForce?: number): void;
  93546. /**
  93547. * Set the motor's limits.
  93548. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93549. * @param upperLimit The upper limit of the motor
  93550. * @param lowerLimit The lower limit of the motor
  93551. */
  93552. setLimit(upperLimit: number, lowerLimit?: number): void;
  93553. }
  93554. /**
  93555. * This class represents a single physics Hinge-Joint
  93556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93557. */
  93558. export class HingeJoint extends MotorEnabledJoint {
  93559. /**
  93560. * Initializes the Hinge-Joint
  93561. * @param jointData The joint data for the Hinge-Joint
  93562. */
  93563. constructor(jointData: PhysicsJointData);
  93564. /**
  93565. * Set the motor values.
  93566. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93567. * @param {number} force the force to apply
  93568. * @param {number} maxForce max force for this motor.
  93569. */
  93570. setMotor(force?: number, maxForce?: number): void;
  93571. /**
  93572. * Set the motor's limits.
  93573. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93574. * @param upperLimit The upper limit of the motor
  93575. * @param lowerLimit The lower limit of the motor
  93576. */
  93577. setLimit(upperLimit: number, lowerLimit?: number): void;
  93578. }
  93579. /**
  93580. * This class represents a dual hinge physics joint (same as wheel joint)
  93581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93582. */
  93583. export class Hinge2Joint extends MotorEnabledJoint {
  93584. /**
  93585. * Initializes the Hinge2-Joint
  93586. * @param jointData The joint data for the Hinge2-Joint
  93587. */
  93588. constructor(jointData: PhysicsJointData);
  93589. /**
  93590. * Set the motor values.
  93591. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93592. * @param {number} targetSpeed the speed the motor is to reach
  93593. * @param {number} maxForce max force for this motor.
  93594. * @param {motorIndex} the motor's index, 0 or 1.
  93595. */
  93596. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  93597. /**
  93598. * Set the motor limits.
  93599. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93600. * @param {number} upperLimit the upper limit
  93601. * @param {number} lowerLimit lower limit
  93602. * @param {motorIndex} the motor's index, 0 or 1.
  93603. */
  93604. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93605. }
  93606. /**
  93607. * Interface for a motor enabled joint
  93608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93609. */
  93610. export interface IMotorEnabledJoint {
  93611. /**
  93612. * Physics joint
  93613. */
  93614. physicsJoint: any;
  93615. /**
  93616. * Sets the motor of the motor-enabled joint
  93617. * @param force The force of the motor
  93618. * @param maxForce The maximum force of the motor
  93619. * @param motorIndex The index of the motor
  93620. */
  93621. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  93622. /**
  93623. * Sets the limit of the motor
  93624. * @param upperLimit The upper limit of the motor
  93625. * @param lowerLimit The lower limit of the motor
  93626. * @param motorIndex The index of the motor
  93627. */
  93628. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93629. }
  93630. /**
  93631. * Joint data for a Distance-Joint
  93632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93633. */
  93634. export interface DistanceJointData extends PhysicsJointData {
  93635. /**
  93636. * Max distance the 2 joint objects can be apart
  93637. */
  93638. maxDistance: number;
  93639. }
  93640. /**
  93641. * Joint data from a spring joint
  93642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93643. */
  93644. export interface SpringJointData extends PhysicsJointData {
  93645. /**
  93646. * Length of the spring
  93647. */
  93648. length: number;
  93649. /**
  93650. * Stiffness of the spring
  93651. */
  93652. stiffness: number;
  93653. /**
  93654. * Damping of the spring
  93655. */
  93656. damping: number;
  93657. /** this callback will be called when applying the force to the impostors. */
  93658. forceApplicationCallback: () => void;
  93659. }
  93660. }
  93661. declare module BABYLON {
  93662. /**
  93663. * Holds the data for the raycast result
  93664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93665. */
  93666. export class PhysicsRaycastResult {
  93667. private _hasHit;
  93668. private _hitDistance;
  93669. private _hitNormalWorld;
  93670. private _hitPointWorld;
  93671. private _rayFromWorld;
  93672. private _rayToWorld;
  93673. /**
  93674. * Gets if there was a hit
  93675. */
  93676. get hasHit(): boolean;
  93677. /**
  93678. * Gets the distance from the hit
  93679. */
  93680. get hitDistance(): number;
  93681. /**
  93682. * Gets the hit normal/direction in the world
  93683. */
  93684. get hitNormalWorld(): Vector3;
  93685. /**
  93686. * Gets the hit point in the world
  93687. */
  93688. get hitPointWorld(): Vector3;
  93689. /**
  93690. * Gets the ray "start point" of the ray in the world
  93691. */
  93692. get rayFromWorld(): Vector3;
  93693. /**
  93694. * Gets the ray "end point" of the ray in the world
  93695. */
  93696. get rayToWorld(): Vector3;
  93697. /**
  93698. * Sets the hit data (normal & point in world space)
  93699. * @param hitNormalWorld defines the normal in world space
  93700. * @param hitPointWorld defines the point in world space
  93701. */
  93702. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  93703. /**
  93704. * Sets the distance from the start point to the hit point
  93705. * @param distance
  93706. */
  93707. setHitDistance(distance: number): void;
  93708. /**
  93709. * Calculates the distance manually
  93710. */
  93711. calculateHitDistance(): void;
  93712. /**
  93713. * Resets all the values to default
  93714. * @param from The from point on world space
  93715. * @param to The to point on world space
  93716. */
  93717. reset(from?: Vector3, to?: Vector3): void;
  93718. }
  93719. /**
  93720. * Interface for the size containing width and height
  93721. */
  93722. interface IXYZ {
  93723. /**
  93724. * X
  93725. */
  93726. x: number;
  93727. /**
  93728. * Y
  93729. */
  93730. y: number;
  93731. /**
  93732. * Z
  93733. */
  93734. z: number;
  93735. }
  93736. }
  93737. declare module BABYLON {
  93738. /**
  93739. * Interface used to describe a physics joint
  93740. */
  93741. export interface PhysicsImpostorJoint {
  93742. /** Defines the main impostor to which the joint is linked */
  93743. mainImpostor: PhysicsImpostor;
  93744. /** Defines the impostor that is connected to the main impostor using this joint */
  93745. connectedImpostor: PhysicsImpostor;
  93746. /** Defines the joint itself */
  93747. joint: PhysicsJoint;
  93748. }
  93749. /** @hidden */
  93750. export interface IPhysicsEnginePlugin {
  93751. world: any;
  93752. name: string;
  93753. setGravity(gravity: Vector3): void;
  93754. setTimeStep(timeStep: number): void;
  93755. getTimeStep(): number;
  93756. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  93757. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93758. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93759. generatePhysicsBody(impostor: PhysicsImpostor): void;
  93760. removePhysicsBody(impostor: PhysicsImpostor): void;
  93761. generateJoint(joint: PhysicsImpostorJoint): void;
  93762. removeJoint(joint: PhysicsImpostorJoint): void;
  93763. isSupported(): boolean;
  93764. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  93765. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  93766. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93767. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93768. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93769. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93770. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  93771. getBodyMass(impostor: PhysicsImpostor): number;
  93772. getBodyFriction(impostor: PhysicsImpostor): number;
  93773. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  93774. getBodyRestitution(impostor: PhysicsImpostor): number;
  93775. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  93776. getBodyPressure?(impostor: PhysicsImpostor): number;
  93777. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  93778. getBodyStiffness?(impostor: PhysicsImpostor): number;
  93779. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  93780. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  93781. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  93782. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  93783. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  93784. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93785. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93786. sleepBody(impostor: PhysicsImpostor): void;
  93787. wakeUpBody(impostor: PhysicsImpostor): void;
  93788. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93789. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  93790. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  93791. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93792. getRadius(impostor: PhysicsImpostor): number;
  93793. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  93794. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  93795. dispose(): void;
  93796. }
  93797. /**
  93798. * Interface used to define a physics engine
  93799. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  93800. */
  93801. export interface IPhysicsEngine {
  93802. /**
  93803. * Gets the gravity vector used by the simulation
  93804. */
  93805. gravity: Vector3;
  93806. /**
  93807. * Sets the gravity vector used by the simulation
  93808. * @param gravity defines the gravity vector to use
  93809. */
  93810. setGravity(gravity: Vector3): void;
  93811. /**
  93812. * Set the time step of the physics engine.
  93813. * Default is 1/60.
  93814. * To slow it down, enter 1/600 for example.
  93815. * To speed it up, 1/30
  93816. * @param newTimeStep the new timestep to apply to this world.
  93817. */
  93818. setTimeStep(newTimeStep: number): void;
  93819. /**
  93820. * Get the time step of the physics engine.
  93821. * @returns the current time step
  93822. */
  93823. getTimeStep(): number;
  93824. /**
  93825. * Set the sub time step of the physics engine.
  93826. * Default is 0 meaning there is no sub steps
  93827. * To increase physics resolution precision, set a small value (like 1 ms)
  93828. * @param subTimeStep defines the new sub timestep used for physics resolution.
  93829. */
  93830. setSubTimeStep(subTimeStep: number): void;
  93831. /**
  93832. * Get the sub time step of the physics engine.
  93833. * @returns the current sub time step
  93834. */
  93835. getSubTimeStep(): number;
  93836. /**
  93837. * Release all resources
  93838. */
  93839. dispose(): void;
  93840. /**
  93841. * Gets the name of the current physics plugin
  93842. * @returns the name of the plugin
  93843. */
  93844. getPhysicsPluginName(): string;
  93845. /**
  93846. * Adding a new impostor for the impostor tracking.
  93847. * This will be done by the impostor itself.
  93848. * @param impostor the impostor to add
  93849. */
  93850. addImpostor(impostor: PhysicsImpostor): void;
  93851. /**
  93852. * Remove an impostor from the engine.
  93853. * This impostor and its mesh will not longer be updated by the physics engine.
  93854. * @param impostor the impostor to remove
  93855. */
  93856. removeImpostor(impostor: PhysicsImpostor): void;
  93857. /**
  93858. * Add a joint to the physics engine
  93859. * @param mainImpostor defines the main impostor to which the joint is added.
  93860. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  93861. * @param joint defines the joint that will connect both impostors.
  93862. */
  93863. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93864. /**
  93865. * Removes a joint from the simulation
  93866. * @param mainImpostor defines the impostor used with the joint
  93867. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  93868. * @param joint defines the joint to remove
  93869. */
  93870. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93871. /**
  93872. * Gets the current plugin used to run the simulation
  93873. * @returns current plugin
  93874. */
  93875. getPhysicsPlugin(): IPhysicsEnginePlugin;
  93876. /**
  93877. * Gets the list of physic impostors
  93878. * @returns an array of PhysicsImpostor
  93879. */
  93880. getImpostors(): Array<PhysicsImpostor>;
  93881. /**
  93882. * Gets the impostor for a physics enabled object
  93883. * @param object defines the object impersonated by the impostor
  93884. * @returns the PhysicsImpostor or null if not found
  93885. */
  93886. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  93887. /**
  93888. * Gets the impostor for a physics body object
  93889. * @param body defines physics body used by the impostor
  93890. * @returns the PhysicsImpostor or null if not found
  93891. */
  93892. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  93893. /**
  93894. * Does a raycast in the physics world
  93895. * @param from when should the ray start?
  93896. * @param to when should the ray end?
  93897. * @returns PhysicsRaycastResult
  93898. */
  93899. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93900. /**
  93901. * Called by the scene. No need to call it.
  93902. * @param delta defines the timespam between frames
  93903. */
  93904. _step(delta: number): void;
  93905. }
  93906. }
  93907. declare module BABYLON {
  93908. /**
  93909. * The interface for the physics imposter parameters
  93910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93911. */
  93912. export interface PhysicsImpostorParameters {
  93913. /**
  93914. * The mass of the physics imposter
  93915. */
  93916. mass: number;
  93917. /**
  93918. * The friction of the physics imposter
  93919. */
  93920. friction?: number;
  93921. /**
  93922. * The coefficient of restitution of the physics imposter
  93923. */
  93924. restitution?: number;
  93925. /**
  93926. * The native options of the physics imposter
  93927. */
  93928. nativeOptions?: any;
  93929. /**
  93930. * Specifies if the parent should be ignored
  93931. */
  93932. ignoreParent?: boolean;
  93933. /**
  93934. * Specifies if bi-directional transformations should be disabled
  93935. */
  93936. disableBidirectionalTransformation?: boolean;
  93937. /**
  93938. * The pressure inside the physics imposter, soft object only
  93939. */
  93940. pressure?: number;
  93941. /**
  93942. * The stiffness the physics imposter, soft object only
  93943. */
  93944. stiffness?: number;
  93945. /**
  93946. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  93947. */
  93948. velocityIterations?: number;
  93949. /**
  93950. * The number of iterations used in maintaining consistent vertex positions, soft object only
  93951. */
  93952. positionIterations?: number;
  93953. /**
  93954. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  93955. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  93956. * Add to fix multiple points
  93957. */
  93958. fixedPoints?: number;
  93959. /**
  93960. * The collision margin around a soft object
  93961. */
  93962. margin?: number;
  93963. /**
  93964. * The collision margin around a soft object
  93965. */
  93966. damping?: number;
  93967. /**
  93968. * The path for a rope based on an extrusion
  93969. */
  93970. path?: any;
  93971. /**
  93972. * The shape of an extrusion used for a rope based on an extrusion
  93973. */
  93974. shape?: any;
  93975. }
  93976. /**
  93977. * Interface for a physics-enabled object
  93978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93979. */
  93980. export interface IPhysicsEnabledObject {
  93981. /**
  93982. * The position of the physics-enabled object
  93983. */
  93984. position: Vector3;
  93985. /**
  93986. * The rotation of the physics-enabled object
  93987. */
  93988. rotationQuaternion: Nullable<Quaternion>;
  93989. /**
  93990. * The scale of the physics-enabled object
  93991. */
  93992. scaling: Vector3;
  93993. /**
  93994. * The rotation of the physics-enabled object
  93995. */
  93996. rotation?: Vector3;
  93997. /**
  93998. * The parent of the physics-enabled object
  93999. */
  94000. parent?: any;
  94001. /**
  94002. * The bounding info of the physics-enabled object
  94003. * @returns The bounding info of the physics-enabled object
  94004. */
  94005. getBoundingInfo(): BoundingInfo;
  94006. /**
  94007. * Computes the world matrix
  94008. * @param force Specifies if the world matrix should be computed by force
  94009. * @returns A world matrix
  94010. */
  94011. computeWorldMatrix(force: boolean): Matrix;
  94012. /**
  94013. * Gets the world matrix
  94014. * @returns A world matrix
  94015. */
  94016. getWorldMatrix?(): Matrix;
  94017. /**
  94018. * Gets the child meshes
  94019. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  94020. * @returns An array of abstract meshes
  94021. */
  94022. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  94023. /**
  94024. * Gets the vertex data
  94025. * @param kind The type of vertex data
  94026. * @returns A nullable array of numbers, or a float32 array
  94027. */
  94028. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  94029. /**
  94030. * Gets the indices from the mesh
  94031. * @returns A nullable array of index arrays
  94032. */
  94033. getIndices?(): Nullable<IndicesArray>;
  94034. /**
  94035. * Gets the scene from the mesh
  94036. * @returns the indices array or null
  94037. */
  94038. getScene?(): Scene;
  94039. /**
  94040. * Gets the absolute position from the mesh
  94041. * @returns the absolute position
  94042. */
  94043. getAbsolutePosition(): Vector3;
  94044. /**
  94045. * Gets the absolute pivot point from the mesh
  94046. * @returns the absolute pivot point
  94047. */
  94048. getAbsolutePivotPoint(): Vector3;
  94049. /**
  94050. * Rotates the mesh
  94051. * @param axis The axis of rotation
  94052. * @param amount The amount of rotation
  94053. * @param space The space of the rotation
  94054. * @returns The rotation transform node
  94055. */
  94056. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94057. /**
  94058. * Translates the mesh
  94059. * @param axis The axis of translation
  94060. * @param distance The distance of translation
  94061. * @param space The space of the translation
  94062. * @returns The transform node
  94063. */
  94064. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94065. /**
  94066. * Sets the absolute position of the mesh
  94067. * @param absolutePosition The absolute position of the mesh
  94068. * @returns The transform node
  94069. */
  94070. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94071. /**
  94072. * Gets the class name of the mesh
  94073. * @returns The class name
  94074. */
  94075. getClassName(): string;
  94076. }
  94077. /**
  94078. * Represents a physics imposter
  94079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94080. */
  94081. export class PhysicsImpostor {
  94082. /**
  94083. * The physics-enabled object used as the physics imposter
  94084. */
  94085. object: IPhysicsEnabledObject;
  94086. /**
  94087. * The type of the physics imposter
  94088. */
  94089. type: number;
  94090. private _options;
  94091. private _scene?;
  94092. /**
  94093. * The default object size of the imposter
  94094. */
  94095. static DEFAULT_OBJECT_SIZE: Vector3;
  94096. /**
  94097. * The identity quaternion of the imposter
  94098. */
  94099. static IDENTITY_QUATERNION: Quaternion;
  94100. /** @hidden */
  94101. _pluginData: any;
  94102. private _physicsEngine;
  94103. private _physicsBody;
  94104. private _bodyUpdateRequired;
  94105. private _onBeforePhysicsStepCallbacks;
  94106. private _onAfterPhysicsStepCallbacks;
  94107. /** @hidden */
  94108. _onPhysicsCollideCallbacks: Array<{
  94109. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  94110. otherImpostors: Array<PhysicsImpostor>;
  94111. }>;
  94112. private _deltaPosition;
  94113. private _deltaRotation;
  94114. private _deltaRotationConjugated;
  94115. /** @hidden */
  94116. _isFromLine: boolean;
  94117. private _parent;
  94118. private _isDisposed;
  94119. private static _tmpVecs;
  94120. private static _tmpQuat;
  94121. /**
  94122. * Specifies if the physics imposter is disposed
  94123. */
  94124. get isDisposed(): boolean;
  94125. /**
  94126. * Gets the mass of the physics imposter
  94127. */
  94128. get mass(): number;
  94129. set mass(value: number);
  94130. /**
  94131. * Gets the coefficient of friction
  94132. */
  94133. get friction(): number;
  94134. /**
  94135. * Sets the coefficient of friction
  94136. */
  94137. set friction(value: number);
  94138. /**
  94139. * Gets the coefficient of restitution
  94140. */
  94141. get restitution(): number;
  94142. /**
  94143. * Sets the coefficient of restitution
  94144. */
  94145. set restitution(value: number);
  94146. /**
  94147. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  94148. */
  94149. get pressure(): number;
  94150. /**
  94151. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  94152. */
  94153. set pressure(value: number);
  94154. /**
  94155. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94156. */
  94157. get stiffness(): number;
  94158. /**
  94159. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94160. */
  94161. set stiffness(value: number);
  94162. /**
  94163. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94164. */
  94165. get velocityIterations(): number;
  94166. /**
  94167. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94168. */
  94169. set velocityIterations(value: number);
  94170. /**
  94171. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94172. */
  94173. get positionIterations(): number;
  94174. /**
  94175. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94176. */
  94177. set positionIterations(value: number);
  94178. /**
  94179. * The unique id of the physics imposter
  94180. * set by the physics engine when adding this impostor to the array
  94181. */
  94182. uniqueId: number;
  94183. /**
  94184. * @hidden
  94185. */
  94186. soft: boolean;
  94187. /**
  94188. * @hidden
  94189. */
  94190. segments: number;
  94191. private _joints;
  94192. /**
  94193. * Initializes the physics imposter
  94194. * @param object The physics-enabled object used as the physics imposter
  94195. * @param type The type of the physics imposter
  94196. * @param _options The options for the physics imposter
  94197. * @param _scene The Babylon scene
  94198. */
  94199. constructor(
  94200. /**
  94201. * The physics-enabled object used as the physics imposter
  94202. */
  94203. object: IPhysicsEnabledObject,
  94204. /**
  94205. * The type of the physics imposter
  94206. */
  94207. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  94208. /**
  94209. * This function will completly initialize this impostor.
  94210. * It will create a new body - but only if this mesh has no parent.
  94211. * If it has, this impostor will not be used other than to define the impostor
  94212. * of the child mesh.
  94213. * @hidden
  94214. */
  94215. _init(): void;
  94216. private _getPhysicsParent;
  94217. /**
  94218. * Should a new body be generated.
  94219. * @returns boolean specifying if body initialization is required
  94220. */
  94221. isBodyInitRequired(): boolean;
  94222. /**
  94223. * Sets the updated scaling
  94224. * @param updated Specifies if the scaling is updated
  94225. */
  94226. setScalingUpdated(): void;
  94227. /**
  94228. * Force a regeneration of this or the parent's impostor's body.
  94229. * Use under cautious - This will remove all joints already implemented.
  94230. */
  94231. forceUpdate(): void;
  94232. /**
  94233. * Gets the body that holds this impostor. Either its own, or its parent.
  94234. */
  94235. get physicsBody(): any;
  94236. /**
  94237. * Get the parent of the physics imposter
  94238. * @returns Physics imposter or null
  94239. */
  94240. get parent(): Nullable<PhysicsImpostor>;
  94241. /**
  94242. * Sets the parent of the physics imposter
  94243. */
  94244. set parent(value: Nullable<PhysicsImpostor>);
  94245. /**
  94246. * Set the physics body. Used mainly by the physics engine/plugin
  94247. */
  94248. set physicsBody(physicsBody: any);
  94249. /**
  94250. * Resets the update flags
  94251. */
  94252. resetUpdateFlags(): void;
  94253. /**
  94254. * Gets the object extend size
  94255. * @returns the object extend size
  94256. */
  94257. getObjectExtendSize(): Vector3;
  94258. /**
  94259. * Gets the object center
  94260. * @returns The object center
  94261. */
  94262. getObjectCenter(): Vector3;
  94263. /**
  94264. * Get a specific parametes from the options parameter
  94265. * @param paramName The object parameter name
  94266. * @returns The object parameter
  94267. */
  94268. getParam(paramName: string): any;
  94269. /**
  94270. * Sets a specific parameter in the options given to the physics plugin
  94271. * @param paramName The parameter name
  94272. * @param value The value of the parameter
  94273. */
  94274. setParam(paramName: string, value: number): void;
  94275. /**
  94276. * Specifically change the body's mass option. Won't recreate the physics body object
  94277. * @param mass The mass of the physics imposter
  94278. */
  94279. setMass(mass: number): void;
  94280. /**
  94281. * Gets the linear velocity
  94282. * @returns linear velocity or null
  94283. */
  94284. getLinearVelocity(): Nullable<Vector3>;
  94285. /**
  94286. * Sets the linear velocity
  94287. * @param velocity linear velocity or null
  94288. */
  94289. setLinearVelocity(velocity: Nullable<Vector3>): void;
  94290. /**
  94291. * Gets the angular velocity
  94292. * @returns angular velocity or null
  94293. */
  94294. getAngularVelocity(): Nullable<Vector3>;
  94295. /**
  94296. * Sets the angular velocity
  94297. * @param velocity The velocity or null
  94298. */
  94299. setAngularVelocity(velocity: Nullable<Vector3>): void;
  94300. /**
  94301. * Execute a function with the physics plugin native code
  94302. * Provide a function the will have two variables - the world object and the physics body object
  94303. * @param func The function to execute with the physics plugin native code
  94304. */
  94305. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  94306. /**
  94307. * Register a function that will be executed before the physics world is stepping forward
  94308. * @param func The function to execute before the physics world is stepped forward
  94309. */
  94310. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94311. /**
  94312. * Unregister a function that will be executed before the physics world is stepping forward
  94313. * @param func The function to execute before the physics world is stepped forward
  94314. */
  94315. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94316. /**
  94317. * Register a function that will be executed after the physics step
  94318. * @param func The function to execute after physics step
  94319. */
  94320. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94321. /**
  94322. * Unregisters a function that will be executed after the physics step
  94323. * @param func The function to execute after physics step
  94324. */
  94325. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94326. /**
  94327. * register a function that will be executed when this impostor collides against a different body
  94328. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  94329. * @param func Callback that is executed on collision
  94330. */
  94331. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  94332. /**
  94333. * Unregisters the physics imposter on contact
  94334. * @param collideAgainst The physics object to collide against
  94335. * @param func Callback to execute on collision
  94336. */
  94337. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  94338. private _tmpQuat;
  94339. private _tmpQuat2;
  94340. /**
  94341. * Get the parent rotation
  94342. * @returns The parent rotation
  94343. */
  94344. getParentsRotation(): Quaternion;
  94345. /**
  94346. * this function is executed by the physics engine.
  94347. */
  94348. beforeStep: () => void;
  94349. /**
  94350. * this function is executed by the physics engine
  94351. */
  94352. afterStep: () => void;
  94353. /**
  94354. * Legacy collision detection event support
  94355. */
  94356. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  94357. /**
  94358. * event and body object due to cannon's event-based architecture.
  94359. */
  94360. onCollide: (e: {
  94361. body: any;
  94362. }) => void;
  94363. /**
  94364. * Apply a force
  94365. * @param force The force to apply
  94366. * @param contactPoint The contact point for the force
  94367. * @returns The physics imposter
  94368. */
  94369. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94370. /**
  94371. * Apply an impulse
  94372. * @param force The impulse force
  94373. * @param contactPoint The contact point for the impulse force
  94374. * @returns The physics imposter
  94375. */
  94376. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94377. /**
  94378. * A help function to create a joint
  94379. * @param otherImpostor A physics imposter used to create a joint
  94380. * @param jointType The type of joint
  94381. * @param jointData The data for the joint
  94382. * @returns The physics imposter
  94383. */
  94384. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  94385. /**
  94386. * Add a joint to this impostor with a different impostor
  94387. * @param otherImpostor A physics imposter used to add a joint
  94388. * @param joint The joint to add
  94389. * @returns The physics imposter
  94390. */
  94391. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  94392. /**
  94393. * Add an anchor to a cloth impostor
  94394. * @param otherImpostor rigid impostor to anchor to
  94395. * @param width ratio across width from 0 to 1
  94396. * @param height ratio up height from 0 to 1
  94397. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  94398. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  94399. * @returns impostor the soft imposter
  94400. */
  94401. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94402. /**
  94403. * Add a hook to a rope impostor
  94404. * @param otherImpostor rigid impostor to anchor to
  94405. * @param length ratio across rope from 0 to 1
  94406. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  94407. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  94408. * @returns impostor the rope imposter
  94409. */
  94410. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94411. /**
  94412. * Will keep this body still, in a sleep mode.
  94413. * @returns the physics imposter
  94414. */
  94415. sleep(): PhysicsImpostor;
  94416. /**
  94417. * Wake the body up.
  94418. * @returns The physics imposter
  94419. */
  94420. wakeUp(): PhysicsImpostor;
  94421. /**
  94422. * Clones the physics imposter
  94423. * @param newObject The physics imposter clones to this physics-enabled object
  94424. * @returns A nullable physics imposter
  94425. */
  94426. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94427. /**
  94428. * Disposes the physics imposter
  94429. */
  94430. dispose(): void;
  94431. /**
  94432. * Sets the delta position
  94433. * @param position The delta position amount
  94434. */
  94435. setDeltaPosition(position: Vector3): void;
  94436. /**
  94437. * Sets the delta rotation
  94438. * @param rotation The delta rotation amount
  94439. */
  94440. setDeltaRotation(rotation: Quaternion): void;
  94441. /**
  94442. * Gets the box size of the physics imposter and stores the result in the input parameter
  94443. * @param result Stores the box size
  94444. * @returns The physics imposter
  94445. */
  94446. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  94447. /**
  94448. * Gets the radius of the physics imposter
  94449. * @returns Radius of the physics imposter
  94450. */
  94451. getRadius(): number;
  94452. /**
  94453. * Sync a bone with this impostor
  94454. * @param bone The bone to sync to the impostor.
  94455. * @param boneMesh The mesh that the bone is influencing.
  94456. * @param jointPivot The pivot of the joint / bone in local space.
  94457. * @param distToJoint Optional distance from the impostor to the joint.
  94458. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94459. */
  94460. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  94461. /**
  94462. * Sync impostor to a bone
  94463. * @param bone The bone that the impostor will be synced to.
  94464. * @param boneMesh The mesh that the bone is influencing.
  94465. * @param jointPivot The pivot of the joint / bone in local space.
  94466. * @param distToJoint Optional distance from the impostor to the joint.
  94467. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94468. * @param boneAxis Optional vector3 axis the bone is aligned with
  94469. */
  94470. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  94471. /**
  94472. * No-Imposter type
  94473. */
  94474. static NoImpostor: number;
  94475. /**
  94476. * Sphere-Imposter type
  94477. */
  94478. static SphereImpostor: number;
  94479. /**
  94480. * Box-Imposter type
  94481. */
  94482. static BoxImpostor: number;
  94483. /**
  94484. * Plane-Imposter type
  94485. */
  94486. static PlaneImpostor: number;
  94487. /**
  94488. * Mesh-imposter type
  94489. */
  94490. static MeshImpostor: number;
  94491. /**
  94492. * Capsule-Impostor type (Ammo.js plugin only)
  94493. */
  94494. static CapsuleImpostor: number;
  94495. /**
  94496. * Cylinder-Imposter type
  94497. */
  94498. static CylinderImpostor: number;
  94499. /**
  94500. * Particle-Imposter type
  94501. */
  94502. static ParticleImpostor: number;
  94503. /**
  94504. * Heightmap-Imposter type
  94505. */
  94506. static HeightmapImpostor: number;
  94507. /**
  94508. * ConvexHull-Impostor type (Ammo.js plugin only)
  94509. */
  94510. static ConvexHullImpostor: number;
  94511. /**
  94512. * Custom-Imposter type (Ammo.js plugin only)
  94513. */
  94514. static CustomImpostor: number;
  94515. /**
  94516. * Rope-Imposter type
  94517. */
  94518. static RopeImpostor: number;
  94519. /**
  94520. * Cloth-Imposter type
  94521. */
  94522. static ClothImpostor: number;
  94523. /**
  94524. * Softbody-Imposter type
  94525. */
  94526. static SoftbodyImpostor: number;
  94527. }
  94528. }
  94529. declare module BABYLON {
  94530. /**
  94531. * @hidden
  94532. **/
  94533. export class _CreationDataStorage {
  94534. closePath?: boolean;
  94535. closeArray?: boolean;
  94536. idx: number[];
  94537. dashSize: number;
  94538. gapSize: number;
  94539. path3D: Path3D;
  94540. pathArray: Vector3[][];
  94541. arc: number;
  94542. radius: number;
  94543. cap: number;
  94544. tessellation: number;
  94545. }
  94546. /**
  94547. * @hidden
  94548. **/
  94549. class _InstanceDataStorage {
  94550. visibleInstances: any;
  94551. batchCache: _InstancesBatch;
  94552. instancesBufferSize: number;
  94553. instancesBuffer: Nullable<Buffer>;
  94554. instancesData: Float32Array;
  94555. overridenInstanceCount: number;
  94556. isFrozen: boolean;
  94557. previousBatch: Nullable<_InstancesBatch>;
  94558. hardwareInstancedRendering: boolean;
  94559. sideOrientation: number;
  94560. manualUpdate: boolean;
  94561. }
  94562. /**
  94563. * @hidden
  94564. **/
  94565. export class _InstancesBatch {
  94566. mustReturn: boolean;
  94567. visibleInstances: Nullable<InstancedMesh[]>[];
  94568. renderSelf: boolean[];
  94569. hardwareInstancedRendering: boolean[];
  94570. }
  94571. /**
  94572. * Class used to represent renderable models
  94573. */
  94574. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  94575. /**
  94576. * Mesh side orientation : usually the external or front surface
  94577. */
  94578. static readonly FRONTSIDE: number;
  94579. /**
  94580. * Mesh side orientation : usually the internal or back surface
  94581. */
  94582. static readonly BACKSIDE: number;
  94583. /**
  94584. * Mesh side orientation : both internal and external or front and back surfaces
  94585. */
  94586. static readonly DOUBLESIDE: number;
  94587. /**
  94588. * Mesh side orientation : by default, `FRONTSIDE`
  94589. */
  94590. static readonly DEFAULTSIDE: number;
  94591. /**
  94592. * Mesh cap setting : no cap
  94593. */
  94594. static readonly NO_CAP: number;
  94595. /**
  94596. * Mesh cap setting : one cap at the beginning of the mesh
  94597. */
  94598. static readonly CAP_START: number;
  94599. /**
  94600. * Mesh cap setting : one cap at the end of the mesh
  94601. */
  94602. static readonly CAP_END: number;
  94603. /**
  94604. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  94605. */
  94606. static readonly CAP_ALL: number;
  94607. /**
  94608. * Mesh pattern setting : no flip or rotate
  94609. */
  94610. static readonly NO_FLIP: number;
  94611. /**
  94612. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  94613. */
  94614. static readonly FLIP_TILE: number;
  94615. /**
  94616. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  94617. */
  94618. static readonly ROTATE_TILE: number;
  94619. /**
  94620. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  94621. */
  94622. static readonly FLIP_ROW: number;
  94623. /**
  94624. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  94625. */
  94626. static readonly ROTATE_ROW: number;
  94627. /**
  94628. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  94629. */
  94630. static readonly FLIP_N_ROTATE_TILE: number;
  94631. /**
  94632. * Mesh pattern setting : rotate pattern and rotate
  94633. */
  94634. static readonly FLIP_N_ROTATE_ROW: number;
  94635. /**
  94636. * Mesh tile positioning : part tiles same on left/right or top/bottom
  94637. */
  94638. static readonly CENTER: number;
  94639. /**
  94640. * Mesh tile positioning : part tiles on left
  94641. */
  94642. static readonly LEFT: number;
  94643. /**
  94644. * Mesh tile positioning : part tiles on right
  94645. */
  94646. static readonly RIGHT: number;
  94647. /**
  94648. * Mesh tile positioning : part tiles on top
  94649. */
  94650. static readonly TOP: number;
  94651. /**
  94652. * Mesh tile positioning : part tiles on bottom
  94653. */
  94654. static readonly BOTTOM: number;
  94655. /**
  94656. * Gets the default side orientation.
  94657. * @param orientation the orientation to value to attempt to get
  94658. * @returns the default orientation
  94659. * @hidden
  94660. */
  94661. static _GetDefaultSideOrientation(orientation?: number): number;
  94662. private _internalMeshDataInfo;
  94663. /**
  94664. * An event triggered before rendering the mesh
  94665. */
  94666. get onBeforeRenderObservable(): Observable<Mesh>;
  94667. /**
  94668. * An event triggered before binding the mesh
  94669. */
  94670. get onBeforeBindObservable(): Observable<Mesh>;
  94671. /**
  94672. * An event triggered after rendering the mesh
  94673. */
  94674. get onAfterRenderObservable(): Observable<Mesh>;
  94675. /**
  94676. * An event triggered before drawing the mesh
  94677. */
  94678. get onBeforeDrawObservable(): Observable<Mesh>;
  94679. private _onBeforeDrawObserver;
  94680. /**
  94681. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  94682. */
  94683. set onBeforeDraw(callback: () => void);
  94684. get hasInstances(): boolean;
  94685. /**
  94686. * Gets the delay loading state of the mesh (when delay loading is turned on)
  94687. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  94688. */
  94689. delayLoadState: number;
  94690. /**
  94691. * Gets the list of instances created from this mesh
  94692. * it is not supposed to be modified manually.
  94693. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  94694. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94695. */
  94696. instances: InstancedMesh[];
  94697. /**
  94698. * Gets the file containing delay loading data for this mesh
  94699. */
  94700. delayLoadingFile: string;
  94701. /** @hidden */
  94702. _binaryInfo: any;
  94703. /**
  94704. * User defined function used to change how LOD level selection is done
  94705. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94706. */
  94707. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  94708. /**
  94709. * Gets or sets the morph target manager
  94710. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  94711. */
  94712. get morphTargetManager(): Nullable<MorphTargetManager>;
  94713. set morphTargetManager(value: Nullable<MorphTargetManager>);
  94714. /** @hidden */
  94715. _creationDataStorage: Nullable<_CreationDataStorage>;
  94716. /** @hidden */
  94717. _geometry: Nullable<Geometry>;
  94718. /** @hidden */
  94719. _delayInfo: Array<string>;
  94720. /** @hidden */
  94721. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  94722. /** @hidden */
  94723. _instanceDataStorage: _InstanceDataStorage;
  94724. private _effectiveMaterial;
  94725. /** @hidden */
  94726. _shouldGenerateFlatShading: boolean;
  94727. /** @hidden */
  94728. _originalBuilderSideOrientation: number;
  94729. /**
  94730. * Use this property to change the original side orientation defined at construction time
  94731. */
  94732. overrideMaterialSideOrientation: Nullable<number>;
  94733. /**
  94734. * Gets the source mesh (the one used to clone this one from)
  94735. */
  94736. get source(): Nullable<Mesh>;
  94737. /**
  94738. * Gets or sets a boolean indicating that this mesh does not use index buffer
  94739. */
  94740. get isUnIndexed(): boolean;
  94741. set isUnIndexed(value: boolean);
  94742. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  94743. get worldMatrixInstancedBuffer(): Float32Array;
  94744. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  94745. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  94746. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  94747. /**
  94748. * @constructor
  94749. * @param name The value used by scene.getMeshByName() to do a lookup.
  94750. * @param scene The scene to add this mesh to.
  94751. * @param parent The parent of this mesh, if it has one
  94752. * @param source An optional Mesh from which geometry is shared, cloned.
  94753. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94754. * When false, achieved by calling a clone(), also passing False.
  94755. * This will make creation of children, recursive.
  94756. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  94757. */
  94758. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  94759. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94760. doNotInstantiate: boolean;
  94761. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94762. /**
  94763. * Gets the class name
  94764. * @returns the string "Mesh".
  94765. */
  94766. getClassName(): string;
  94767. /** @hidden */
  94768. get _isMesh(): boolean;
  94769. /**
  94770. * Returns a description of this mesh
  94771. * @param fullDetails define if full details about this mesh must be used
  94772. * @returns a descriptive string representing this mesh
  94773. */
  94774. toString(fullDetails?: boolean): string;
  94775. /** @hidden */
  94776. _unBindEffect(): void;
  94777. /**
  94778. * Gets a boolean indicating if this mesh has LOD
  94779. */
  94780. get hasLODLevels(): boolean;
  94781. /**
  94782. * Gets the list of MeshLODLevel associated with the current mesh
  94783. * @returns an array of MeshLODLevel
  94784. */
  94785. getLODLevels(): MeshLODLevel[];
  94786. private _sortLODLevels;
  94787. /**
  94788. * Add a mesh as LOD level triggered at the given distance.
  94789. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94790. * @param distance The distance from the center of the object to show this level
  94791. * @param mesh The mesh to be added as LOD level (can be null)
  94792. * @return This mesh (for chaining)
  94793. */
  94794. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  94795. /**
  94796. * Returns the LOD level mesh at the passed distance or null if not found.
  94797. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94798. * @param distance The distance from the center of the object to show this level
  94799. * @returns a Mesh or `null`
  94800. */
  94801. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  94802. /**
  94803. * Remove a mesh from the LOD array
  94804. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94805. * @param mesh defines the mesh to be removed
  94806. * @return This mesh (for chaining)
  94807. */
  94808. removeLODLevel(mesh: Mesh): Mesh;
  94809. /**
  94810. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  94811. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94812. * @param camera defines the camera to use to compute distance
  94813. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  94814. * @return This mesh (for chaining)
  94815. */
  94816. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  94817. /**
  94818. * Gets the mesh internal Geometry object
  94819. */
  94820. get geometry(): Nullable<Geometry>;
  94821. /**
  94822. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  94823. * @returns the total number of vertices
  94824. */
  94825. getTotalVertices(): number;
  94826. /**
  94827. * Returns the content of an associated vertex buffer
  94828. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94829. * - VertexBuffer.PositionKind
  94830. * - VertexBuffer.UVKind
  94831. * - VertexBuffer.UV2Kind
  94832. * - VertexBuffer.UV3Kind
  94833. * - VertexBuffer.UV4Kind
  94834. * - VertexBuffer.UV5Kind
  94835. * - VertexBuffer.UV6Kind
  94836. * - VertexBuffer.ColorKind
  94837. * - VertexBuffer.MatricesIndicesKind
  94838. * - VertexBuffer.MatricesIndicesExtraKind
  94839. * - VertexBuffer.MatricesWeightsKind
  94840. * - VertexBuffer.MatricesWeightsExtraKind
  94841. * @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
  94842. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  94843. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  94844. */
  94845. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94846. /**
  94847. * Returns the mesh VertexBuffer object from the requested `kind`
  94848. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94849. * - VertexBuffer.PositionKind
  94850. * - VertexBuffer.NormalKind
  94851. * - VertexBuffer.UVKind
  94852. * - VertexBuffer.UV2Kind
  94853. * - VertexBuffer.UV3Kind
  94854. * - VertexBuffer.UV4Kind
  94855. * - VertexBuffer.UV5Kind
  94856. * - VertexBuffer.UV6Kind
  94857. * - VertexBuffer.ColorKind
  94858. * - VertexBuffer.MatricesIndicesKind
  94859. * - VertexBuffer.MatricesIndicesExtraKind
  94860. * - VertexBuffer.MatricesWeightsKind
  94861. * - VertexBuffer.MatricesWeightsExtraKind
  94862. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  94863. */
  94864. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94865. /**
  94866. * Tests if a specific vertex buffer is associated with this mesh
  94867. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94868. * - VertexBuffer.PositionKind
  94869. * - VertexBuffer.NormalKind
  94870. * - VertexBuffer.UVKind
  94871. * - VertexBuffer.UV2Kind
  94872. * - VertexBuffer.UV3Kind
  94873. * - VertexBuffer.UV4Kind
  94874. * - VertexBuffer.UV5Kind
  94875. * - VertexBuffer.UV6Kind
  94876. * - VertexBuffer.ColorKind
  94877. * - VertexBuffer.MatricesIndicesKind
  94878. * - VertexBuffer.MatricesIndicesExtraKind
  94879. * - VertexBuffer.MatricesWeightsKind
  94880. * - VertexBuffer.MatricesWeightsExtraKind
  94881. * @returns a boolean
  94882. */
  94883. isVerticesDataPresent(kind: string): boolean;
  94884. /**
  94885. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  94886. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94887. * - VertexBuffer.PositionKind
  94888. * - VertexBuffer.UVKind
  94889. * - VertexBuffer.UV2Kind
  94890. * - VertexBuffer.UV3Kind
  94891. * - VertexBuffer.UV4Kind
  94892. * - VertexBuffer.UV5Kind
  94893. * - VertexBuffer.UV6Kind
  94894. * - VertexBuffer.ColorKind
  94895. * - VertexBuffer.MatricesIndicesKind
  94896. * - VertexBuffer.MatricesIndicesExtraKind
  94897. * - VertexBuffer.MatricesWeightsKind
  94898. * - VertexBuffer.MatricesWeightsExtraKind
  94899. * @returns a boolean
  94900. */
  94901. isVertexBufferUpdatable(kind: string): boolean;
  94902. /**
  94903. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  94904. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94905. * - VertexBuffer.PositionKind
  94906. * - VertexBuffer.NormalKind
  94907. * - VertexBuffer.UVKind
  94908. * - VertexBuffer.UV2Kind
  94909. * - VertexBuffer.UV3Kind
  94910. * - VertexBuffer.UV4Kind
  94911. * - VertexBuffer.UV5Kind
  94912. * - VertexBuffer.UV6Kind
  94913. * - VertexBuffer.ColorKind
  94914. * - VertexBuffer.MatricesIndicesKind
  94915. * - VertexBuffer.MatricesIndicesExtraKind
  94916. * - VertexBuffer.MatricesWeightsKind
  94917. * - VertexBuffer.MatricesWeightsExtraKind
  94918. * @returns an array of strings
  94919. */
  94920. getVerticesDataKinds(): string[];
  94921. /**
  94922. * Returns a positive integer : the total number of indices in this mesh geometry.
  94923. * @returns the numner of indices or zero if the mesh has no geometry.
  94924. */
  94925. getTotalIndices(): number;
  94926. /**
  94927. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94928. * @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.
  94929. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94930. * @returns the indices array or an empty array if the mesh has no geometry
  94931. */
  94932. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94933. get isBlocked(): boolean;
  94934. /**
  94935. * Determine if the current mesh is ready to be rendered
  94936. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94937. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  94938. * @returns true if all associated assets are ready (material, textures, shaders)
  94939. */
  94940. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  94941. /**
  94942. * 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.
  94943. */
  94944. get areNormalsFrozen(): boolean;
  94945. /**
  94946. * 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.
  94947. * @returns the current mesh
  94948. */
  94949. freezeNormals(): Mesh;
  94950. /**
  94951. * 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
  94952. * @returns the current mesh
  94953. */
  94954. unfreezeNormals(): Mesh;
  94955. /**
  94956. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  94957. */
  94958. set overridenInstanceCount(count: number);
  94959. /** @hidden */
  94960. _preActivate(): Mesh;
  94961. /** @hidden */
  94962. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94963. /** @hidden */
  94964. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  94965. /**
  94966. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94967. * This means the mesh underlying bounding box and sphere are recomputed.
  94968. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94969. * @returns the current mesh
  94970. */
  94971. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  94972. /** @hidden */
  94973. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  94974. /**
  94975. * This function will subdivide the mesh into multiple submeshes
  94976. * @param count defines the expected number of submeshes
  94977. */
  94978. subdivide(count: number): void;
  94979. /**
  94980. * Copy a FloatArray into a specific associated vertex buffer
  94981. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94982. * - VertexBuffer.PositionKind
  94983. * - VertexBuffer.UVKind
  94984. * - VertexBuffer.UV2Kind
  94985. * - VertexBuffer.UV3Kind
  94986. * - VertexBuffer.UV4Kind
  94987. * - VertexBuffer.UV5Kind
  94988. * - VertexBuffer.UV6Kind
  94989. * - VertexBuffer.ColorKind
  94990. * - VertexBuffer.MatricesIndicesKind
  94991. * - VertexBuffer.MatricesIndicesExtraKind
  94992. * - VertexBuffer.MatricesWeightsKind
  94993. * - VertexBuffer.MatricesWeightsExtraKind
  94994. * @param data defines the data source
  94995. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  94996. * @param stride defines the data stride size (can be null)
  94997. * @returns the current mesh
  94998. */
  94999. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95000. /**
  95001. * Delete a vertex buffer associated with this mesh
  95002. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  95003. * - VertexBuffer.PositionKind
  95004. * - VertexBuffer.UVKind
  95005. * - VertexBuffer.UV2Kind
  95006. * - VertexBuffer.UV3Kind
  95007. * - VertexBuffer.UV4Kind
  95008. * - VertexBuffer.UV5Kind
  95009. * - VertexBuffer.UV6Kind
  95010. * - VertexBuffer.ColorKind
  95011. * - VertexBuffer.MatricesIndicesKind
  95012. * - VertexBuffer.MatricesIndicesExtraKind
  95013. * - VertexBuffer.MatricesWeightsKind
  95014. * - VertexBuffer.MatricesWeightsExtraKind
  95015. */
  95016. removeVerticesData(kind: string): void;
  95017. /**
  95018. * Flags an associated vertex buffer as updatable
  95019. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  95020. * - VertexBuffer.PositionKind
  95021. * - VertexBuffer.UVKind
  95022. * - VertexBuffer.UV2Kind
  95023. * - VertexBuffer.UV3Kind
  95024. * - VertexBuffer.UV4Kind
  95025. * - VertexBuffer.UV5Kind
  95026. * - VertexBuffer.UV6Kind
  95027. * - VertexBuffer.ColorKind
  95028. * - VertexBuffer.MatricesIndicesKind
  95029. * - VertexBuffer.MatricesIndicesExtraKind
  95030. * - VertexBuffer.MatricesWeightsKind
  95031. * - VertexBuffer.MatricesWeightsExtraKind
  95032. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95033. */
  95034. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  95035. /**
  95036. * Sets the mesh global Vertex Buffer
  95037. * @param buffer defines the buffer to use
  95038. * @returns the current mesh
  95039. */
  95040. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  95041. /**
  95042. * Update a specific associated vertex buffer
  95043. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95044. * - VertexBuffer.PositionKind
  95045. * - VertexBuffer.UVKind
  95046. * - VertexBuffer.UV2Kind
  95047. * - VertexBuffer.UV3Kind
  95048. * - VertexBuffer.UV4Kind
  95049. * - VertexBuffer.UV5Kind
  95050. * - VertexBuffer.UV6Kind
  95051. * - VertexBuffer.ColorKind
  95052. * - VertexBuffer.MatricesIndicesKind
  95053. * - VertexBuffer.MatricesIndicesExtraKind
  95054. * - VertexBuffer.MatricesWeightsKind
  95055. * - VertexBuffer.MatricesWeightsExtraKind
  95056. * @param data defines the data source
  95057. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95058. * @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)
  95059. * @returns the current mesh
  95060. */
  95061. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95062. /**
  95063. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  95064. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  95065. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  95066. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  95067. * @returns the current mesh
  95068. */
  95069. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  95070. /**
  95071. * Creates a un-shared specific occurence of the geometry for the mesh.
  95072. * @returns the current mesh
  95073. */
  95074. makeGeometryUnique(): Mesh;
  95075. /**
  95076. * Set the index buffer of this mesh
  95077. * @param indices defines the source data
  95078. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  95079. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  95080. * @returns the current mesh
  95081. */
  95082. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  95083. /**
  95084. * Update the current index buffer
  95085. * @param indices defines the source data
  95086. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95087. * @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)
  95088. * @returns the current mesh
  95089. */
  95090. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95091. /**
  95092. * Invert the geometry to move from a right handed system to a left handed one.
  95093. * @returns the current mesh
  95094. */
  95095. toLeftHanded(): Mesh;
  95096. /** @hidden */
  95097. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95098. /** @hidden */
  95099. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95100. /**
  95101. * Registers for this mesh a javascript function called just before the rendering process
  95102. * @param func defines the function to call before rendering this mesh
  95103. * @returns the current mesh
  95104. */
  95105. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95106. /**
  95107. * Disposes a previously registered javascript function called before the rendering
  95108. * @param func defines the function to remove
  95109. * @returns the current mesh
  95110. */
  95111. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95112. /**
  95113. * Registers for this mesh a javascript function called just after the rendering is complete
  95114. * @param func defines the function to call after rendering this mesh
  95115. * @returns the current mesh
  95116. */
  95117. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95118. /**
  95119. * Disposes a previously registered javascript function called after the rendering.
  95120. * @param func defines the function to remove
  95121. * @returns the current mesh
  95122. */
  95123. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95124. /** @hidden */
  95125. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  95126. /** @hidden */
  95127. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  95128. /** @hidden */
  95129. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  95130. /** @hidden */
  95131. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  95132. /** @hidden */
  95133. _rebuild(): void;
  95134. /** @hidden */
  95135. _freeze(): void;
  95136. /** @hidden */
  95137. _unFreeze(): void;
  95138. /**
  95139. * 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
  95140. * @param subMesh defines the subMesh to render
  95141. * @param enableAlphaMode defines if alpha mode can be changed
  95142. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  95143. * @returns the current mesh
  95144. */
  95145. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  95146. private _onBeforeDraw;
  95147. /**
  95148. * Renormalize the mesh and patch it up if there are no weights
  95149. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  95150. * However in the case of zero weights then we set just a single influence to 1.
  95151. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  95152. */
  95153. cleanMatrixWeights(): void;
  95154. private normalizeSkinFourWeights;
  95155. private normalizeSkinWeightsAndExtra;
  95156. /**
  95157. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  95158. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  95159. * the user know there was an issue with importing the mesh
  95160. * @returns a validation object with skinned, valid and report string
  95161. */
  95162. validateSkinning(): {
  95163. skinned: boolean;
  95164. valid: boolean;
  95165. report: string;
  95166. };
  95167. /** @hidden */
  95168. _checkDelayState(): Mesh;
  95169. private _queueLoad;
  95170. /**
  95171. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95172. * A mesh is in the frustum if its bounding box intersects the frustum
  95173. * @param frustumPlanes defines the frustum to test
  95174. * @returns true if the mesh is in the frustum planes
  95175. */
  95176. isInFrustum(frustumPlanes: Plane[]): boolean;
  95177. /**
  95178. * Sets the mesh material by the material or multiMaterial `id` property
  95179. * @param id is a string identifying the material or the multiMaterial
  95180. * @returns the current mesh
  95181. */
  95182. setMaterialByID(id: string): Mesh;
  95183. /**
  95184. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  95185. * @returns an array of IAnimatable
  95186. */
  95187. getAnimatables(): IAnimatable[];
  95188. /**
  95189. * Modifies the mesh geometry according to the passed transformation matrix.
  95190. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  95191. * The mesh normals are modified using the same transformation.
  95192. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95193. * @param transform defines the transform matrix to use
  95194. * @see http://doc.babylonjs.com/resources/baking_transformations
  95195. * @returns the current mesh
  95196. */
  95197. bakeTransformIntoVertices(transform: Matrix): Mesh;
  95198. /**
  95199. * Modifies the mesh geometry according to its own current World Matrix.
  95200. * The mesh World Matrix is then reset.
  95201. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  95202. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95203. * @see http://doc.babylonjs.com/resources/baking_transformations
  95204. * @returns the current mesh
  95205. */
  95206. bakeCurrentTransformIntoVertices(): Mesh;
  95207. /** @hidden */
  95208. get _positions(): Nullable<Vector3[]>;
  95209. /** @hidden */
  95210. _resetPointsArrayCache(): Mesh;
  95211. /** @hidden */
  95212. _generatePointsArray(): boolean;
  95213. /**
  95214. * Returns a new Mesh object generated from the current mesh properties.
  95215. * This method must not get confused with createInstance()
  95216. * @param name is a string, the name given to the new mesh
  95217. * @param newParent can be any Node object (default `null`)
  95218. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  95219. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  95220. * @returns a new mesh
  95221. */
  95222. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  95223. /**
  95224. * Releases resources associated with this mesh.
  95225. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95226. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95227. */
  95228. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95229. /** @hidden */
  95230. _disposeInstanceSpecificData(): void;
  95231. /**
  95232. * Modifies the mesh geometry according to a displacement map.
  95233. * 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.
  95234. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95235. * @param url is a string, the URL from the image file is to be downloaded.
  95236. * @param minHeight is the lower limit of the displacement.
  95237. * @param maxHeight is the upper limit of the displacement.
  95238. * @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.
  95239. * @param uvOffset is an optional vector2 used to offset UV.
  95240. * @param uvScale is an optional vector2 used to scale UV.
  95241. * @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.
  95242. * @returns the Mesh.
  95243. */
  95244. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95245. /**
  95246. * Modifies the mesh geometry according to a displacementMap buffer.
  95247. * 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.
  95248. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95249. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  95250. * @param heightMapWidth is the width of the buffer image.
  95251. * @param heightMapHeight is the height of the buffer image.
  95252. * @param minHeight is the lower limit of the displacement.
  95253. * @param maxHeight is the upper limit of the displacement.
  95254. * @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.
  95255. * @param uvOffset is an optional vector2 used to offset UV.
  95256. * @param uvScale is an optional vector2 used to scale UV.
  95257. * @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.
  95258. * @returns the Mesh.
  95259. */
  95260. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95261. /**
  95262. * Modify the mesh to get a flat shading rendering.
  95263. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  95264. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  95265. * @returns current mesh
  95266. */
  95267. convertToFlatShadedMesh(): Mesh;
  95268. /**
  95269. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  95270. * In other words, more vertices, no more indices and a single bigger VBO.
  95271. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  95272. * @returns current mesh
  95273. */
  95274. convertToUnIndexedMesh(): Mesh;
  95275. /**
  95276. * Inverses facet orientations.
  95277. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95278. * @param flipNormals will also inverts the normals
  95279. * @returns current mesh
  95280. */
  95281. flipFaces(flipNormals?: boolean): Mesh;
  95282. /**
  95283. * Increase the number of facets and hence vertices in a mesh
  95284. * Vertex normals are interpolated from existing vertex normals
  95285. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95286. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  95287. */
  95288. increaseVertices(numberPerEdge: number): void;
  95289. /**
  95290. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  95291. * This will undo any application of covertToFlatShadedMesh
  95292. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95293. */
  95294. forceSharedVertices(): void;
  95295. /** @hidden */
  95296. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  95297. /** @hidden */
  95298. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  95299. /**
  95300. * Creates a new InstancedMesh object from the mesh model.
  95301. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  95302. * @param name defines the name of the new instance
  95303. * @returns a new InstancedMesh
  95304. */
  95305. createInstance(name: string): InstancedMesh;
  95306. /**
  95307. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  95308. * After this call, all the mesh instances have the same submeshes than the current mesh.
  95309. * @returns the current mesh
  95310. */
  95311. synchronizeInstances(): Mesh;
  95312. /**
  95313. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  95314. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  95315. * This should be used together with the simplification to avoid disappearing triangles.
  95316. * @param successCallback an optional success callback to be called after the optimization finished.
  95317. * @returns the current mesh
  95318. */
  95319. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  95320. /**
  95321. * Serialize current mesh
  95322. * @param serializationObject defines the object which will receive the serialization data
  95323. */
  95324. serialize(serializationObject: any): void;
  95325. /** @hidden */
  95326. _syncGeometryWithMorphTargetManager(): void;
  95327. /** @hidden */
  95328. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  95329. /**
  95330. * Returns a new Mesh object parsed from the source provided.
  95331. * @param parsedMesh is the source
  95332. * @param scene defines the hosting scene
  95333. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  95334. * @returns a new Mesh
  95335. */
  95336. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  95337. /**
  95338. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  95339. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95340. * @param name defines the name of the mesh to create
  95341. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  95342. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  95343. * @param closePath creates a seam between the first and the last points of each path of the path array
  95344. * @param offset is taken in account only if the `pathArray` is containing a single path
  95345. * @param scene defines the hosting scene
  95346. * @param updatable defines if the mesh must be flagged as updatable
  95347. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95348. * @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)
  95349. * @returns a new Mesh
  95350. */
  95351. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95352. /**
  95353. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  95354. * @param name defines the name of the mesh to create
  95355. * @param radius sets the radius size (float) of the polygon (default 0.5)
  95356. * @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
  95357. * @param scene defines the hosting scene
  95358. * @param updatable defines if the mesh must be flagged as updatable
  95359. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95360. * @returns a new Mesh
  95361. */
  95362. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95363. /**
  95364. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  95365. * @param name defines the name of the mesh to create
  95366. * @param size sets the size (float) of each box side (default 1)
  95367. * @param scene defines the hosting scene
  95368. * @param updatable defines if the mesh must be flagged as updatable
  95369. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95370. * @returns a new Mesh
  95371. */
  95372. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95373. /**
  95374. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  95375. * @param name defines the name of the mesh to create
  95376. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95377. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95378. * @param scene defines the hosting scene
  95379. * @param updatable defines if the mesh must be flagged as updatable
  95380. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95381. * @returns a new Mesh
  95382. */
  95383. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95384. /**
  95385. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  95386. * @param name defines the name of the mesh to create
  95387. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95388. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95389. * @param scene defines the hosting scene
  95390. * @returns a new Mesh
  95391. */
  95392. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  95393. /**
  95394. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  95395. * @param name defines the name of the mesh to create
  95396. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  95397. * @param diameterTop set the top cap diameter (floats, default 1)
  95398. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  95399. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  95400. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  95401. * @param scene defines the hosting scene
  95402. * @param updatable defines if the mesh must be flagged as updatable
  95403. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95404. * @returns a new Mesh
  95405. */
  95406. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  95407. /**
  95408. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  95409. * @param name defines the name of the mesh to create
  95410. * @param diameter sets the diameter size (float) of the torus (default 1)
  95411. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  95412. * @param tessellation sets the number of torus sides (postive integer, default 16)
  95413. * @param scene defines the hosting scene
  95414. * @param updatable defines if the mesh must be flagged as updatable
  95415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95416. * @returns a new Mesh
  95417. */
  95418. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95419. /**
  95420. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  95421. * @param name defines the name of the mesh to create
  95422. * @param radius sets the global radius size (float) of the torus knot (default 2)
  95423. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  95424. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  95425. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  95426. * @param p the number of windings on X axis (positive integers, default 2)
  95427. * @param q the number of windings on Y axis (positive integers, default 3)
  95428. * @param scene defines the hosting scene
  95429. * @param updatable defines if the mesh must be flagged as updatable
  95430. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95431. * @returns a new Mesh
  95432. */
  95433. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95434. /**
  95435. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  95436. * @param name defines the name of the mesh to create
  95437. * @param points is an array successive Vector3
  95438. * @param scene defines the hosting scene
  95439. * @param updatable defines if the mesh must be flagged as updatable
  95440. * @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).
  95441. * @returns a new Mesh
  95442. */
  95443. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  95444. /**
  95445. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  95446. * @param name defines the name of the mesh to create
  95447. * @param points is an array successive Vector3
  95448. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  95449. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95450. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  95451. * @param scene defines the hosting scene
  95452. * @param updatable defines if the mesh must be flagged as updatable
  95453. * @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)
  95454. * @returns a new Mesh
  95455. */
  95456. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  95457. /**
  95458. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  95459. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  95460. * 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.
  95461. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95462. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95463. * Remember you can only change the shape positions, not their number when updating a polygon.
  95464. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  95465. * @param name defines the name of the mesh to create
  95466. * @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
  95467. * @param scene defines the hosting scene
  95468. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95469. * @param updatable defines if the mesh must be flagged as updatable
  95470. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95471. * @param earcutInjection can be used to inject your own earcut reference
  95472. * @returns a new Mesh
  95473. */
  95474. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95475. /**
  95476. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  95477. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  95478. * @param name defines the name of the mesh to create
  95479. * @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
  95480. * @param depth defines the height of extrusion
  95481. * @param scene defines the hosting scene
  95482. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95483. * @param updatable defines if the mesh must be flagged as updatable
  95484. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95485. * @param earcutInjection can be used to inject your own earcut reference
  95486. * @returns a new Mesh
  95487. */
  95488. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95489. /**
  95490. * Creates an extruded shape mesh.
  95491. * 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
  95492. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95493. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95494. * @param name defines the name of the mesh to create
  95495. * @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
  95496. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95497. * @param scale is the value to scale the shape
  95498. * @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
  95499. * @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
  95500. * @param scene defines the hosting scene
  95501. * @param updatable defines if the mesh must be flagged as updatable
  95502. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95503. * @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)
  95504. * @returns a new Mesh
  95505. */
  95506. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95507. /**
  95508. * Creates an custom extruded shape mesh.
  95509. * The custom extrusion is a parametric shape.
  95510. * It has no predefined shape. Its final shape will depend on the input parameters.
  95511. * Please consider using the same method from the MeshBuilder class instead
  95512. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95513. * @param name defines the name of the mesh to create
  95514. * @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
  95515. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95516. * @param scaleFunction is a custom Javascript function called on each path point
  95517. * @param rotationFunction is a custom Javascript function called on each path point
  95518. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  95519. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  95520. * @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
  95521. * @param scene defines the hosting scene
  95522. * @param updatable defines if the mesh must be flagged as updatable
  95523. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95524. * @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)
  95525. * @returns a new Mesh
  95526. */
  95527. 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;
  95528. /**
  95529. * Creates lathe mesh.
  95530. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  95531. * Please consider using the same method from the MeshBuilder class instead
  95532. * @param name defines the name of the mesh to create
  95533. * @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
  95534. * @param radius is the radius value of the lathe
  95535. * @param tessellation is the side number of the lathe.
  95536. * @param scene defines the hosting scene
  95537. * @param updatable defines if the mesh must be flagged as updatable
  95538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95539. * @returns a new Mesh
  95540. */
  95541. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95542. /**
  95543. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  95544. * @param name defines the name of the mesh to create
  95545. * @param size sets the size (float) of both sides of the plane at once (default 1)
  95546. * @param scene defines the hosting scene
  95547. * @param updatable defines if the mesh must be flagged as updatable
  95548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95549. * @returns a new Mesh
  95550. */
  95551. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95552. /**
  95553. * Creates a ground mesh.
  95554. * Please consider using the same method from the MeshBuilder class instead
  95555. * @param name defines the name of the mesh to create
  95556. * @param width set the width of the ground
  95557. * @param height set the height of the ground
  95558. * @param subdivisions sets the number of subdivisions per side
  95559. * @param scene defines the hosting scene
  95560. * @param updatable defines if the mesh must be flagged as updatable
  95561. * @returns a new Mesh
  95562. */
  95563. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  95564. /**
  95565. * Creates a tiled ground mesh.
  95566. * Please consider using the same method from the MeshBuilder class instead
  95567. * @param name defines the name of the mesh to create
  95568. * @param xmin set the ground minimum X coordinate
  95569. * @param zmin set the ground minimum Y coordinate
  95570. * @param xmax set the ground maximum X coordinate
  95571. * @param zmax set the ground maximum Z coordinate
  95572. * @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
  95573. * @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
  95574. * @param scene defines the hosting scene
  95575. * @param updatable defines if the mesh must be flagged as updatable
  95576. * @returns a new Mesh
  95577. */
  95578. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  95579. w: number;
  95580. h: number;
  95581. }, precision: {
  95582. w: number;
  95583. h: number;
  95584. }, scene: Scene, updatable?: boolean): Mesh;
  95585. /**
  95586. * Creates a ground mesh from a height map.
  95587. * Please consider using the same method from the MeshBuilder class instead
  95588. * @see http://doc.babylonjs.com/babylon101/height_map
  95589. * @param name defines the name of the mesh to create
  95590. * @param url sets the URL of the height map image resource
  95591. * @param width set the ground width size
  95592. * @param height set the ground height size
  95593. * @param subdivisions sets the number of subdivision per side
  95594. * @param minHeight is the minimum altitude on the ground
  95595. * @param maxHeight is the maximum altitude on the ground
  95596. * @param scene defines the hosting scene
  95597. * @param updatable defines if the mesh must be flagged as updatable
  95598. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  95599. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95600. * @returns a new Mesh
  95601. */
  95602. 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;
  95603. /**
  95604. * Creates a tube mesh.
  95605. * The tube is a parametric shape.
  95606. * It has no predefined shape. Its final shape will depend on the input parameters.
  95607. * Please consider using the same method from the MeshBuilder class instead
  95608. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95609. * @param name defines the name of the mesh to create
  95610. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  95611. * @param radius sets the tube radius size
  95612. * @param tessellation is the number of sides on the tubular surface
  95613. * @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
  95614. * @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
  95615. * @param scene defines the hosting scene
  95616. * @param updatable defines if the mesh must be flagged as updatable
  95617. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95618. * @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)
  95619. * @returns a new Mesh
  95620. */
  95621. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  95622. (i: number, distance: number): number;
  95623. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95624. /**
  95625. * Creates a polyhedron mesh.
  95626. * Please consider using the same method from the MeshBuilder class instead.
  95627. * * 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
  95628. * * The parameter `size` (positive float, default 1) sets the polygon size
  95629. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  95630. * * 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`
  95631. * * 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
  95632. * * 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)`)
  95633. * * 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
  95634. * * 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
  95635. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95636. * * If you create a double-sided mesh, you can choose what parts of 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
  95637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95638. * @param name defines the name of the mesh to create
  95639. * @param options defines the options used to create the mesh
  95640. * @param scene defines the hosting scene
  95641. * @returns a new Mesh
  95642. */
  95643. static CreatePolyhedron(name: string, options: {
  95644. type?: number;
  95645. size?: number;
  95646. sizeX?: number;
  95647. sizeY?: number;
  95648. sizeZ?: number;
  95649. custom?: any;
  95650. faceUV?: Vector4[];
  95651. faceColors?: Color4[];
  95652. updatable?: boolean;
  95653. sideOrientation?: number;
  95654. }, scene: Scene): Mesh;
  95655. /**
  95656. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  95657. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  95658. * * 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`)
  95659. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  95660. * * 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
  95661. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95662. * * If you create a double-sided mesh, you can choose what parts of 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
  95663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95664. * @param name defines the name of the mesh
  95665. * @param options defines the options used to create the mesh
  95666. * @param scene defines the hosting scene
  95667. * @returns a new Mesh
  95668. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  95669. */
  95670. static CreateIcoSphere(name: string, options: {
  95671. radius?: number;
  95672. flat?: boolean;
  95673. subdivisions?: number;
  95674. sideOrientation?: number;
  95675. updatable?: boolean;
  95676. }, scene: Scene): Mesh;
  95677. /**
  95678. * Creates a decal mesh.
  95679. * Please consider using the same method from the MeshBuilder class instead.
  95680. * A decal is a mesh usually applied as a model onto the surface of another mesh
  95681. * @param name defines the name of the mesh
  95682. * @param sourceMesh defines the mesh receiving the decal
  95683. * @param position sets the position of the decal in world coordinates
  95684. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  95685. * @param size sets the decal scaling
  95686. * @param angle sets the angle to rotate the decal
  95687. * @returns a new Mesh
  95688. */
  95689. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  95690. /**
  95691. * Prepare internal position array for software CPU skinning
  95692. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  95693. */
  95694. setPositionsForCPUSkinning(): Float32Array;
  95695. /**
  95696. * Prepare internal normal array for software CPU skinning
  95697. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  95698. */
  95699. setNormalsForCPUSkinning(): Float32Array;
  95700. /**
  95701. * Updates the vertex buffer by applying transformation from the bones
  95702. * @param skeleton defines the skeleton to apply to current mesh
  95703. * @returns the current mesh
  95704. */
  95705. applySkeleton(skeleton: Skeleton): Mesh;
  95706. /**
  95707. * 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
  95708. * @param meshes defines the list of meshes to scan
  95709. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  95710. */
  95711. static MinMax(meshes: AbstractMesh[]): {
  95712. min: Vector3;
  95713. max: Vector3;
  95714. };
  95715. /**
  95716. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  95717. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  95718. * @returns a vector3
  95719. */
  95720. static Center(meshesOrMinMaxVector: {
  95721. min: Vector3;
  95722. max: Vector3;
  95723. } | AbstractMesh[]): Vector3;
  95724. /**
  95725. * Merge the array of meshes into a single mesh for performance reasons.
  95726. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  95727. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  95728. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  95729. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  95730. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  95731. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  95732. * @returns a new mesh
  95733. */
  95734. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  95735. /** @hidden */
  95736. addInstance(instance: InstancedMesh): void;
  95737. /** @hidden */
  95738. removeInstance(instance: InstancedMesh): void;
  95739. }
  95740. }
  95741. declare module BABYLON {
  95742. /**
  95743. * This is the base class of all the camera used in the application.
  95744. * @see http://doc.babylonjs.com/features/cameras
  95745. */
  95746. export class Camera extends Node {
  95747. /** @hidden */
  95748. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  95749. /**
  95750. * This is the default projection mode used by the cameras.
  95751. * It helps recreating a feeling of perspective and better appreciate depth.
  95752. * This is the best way to simulate real life cameras.
  95753. */
  95754. static readonly PERSPECTIVE_CAMERA: number;
  95755. /**
  95756. * This helps creating camera with an orthographic mode.
  95757. * 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.
  95758. */
  95759. static readonly ORTHOGRAPHIC_CAMERA: number;
  95760. /**
  95761. * This is the default FOV mode for perspective cameras.
  95762. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  95763. */
  95764. static readonly FOVMODE_VERTICAL_FIXED: number;
  95765. /**
  95766. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  95767. */
  95768. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  95769. /**
  95770. * This specifies ther is no need for a camera rig.
  95771. * Basically only one eye is rendered corresponding to the camera.
  95772. */
  95773. static readonly RIG_MODE_NONE: number;
  95774. /**
  95775. * Simulates a camera Rig with one blue eye and one red eye.
  95776. * This can be use with 3d blue and red glasses.
  95777. */
  95778. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  95779. /**
  95780. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  95781. */
  95782. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  95783. /**
  95784. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  95785. */
  95786. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  95787. /**
  95788. * Defines that both eyes of the camera will be rendered over under each other.
  95789. */
  95790. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  95791. /**
  95792. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  95793. */
  95794. static readonly RIG_MODE_VR: number;
  95795. /**
  95796. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  95797. */
  95798. static readonly RIG_MODE_WEBVR: number;
  95799. /**
  95800. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  95801. */
  95802. static readonly RIG_MODE_CUSTOM: number;
  95803. /**
  95804. * Defines if by default attaching controls should prevent the default javascript event to continue.
  95805. */
  95806. static ForceAttachControlToAlwaysPreventDefault: boolean;
  95807. /**
  95808. * Define the input manager associated with the camera.
  95809. */
  95810. inputs: CameraInputsManager<Camera>;
  95811. /** @hidden */
  95812. _position: Vector3;
  95813. /**
  95814. * Define the current local position of the camera in the scene
  95815. */
  95816. get position(): Vector3;
  95817. set position(newPosition: Vector3);
  95818. /**
  95819. * The vector the camera should consider as up.
  95820. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  95821. */
  95822. upVector: Vector3;
  95823. /**
  95824. * Define the current limit on the left side for an orthographic camera
  95825. * In scene unit
  95826. */
  95827. orthoLeft: Nullable<number>;
  95828. /**
  95829. * Define the current limit on the right side for an orthographic camera
  95830. * In scene unit
  95831. */
  95832. orthoRight: Nullable<number>;
  95833. /**
  95834. * Define the current limit on the bottom side for an orthographic camera
  95835. * In scene unit
  95836. */
  95837. orthoBottom: Nullable<number>;
  95838. /**
  95839. * Define the current limit on the top side for an orthographic camera
  95840. * In scene unit
  95841. */
  95842. orthoTop: Nullable<number>;
  95843. /**
  95844. * Field Of View is set in Radians. (default is 0.8)
  95845. */
  95846. fov: number;
  95847. /**
  95848. * Define the minimum distance the camera can see from.
  95849. * This is important to note that the depth buffer are not infinite and the closer it starts
  95850. * the more your scene might encounter depth fighting issue.
  95851. */
  95852. minZ: number;
  95853. /**
  95854. * Define the maximum distance the camera can see to.
  95855. * This is important to note that the depth buffer are not infinite and the further it end
  95856. * the more your scene might encounter depth fighting issue.
  95857. */
  95858. maxZ: number;
  95859. /**
  95860. * Define the default inertia of the camera.
  95861. * This helps giving a smooth feeling to the camera movement.
  95862. */
  95863. inertia: number;
  95864. /**
  95865. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  95866. */
  95867. mode: number;
  95868. /**
  95869. * Define wether the camera is intermediate.
  95870. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  95871. */
  95872. isIntermediate: boolean;
  95873. /**
  95874. * Define the viewport of the camera.
  95875. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  95876. */
  95877. viewport: Viewport;
  95878. /**
  95879. * Restricts the camera to viewing objects with the same layerMask.
  95880. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  95881. */
  95882. layerMask: number;
  95883. /**
  95884. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  95885. */
  95886. fovMode: number;
  95887. /**
  95888. * Rig mode of the camera.
  95889. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  95890. * This is normally controlled byt the camera themselves as internal use.
  95891. */
  95892. cameraRigMode: number;
  95893. /**
  95894. * Defines the distance between both "eyes" in case of a RIG
  95895. */
  95896. interaxialDistance: number;
  95897. /**
  95898. * Defines if stereoscopic rendering is done side by side or over under.
  95899. */
  95900. isStereoscopicSideBySide: boolean;
  95901. /**
  95902. * 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
  95903. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  95904. * else in the scene. (Eg. security camera)
  95905. *
  95906. * 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)
  95907. */
  95908. customRenderTargets: RenderTargetTexture[];
  95909. /**
  95910. * When set, the camera will render to this render target instead of the default canvas
  95911. *
  95912. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  95913. */
  95914. outputRenderTarget: Nullable<RenderTargetTexture>;
  95915. /**
  95916. * Observable triggered when the camera view matrix has changed.
  95917. */
  95918. onViewMatrixChangedObservable: Observable<Camera>;
  95919. /**
  95920. * Observable triggered when the camera Projection matrix has changed.
  95921. */
  95922. onProjectionMatrixChangedObservable: Observable<Camera>;
  95923. /**
  95924. * Observable triggered when the inputs have been processed.
  95925. */
  95926. onAfterCheckInputsObservable: Observable<Camera>;
  95927. /**
  95928. * Observable triggered when reset has been called and applied to the camera.
  95929. */
  95930. onRestoreStateObservable: Observable<Camera>;
  95931. /** @hidden */
  95932. _cameraRigParams: any;
  95933. /** @hidden */
  95934. _rigCameras: Camera[];
  95935. /** @hidden */
  95936. _rigPostProcess: Nullable<PostProcess>;
  95937. protected _webvrViewMatrix: Matrix;
  95938. /** @hidden */
  95939. _skipRendering: boolean;
  95940. /** @hidden */
  95941. _projectionMatrix: Matrix;
  95942. /** @hidden */
  95943. _postProcesses: Nullable<PostProcess>[];
  95944. /** @hidden */
  95945. _activeMeshes: SmartArray<AbstractMesh>;
  95946. protected _globalPosition: Vector3;
  95947. /** @hidden */
  95948. _computedViewMatrix: Matrix;
  95949. private _doNotComputeProjectionMatrix;
  95950. private _transformMatrix;
  95951. private _frustumPlanes;
  95952. private _refreshFrustumPlanes;
  95953. private _storedFov;
  95954. private _stateStored;
  95955. /**
  95956. * Instantiates a new camera object.
  95957. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  95958. * @see http://doc.babylonjs.com/features/cameras
  95959. * @param name Defines the name of the camera in the scene
  95960. * @param position Defines the position of the camera
  95961. * @param scene Defines the scene the camera belongs too
  95962. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  95963. */
  95964. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95965. /**
  95966. * Store current camera state (fov, position, etc..)
  95967. * @returns the camera
  95968. */
  95969. storeState(): Camera;
  95970. /**
  95971. * Restores the camera state values if it has been stored. You must call storeState() first
  95972. */
  95973. protected _restoreStateValues(): boolean;
  95974. /**
  95975. * Restored camera state. You must call storeState() first.
  95976. * @returns true if restored and false otherwise
  95977. */
  95978. restoreState(): boolean;
  95979. /**
  95980. * Gets the class name of the camera.
  95981. * @returns the class name
  95982. */
  95983. getClassName(): string;
  95984. /** @hidden */
  95985. readonly _isCamera: boolean;
  95986. /**
  95987. * Gets a string representation of the camera useful for debug purpose.
  95988. * @param fullDetails Defines that a more verboe level of logging is required
  95989. * @returns the string representation
  95990. */
  95991. toString(fullDetails?: boolean): string;
  95992. /**
  95993. * Gets the current world space position of the camera.
  95994. */
  95995. get globalPosition(): Vector3;
  95996. /**
  95997. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  95998. * @returns the active meshe list
  95999. */
  96000. getActiveMeshes(): SmartArray<AbstractMesh>;
  96001. /**
  96002. * Check wether a mesh is part of the current active mesh list of the camera
  96003. * @param mesh Defines the mesh to check
  96004. * @returns true if active, false otherwise
  96005. */
  96006. isActiveMesh(mesh: Mesh): boolean;
  96007. /**
  96008. * Is this camera ready to be used/rendered
  96009. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  96010. * @return true if the camera is ready
  96011. */
  96012. isReady(completeCheck?: boolean): boolean;
  96013. /** @hidden */
  96014. _initCache(): void;
  96015. /** @hidden */
  96016. _updateCache(ignoreParentClass?: boolean): void;
  96017. /** @hidden */
  96018. _isSynchronized(): boolean;
  96019. /** @hidden */
  96020. _isSynchronizedViewMatrix(): boolean;
  96021. /** @hidden */
  96022. _isSynchronizedProjectionMatrix(): boolean;
  96023. /**
  96024. * Attach the input controls to a specific dom element to get the input from.
  96025. * @param element Defines the element the controls should be listened from
  96026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96027. */
  96028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96029. /**
  96030. * Detach the current controls from the specified dom element.
  96031. * @param element Defines the element to stop listening the inputs from
  96032. */
  96033. detachControl(element: HTMLElement): void;
  96034. /**
  96035. * Update the camera state according to the different inputs gathered during the frame.
  96036. */
  96037. update(): void;
  96038. /** @hidden */
  96039. _checkInputs(): void;
  96040. /** @hidden */
  96041. get rigCameras(): Camera[];
  96042. /**
  96043. * Gets the post process used by the rig cameras
  96044. */
  96045. get rigPostProcess(): Nullable<PostProcess>;
  96046. /**
  96047. * Internal, gets the first post proces.
  96048. * @returns the first post process to be run on this camera.
  96049. */
  96050. _getFirstPostProcess(): Nullable<PostProcess>;
  96051. private _cascadePostProcessesToRigCams;
  96052. /**
  96053. * Attach a post process to the camera.
  96054. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96055. * @param postProcess The post process to attach to the camera
  96056. * @param insertAt The position of the post process in case several of them are in use in the scene
  96057. * @returns the position the post process has been inserted at
  96058. */
  96059. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  96060. /**
  96061. * Detach a post process to the camera.
  96062. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96063. * @param postProcess The post process to detach from the camera
  96064. */
  96065. detachPostProcess(postProcess: PostProcess): void;
  96066. /**
  96067. * Gets the current world matrix of the camera
  96068. */
  96069. getWorldMatrix(): Matrix;
  96070. /** @hidden */
  96071. _getViewMatrix(): Matrix;
  96072. /**
  96073. * Gets the current view matrix of the camera.
  96074. * @param force forces the camera to recompute the matrix without looking at the cached state
  96075. * @returns the view matrix
  96076. */
  96077. getViewMatrix(force?: boolean): Matrix;
  96078. /**
  96079. * Freeze the projection matrix.
  96080. * It will prevent the cache check of the camera projection compute and can speed up perf
  96081. * if no parameter of the camera are meant to change
  96082. * @param projection Defines manually a projection if necessary
  96083. */
  96084. freezeProjectionMatrix(projection?: Matrix): void;
  96085. /**
  96086. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  96087. */
  96088. unfreezeProjectionMatrix(): void;
  96089. /**
  96090. * Gets the current projection matrix of the camera.
  96091. * @param force forces the camera to recompute the matrix without looking at the cached state
  96092. * @returns the projection matrix
  96093. */
  96094. getProjectionMatrix(force?: boolean): Matrix;
  96095. /**
  96096. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  96097. * @returns a Matrix
  96098. */
  96099. getTransformationMatrix(): Matrix;
  96100. private _updateFrustumPlanes;
  96101. /**
  96102. * Checks if a cullable object (mesh...) is in the camera frustum
  96103. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  96104. * @param target The object to check
  96105. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  96106. * @returns true if the object is in frustum otherwise false
  96107. */
  96108. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  96109. /**
  96110. * Checks if a cullable object (mesh...) is in the camera frustum
  96111. * Unlike isInFrustum this cheks the full bounding box
  96112. * @param target The object to check
  96113. * @returns true if the object is in frustum otherwise false
  96114. */
  96115. isCompletelyInFrustum(target: ICullable): boolean;
  96116. /**
  96117. * Gets a ray in the forward direction from the camera.
  96118. * @param length Defines the length of the ray to create
  96119. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  96120. * @param origin Defines the start point of the ray which defaults to the camera position
  96121. * @returns the forward ray
  96122. */
  96123. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  96124. /**
  96125. * Releases resources associated with this node.
  96126. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96127. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96128. */
  96129. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96130. /** @hidden */
  96131. _isLeftCamera: boolean;
  96132. /**
  96133. * Gets the left camera of a rig setup in case of Rigged Camera
  96134. */
  96135. get isLeftCamera(): boolean;
  96136. /** @hidden */
  96137. _isRightCamera: boolean;
  96138. /**
  96139. * Gets the right camera of a rig setup in case of Rigged Camera
  96140. */
  96141. get isRightCamera(): boolean;
  96142. /**
  96143. * Gets the left camera of a rig setup in case of Rigged Camera
  96144. */
  96145. get leftCamera(): Nullable<FreeCamera>;
  96146. /**
  96147. * Gets the right camera of a rig setup in case of Rigged Camera
  96148. */
  96149. get rightCamera(): Nullable<FreeCamera>;
  96150. /**
  96151. * Gets the left camera target of a rig setup in case of Rigged Camera
  96152. * @returns the target position
  96153. */
  96154. getLeftTarget(): Nullable<Vector3>;
  96155. /**
  96156. * Gets the right camera target of a rig setup in case of Rigged Camera
  96157. * @returns the target position
  96158. */
  96159. getRightTarget(): Nullable<Vector3>;
  96160. /**
  96161. * @hidden
  96162. */
  96163. setCameraRigMode(mode: number, rigParams: any): void;
  96164. /** @hidden */
  96165. static _setStereoscopicRigMode(camera: Camera): void;
  96166. /** @hidden */
  96167. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  96168. /** @hidden */
  96169. static _setVRRigMode(camera: Camera, rigParams: any): void;
  96170. /** @hidden */
  96171. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  96172. /** @hidden */
  96173. _getVRProjectionMatrix(): Matrix;
  96174. protected _updateCameraRotationMatrix(): void;
  96175. protected _updateWebVRCameraRotationMatrix(): void;
  96176. /**
  96177. * This function MUST be overwritten by the different WebVR cameras available.
  96178. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96179. * @hidden
  96180. */
  96181. _getWebVRProjectionMatrix(): Matrix;
  96182. /**
  96183. * This function MUST be overwritten by the different WebVR cameras available.
  96184. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96185. * @hidden
  96186. */
  96187. _getWebVRViewMatrix(): Matrix;
  96188. /** @hidden */
  96189. setCameraRigParameter(name: string, value: any): void;
  96190. /**
  96191. * needs to be overridden by children so sub has required properties to be copied
  96192. * @hidden
  96193. */
  96194. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96195. /**
  96196. * May need to be overridden by children
  96197. * @hidden
  96198. */
  96199. _updateRigCameras(): void;
  96200. /** @hidden */
  96201. _setupInputs(): void;
  96202. /**
  96203. * Serialiaze the camera setup to a json represention
  96204. * @returns the JSON representation
  96205. */
  96206. serialize(): any;
  96207. /**
  96208. * Clones the current camera.
  96209. * @param name The cloned camera name
  96210. * @returns the cloned camera
  96211. */
  96212. clone(name: string): Camera;
  96213. /**
  96214. * Gets the direction of the camera relative to a given local axis.
  96215. * @param localAxis Defines the reference axis to provide a relative direction.
  96216. * @return the direction
  96217. */
  96218. getDirection(localAxis: Vector3): Vector3;
  96219. /**
  96220. * Returns the current camera absolute rotation
  96221. */
  96222. get absoluteRotation(): Quaternion;
  96223. /**
  96224. * Gets the direction of the camera relative to a given local axis into a passed vector.
  96225. * @param localAxis Defines the reference axis to provide a relative direction.
  96226. * @param result Defines the vector to store the result in
  96227. */
  96228. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  96229. /**
  96230. * Gets a camera constructor for a given camera type
  96231. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  96232. * @param name The name of the camera the result will be able to instantiate
  96233. * @param scene The scene the result will construct the camera in
  96234. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  96235. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  96236. * @returns a factory method to construc the camera
  96237. */
  96238. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  96239. /**
  96240. * Compute the world matrix of the camera.
  96241. * @returns the camera world matrix
  96242. */
  96243. computeWorldMatrix(): Matrix;
  96244. /**
  96245. * Parse a JSON and creates the camera from the parsed information
  96246. * @param parsedCamera The JSON to parse
  96247. * @param scene The scene to instantiate the camera in
  96248. * @returns the newly constructed camera
  96249. */
  96250. static Parse(parsedCamera: any, scene: Scene): Camera;
  96251. }
  96252. }
  96253. declare module BABYLON {
  96254. /**
  96255. * Class containing static functions to help procedurally build meshes
  96256. */
  96257. export class DiscBuilder {
  96258. /**
  96259. * Creates a plane polygonal mesh. By default, this is a disc
  96260. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  96261. * * 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
  96262. * * 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
  96263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96266. * @param name defines the name of the mesh
  96267. * @param options defines the options used to create the mesh
  96268. * @param scene defines the hosting scene
  96269. * @returns the plane polygonal mesh
  96270. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  96271. */
  96272. static CreateDisc(name: string, options: {
  96273. radius?: number;
  96274. tessellation?: number;
  96275. arc?: number;
  96276. updatable?: boolean;
  96277. sideOrientation?: number;
  96278. frontUVs?: Vector4;
  96279. backUVs?: Vector4;
  96280. }, scene?: Nullable<Scene>): Mesh;
  96281. }
  96282. }
  96283. declare module BABYLON {
  96284. /**
  96285. * This represents all the required information to add a fresnel effect on a material:
  96286. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96287. */
  96288. export class FresnelParameters {
  96289. private _isEnabled;
  96290. /**
  96291. * Define if the fresnel effect is enable or not.
  96292. */
  96293. get isEnabled(): boolean;
  96294. set isEnabled(value: boolean);
  96295. /**
  96296. * Define the color used on edges (grazing angle)
  96297. */
  96298. leftColor: Color3;
  96299. /**
  96300. * Define the color used on center
  96301. */
  96302. rightColor: Color3;
  96303. /**
  96304. * Define bias applied to computed fresnel term
  96305. */
  96306. bias: number;
  96307. /**
  96308. * Defined the power exponent applied to fresnel term
  96309. */
  96310. power: number;
  96311. /**
  96312. * Clones the current fresnel and its valuues
  96313. * @returns a clone fresnel configuration
  96314. */
  96315. clone(): FresnelParameters;
  96316. /**
  96317. * Serializes the current fresnel parameters to a JSON representation.
  96318. * @return the JSON serialization
  96319. */
  96320. serialize(): any;
  96321. /**
  96322. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96323. * @param parsedFresnelParameters Define the JSON representation
  96324. * @returns the parsed parameters
  96325. */
  96326. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96327. }
  96328. }
  96329. declare module BABYLON {
  96330. /**
  96331. * Base class of materials working in push mode in babylon JS
  96332. * @hidden
  96333. */
  96334. export class PushMaterial extends Material {
  96335. protected _activeEffect: Effect;
  96336. protected _normalMatrix: Matrix;
  96337. /**
  96338. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96339. * This means that the material can keep using a previous shader while a new one is being compiled.
  96340. * This is mostly used when shader parallel compilation is supported (true by default)
  96341. */
  96342. allowShaderHotSwapping: boolean;
  96343. constructor(name: string, scene: Scene);
  96344. getEffect(): Effect;
  96345. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96346. /**
  96347. * Binds the given world matrix to the active effect
  96348. *
  96349. * @param world the matrix to bind
  96350. */
  96351. bindOnlyWorldMatrix(world: Matrix): void;
  96352. /**
  96353. * Binds the given normal matrix to the active effect
  96354. *
  96355. * @param normalMatrix the matrix to bind
  96356. */
  96357. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96358. bind(world: Matrix, mesh?: Mesh): void;
  96359. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96360. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96361. }
  96362. }
  96363. declare module BABYLON {
  96364. /**
  96365. * This groups all the flags used to control the materials channel.
  96366. */
  96367. export class MaterialFlags {
  96368. private static _DiffuseTextureEnabled;
  96369. /**
  96370. * Are diffuse textures enabled in the application.
  96371. */
  96372. static get DiffuseTextureEnabled(): boolean;
  96373. static set DiffuseTextureEnabled(value: boolean);
  96374. private static _AmbientTextureEnabled;
  96375. /**
  96376. * Are ambient textures enabled in the application.
  96377. */
  96378. static get AmbientTextureEnabled(): boolean;
  96379. static set AmbientTextureEnabled(value: boolean);
  96380. private static _OpacityTextureEnabled;
  96381. /**
  96382. * Are opacity textures enabled in the application.
  96383. */
  96384. static get OpacityTextureEnabled(): boolean;
  96385. static set OpacityTextureEnabled(value: boolean);
  96386. private static _ReflectionTextureEnabled;
  96387. /**
  96388. * Are reflection textures enabled in the application.
  96389. */
  96390. static get ReflectionTextureEnabled(): boolean;
  96391. static set ReflectionTextureEnabled(value: boolean);
  96392. private static _EmissiveTextureEnabled;
  96393. /**
  96394. * Are emissive textures enabled in the application.
  96395. */
  96396. static get EmissiveTextureEnabled(): boolean;
  96397. static set EmissiveTextureEnabled(value: boolean);
  96398. private static _SpecularTextureEnabled;
  96399. /**
  96400. * Are specular textures enabled in the application.
  96401. */
  96402. static get SpecularTextureEnabled(): boolean;
  96403. static set SpecularTextureEnabled(value: boolean);
  96404. private static _BumpTextureEnabled;
  96405. /**
  96406. * Are bump textures enabled in the application.
  96407. */
  96408. static get BumpTextureEnabled(): boolean;
  96409. static set BumpTextureEnabled(value: boolean);
  96410. private static _LightmapTextureEnabled;
  96411. /**
  96412. * Are lightmap textures enabled in the application.
  96413. */
  96414. static get LightmapTextureEnabled(): boolean;
  96415. static set LightmapTextureEnabled(value: boolean);
  96416. private static _RefractionTextureEnabled;
  96417. /**
  96418. * Are refraction textures enabled in the application.
  96419. */
  96420. static get RefractionTextureEnabled(): boolean;
  96421. static set RefractionTextureEnabled(value: boolean);
  96422. private static _ColorGradingTextureEnabled;
  96423. /**
  96424. * Are color grading textures enabled in the application.
  96425. */
  96426. static get ColorGradingTextureEnabled(): boolean;
  96427. static set ColorGradingTextureEnabled(value: boolean);
  96428. private static _FresnelEnabled;
  96429. /**
  96430. * Are fresnels enabled in the application.
  96431. */
  96432. static get FresnelEnabled(): boolean;
  96433. static set FresnelEnabled(value: boolean);
  96434. private static _ClearCoatTextureEnabled;
  96435. /**
  96436. * Are clear coat textures enabled in the application.
  96437. */
  96438. static get ClearCoatTextureEnabled(): boolean;
  96439. static set ClearCoatTextureEnabled(value: boolean);
  96440. private static _ClearCoatBumpTextureEnabled;
  96441. /**
  96442. * Are clear coat bump textures enabled in the application.
  96443. */
  96444. static get ClearCoatBumpTextureEnabled(): boolean;
  96445. static set ClearCoatBumpTextureEnabled(value: boolean);
  96446. private static _ClearCoatTintTextureEnabled;
  96447. /**
  96448. * Are clear coat tint textures enabled in the application.
  96449. */
  96450. static get ClearCoatTintTextureEnabled(): boolean;
  96451. static set ClearCoatTintTextureEnabled(value: boolean);
  96452. private static _SheenTextureEnabled;
  96453. /**
  96454. * Are sheen textures enabled in the application.
  96455. */
  96456. static get SheenTextureEnabled(): boolean;
  96457. static set SheenTextureEnabled(value: boolean);
  96458. private static _AnisotropicTextureEnabled;
  96459. /**
  96460. * Are anisotropic textures enabled in the application.
  96461. */
  96462. static get AnisotropicTextureEnabled(): boolean;
  96463. static set AnisotropicTextureEnabled(value: boolean);
  96464. private static _ThicknessTextureEnabled;
  96465. /**
  96466. * Are thickness textures enabled in the application.
  96467. */
  96468. static get ThicknessTextureEnabled(): boolean;
  96469. static set ThicknessTextureEnabled(value: boolean);
  96470. }
  96471. }
  96472. declare module BABYLON {
  96473. /** @hidden */
  96474. export var defaultFragmentDeclaration: {
  96475. name: string;
  96476. shader: string;
  96477. };
  96478. }
  96479. declare module BABYLON {
  96480. /** @hidden */
  96481. export var defaultUboDeclaration: {
  96482. name: string;
  96483. shader: string;
  96484. };
  96485. }
  96486. declare module BABYLON {
  96487. /** @hidden */
  96488. export var lightFragmentDeclaration: {
  96489. name: string;
  96490. shader: string;
  96491. };
  96492. }
  96493. declare module BABYLON {
  96494. /** @hidden */
  96495. export var lightUboDeclaration: {
  96496. name: string;
  96497. shader: string;
  96498. };
  96499. }
  96500. declare module BABYLON {
  96501. /** @hidden */
  96502. export var lightsFragmentFunctions: {
  96503. name: string;
  96504. shader: string;
  96505. };
  96506. }
  96507. declare module BABYLON {
  96508. /** @hidden */
  96509. export var shadowsFragmentFunctions: {
  96510. name: string;
  96511. shader: string;
  96512. };
  96513. }
  96514. declare module BABYLON {
  96515. /** @hidden */
  96516. export var fresnelFunction: {
  96517. name: string;
  96518. shader: string;
  96519. };
  96520. }
  96521. declare module BABYLON {
  96522. /** @hidden */
  96523. export var reflectionFunction: {
  96524. name: string;
  96525. shader: string;
  96526. };
  96527. }
  96528. declare module BABYLON {
  96529. /** @hidden */
  96530. export var bumpFragmentFunctions: {
  96531. name: string;
  96532. shader: string;
  96533. };
  96534. }
  96535. declare module BABYLON {
  96536. /** @hidden */
  96537. export var logDepthDeclaration: {
  96538. name: string;
  96539. shader: string;
  96540. };
  96541. }
  96542. declare module BABYLON {
  96543. /** @hidden */
  96544. export var bumpFragment: {
  96545. name: string;
  96546. shader: string;
  96547. };
  96548. }
  96549. declare module BABYLON {
  96550. /** @hidden */
  96551. export var depthPrePass: {
  96552. name: string;
  96553. shader: string;
  96554. };
  96555. }
  96556. declare module BABYLON {
  96557. /** @hidden */
  96558. export var lightFragment: {
  96559. name: string;
  96560. shader: string;
  96561. };
  96562. }
  96563. declare module BABYLON {
  96564. /** @hidden */
  96565. export var logDepthFragment: {
  96566. name: string;
  96567. shader: string;
  96568. };
  96569. }
  96570. declare module BABYLON {
  96571. /** @hidden */
  96572. export var defaultPixelShader: {
  96573. name: string;
  96574. shader: string;
  96575. };
  96576. }
  96577. declare module BABYLON {
  96578. /** @hidden */
  96579. export var defaultVertexDeclaration: {
  96580. name: string;
  96581. shader: string;
  96582. };
  96583. }
  96584. declare module BABYLON {
  96585. /** @hidden */
  96586. export var bumpVertexDeclaration: {
  96587. name: string;
  96588. shader: string;
  96589. };
  96590. }
  96591. declare module BABYLON {
  96592. /** @hidden */
  96593. export var bumpVertex: {
  96594. name: string;
  96595. shader: string;
  96596. };
  96597. }
  96598. declare module BABYLON {
  96599. /** @hidden */
  96600. export var fogVertex: {
  96601. name: string;
  96602. shader: string;
  96603. };
  96604. }
  96605. declare module BABYLON {
  96606. /** @hidden */
  96607. export var shadowsVertex: {
  96608. name: string;
  96609. shader: string;
  96610. };
  96611. }
  96612. declare module BABYLON {
  96613. /** @hidden */
  96614. export var pointCloudVertex: {
  96615. name: string;
  96616. shader: string;
  96617. };
  96618. }
  96619. declare module BABYLON {
  96620. /** @hidden */
  96621. export var logDepthVertex: {
  96622. name: string;
  96623. shader: string;
  96624. };
  96625. }
  96626. declare module BABYLON {
  96627. /** @hidden */
  96628. export var defaultVertexShader: {
  96629. name: string;
  96630. shader: string;
  96631. };
  96632. }
  96633. declare module BABYLON {
  96634. /** @hidden */
  96635. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96636. MAINUV1: boolean;
  96637. MAINUV2: boolean;
  96638. DIFFUSE: boolean;
  96639. DIFFUSEDIRECTUV: number;
  96640. AMBIENT: boolean;
  96641. AMBIENTDIRECTUV: number;
  96642. OPACITY: boolean;
  96643. OPACITYDIRECTUV: number;
  96644. OPACITYRGB: boolean;
  96645. REFLECTION: boolean;
  96646. EMISSIVE: boolean;
  96647. EMISSIVEDIRECTUV: number;
  96648. SPECULAR: boolean;
  96649. SPECULARDIRECTUV: number;
  96650. BUMP: boolean;
  96651. BUMPDIRECTUV: number;
  96652. PARALLAX: boolean;
  96653. PARALLAXOCCLUSION: boolean;
  96654. SPECULAROVERALPHA: boolean;
  96655. CLIPPLANE: boolean;
  96656. CLIPPLANE2: boolean;
  96657. CLIPPLANE3: boolean;
  96658. CLIPPLANE4: boolean;
  96659. CLIPPLANE5: boolean;
  96660. CLIPPLANE6: boolean;
  96661. ALPHATEST: boolean;
  96662. DEPTHPREPASS: boolean;
  96663. ALPHAFROMDIFFUSE: boolean;
  96664. POINTSIZE: boolean;
  96665. FOG: boolean;
  96666. SPECULARTERM: boolean;
  96667. DIFFUSEFRESNEL: boolean;
  96668. OPACITYFRESNEL: boolean;
  96669. REFLECTIONFRESNEL: boolean;
  96670. REFRACTIONFRESNEL: boolean;
  96671. EMISSIVEFRESNEL: boolean;
  96672. FRESNEL: boolean;
  96673. NORMAL: boolean;
  96674. UV1: boolean;
  96675. UV2: boolean;
  96676. VERTEXCOLOR: boolean;
  96677. VERTEXALPHA: boolean;
  96678. NUM_BONE_INFLUENCERS: number;
  96679. BonesPerMesh: number;
  96680. BONETEXTURE: boolean;
  96681. INSTANCES: boolean;
  96682. GLOSSINESS: boolean;
  96683. ROUGHNESS: boolean;
  96684. EMISSIVEASILLUMINATION: boolean;
  96685. LINKEMISSIVEWITHDIFFUSE: boolean;
  96686. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96687. LIGHTMAP: boolean;
  96688. LIGHTMAPDIRECTUV: number;
  96689. OBJECTSPACE_NORMALMAP: boolean;
  96690. USELIGHTMAPASSHADOWMAP: boolean;
  96691. REFLECTIONMAP_3D: boolean;
  96692. REFLECTIONMAP_SPHERICAL: boolean;
  96693. REFLECTIONMAP_PLANAR: boolean;
  96694. REFLECTIONMAP_CUBIC: boolean;
  96695. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96696. REFLECTIONMAP_PROJECTION: boolean;
  96697. REFLECTIONMAP_SKYBOX: boolean;
  96698. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96699. REFLECTIONMAP_EXPLICIT: boolean;
  96700. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96701. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96702. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96703. INVERTCUBICMAP: boolean;
  96704. LOGARITHMICDEPTH: boolean;
  96705. REFRACTION: boolean;
  96706. REFRACTIONMAP_3D: boolean;
  96707. REFLECTIONOVERALPHA: boolean;
  96708. TWOSIDEDLIGHTING: boolean;
  96709. SHADOWFLOAT: boolean;
  96710. MORPHTARGETS: boolean;
  96711. MORPHTARGETS_NORMAL: boolean;
  96712. MORPHTARGETS_TANGENT: boolean;
  96713. MORPHTARGETS_UV: boolean;
  96714. NUM_MORPH_INFLUENCERS: number;
  96715. NONUNIFORMSCALING: boolean;
  96716. PREMULTIPLYALPHA: boolean;
  96717. IMAGEPROCESSING: boolean;
  96718. VIGNETTE: boolean;
  96719. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96720. VIGNETTEBLENDMODEOPAQUE: boolean;
  96721. TONEMAPPING: boolean;
  96722. TONEMAPPING_ACES: boolean;
  96723. CONTRAST: boolean;
  96724. COLORCURVES: boolean;
  96725. COLORGRADING: boolean;
  96726. COLORGRADING3D: boolean;
  96727. SAMPLER3DGREENDEPTH: boolean;
  96728. SAMPLER3DBGRMAP: boolean;
  96729. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96730. MULTIVIEW: boolean;
  96731. /**
  96732. * If the reflection texture on this material is in linear color space
  96733. * @hidden
  96734. */
  96735. IS_REFLECTION_LINEAR: boolean;
  96736. /**
  96737. * If the refraction texture on this material is in linear color space
  96738. * @hidden
  96739. */
  96740. IS_REFRACTION_LINEAR: boolean;
  96741. EXPOSURE: boolean;
  96742. constructor();
  96743. setReflectionMode(modeToEnable: string): void;
  96744. }
  96745. /**
  96746. * This is the default material used in Babylon. It is the best trade off between quality
  96747. * and performances.
  96748. * @see http://doc.babylonjs.com/babylon101/materials
  96749. */
  96750. export class StandardMaterial extends PushMaterial {
  96751. private _diffuseTexture;
  96752. /**
  96753. * The basic texture of the material as viewed under a light.
  96754. */
  96755. diffuseTexture: Nullable<BaseTexture>;
  96756. private _ambientTexture;
  96757. /**
  96758. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96759. */
  96760. ambientTexture: Nullable<BaseTexture>;
  96761. private _opacityTexture;
  96762. /**
  96763. * Define the transparency of the material from a texture.
  96764. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96765. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96766. */
  96767. opacityTexture: Nullable<BaseTexture>;
  96768. private _reflectionTexture;
  96769. /**
  96770. * Define the texture used to display the reflection.
  96771. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96772. */
  96773. reflectionTexture: Nullable<BaseTexture>;
  96774. private _emissiveTexture;
  96775. /**
  96776. * Define texture of the material as if self lit.
  96777. * This will be mixed in the final result even in the absence of light.
  96778. */
  96779. emissiveTexture: Nullable<BaseTexture>;
  96780. private _specularTexture;
  96781. /**
  96782. * Define how the color and intensity of the highlight given by the light in the material.
  96783. */
  96784. specularTexture: Nullable<BaseTexture>;
  96785. private _bumpTexture;
  96786. /**
  96787. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96788. * 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.
  96789. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96790. */
  96791. bumpTexture: Nullable<BaseTexture>;
  96792. private _lightmapTexture;
  96793. /**
  96794. * Complex lighting can be computationally expensive to compute at runtime.
  96795. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96796. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96797. */
  96798. lightmapTexture: Nullable<BaseTexture>;
  96799. private _refractionTexture;
  96800. /**
  96801. * Define the texture used to display the refraction.
  96802. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96803. */
  96804. refractionTexture: Nullable<BaseTexture>;
  96805. /**
  96806. * The color of the material lit by the environmental background lighting.
  96807. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96808. */
  96809. ambientColor: Color3;
  96810. /**
  96811. * The basic color of the material as viewed under a light.
  96812. */
  96813. diffuseColor: Color3;
  96814. /**
  96815. * Define how the color and intensity of the highlight given by the light in the material.
  96816. */
  96817. specularColor: Color3;
  96818. /**
  96819. * Define the color of the material as if self lit.
  96820. * This will be mixed in the final result even in the absence of light.
  96821. */
  96822. emissiveColor: Color3;
  96823. /**
  96824. * Defines how sharp are the highlights in the material.
  96825. * The bigger the value the sharper giving a more glossy feeling to the result.
  96826. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96827. */
  96828. specularPower: number;
  96829. private _useAlphaFromDiffuseTexture;
  96830. /**
  96831. * Does the transparency come from the diffuse texture alpha channel.
  96832. */
  96833. useAlphaFromDiffuseTexture: boolean;
  96834. private _useEmissiveAsIllumination;
  96835. /**
  96836. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96837. */
  96838. useEmissiveAsIllumination: boolean;
  96839. private _linkEmissiveWithDiffuse;
  96840. /**
  96841. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96842. * the emissive level when the final color is close to one.
  96843. */
  96844. linkEmissiveWithDiffuse: boolean;
  96845. private _useSpecularOverAlpha;
  96846. /**
  96847. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96848. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96849. */
  96850. useSpecularOverAlpha: boolean;
  96851. private _useReflectionOverAlpha;
  96852. /**
  96853. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96854. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96855. */
  96856. useReflectionOverAlpha: boolean;
  96857. private _disableLighting;
  96858. /**
  96859. * Does lights from the scene impacts this material.
  96860. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96861. */
  96862. disableLighting: boolean;
  96863. private _useObjectSpaceNormalMap;
  96864. /**
  96865. * Allows using an object space normal map (instead of tangent space).
  96866. */
  96867. useObjectSpaceNormalMap: boolean;
  96868. private _useParallax;
  96869. /**
  96870. * Is parallax enabled or not.
  96871. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96872. */
  96873. useParallax: boolean;
  96874. private _useParallaxOcclusion;
  96875. /**
  96876. * Is parallax occlusion enabled or not.
  96877. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96878. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96879. */
  96880. useParallaxOcclusion: boolean;
  96881. /**
  96882. * 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.
  96883. */
  96884. parallaxScaleBias: number;
  96885. private _roughness;
  96886. /**
  96887. * Helps to define how blurry the reflections should appears in the material.
  96888. */
  96889. roughness: number;
  96890. /**
  96891. * In case of refraction, define the value of the index of refraction.
  96892. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96893. */
  96894. indexOfRefraction: number;
  96895. /**
  96896. * Invert the refraction texture alongside the y axis.
  96897. * It can be useful with procedural textures or probe for instance.
  96898. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96899. */
  96900. invertRefractionY: boolean;
  96901. /**
  96902. * Defines the alpha limits in alpha test mode.
  96903. */
  96904. alphaCutOff: number;
  96905. private _useLightmapAsShadowmap;
  96906. /**
  96907. * In case of light mapping, define whether the map contains light or shadow informations.
  96908. */
  96909. useLightmapAsShadowmap: boolean;
  96910. private _diffuseFresnelParameters;
  96911. /**
  96912. * Define the diffuse fresnel parameters of the material.
  96913. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96914. */
  96915. diffuseFresnelParameters: FresnelParameters;
  96916. private _opacityFresnelParameters;
  96917. /**
  96918. * Define the opacity fresnel parameters of the material.
  96919. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96920. */
  96921. opacityFresnelParameters: FresnelParameters;
  96922. private _reflectionFresnelParameters;
  96923. /**
  96924. * Define the reflection fresnel parameters of the material.
  96925. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96926. */
  96927. reflectionFresnelParameters: FresnelParameters;
  96928. private _refractionFresnelParameters;
  96929. /**
  96930. * Define the refraction fresnel parameters of the material.
  96931. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96932. */
  96933. refractionFresnelParameters: FresnelParameters;
  96934. private _emissiveFresnelParameters;
  96935. /**
  96936. * Define the emissive fresnel parameters of the material.
  96937. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96938. */
  96939. emissiveFresnelParameters: FresnelParameters;
  96940. private _useReflectionFresnelFromSpecular;
  96941. /**
  96942. * If true automatically deducts the fresnels values from the material specularity.
  96943. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96944. */
  96945. useReflectionFresnelFromSpecular: boolean;
  96946. private _useGlossinessFromSpecularMapAlpha;
  96947. /**
  96948. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  96949. */
  96950. useGlossinessFromSpecularMapAlpha: boolean;
  96951. private _maxSimultaneousLights;
  96952. /**
  96953. * Defines the maximum number of lights that can be used in the material
  96954. */
  96955. maxSimultaneousLights: number;
  96956. private _invertNormalMapX;
  96957. /**
  96958. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  96959. */
  96960. invertNormalMapX: boolean;
  96961. private _invertNormalMapY;
  96962. /**
  96963. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  96964. */
  96965. invertNormalMapY: boolean;
  96966. private _twoSidedLighting;
  96967. /**
  96968. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  96969. */
  96970. twoSidedLighting: boolean;
  96971. /**
  96972. * Default configuration related to image processing available in the standard Material.
  96973. */
  96974. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96975. /**
  96976. * Gets the image processing configuration used either in this material.
  96977. */
  96978. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  96979. /**
  96980. * Sets the Default image processing configuration used either in the this material.
  96981. *
  96982. * If sets to null, the scene one is in use.
  96983. */
  96984. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  96985. /**
  96986. * Keep track of the image processing observer to allow dispose and replace.
  96987. */
  96988. private _imageProcessingObserver;
  96989. /**
  96990. * Attaches a new image processing configuration to the Standard Material.
  96991. * @param configuration
  96992. */
  96993. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96994. /**
  96995. * Gets wether the color curves effect is enabled.
  96996. */
  96997. get cameraColorCurvesEnabled(): boolean;
  96998. /**
  96999. * Sets wether the color curves effect is enabled.
  97000. */
  97001. set cameraColorCurvesEnabled(value: boolean);
  97002. /**
  97003. * Gets wether the color grading effect is enabled.
  97004. */
  97005. get cameraColorGradingEnabled(): boolean;
  97006. /**
  97007. * Gets wether the color grading effect is enabled.
  97008. */
  97009. set cameraColorGradingEnabled(value: boolean);
  97010. /**
  97011. * Gets wether tonemapping is enabled or not.
  97012. */
  97013. get cameraToneMappingEnabled(): boolean;
  97014. /**
  97015. * Sets wether tonemapping is enabled or not
  97016. */
  97017. set cameraToneMappingEnabled(value: boolean);
  97018. /**
  97019. * The camera exposure used on this material.
  97020. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97021. * This corresponds to a photographic exposure.
  97022. */
  97023. get cameraExposure(): number;
  97024. /**
  97025. * The camera exposure used on this material.
  97026. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97027. * This corresponds to a photographic exposure.
  97028. */
  97029. set cameraExposure(value: number);
  97030. /**
  97031. * Gets The camera contrast used on this material.
  97032. */
  97033. get cameraContrast(): number;
  97034. /**
  97035. * Sets The camera contrast used on this material.
  97036. */
  97037. set cameraContrast(value: number);
  97038. /**
  97039. * Gets the Color Grading 2D Lookup Texture.
  97040. */
  97041. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  97042. /**
  97043. * Sets the Color Grading 2D Lookup Texture.
  97044. */
  97045. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  97046. /**
  97047. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97048. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97049. * 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;
  97050. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97051. */
  97052. get cameraColorCurves(): Nullable<ColorCurves>;
  97053. /**
  97054. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97055. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97056. * 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;
  97057. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97058. */
  97059. set cameraColorCurves(value: Nullable<ColorCurves>);
  97060. /**
  97061. * Custom callback helping to override the default shader used in the material.
  97062. */
  97063. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97064. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97065. protected _worldViewProjectionMatrix: Matrix;
  97066. protected _globalAmbientColor: Color3;
  97067. protected _useLogarithmicDepth: boolean;
  97068. protected _rebuildInParallel: boolean;
  97069. /**
  97070. * Instantiates a new standard material.
  97071. * This is the default material used in Babylon. It is the best trade off between quality
  97072. * and performances.
  97073. * @see http://doc.babylonjs.com/babylon101/materials
  97074. * @param name Define the name of the material in the scene
  97075. * @param scene Define the scene the material belong to
  97076. */
  97077. constructor(name: string, scene: Scene);
  97078. /**
  97079. * Gets a boolean indicating that current material needs to register RTT
  97080. */
  97081. get hasRenderTargetTextures(): boolean;
  97082. /**
  97083. * Gets the current class name of the material e.g. "StandardMaterial"
  97084. * Mainly use in serialization.
  97085. * @returns the class name
  97086. */
  97087. getClassName(): string;
  97088. /**
  97089. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97090. * You can try switching to logarithmic depth.
  97091. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97092. */
  97093. get useLogarithmicDepth(): boolean;
  97094. set useLogarithmicDepth(value: boolean);
  97095. /**
  97096. * Specifies if the material will require alpha blending
  97097. * @returns a boolean specifying if alpha blending is needed
  97098. */
  97099. needAlphaBlending(): boolean;
  97100. /**
  97101. * Specifies if this material should be rendered in alpha test mode
  97102. * @returns a boolean specifying if an alpha test is needed.
  97103. */
  97104. needAlphaTesting(): boolean;
  97105. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97106. /**
  97107. * Get the texture used for alpha test purpose.
  97108. * @returns the diffuse texture in case of the standard material.
  97109. */
  97110. getAlphaTestTexture(): Nullable<BaseTexture>;
  97111. /**
  97112. * Get if the submesh is ready to be used and all its information available.
  97113. * Child classes can use it to update shaders
  97114. * @param mesh defines the mesh to check
  97115. * @param subMesh defines which submesh to check
  97116. * @param useInstances specifies that instances should be used
  97117. * @returns a boolean indicating that the submesh is ready or not
  97118. */
  97119. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97120. /**
  97121. * Builds the material UBO layouts.
  97122. * Used internally during the effect preparation.
  97123. */
  97124. buildUniformLayout(): void;
  97125. /**
  97126. * Unbinds the material from the mesh
  97127. */
  97128. unbind(): void;
  97129. /**
  97130. * Binds the submesh to this material by preparing the effect and shader to draw
  97131. * @param world defines the world transformation matrix
  97132. * @param mesh defines the mesh containing the submesh
  97133. * @param subMesh defines the submesh to bind the material to
  97134. */
  97135. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97136. /**
  97137. * Get the list of animatables in the material.
  97138. * @returns the list of animatables object used in the material
  97139. */
  97140. getAnimatables(): IAnimatable[];
  97141. /**
  97142. * Gets the active textures from the material
  97143. * @returns an array of textures
  97144. */
  97145. getActiveTextures(): BaseTexture[];
  97146. /**
  97147. * Specifies if the material uses a texture
  97148. * @param texture defines the texture to check against the material
  97149. * @returns a boolean specifying if the material uses the texture
  97150. */
  97151. hasTexture(texture: BaseTexture): boolean;
  97152. /**
  97153. * Disposes the material
  97154. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97155. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97156. */
  97157. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97158. /**
  97159. * Makes a duplicate of the material, and gives it a new name
  97160. * @param name defines the new name for the duplicated material
  97161. * @returns the cloned material
  97162. */
  97163. clone(name: string): StandardMaterial;
  97164. /**
  97165. * Serializes this material in a JSON representation
  97166. * @returns the serialized material object
  97167. */
  97168. serialize(): any;
  97169. /**
  97170. * Creates a standard material from parsed material data
  97171. * @param source defines the JSON representation of the material
  97172. * @param scene defines the hosting scene
  97173. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97174. * @returns a new standard material
  97175. */
  97176. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97177. /**
  97178. * Are diffuse textures enabled in the application.
  97179. */
  97180. static get DiffuseTextureEnabled(): boolean;
  97181. static set DiffuseTextureEnabled(value: boolean);
  97182. /**
  97183. * Are ambient textures enabled in the application.
  97184. */
  97185. static get AmbientTextureEnabled(): boolean;
  97186. static set AmbientTextureEnabled(value: boolean);
  97187. /**
  97188. * Are opacity textures enabled in the application.
  97189. */
  97190. static get OpacityTextureEnabled(): boolean;
  97191. static set OpacityTextureEnabled(value: boolean);
  97192. /**
  97193. * Are reflection textures enabled in the application.
  97194. */
  97195. static get ReflectionTextureEnabled(): boolean;
  97196. static set ReflectionTextureEnabled(value: boolean);
  97197. /**
  97198. * Are emissive textures enabled in the application.
  97199. */
  97200. static get EmissiveTextureEnabled(): boolean;
  97201. static set EmissiveTextureEnabled(value: boolean);
  97202. /**
  97203. * Are specular textures enabled in the application.
  97204. */
  97205. static get SpecularTextureEnabled(): boolean;
  97206. static set SpecularTextureEnabled(value: boolean);
  97207. /**
  97208. * Are bump textures enabled in the application.
  97209. */
  97210. static get BumpTextureEnabled(): boolean;
  97211. static set BumpTextureEnabled(value: boolean);
  97212. /**
  97213. * Are lightmap textures enabled in the application.
  97214. */
  97215. static get LightmapTextureEnabled(): boolean;
  97216. static set LightmapTextureEnabled(value: boolean);
  97217. /**
  97218. * Are refraction textures enabled in the application.
  97219. */
  97220. static get RefractionTextureEnabled(): boolean;
  97221. static set RefractionTextureEnabled(value: boolean);
  97222. /**
  97223. * Are color grading textures enabled in the application.
  97224. */
  97225. static get ColorGradingTextureEnabled(): boolean;
  97226. static set ColorGradingTextureEnabled(value: boolean);
  97227. /**
  97228. * Are fresnels enabled in the application.
  97229. */
  97230. static get FresnelEnabled(): boolean;
  97231. static set FresnelEnabled(value: boolean);
  97232. }
  97233. }
  97234. declare module BABYLON {
  97235. /**
  97236. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  97237. *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.
  97238. * The SPS is also a particle system. It provides some methods to manage the particles.
  97239. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  97240. *
  97241. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  97242. */
  97243. export class SolidParticleSystem implements IDisposable {
  97244. /**
  97245. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  97246. * Example : var p = SPS.particles[i];
  97247. */
  97248. particles: SolidParticle[];
  97249. /**
  97250. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  97251. */
  97252. nbParticles: number;
  97253. /**
  97254. * If the particles must ever face the camera (default false). Useful for planar particles.
  97255. */
  97256. billboard: boolean;
  97257. /**
  97258. * Recompute normals when adding a shape
  97259. */
  97260. recomputeNormals: boolean;
  97261. /**
  97262. * This a counter ofr your own usage. It's not set by any SPS functions.
  97263. */
  97264. counter: number;
  97265. /**
  97266. * The SPS name. This name is also given to the underlying mesh.
  97267. */
  97268. name: string;
  97269. /**
  97270. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  97271. */
  97272. mesh: Mesh;
  97273. /**
  97274. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  97275. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  97276. */
  97277. vars: any;
  97278. /**
  97279. * This array is populated when the SPS is set as 'pickable'.
  97280. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  97281. * Each element of this array is an object `{idx: int, faceId: int}`.
  97282. * `idx` is the picked particle index in the `SPS.particles` array
  97283. * `faceId` is the picked face index counted within this particle.
  97284. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  97285. */
  97286. pickedParticles: {
  97287. idx: number;
  97288. faceId: number;
  97289. }[];
  97290. /**
  97291. * This array is populated when `enableDepthSort` is set to true.
  97292. * Each element of this array is an instance of the class DepthSortedParticle.
  97293. */
  97294. depthSortedParticles: DepthSortedParticle[];
  97295. /**
  97296. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  97297. * @hidden
  97298. */
  97299. _bSphereOnly: boolean;
  97300. /**
  97301. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  97302. * @hidden
  97303. */
  97304. _bSphereRadiusFactor: number;
  97305. private _scene;
  97306. private _positions;
  97307. private _indices;
  97308. private _normals;
  97309. private _colors;
  97310. private _uvs;
  97311. private _indices32;
  97312. private _positions32;
  97313. private _normals32;
  97314. private _fixedNormal32;
  97315. private _colors32;
  97316. private _uvs32;
  97317. private _index;
  97318. private _updatable;
  97319. private _pickable;
  97320. private _isVisibilityBoxLocked;
  97321. private _alwaysVisible;
  97322. private _depthSort;
  97323. private _expandable;
  97324. private _shapeCounter;
  97325. private _copy;
  97326. private _color;
  97327. private _computeParticleColor;
  97328. private _computeParticleTexture;
  97329. private _computeParticleRotation;
  97330. private _computeParticleVertex;
  97331. private _computeBoundingBox;
  97332. private _depthSortParticles;
  97333. private _camera;
  97334. private _mustUnrotateFixedNormals;
  97335. private _particlesIntersect;
  97336. private _needs32Bits;
  97337. private _isNotBuilt;
  97338. private _lastParticleId;
  97339. private _idxOfId;
  97340. private _multimaterialEnabled;
  97341. private _useModelMaterial;
  97342. private _indicesByMaterial;
  97343. private _materialIndexes;
  97344. private _depthSortFunction;
  97345. private _materialSortFunction;
  97346. private _materials;
  97347. private _multimaterial;
  97348. private _materialIndexesById;
  97349. private _defaultMaterial;
  97350. private _autoUpdateSubMeshes;
  97351. /**
  97352. * Creates a SPS (Solid Particle System) object.
  97353. * @param name (String) is the SPS name, this will be the underlying mesh name.
  97354. * @param scene (Scene) is the scene in which the SPS is added.
  97355. * @param options defines the options of the sps e.g.
  97356. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  97357. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  97358. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  97359. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  97360. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  97361. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  97362. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  97363. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  97364. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  97365. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  97366. */
  97367. constructor(name: string, scene: Scene, options?: {
  97368. updatable?: boolean;
  97369. isPickable?: boolean;
  97370. enableDepthSort?: boolean;
  97371. particleIntersection?: boolean;
  97372. boundingSphereOnly?: boolean;
  97373. bSphereRadiusFactor?: number;
  97374. expandable?: boolean;
  97375. useModelMaterial?: boolean;
  97376. enableMultiMaterial?: boolean;
  97377. });
  97378. /**
  97379. * Builds the SPS underlying mesh. Returns a standard Mesh.
  97380. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  97381. * @returns the created mesh
  97382. */
  97383. buildMesh(): Mesh;
  97384. /**
  97385. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  97386. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  97387. * Thus the particles generated from `digest()` have their property `position` set yet.
  97388. * @param mesh ( Mesh ) is the mesh to be digested
  97389. * @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
  97390. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  97391. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  97392. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97393. * @returns the current SPS
  97394. */
  97395. digest(mesh: Mesh, options?: {
  97396. facetNb?: number;
  97397. number?: number;
  97398. delta?: number;
  97399. storage?: [];
  97400. }): SolidParticleSystem;
  97401. /**
  97402. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  97403. * @hidden
  97404. */
  97405. private _unrotateFixedNormals;
  97406. /**
  97407. * Resets the temporary working copy particle
  97408. * @hidden
  97409. */
  97410. private _resetCopy;
  97411. /**
  97412. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  97413. * @param p the current index in the positions array to be updated
  97414. * @param ind the current index in the indices array
  97415. * @param shape a Vector3 array, the shape geometry
  97416. * @param positions the positions array to be updated
  97417. * @param meshInd the shape indices array
  97418. * @param indices the indices array to be updated
  97419. * @param meshUV the shape uv array
  97420. * @param uvs the uv array to be updated
  97421. * @param meshCol the shape color array
  97422. * @param colors the color array to be updated
  97423. * @param meshNor the shape normals array
  97424. * @param normals the normals array to be updated
  97425. * @param idx the particle index
  97426. * @param idxInShape the particle index in its shape
  97427. * @param options the addShape() method passed options
  97428. * @model the particle model
  97429. * @hidden
  97430. */
  97431. private _meshBuilder;
  97432. /**
  97433. * Returns a shape Vector3 array from positions float array
  97434. * @param positions float array
  97435. * @returns a vector3 array
  97436. * @hidden
  97437. */
  97438. private _posToShape;
  97439. /**
  97440. * Returns a shapeUV array from a float uvs (array deep copy)
  97441. * @param uvs as a float array
  97442. * @returns a shapeUV array
  97443. * @hidden
  97444. */
  97445. private _uvsToShapeUV;
  97446. /**
  97447. * Adds a new particle object in the particles array
  97448. * @param idx particle index in particles array
  97449. * @param id particle id
  97450. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  97451. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  97452. * @param model particle ModelShape object
  97453. * @param shapeId model shape identifier
  97454. * @param idxInShape index of the particle in the current model
  97455. * @param bInfo model bounding info object
  97456. * @param storage target storage array, if any
  97457. * @hidden
  97458. */
  97459. private _addParticle;
  97460. /**
  97461. * Adds some particles to the SPS from the model shape. Returns the shape id.
  97462. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  97463. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  97464. * @param nb (positive integer) the number of particles to be created from this model
  97465. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  97466. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  97467. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97468. * @returns the number of shapes in the system
  97469. */
  97470. addShape(mesh: Mesh, nb: number, options?: {
  97471. positionFunction?: any;
  97472. vertexFunction?: any;
  97473. storage?: [];
  97474. }): number;
  97475. /**
  97476. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  97477. * @hidden
  97478. */
  97479. private _rebuildParticle;
  97480. /**
  97481. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  97482. * @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.
  97483. * @returns the SPS.
  97484. */
  97485. rebuildMesh(reset?: boolean): SolidParticleSystem;
  97486. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  97487. * Returns an array with the removed particles.
  97488. * 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.
  97489. * The SPS can't be empty so at least one particle needs to remain in place.
  97490. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  97491. * @param start index of the first particle to remove
  97492. * @param end index of the last particle to remove (included)
  97493. * @returns an array populated with the removed particles
  97494. */
  97495. removeParticles(start: number, end: number): SolidParticle[];
  97496. /**
  97497. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  97498. * @param solidParticleArray an array populated with Solid Particles objects
  97499. * @returns the SPS
  97500. */
  97501. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  97502. /**
  97503. * Creates a new particle and modifies the SPS mesh geometry :
  97504. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  97505. * - calls _addParticle() to populate the particle array
  97506. * factorized code from addShape() and insertParticlesFromArray()
  97507. * @param idx particle index in the particles array
  97508. * @param i particle index in its shape
  97509. * @param modelShape particle ModelShape object
  97510. * @param shape shape vertex array
  97511. * @param meshInd shape indices array
  97512. * @param meshUV shape uv array
  97513. * @param meshCol shape color array
  97514. * @param meshNor shape normals array
  97515. * @param bbInfo shape bounding info
  97516. * @param storage target particle storage
  97517. * @options addShape() passed options
  97518. * @hidden
  97519. */
  97520. private _insertNewParticle;
  97521. /**
  97522. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  97523. * This method calls `updateParticle()` for each particle of the SPS.
  97524. * For an animated SPS, it is usually called within the render loop.
  97525. * 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.
  97526. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  97527. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  97528. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  97529. * @returns the SPS.
  97530. */
  97531. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  97532. /**
  97533. * Disposes the SPS.
  97534. */
  97535. dispose(): void;
  97536. /**
  97537. * Returns a SolidParticle object from its identifier : particle.id
  97538. * @param id (integer) the particle Id
  97539. * @returns the searched particle or null if not found in the SPS.
  97540. */
  97541. getParticleById(id: number): Nullable<SolidParticle>;
  97542. /**
  97543. * Returns a new array populated with the particles having the passed shapeId.
  97544. * @param shapeId (integer) the shape identifier
  97545. * @returns a new solid particle array
  97546. */
  97547. getParticlesByShapeId(shapeId: number): SolidParticle[];
  97548. /**
  97549. * Populates the passed array "ref" with the particles having the passed shapeId.
  97550. * @param shapeId the shape identifier
  97551. * @returns the SPS
  97552. * @param ref
  97553. */
  97554. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  97555. /**
  97556. * Computes the required SubMeshes according the materials assigned to the particles.
  97557. * @returns the solid particle system.
  97558. * Does nothing if called before the SPS mesh is built.
  97559. */
  97560. computeSubMeshes(): SolidParticleSystem;
  97561. /**
  97562. * Sorts the solid particles by material when MultiMaterial is enabled.
  97563. * Updates the indices32 array.
  97564. * Updates the indicesByMaterial array.
  97565. * Updates the mesh indices array.
  97566. * @returns the SPS
  97567. * @hidden
  97568. */
  97569. private _sortParticlesByMaterial;
  97570. /**
  97571. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  97572. * @hidden
  97573. */
  97574. private _setMaterialIndexesById;
  97575. /**
  97576. * Returns an array with unique values of Materials from the passed array
  97577. * @param array the material array to be checked and filtered
  97578. * @hidden
  97579. */
  97580. private _filterUniqueMaterialId;
  97581. /**
  97582. * Sets a new Standard Material as _defaultMaterial if not already set.
  97583. * @hidden
  97584. */
  97585. private _setDefaultMaterial;
  97586. /**
  97587. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  97588. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97589. * @returns the SPS.
  97590. */
  97591. refreshVisibleSize(): SolidParticleSystem;
  97592. /**
  97593. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  97594. * @param size the size (float) of the visibility box
  97595. * note : this doesn't lock the SPS mesh bounding box.
  97596. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97597. */
  97598. setVisibilityBox(size: number): void;
  97599. /**
  97600. * Gets whether the SPS as always visible or not
  97601. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97602. */
  97603. get isAlwaysVisible(): boolean;
  97604. /**
  97605. * Sets the SPS as always visible or not
  97606. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97607. */
  97608. set isAlwaysVisible(val: boolean);
  97609. /**
  97610. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97611. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97612. */
  97613. set isVisibilityBoxLocked(val: boolean);
  97614. /**
  97615. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97616. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97617. */
  97618. get isVisibilityBoxLocked(): boolean;
  97619. /**
  97620. * Tells to `setParticles()` to compute the particle rotations or not.
  97621. * Default value : true. The SPS is faster when it's set to false.
  97622. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97623. */
  97624. set computeParticleRotation(val: boolean);
  97625. /**
  97626. * Tells to `setParticles()` to compute the particle colors or not.
  97627. * Default value : true. The SPS is faster when it's set to false.
  97628. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97629. */
  97630. set computeParticleColor(val: boolean);
  97631. set computeParticleTexture(val: boolean);
  97632. /**
  97633. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  97634. * Default value : false. The SPS is faster when it's set to false.
  97635. * Note : the particle custom vertex positions aren't stored values.
  97636. */
  97637. set computeParticleVertex(val: boolean);
  97638. /**
  97639. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  97640. */
  97641. set computeBoundingBox(val: boolean);
  97642. /**
  97643. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  97644. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97645. * Default : `true`
  97646. */
  97647. set depthSortParticles(val: boolean);
  97648. /**
  97649. * Gets if `setParticles()` computes the particle rotations or not.
  97650. * Default value : true. The SPS is faster when it's set to false.
  97651. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97652. */
  97653. get computeParticleRotation(): boolean;
  97654. /**
  97655. * Gets if `setParticles()` computes the particle colors or not.
  97656. * Default value : true. The SPS is faster when it's set to false.
  97657. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97658. */
  97659. get computeParticleColor(): boolean;
  97660. /**
  97661. * Gets if `setParticles()` computes the particle textures or not.
  97662. * Default value : true. The SPS is faster when it's set to false.
  97663. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  97664. */
  97665. get computeParticleTexture(): boolean;
  97666. /**
  97667. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  97668. * Default value : false. The SPS is faster when it's set to false.
  97669. * Note : the particle custom vertex positions aren't stored values.
  97670. */
  97671. get computeParticleVertex(): boolean;
  97672. /**
  97673. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  97674. */
  97675. get computeBoundingBox(): boolean;
  97676. /**
  97677. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  97678. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97679. * Default : `true`
  97680. */
  97681. get depthSortParticles(): boolean;
  97682. /**
  97683. * Gets if the SPS is created as expandable at construction time.
  97684. * Default : `false`
  97685. */
  97686. get expandable(): boolean;
  97687. /**
  97688. * Gets if the SPS supports the Multi Materials
  97689. */
  97690. get multimaterialEnabled(): boolean;
  97691. /**
  97692. * Gets if the SPS uses the model materials for its own multimaterial.
  97693. */
  97694. get useModelMaterial(): boolean;
  97695. /**
  97696. * The SPS used material array.
  97697. */
  97698. get materials(): Material[];
  97699. /**
  97700. * Sets the SPS MultiMaterial from the passed materials.
  97701. * Note : the passed array is internally copied and not used then by reference.
  97702. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  97703. */
  97704. setMultiMaterial(materials: Material[]): void;
  97705. /**
  97706. * The SPS computed multimaterial object
  97707. */
  97708. get multimaterial(): MultiMaterial;
  97709. set multimaterial(mm: MultiMaterial);
  97710. /**
  97711. * If the subMeshes must be updated on the next call to setParticles()
  97712. */
  97713. get autoUpdateSubMeshes(): boolean;
  97714. set autoUpdateSubMeshes(val: boolean);
  97715. /**
  97716. * This function does nothing. It may be overwritten to set all the particle first values.
  97717. * The SPS doesn't call this function, you may have to call it by your own.
  97718. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97719. */
  97720. initParticles(): void;
  97721. /**
  97722. * This function does nothing. It may be overwritten to recycle a particle.
  97723. * The SPS doesn't call this function, you may have to call it by your own.
  97724. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97725. * @param particle The particle to recycle
  97726. * @returns the recycled particle
  97727. */
  97728. recycleParticle(particle: SolidParticle): SolidParticle;
  97729. /**
  97730. * Updates a particle : this function should be overwritten by the user.
  97731. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  97732. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97733. * @example : just set a particle position or velocity and recycle conditions
  97734. * @param particle The particle to update
  97735. * @returns the updated particle
  97736. */
  97737. updateParticle(particle: SolidParticle): SolidParticle;
  97738. /**
  97739. * Updates a vertex of a particle : it can be overwritten by the user.
  97740. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  97741. * @param particle the current particle
  97742. * @param vertex the current index of the current particle
  97743. * @param pt the index of the current vertex in the particle shape
  97744. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  97745. * @example : just set a vertex particle position
  97746. * @returns the updated vertex
  97747. */
  97748. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  97749. /**
  97750. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  97751. * This does nothing and may be overwritten by the user.
  97752. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97753. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97754. * @param update the boolean update value actually passed to setParticles()
  97755. */
  97756. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97757. /**
  97758. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  97759. * This will be passed three parameters.
  97760. * This does nothing and may be overwritten by the user.
  97761. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97762. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97763. * @param update the boolean update value actually passed to setParticles()
  97764. */
  97765. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97766. }
  97767. }
  97768. declare module BABYLON {
  97769. /**
  97770. * Represents one particle of a solid particle system.
  97771. */
  97772. export class SolidParticle {
  97773. /**
  97774. * particle global index
  97775. */
  97776. idx: number;
  97777. /**
  97778. * particle identifier
  97779. */
  97780. id: number;
  97781. /**
  97782. * The color of the particle
  97783. */
  97784. color: Nullable<Color4>;
  97785. /**
  97786. * The world space position of the particle.
  97787. */
  97788. position: Vector3;
  97789. /**
  97790. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  97791. */
  97792. rotation: Vector3;
  97793. /**
  97794. * The world space rotation quaternion of the particle.
  97795. */
  97796. rotationQuaternion: Nullable<Quaternion>;
  97797. /**
  97798. * The scaling of the particle.
  97799. */
  97800. scaling: Vector3;
  97801. /**
  97802. * The uvs of the particle.
  97803. */
  97804. uvs: Vector4;
  97805. /**
  97806. * The current speed of the particle.
  97807. */
  97808. velocity: Vector3;
  97809. /**
  97810. * The pivot point in the particle local space.
  97811. */
  97812. pivot: Vector3;
  97813. /**
  97814. * Must the particle be translated from its pivot point in its local space ?
  97815. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  97816. * Default : false
  97817. */
  97818. translateFromPivot: boolean;
  97819. /**
  97820. * Is the particle active or not ?
  97821. */
  97822. alive: boolean;
  97823. /**
  97824. * Is the particle visible or not ?
  97825. */
  97826. isVisible: boolean;
  97827. /**
  97828. * Index of this particle in the global "positions" array (Internal use)
  97829. * @hidden
  97830. */
  97831. _pos: number;
  97832. /**
  97833. * @hidden Index of this particle in the global "indices" array (Internal use)
  97834. */
  97835. _ind: number;
  97836. /**
  97837. * @hidden ModelShape of this particle (Internal use)
  97838. */
  97839. _model: ModelShape;
  97840. /**
  97841. * ModelShape id of this particle
  97842. */
  97843. shapeId: number;
  97844. /**
  97845. * Index of the particle in its shape id
  97846. */
  97847. idxInShape: number;
  97848. /**
  97849. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  97850. */
  97851. _modelBoundingInfo: BoundingInfo;
  97852. /**
  97853. * @hidden Particle BoundingInfo object (Internal use)
  97854. */
  97855. _boundingInfo: BoundingInfo;
  97856. /**
  97857. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  97858. */
  97859. _sps: SolidParticleSystem;
  97860. /**
  97861. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  97862. */
  97863. _stillInvisible: boolean;
  97864. /**
  97865. * @hidden Last computed particle rotation matrix
  97866. */
  97867. _rotationMatrix: number[];
  97868. /**
  97869. * Parent particle Id, if any.
  97870. * Default null.
  97871. */
  97872. parentId: Nullable<number>;
  97873. /**
  97874. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  97875. */
  97876. materialIndex: Nullable<number>;
  97877. /**
  97878. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  97879. * The possible values are :
  97880. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  97881. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97882. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  97883. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  97884. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97885. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  97886. * */
  97887. cullingStrategy: number;
  97888. /**
  97889. * @hidden Internal global position in the SPS.
  97890. */
  97891. _globalPosition: Vector3;
  97892. /**
  97893. * Creates a Solid Particle object.
  97894. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  97895. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  97896. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  97897. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  97898. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  97899. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  97900. * @param shapeId (integer) is the model shape identifier in the SPS.
  97901. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  97902. * @param sps defines the sps it is associated to
  97903. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  97904. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  97905. */
  97906. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  97907. /**
  97908. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  97909. * @param target the particle target
  97910. * @returns the current particle
  97911. */
  97912. copyToRef(target: SolidParticle): SolidParticle;
  97913. /**
  97914. * Legacy support, changed scale to scaling
  97915. */
  97916. get scale(): Vector3;
  97917. /**
  97918. * Legacy support, changed scale to scaling
  97919. */
  97920. set scale(scale: Vector3);
  97921. /**
  97922. * Legacy support, changed quaternion to rotationQuaternion
  97923. */
  97924. get quaternion(): Nullable<Quaternion>;
  97925. /**
  97926. * Legacy support, changed quaternion to rotationQuaternion
  97927. */
  97928. set quaternion(q: Nullable<Quaternion>);
  97929. /**
  97930. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  97931. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  97932. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  97933. * @returns true if it intersects
  97934. */
  97935. intersectsMesh(target: Mesh | SolidParticle): boolean;
  97936. /**
  97937. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  97938. * A particle is in the frustum if its bounding box intersects the frustum
  97939. * @param frustumPlanes defines the frustum to test
  97940. * @returns true if the particle is in the frustum planes
  97941. */
  97942. isInFrustum(frustumPlanes: Plane[]): boolean;
  97943. /**
  97944. * get the rotation matrix of the particle
  97945. * @hidden
  97946. */
  97947. getRotationMatrix(m: Matrix): void;
  97948. }
  97949. /**
  97950. * Represents the shape of the model used by one particle of a solid particle system.
  97951. * SPS internal tool, don't use it manually.
  97952. */
  97953. export class ModelShape {
  97954. /**
  97955. * The shape id
  97956. * @hidden
  97957. */
  97958. shapeID: number;
  97959. /**
  97960. * flat array of model positions (internal use)
  97961. * @hidden
  97962. */
  97963. _shape: Vector3[];
  97964. /**
  97965. * flat array of model UVs (internal use)
  97966. * @hidden
  97967. */
  97968. _shapeUV: number[];
  97969. /**
  97970. * color array of the model
  97971. * @hidden
  97972. */
  97973. _shapeColors: number[];
  97974. /**
  97975. * indices array of the model
  97976. * @hidden
  97977. */
  97978. _indices: number[];
  97979. /**
  97980. * normals array of the model
  97981. * @hidden
  97982. */
  97983. _normals: number[];
  97984. /**
  97985. * length of the shape in the model indices array (internal use)
  97986. * @hidden
  97987. */
  97988. _indicesLength: number;
  97989. /**
  97990. * Custom position function (internal use)
  97991. * @hidden
  97992. */
  97993. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  97994. /**
  97995. * Custom vertex function (internal use)
  97996. * @hidden
  97997. */
  97998. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  97999. /**
  98000. * Model material (internal use)
  98001. * @hidden
  98002. */
  98003. _material: Nullable<Material>;
  98004. /**
  98005. * 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.
  98006. * SPS internal tool, don't use it manually.
  98007. * @hidden
  98008. */
  98009. 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>, material: Nullable<Material>);
  98010. }
  98011. /**
  98012. * Represents a Depth Sorted Particle in the solid particle system.
  98013. * @hidden
  98014. */
  98015. export class DepthSortedParticle {
  98016. /**
  98017. * Index of the particle in the "indices" array
  98018. */
  98019. ind: number;
  98020. /**
  98021. * Length of the particle shape in the "indices" array
  98022. */
  98023. indicesLength: number;
  98024. /**
  98025. * Squared distance from the particle to the camera
  98026. */
  98027. sqDistance: number;
  98028. /**
  98029. * Material index when used with MultiMaterials
  98030. */
  98031. materialIndex: number;
  98032. /**
  98033. * Creates a new sorted particle
  98034. * @param materialIndex
  98035. */
  98036. constructor(ind: number, indLength: number, materialIndex: number);
  98037. }
  98038. }
  98039. declare module BABYLON {
  98040. /**
  98041. * @hidden
  98042. */
  98043. export class _MeshCollisionData {
  98044. _checkCollisions: boolean;
  98045. _collisionMask: number;
  98046. _collisionGroup: number;
  98047. _collider: Nullable<Collider>;
  98048. _oldPositionForCollisions: Vector3;
  98049. _diffPositionForCollisions: Vector3;
  98050. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  98051. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  98052. }
  98053. }
  98054. declare module BABYLON {
  98055. /** @hidden */
  98056. class _FacetDataStorage {
  98057. facetPositions: Vector3[];
  98058. facetNormals: Vector3[];
  98059. facetPartitioning: number[][];
  98060. facetNb: number;
  98061. partitioningSubdivisions: number;
  98062. partitioningBBoxRatio: number;
  98063. facetDataEnabled: boolean;
  98064. facetParameters: any;
  98065. bbSize: Vector3;
  98066. subDiv: {
  98067. max: number;
  98068. X: number;
  98069. Y: number;
  98070. Z: number;
  98071. };
  98072. facetDepthSort: boolean;
  98073. facetDepthSortEnabled: boolean;
  98074. depthSortedIndices: IndicesArray;
  98075. depthSortedFacets: {
  98076. ind: number;
  98077. sqDistance: number;
  98078. }[];
  98079. facetDepthSortFunction: (f1: {
  98080. ind: number;
  98081. sqDistance: number;
  98082. }, f2: {
  98083. ind: number;
  98084. sqDistance: number;
  98085. }) => number;
  98086. facetDepthSortFrom: Vector3;
  98087. facetDepthSortOrigin: Vector3;
  98088. invertedMatrix: Matrix;
  98089. }
  98090. /**
  98091. * @hidden
  98092. **/
  98093. class _InternalAbstractMeshDataInfo {
  98094. _hasVertexAlpha: boolean;
  98095. _useVertexColors: boolean;
  98096. _numBoneInfluencers: number;
  98097. _applyFog: boolean;
  98098. _receiveShadows: boolean;
  98099. _facetData: _FacetDataStorage;
  98100. _visibility: number;
  98101. _skeleton: Nullable<Skeleton>;
  98102. _layerMask: number;
  98103. _computeBonesUsingShaders: boolean;
  98104. _isActive: boolean;
  98105. _onlyForInstances: boolean;
  98106. _isActiveIntermediate: boolean;
  98107. _onlyForInstancesIntermediate: boolean;
  98108. _actAsRegularMesh: boolean;
  98109. }
  98110. /**
  98111. * Class used to store all common mesh properties
  98112. */
  98113. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  98114. /** No occlusion */
  98115. static OCCLUSION_TYPE_NONE: number;
  98116. /** Occlusion set to optimisitic */
  98117. static OCCLUSION_TYPE_OPTIMISTIC: number;
  98118. /** Occlusion set to strict */
  98119. static OCCLUSION_TYPE_STRICT: number;
  98120. /** Use an accurante occlusion algorithm */
  98121. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  98122. /** Use a conservative occlusion algorithm */
  98123. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  98124. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  98125. * Test order :
  98126. * Is the bounding sphere outside the frustum ?
  98127. * If not, are the bounding box vertices outside the frustum ?
  98128. * It not, then the cullable object is in the frustum.
  98129. */
  98130. static readonly CULLINGSTRATEGY_STANDARD: number;
  98131. /** Culling strategy : Bounding Sphere Only.
  98132. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  98133. * It's also less accurate than the standard because some not visible objects can still be selected.
  98134. * Test : is the bounding sphere outside the frustum ?
  98135. * If not, then the cullable object is in the frustum.
  98136. */
  98137. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  98138. /** Culling strategy : Optimistic Inclusion.
  98139. * This in an inclusion test first, then the standard exclusion test.
  98140. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  98141. * 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.
  98142. * Anyway, it's as accurate as the standard strategy.
  98143. * Test :
  98144. * Is the cullable object bounding sphere center in the frustum ?
  98145. * If not, apply the default culling strategy.
  98146. */
  98147. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  98148. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  98149. * This in an inclusion test first, then the bounding sphere only exclusion test.
  98150. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  98151. * 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.
  98152. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  98153. * Test :
  98154. * Is the cullable object bounding sphere center in the frustum ?
  98155. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  98156. */
  98157. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  98158. /**
  98159. * No billboard
  98160. */
  98161. static get BILLBOARDMODE_NONE(): number;
  98162. /** Billboard on X axis */
  98163. static get BILLBOARDMODE_X(): number;
  98164. /** Billboard on Y axis */
  98165. static get BILLBOARDMODE_Y(): number;
  98166. /** Billboard on Z axis */
  98167. static get BILLBOARDMODE_Z(): number;
  98168. /** Billboard on all axes */
  98169. static get BILLBOARDMODE_ALL(): number;
  98170. /** Billboard on using position instead of orientation */
  98171. static get BILLBOARDMODE_USE_POSITION(): number;
  98172. /** @hidden */
  98173. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  98174. /**
  98175. * The culling strategy to use to check whether the mesh must be rendered or not.
  98176. * This value can be changed at any time and will be used on the next render mesh selection.
  98177. * The possible values are :
  98178. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98179. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98180. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98181. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98182. * Please read each static variable documentation to get details about the culling process.
  98183. * */
  98184. cullingStrategy: number;
  98185. /**
  98186. * Gets the number of facets in the mesh
  98187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98188. */
  98189. get facetNb(): number;
  98190. /**
  98191. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  98192. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98193. */
  98194. get partitioningSubdivisions(): number;
  98195. set partitioningSubdivisions(nb: number);
  98196. /**
  98197. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  98198. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  98199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98200. */
  98201. get partitioningBBoxRatio(): number;
  98202. set partitioningBBoxRatio(ratio: number);
  98203. /**
  98204. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  98205. * Works only for updatable meshes.
  98206. * Doesn't work with multi-materials
  98207. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98208. */
  98209. get mustDepthSortFacets(): boolean;
  98210. set mustDepthSortFacets(sort: boolean);
  98211. /**
  98212. * The location (Vector3) where the facet depth sort must be computed from.
  98213. * By default, the active camera position.
  98214. * Used only when facet depth sort is enabled
  98215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98216. */
  98217. get facetDepthSortFrom(): Vector3;
  98218. set facetDepthSortFrom(location: Vector3);
  98219. /**
  98220. * gets a boolean indicating if facetData is enabled
  98221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98222. */
  98223. get isFacetDataEnabled(): boolean;
  98224. /** @hidden */
  98225. _updateNonUniformScalingState(value: boolean): boolean;
  98226. /**
  98227. * An event triggered when this mesh collides with another one
  98228. */
  98229. onCollideObservable: Observable<AbstractMesh>;
  98230. /** Set a function to call when this mesh collides with another one */
  98231. set onCollide(callback: () => void);
  98232. /**
  98233. * An event triggered when the collision's position changes
  98234. */
  98235. onCollisionPositionChangeObservable: Observable<Vector3>;
  98236. /** Set a function to call when the collision's position changes */
  98237. set onCollisionPositionChange(callback: () => void);
  98238. /**
  98239. * An event triggered when material is changed
  98240. */
  98241. onMaterialChangedObservable: Observable<AbstractMesh>;
  98242. /**
  98243. * Gets or sets the orientation for POV movement & rotation
  98244. */
  98245. definedFacingForward: boolean;
  98246. /** @hidden */
  98247. _occlusionQuery: Nullable<WebGLQuery>;
  98248. /** @hidden */
  98249. _renderingGroup: Nullable<RenderingGroup>;
  98250. /**
  98251. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98252. */
  98253. get visibility(): number;
  98254. /**
  98255. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98256. */
  98257. set visibility(value: number);
  98258. /** Gets or sets the alpha index used to sort transparent meshes
  98259. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  98260. */
  98261. alphaIndex: number;
  98262. /**
  98263. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  98264. */
  98265. isVisible: boolean;
  98266. /**
  98267. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  98268. */
  98269. isPickable: boolean;
  98270. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  98271. showSubMeshesBoundingBox: boolean;
  98272. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  98273. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  98274. */
  98275. isBlocker: boolean;
  98276. /**
  98277. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  98278. */
  98279. enablePointerMoveEvents: boolean;
  98280. /**
  98281. * Specifies the rendering group id for this mesh (0 by default)
  98282. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  98283. */
  98284. renderingGroupId: number;
  98285. private _material;
  98286. /** Gets or sets current material */
  98287. get material(): Nullable<Material>;
  98288. set material(value: Nullable<Material>);
  98289. /**
  98290. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  98291. * @see http://doc.babylonjs.com/babylon101/shadows
  98292. */
  98293. get receiveShadows(): boolean;
  98294. set receiveShadows(value: boolean);
  98295. /** Defines color to use when rendering outline */
  98296. outlineColor: Color3;
  98297. /** Define width to use when rendering outline */
  98298. outlineWidth: number;
  98299. /** Defines color to use when rendering overlay */
  98300. overlayColor: Color3;
  98301. /** Defines alpha to use when rendering overlay */
  98302. overlayAlpha: number;
  98303. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  98304. get hasVertexAlpha(): boolean;
  98305. set hasVertexAlpha(value: boolean);
  98306. /** 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) */
  98307. get useVertexColors(): boolean;
  98308. set useVertexColors(value: boolean);
  98309. /**
  98310. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  98311. */
  98312. get computeBonesUsingShaders(): boolean;
  98313. set computeBonesUsingShaders(value: boolean);
  98314. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  98315. get numBoneInfluencers(): number;
  98316. set numBoneInfluencers(value: number);
  98317. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  98318. get applyFog(): boolean;
  98319. set applyFog(value: boolean);
  98320. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  98321. useOctreeForRenderingSelection: boolean;
  98322. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  98323. useOctreeForPicking: boolean;
  98324. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  98325. useOctreeForCollisions: boolean;
  98326. /**
  98327. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  98328. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  98329. */
  98330. get layerMask(): number;
  98331. set layerMask(value: number);
  98332. /**
  98333. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  98334. */
  98335. alwaysSelectAsActiveMesh: boolean;
  98336. /**
  98337. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  98338. */
  98339. doNotSyncBoundingInfo: boolean;
  98340. /**
  98341. * Gets or sets the current action manager
  98342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98343. */
  98344. actionManager: Nullable<AbstractActionManager>;
  98345. private _meshCollisionData;
  98346. /**
  98347. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  98348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98349. */
  98350. ellipsoid: Vector3;
  98351. /**
  98352. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  98353. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98354. */
  98355. ellipsoidOffset: Vector3;
  98356. /**
  98357. * Gets or sets a collision mask used to mask collisions (default is -1).
  98358. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98359. */
  98360. get collisionMask(): number;
  98361. set collisionMask(mask: number);
  98362. /**
  98363. * Gets or sets the current collision group mask (-1 by default).
  98364. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98365. */
  98366. get collisionGroup(): number;
  98367. set collisionGroup(mask: number);
  98368. /**
  98369. * Defines edge width used when edgesRenderer is enabled
  98370. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98371. */
  98372. edgesWidth: number;
  98373. /**
  98374. * Defines edge color used when edgesRenderer is enabled
  98375. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98376. */
  98377. edgesColor: Color4;
  98378. /** @hidden */
  98379. _edgesRenderer: Nullable<IEdgesRenderer>;
  98380. /** @hidden */
  98381. _masterMesh: Nullable<AbstractMesh>;
  98382. /** @hidden */
  98383. _boundingInfo: Nullable<BoundingInfo>;
  98384. /** @hidden */
  98385. _renderId: number;
  98386. /**
  98387. * Gets or sets the list of subMeshes
  98388. * @see http://doc.babylonjs.com/how_to/multi_materials
  98389. */
  98390. subMeshes: SubMesh[];
  98391. /** @hidden */
  98392. _intersectionsInProgress: AbstractMesh[];
  98393. /** @hidden */
  98394. _unIndexed: boolean;
  98395. /** @hidden */
  98396. _lightSources: Light[];
  98397. /** Gets the list of lights affecting that mesh */
  98398. get lightSources(): Light[];
  98399. /** @hidden */
  98400. get _positions(): Nullable<Vector3[]>;
  98401. /** @hidden */
  98402. _waitingData: {
  98403. lods: Nullable<any>;
  98404. actions: Nullable<any>;
  98405. freezeWorldMatrix: Nullable<boolean>;
  98406. };
  98407. /** @hidden */
  98408. _bonesTransformMatrices: Nullable<Float32Array>;
  98409. /** @hidden */
  98410. _transformMatrixTexture: Nullable<RawTexture>;
  98411. /**
  98412. * Gets or sets a skeleton to apply skining transformations
  98413. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98414. */
  98415. set skeleton(value: Nullable<Skeleton>);
  98416. get skeleton(): Nullable<Skeleton>;
  98417. /**
  98418. * An event triggered when the mesh is rebuilt.
  98419. */
  98420. onRebuildObservable: Observable<AbstractMesh>;
  98421. /**
  98422. * Creates a new AbstractMesh
  98423. * @param name defines the name of the mesh
  98424. * @param scene defines the hosting scene
  98425. */
  98426. constructor(name: string, scene?: Nullable<Scene>);
  98427. /**
  98428. * Returns the string "AbstractMesh"
  98429. * @returns "AbstractMesh"
  98430. */
  98431. getClassName(): string;
  98432. /**
  98433. * Gets a string representation of the current mesh
  98434. * @param fullDetails defines a boolean indicating if full details must be included
  98435. * @returns a string representation of the current mesh
  98436. */
  98437. toString(fullDetails?: boolean): string;
  98438. /**
  98439. * @hidden
  98440. */
  98441. protected _getEffectiveParent(): Nullable<Node>;
  98442. /** @hidden */
  98443. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  98444. /** @hidden */
  98445. _rebuild(): void;
  98446. /** @hidden */
  98447. _resyncLightSources(): void;
  98448. /** @hidden */
  98449. _resyncLightSource(light: Light): void;
  98450. /** @hidden */
  98451. _unBindEffect(): void;
  98452. /** @hidden */
  98453. _removeLightSource(light: Light, dispose: boolean): void;
  98454. private _markSubMeshesAsDirty;
  98455. /** @hidden */
  98456. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  98457. /** @hidden */
  98458. _markSubMeshesAsAttributesDirty(): void;
  98459. /** @hidden */
  98460. _markSubMeshesAsMiscDirty(): void;
  98461. /**
  98462. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  98463. */
  98464. get scaling(): Vector3;
  98465. set scaling(newScaling: Vector3);
  98466. /**
  98467. * Returns true if the mesh is blocked. Implemented by child classes
  98468. */
  98469. get isBlocked(): boolean;
  98470. /**
  98471. * Returns the mesh itself by default. Implemented by child classes
  98472. * @param camera defines the camera to use to pick the right LOD level
  98473. * @returns the currentAbstractMesh
  98474. */
  98475. getLOD(camera: Camera): Nullable<AbstractMesh>;
  98476. /**
  98477. * Returns 0 by default. Implemented by child classes
  98478. * @returns an integer
  98479. */
  98480. getTotalVertices(): number;
  98481. /**
  98482. * Returns a positive integer : the total number of indices in this mesh geometry.
  98483. * @returns the numner of indices or zero if the mesh has no geometry.
  98484. */
  98485. getTotalIndices(): number;
  98486. /**
  98487. * Returns null by default. Implemented by child classes
  98488. * @returns null
  98489. */
  98490. getIndices(): Nullable<IndicesArray>;
  98491. /**
  98492. * Returns the array of the requested vertex data kind. Implemented by child classes
  98493. * @param kind defines the vertex data kind to use
  98494. * @returns null
  98495. */
  98496. getVerticesData(kind: string): Nullable<FloatArray>;
  98497. /**
  98498. * Sets the vertex data of the mesh geometry for the requested `kind`.
  98499. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  98500. * Note that a new underlying VertexBuffer object is created each call.
  98501. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  98502. * @param kind defines vertex data kind:
  98503. * * VertexBuffer.PositionKind
  98504. * * VertexBuffer.UVKind
  98505. * * VertexBuffer.UV2Kind
  98506. * * VertexBuffer.UV3Kind
  98507. * * VertexBuffer.UV4Kind
  98508. * * VertexBuffer.UV5Kind
  98509. * * VertexBuffer.UV6Kind
  98510. * * VertexBuffer.ColorKind
  98511. * * VertexBuffer.MatricesIndicesKind
  98512. * * VertexBuffer.MatricesIndicesExtraKind
  98513. * * VertexBuffer.MatricesWeightsKind
  98514. * * VertexBuffer.MatricesWeightsExtraKind
  98515. * @param data defines the data source
  98516. * @param updatable defines if the data must be flagged as updatable (or static)
  98517. * @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
  98518. * @returns the current mesh
  98519. */
  98520. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98521. /**
  98522. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  98523. * If the mesh has no geometry, it is simply returned as it is.
  98524. * @param kind defines vertex data kind:
  98525. * * VertexBuffer.PositionKind
  98526. * * VertexBuffer.UVKind
  98527. * * VertexBuffer.UV2Kind
  98528. * * VertexBuffer.UV3Kind
  98529. * * VertexBuffer.UV4Kind
  98530. * * VertexBuffer.UV5Kind
  98531. * * VertexBuffer.UV6Kind
  98532. * * VertexBuffer.ColorKind
  98533. * * VertexBuffer.MatricesIndicesKind
  98534. * * VertexBuffer.MatricesIndicesExtraKind
  98535. * * VertexBuffer.MatricesWeightsKind
  98536. * * VertexBuffer.MatricesWeightsExtraKind
  98537. * @param data defines the data source
  98538. * @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
  98539. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  98540. * @returns the current mesh
  98541. */
  98542. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98543. /**
  98544. * Sets the mesh indices,
  98545. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  98546. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  98547. * @param totalVertices Defines the total number of vertices
  98548. * @returns the current mesh
  98549. */
  98550. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  98551. /**
  98552. * Gets a boolean indicating if specific vertex data is present
  98553. * @param kind defines the vertex data kind to use
  98554. * @returns true is data kind is present
  98555. */
  98556. isVerticesDataPresent(kind: string): boolean;
  98557. /**
  98558. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  98559. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  98560. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  98561. * @returns a BoundingInfo
  98562. */
  98563. getBoundingInfo(): BoundingInfo;
  98564. /**
  98565. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  98566. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  98567. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  98568. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  98569. * @returns the current mesh
  98570. */
  98571. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  98572. /**
  98573. * Overwrite the current bounding info
  98574. * @param boundingInfo defines the new bounding info
  98575. * @returns the current mesh
  98576. */
  98577. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  98578. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  98579. get useBones(): boolean;
  98580. /** @hidden */
  98581. _preActivate(): void;
  98582. /** @hidden */
  98583. _preActivateForIntermediateRendering(renderId: number): void;
  98584. /** @hidden */
  98585. _activate(renderId: number, intermediateRendering: boolean): boolean;
  98586. /** @hidden */
  98587. _postActivate(): void;
  98588. /** @hidden */
  98589. _freeze(): void;
  98590. /** @hidden */
  98591. _unFreeze(): void;
  98592. /**
  98593. * Gets the current world matrix
  98594. * @returns a Matrix
  98595. */
  98596. getWorldMatrix(): Matrix;
  98597. /** @hidden */
  98598. _getWorldMatrixDeterminant(): number;
  98599. /**
  98600. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  98601. */
  98602. get isAnInstance(): boolean;
  98603. /**
  98604. * Gets a boolean indicating if this mesh has instances
  98605. */
  98606. get hasInstances(): boolean;
  98607. /**
  98608. * Perform relative position change from the point of view of behind the front of the mesh.
  98609. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98610. * Supports definition of mesh facing forward or backward
  98611. * @param amountRight defines the distance on the right axis
  98612. * @param amountUp defines the distance on the up axis
  98613. * @param amountForward defines the distance on the forward axis
  98614. * @returns the current mesh
  98615. */
  98616. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  98617. /**
  98618. * Calculate relative position change from the point of view of behind the front of the mesh.
  98619. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98620. * Supports definition of mesh facing forward or backward
  98621. * @param amountRight defines the distance on the right axis
  98622. * @param amountUp defines the distance on the up axis
  98623. * @param amountForward defines the distance on the forward axis
  98624. * @returns the new displacement vector
  98625. */
  98626. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  98627. /**
  98628. * Perform relative rotation change from the point of view of behind the front of the mesh.
  98629. * Supports definition of mesh facing forward or backward
  98630. * @param flipBack defines the flip
  98631. * @param twirlClockwise defines the twirl
  98632. * @param tiltRight defines the tilt
  98633. * @returns the current mesh
  98634. */
  98635. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  98636. /**
  98637. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  98638. * Supports definition of mesh facing forward or backward.
  98639. * @param flipBack defines the flip
  98640. * @param twirlClockwise defines the twirl
  98641. * @param tiltRight defines the tilt
  98642. * @returns the new rotation vector
  98643. */
  98644. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  98645. /**
  98646. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98647. * This means the mesh underlying bounding box and sphere are recomputed.
  98648. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98649. * @returns the current mesh
  98650. */
  98651. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  98652. /** @hidden */
  98653. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  98654. /** @hidden */
  98655. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  98656. /** @hidden */
  98657. _updateBoundingInfo(): AbstractMesh;
  98658. /** @hidden */
  98659. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  98660. /** @hidden */
  98661. protected _afterComputeWorldMatrix(): void;
  98662. /** @hidden */
  98663. get _effectiveMesh(): AbstractMesh;
  98664. /**
  98665. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98666. * A mesh is in the frustum if its bounding box intersects the frustum
  98667. * @param frustumPlanes defines the frustum to test
  98668. * @returns true if the mesh is in the frustum planes
  98669. */
  98670. isInFrustum(frustumPlanes: Plane[]): boolean;
  98671. /**
  98672. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  98673. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  98674. * @param frustumPlanes defines the frustum to test
  98675. * @returns true if the mesh is completely in the frustum planes
  98676. */
  98677. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98678. /**
  98679. * True if the mesh intersects another mesh or a SolidParticle object
  98680. * @param mesh defines a target mesh or SolidParticle to test
  98681. * @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)
  98682. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  98683. * @returns true if there is an intersection
  98684. */
  98685. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  98686. /**
  98687. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  98688. * @param point defines the point to test
  98689. * @returns true if there is an intersection
  98690. */
  98691. intersectsPoint(point: Vector3): boolean;
  98692. /**
  98693. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  98694. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98695. */
  98696. get checkCollisions(): boolean;
  98697. set checkCollisions(collisionEnabled: boolean);
  98698. /**
  98699. * Gets Collider object used to compute collisions (not physics)
  98700. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98701. */
  98702. get collider(): Nullable<Collider>;
  98703. /**
  98704. * Move the mesh using collision engine
  98705. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98706. * @param displacement defines the requested displacement vector
  98707. * @returns the current mesh
  98708. */
  98709. moveWithCollisions(displacement: Vector3): AbstractMesh;
  98710. private _onCollisionPositionChange;
  98711. /** @hidden */
  98712. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  98713. /** @hidden */
  98714. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  98715. /** @hidden */
  98716. _checkCollision(collider: Collider): AbstractMesh;
  98717. /** @hidden */
  98718. _generatePointsArray(): boolean;
  98719. /**
  98720. * Checks if the passed Ray intersects with the mesh
  98721. * @param ray defines the ray to use
  98722. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  98723. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98724. * @returns the picking info
  98725. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  98726. */
  98727. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  98728. /**
  98729. * Clones the current mesh
  98730. * @param name defines the mesh name
  98731. * @param newParent defines the new mesh parent
  98732. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  98733. * @returns the new mesh
  98734. */
  98735. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  98736. /**
  98737. * Disposes all the submeshes of the current meshnp
  98738. * @returns the current mesh
  98739. */
  98740. releaseSubMeshes(): AbstractMesh;
  98741. /**
  98742. * Releases resources associated with this abstract mesh.
  98743. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98744. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98745. */
  98746. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98747. /**
  98748. * Adds the passed mesh as a child to the current mesh
  98749. * @param mesh defines the child mesh
  98750. * @returns the current mesh
  98751. */
  98752. addChild(mesh: AbstractMesh): AbstractMesh;
  98753. /**
  98754. * Removes the passed mesh from the current mesh children list
  98755. * @param mesh defines the child mesh
  98756. * @returns the current mesh
  98757. */
  98758. removeChild(mesh: AbstractMesh): AbstractMesh;
  98759. /** @hidden */
  98760. private _initFacetData;
  98761. /**
  98762. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  98763. * This method can be called within the render loop.
  98764. * 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
  98765. * @returns the current mesh
  98766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98767. */
  98768. updateFacetData(): AbstractMesh;
  98769. /**
  98770. * Returns the facetLocalNormals array.
  98771. * The normals are expressed in the mesh local spac
  98772. * @returns an array of Vector3
  98773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98774. */
  98775. getFacetLocalNormals(): Vector3[];
  98776. /**
  98777. * Returns the facetLocalPositions array.
  98778. * The facet positions are expressed in the mesh local space
  98779. * @returns an array of Vector3
  98780. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98781. */
  98782. getFacetLocalPositions(): Vector3[];
  98783. /**
  98784. * Returns the facetLocalPartioning array
  98785. * @returns an array of array of numbers
  98786. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98787. */
  98788. getFacetLocalPartitioning(): number[][];
  98789. /**
  98790. * Returns the i-th facet position in the world system.
  98791. * This method allocates a new Vector3 per call
  98792. * @param i defines the facet index
  98793. * @returns a new Vector3
  98794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98795. */
  98796. getFacetPosition(i: number): Vector3;
  98797. /**
  98798. * Sets the reference Vector3 with the i-th facet position in the world system
  98799. * @param i defines the facet index
  98800. * @param ref defines the target vector
  98801. * @returns the current mesh
  98802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98803. */
  98804. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  98805. /**
  98806. * Returns the i-th facet normal in the world system.
  98807. * This method allocates a new Vector3 per call
  98808. * @param i defines the facet index
  98809. * @returns a new Vector3
  98810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98811. */
  98812. getFacetNormal(i: number): Vector3;
  98813. /**
  98814. * Sets the reference Vector3 with the i-th facet normal in the world system
  98815. * @param i defines the facet index
  98816. * @param ref defines the target vector
  98817. * @returns the current mesh
  98818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98819. */
  98820. getFacetNormalToRef(i: number, ref: Vector3): this;
  98821. /**
  98822. * 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)
  98823. * @param x defines x coordinate
  98824. * @param y defines y coordinate
  98825. * @param z defines z coordinate
  98826. * @returns the array of facet indexes
  98827. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98828. */
  98829. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  98830. /**
  98831. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  98832. * @param projected sets as the (x,y,z) world projection on the facet
  98833. * @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
  98834. * @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
  98835. * @param x defines x coordinate
  98836. * @param y defines y coordinate
  98837. * @param z defines z coordinate
  98838. * @returns the face index if found (or null instead)
  98839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98840. */
  98841. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98842. /**
  98843. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  98844. * @param projected sets as the (x,y,z) local projection on the facet
  98845. * @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
  98846. * @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
  98847. * @param x defines x coordinate
  98848. * @param y defines y coordinate
  98849. * @param z defines z coordinate
  98850. * @returns the face index if found (or null instead)
  98851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98852. */
  98853. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98854. /**
  98855. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  98856. * @returns the parameters
  98857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98858. */
  98859. getFacetDataParameters(): any;
  98860. /**
  98861. * Disables the feature FacetData and frees the related memory
  98862. * @returns the current mesh
  98863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98864. */
  98865. disableFacetData(): AbstractMesh;
  98866. /**
  98867. * Updates the AbstractMesh indices array
  98868. * @param indices defines the data source
  98869. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98870. * @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)
  98871. * @returns the current mesh
  98872. */
  98873. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98874. /**
  98875. * Creates new normals data for the mesh
  98876. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  98877. * @returns the current mesh
  98878. */
  98879. createNormals(updatable: boolean): AbstractMesh;
  98880. /**
  98881. * Align the mesh with a normal
  98882. * @param normal defines the normal to use
  98883. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  98884. * @returns the current mesh
  98885. */
  98886. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  98887. /** @hidden */
  98888. _checkOcclusionQuery(): boolean;
  98889. /**
  98890. * Disables the mesh edge rendering mode
  98891. * @returns the currentAbstractMesh
  98892. */
  98893. disableEdgesRendering(): AbstractMesh;
  98894. /**
  98895. * Enables the edge rendering mode on the mesh.
  98896. * This mode makes the mesh edges visible
  98897. * @param epsilon defines the maximal distance between two angles to detect a face
  98898. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98899. * @returns the currentAbstractMesh
  98900. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98901. */
  98902. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  98903. }
  98904. }
  98905. declare module BABYLON {
  98906. /**
  98907. * Interface used to define ActionEvent
  98908. */
  98909. export interface IActionEvent {
  98910. /** The mesh or sprite that triggered the action */
  98911. source: any;
  98912. /** The X mouse cursor position at the time of the event */
  98913. pointerX: number;
  98914. /** The Y mouse cursor position at the time of the event */
  98915. pointerY: number;
  98916. /** The mesh that is currently pointed at (can be null) */
  98917. meshUnderPointer: Nullable<AbstractMesh>;
  98918. /** the original (browser) event that triggered the ActionEvent */
  98919. sourceEvent?: any;
  98920. /** additional data for the event */
  98921. additionalData?: any;
  98922. }
  98923. /**
  98924. * ActionEvent is the event being sent when an action is triggered.
  98925. */
  98926. export class ActionEvent implements IActionEvent {
  98927. /** The mesh or sprite that triggered the action */
  98928. source: any;
  98929. /** The X mouse cursor position at the time of the event */
  98930. pointerX: number;
  98931. /** The Y mouse cursor position at the time of the event */
  98932. pointerY: number;
  98933. /** The mesh that is currently pointed at (can be null) */
  98934. meshUnderPointer: Nullable<AbstractMesh>;
  98935. /** the original (browser) event that triggered the ActionEvent */
  98936. sourceEvent?: any;
  98937. /** additional data for the event */
  98938. additionalData?: any;
  98939. /**
  98940. * Creates a new ActionEvent
  98941. * @param source The mesh or sprite that triggered the action
  98942. * @param pointerX The X mouse cursor position at the time of the event
  98943. * @param pointerY The Y mouse cursor position at the time of the event
  98944. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  98945. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  98946. * @param additionalData additional data for the event
  98947. */
  98948. constructor(
  98949. /** The mesh or sprite that triggered the action */
  98950. source: any,
  98951. /** The X mouse cursor position at the time of the event */
  98952. pointerX: number,
  98953. /** The Y mouse cursor position at the time of the event */
  98954. pointerY: number,
  98955. /** The mesh that is currently pointed at (can be null) */
  98956. meshUnderPointer: Nullable<AbstractMesh>,
  98957. /** the original (browser) event that triggered the ActionEvent */
  98958. sourceEvent?: any,
  98959. /** additional data for the event */
  98960. additionalData?: any);
  98961. /**
  98962. * Helper function to auto-create an ActionEvent from a source mesh.
  98963. * @param source The source mesh that triggered the event
  98964. * @param evt The original (browser) event
  98965. * @param additionalData additional data for the event
  98966. * @returns the new ActionEvent
  98967. */
  98968. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  98969. /**
  98970. * Helper function to auto-create an ActionEvent from a source sprite
  98971. * @param source The source sprite that triggered the event
  98972. * @param scene Scene associated with the sprite
  98973. * @param evt The original (browser) event
  98974. * @param additionalData additional data for the event
  98975. * @returns the new ActionEvent
  98976. */
  98977. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  98978. /**
  98979. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  98980. * @param scene the scene where the event occurred
  98981. * @param evt The original (browser) event
  98982. * @returns the new ActionEvent
  98983. */
  98984. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  98985. /**
  98986. * Helper function to auto-create an ActionEvent from a primitive
  98987. * @param prim defines the target primitive
  98988. * @param pointerPos defines the pointer position
  98989. * @param evt The original (browser) event
  98990. * @param additionalData additional data for the event
  98991. * @returns the new ActionEvent
  98992. */
  98993. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  98994. }
  98995. }
  98996. declare module BABYLON {
  98997. /**
  98998. * Abstract class used to decouple action Manager from scene and meshes.
  98999. * Do not instantiate.
  99000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99001. */
  99002. export abstract class AbstractActionManager implements IDisposable {
  99003. /** Gets the list of active triggers */
  99004. static Triggers: {
  99005. [key: string]: number;
  99006. };
  99007. /** Gets the cursor to use when hovering items */
  99008. hoverCursor: string;
  99009. /** Gets the list of actions */
  99010. actions: IAction[];
  99011. /**
  99012. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  99013. */
  99014. isRecursive: boolean;
  99015. /**
  99016. * Releases all associated resources
  99017. */
  99018. abstract dispose(): void;
  99019. /**
  99020. * Does this action manager has pointer triggers
  99021. */
  99022. abstract get hasPointerTriggers(): boolean;
  99023. /**
  99024. * Does this action manager has pick triggers
  99025. */
  99026. abstract get hasPickTriggers(): boolean;
  99027. /**
  99028. * Process a specific trigger
  99029. * @param trigger defines the trigger to process
  99030. * @param evt defines the event details to be processed
  99031. */
  99032. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  99033. /**
  99034. * Does this action manager handles actions of any of the given triggers
  99035. * @param triggers defines the triggers to be tested
  99036. * @return a boolean indicating whether one (or more) of the triggers is handled
  99037. */
  99038. abstract hasSpecificTriggers(triggers: number[]): boolean;
  99039. /**
  99040. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  99041. * speed.
  99042. * @param triggerA defines the trigger to be tested
  99043. * @param triggerB defines the trigger to be tested
  99044. * @return a boolean indicating whether one (or more) of the triggers is handled
  99045. */
  99046. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  99047. /**
  99048. * Does this action manager handles actions of a given trigger
  99049. * @param trigger defines the trigger to be tested
  99050. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  99051. * @return whether the trigger is handled
  99052. */
  99053. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  99054. /**
  99055. * Serialize this manager to a JSON object
  99056. * @param name defines the property name to store this manager
  99057. * @returns a JSON representation of this manager
  99058. */
  99059. abstract serialize(name: string): any;
  99060. /**
  99061. * Registers an action to this action manager
  99062. * @param action defines the action to be registered
  99063. * @return the action amended (prepared) after registration
  99064. */
  99065. abstract registerAction(action: IAction): Nullable<IAction>;
  99066. /**
  99067. * Unregisters an action to this action manager
  99068. * @param action defines the action to be unregistered
  99069. * @return a boolean indicating whether the action has been unregistered
  99070. */
  99071. abstract unregisterAction(action: IAction): Boolean;
  99072. /**
  99073. * Does exist one action manager with at least one trigger
  99074. **/
  99075. static get HasTriggers(): boolean;
  99076. /**
  99077. * Does exist one action manager with at least one pick trigger
  99078. **/
  99079. static get HasPickTriggers(): boolean;
  99080. /**
  99081. * Does exist one action manager that handles actions of a given trigger
  99082. * @param trigger defines the trigger to be tested
  99083. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  99084. **/
  99085. static HasSpecificTrigger(trigger: number): boolean;
  99086. }
  99087. }
  99088. declare module BABYLON {
  99089. /**
  99090. * Defines how a node can be built from a string name.
  99091. */
  99092. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  99093. /**
  99094. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  99095. */
  99096. export class Node implements IBehaviorAware<Node> {
  99097. /** @hidden */
  99098. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  99099. private static _NodeConstructors;
  99100. /**
  99101. * Add a new node constructor
  99102. * @param type defines the type name of the node to construct
  99103. * @param constructorFunc defines the constructor function
  99104. */
  99105. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  99106. /**
  99107. * Returns a node constructor based on type name
  99108. * @param type defines the type name
  99109. * @param name defines the new node name
  99110. * @param scene defines the hosting scene
  99111. * @param options defines optional options to transmit to constructors
  99112. * @returns the new constructor or null
  99113. */
  99114. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  99115. /**
  99116. * Gets or sets the name of the node
  99117. */
  99118. name: string;
  99119. /**
  99120. * Gets or sets the id of the node
  99121. */
  99122. id: string;
  99123. /**
  99124. * Gets or sets the unique id of the node
  99125. */
  99126. uniqueId: number;
  99127. /**
  99128. * Gets or sets a string used to store user defined state for the node
  99129. */
  99130. state: string;
  99131. /**
  99132. * Gets or sets an object used to store user defined information for the node
  99133. */
  99134. metadata: any;
  99135. /**
  99136. * For internal use only. Please do not use.
  99137. */
  99138. reservedDataStore: any;
  99139. /**
  99140. * List of inspectable custom properties (used by the Inspector)
  99141. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99142. */
  99143. inspectableCustomProperties: IInspectable[];
  99144. private _doNotSerialize;
  99145. /**
  99146. * Gets or sets a boolean used to define if the node must be serialized
  99147. */
  99148. get doNotSerialize(): boolean;
  99149. set doNotSerialize(value: boolean);
  99150. /** @hidden */
  99151. _isDisposed: boolean;
  99152. /**
  99153. * Gets a list of Animations associated with the node
  99154. */
  99155. animations: Animation[];
  99156. protected _ranges: {
  99157. [name: string]: Nullable<AnimationRange>;
  99158. };
  99159. /**
  99160. * Callback raised when the node is ready to be used
  99161. */
  99162. onReady: Nullable<(node: Node) => void>;
  99163. private _isEnabled;
  99164. private _isParentEnabled;
  99165. private _isReady;
  99166. /** @hidden */
  99167. _currentRenderId: number;
  99168. private _parentUpdateId;
  99169. /** @hidden */
  99170. _childUpdateId: number;
  99171. /** @hidden */
  99172. _waitingParentId: Nullable<string>;
  99173. /** @hidden */
  99174. _scene: Scene;
  99175. /** @hidden */
  99176. _cache: any;
  99177. private _parentNode;
  99178. private _children;
  99179. /** @hidden */
  99180. _worldMatrix: Matrix;
  99181. /** @hidden */
  99182. _worldMatrixDeterminant: number;
  99183. /** @hidden */
  99184. _worldMatrixDeterminantIsDirty: boolean;
  99185. /** @hidden */
  99186. private _sceneRootNodesIndex;
  99187. /**
  99188. * Gets a boolean indicating if the node has been disposed
  99189. * @returns true if the node was disposed
  99190. */
  99191. isDisposed(): boolean;
  99192. /**
  99193. * Gets or sets the parent of the node (without keeping the current position in the scene)
  99194. * @see https://doc.babylonjs.com/how_to/parenting
  99195. */
  99196. set parent(parent: Nullable<Node>);
  99197. get parent(): Nullable<Node>;
  99198. /** @hidden */
  99199. _addToSceneRootNodes(): void;
  99200. /** @hidden */
  99201. _removeFromSceneRootNodes(): void;
  99202. private _animationPropertiesOverride;
  99203. /**
  99204. * Gets or sets the animation properties override
  99205. */
  99206. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99207. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99208. /**
  99209. * Gets a string idenfifying the name of the class
  99210. * @returns "Node" string
  99211. */
  99212. getClassName(): string;
  99213. /** @hidden */
  99214. readonly _isNode: boolean;
  99215. /**
  99216. * An event triggered when the mesh is disposed
  99217. */
  99218. onDisposeObservable: Observable<Node>;
  99219. private _onDisposeObserver;
  99220. /**
  99221. * Sets a callback that will be raised when the node will be disposed
  99222. */
  99223. set onDispose(callback: () => void);
  99224. /**
  99225. * Creates a new Node
  99226. * @param name the name and id to be given to this node
  99227. * @param scene the scene this node will be added to
  99228. */
  99229. constructor(name: string, scene?: Nullable<Scene>);
  99230. /**
  99231. * Gets the scene of the node
  99232. * @returns a scene
  99233. */
  99234. getScene(): Scene;
  99235. /**
  99236. * Gets the engine of the node
  99237. * @returns a Engine
  99238. */
  99239. getEngine(): Engine;
  99240. private _behaviors;
  99241. /**
  99242. * Attach a behavior to the node
  99243. * @see http://doc.babylonjs.com/features/behaviour
  99244. * @param behavior defines the behavior to attach
  99245. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  99246. * @returns the current Node
  99247. */
  99248. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  99249. /**
  99250. * Remove an attached behavior
  99251. * @see http://doc.babylonjs.com/features/behaviour
  99252. * @param behavior defines the behavior to attach
  99253. * @returns the current Node
  99254. */
  99255. removeBehavior(behavior: Behavior<Node>): Node;
  99256. /**
  99257. * Gets the list of attached behaviors
  99258. * @see http://doc.babylonjs.com/features/behaviour
  99259. */
  99260. get behaviors(): Behavior<Node>[];
  99261. /**
  99262. * Gets an attached behavior by name
  99263. * @param name defines the name of the behavior to look for
  99264. * @see http://doc.babylonjs.com/features/behaviour
  99265. * @returns null if behavior was not found else the requested behavior
  99266. */
  99267. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  99268. /**
  99269. * Returns the latest update of the World matrix
  99270. * @returns a Matrix
  99271. */
  99272. getWorldMatrix(): Matrix;
  99273. /** @hidden */
  99274. _getWorldMatrixDeterminant(): number;
  99275. /**
  99276. * Returns directly the latest state of the mesh World matrix.
  99277. * A Matrix is returned.
  99278. */
  99279. get worldMatrixFromCache(): Matrix;
  99280. /** @hidden */
  99281. _initCache(): void;
  99282. /** @hidden */
  99283. updateCache(force?: boolean): void;
  99284. /** @hidden */
  99285. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  99286. /** @hidden */
  99287. _updateCache(ignoreParentClass?: boolean): void;
  99288. /** @hidden */
  99289. _isSynchronized(): boolean;
  99290. /** @hidden */
  99291. _markSyncedWithParent(): void;
  99292. /** @hidden */
  99293. isSynchronizedWithParent(): boolean;
  99294. /** @hidden */
  99295. isSynchronized(): boolean;
  99296. /**
  99297. * Is this node ready to be used/rendered
  99298. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99299. * @return true if the node is ready
  99300. */
  99301. isReady(completeCheck?: boolean): boolean;
  99302. /**
  99303. * Is this node enabled?
  99304. * 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
  99305. * @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
  99306. * @return whether this node (and its parent) is enabled
  99307. */
  99308. isEnabled(checkAncestors?: boolean): boolean;
  99309. /** @hidden */
  99310. protected _syncParentEnabledState(): void;
  99311. /**
  99312. * Set the enabled state of this node
  99313. * @param value defines the new enabled state
  99314. */
  99315. setEnabled(value: boolean): void;
  99316. /**
  99317. * Is this node a descendant of the given node?
  99318. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  99319. * @param ancestor defines the parent node to inspect
  99320. * @returns a boolean indicating if this node is a descendant of the given node
  99321. */
  99322. isDescendantOf(ancestor: Node): boolean;
  99323. /** @hidden */
  99324. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  99325. /**
  99326. * Will return all nodes that have this node as ascendant
  99327. * @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
  99328. * @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
  99329. * @return all children nodes of all types
  99330. */
  99331. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  99332. /**
  99333. * Get all child-meshes of this node
  99334. * @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)
  99335. * @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
  99336. * @returns an array of AbstractMesh
  99337. */
  99338. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  99339. /**
  99340. * Get all direct children of this node
  99341. * @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
  99342. * @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)
  99343. * @returns an array of Node
  99344. */
  99345. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  99346. /** @hidden */
  99347. _setReady(state: boolean): void;
  99348. /**
  99349. * Get an animation by name
  99350. * @param name defines the name of the animation to look for
  99351. * @returns null if not found else the requested animation
  99352. */
  99353. getAnimationByName(name: string): Nullable<Animation>;
  99354. /**
  99355. * Creates an animation range for this node
  99356. * @param name defines the name of the range
  99357. * @param from defines the starting key
  99358. * @param to defines the end key
  99359. */
  99360. createAnimationRange(name: string, from: number, to: number): void;
  99361. /**
  99362. * Delete a specific animation range
  99363. * @param name defines the name of the range to delete
  99364. * @param deleteFrames defines if animation frames from the range must be deleted as well
  99365. */
  99366. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  99367. /**
  99368. * Get an animation range by name
  99369. * @param name defines the name of the animation range to look for
  99370. * @returns null if not found else the requested animation range
  99371. */
  99372. getAnimationRange(name: string): Nullable<AnimationRange>;
  99373. /**
  99374. * Gets the list of all animation ranges defined on this node
  99375. * @returns an array
  99376. */
  99377. getAnimationRanges(): Nullable<AnimationRange>[];
  99378. /**
  99379. * Will start the animation sequence
  99380. * @param name defines the range frames for animation sequence
  99381. * @param loop defines if the animation should loop (false by default)
  99382. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  99383. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  99384. * @returns the object created for this animation. If range does not exist, it will return null
  99385. */
  99386. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  99387. /**
  99388. * Serialize animation ranges into a JSON compatible object
  99389. * @returns serialization object
  99390. */
  99391. serializeAnimationRanges(): any;
  99392. /**
  99393. * Computes the world matrix of the node
  99394. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99395. * @returns the world matrix
  99396. */
  99397. computeWorldMatrix(force?: boolean): Matrix;
  99398. /**
  99399. * Releases resources associated with this node.
  99400. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99401. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99402. */
  99403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99404. /**
  99405. * Parse animation range data from a serialization object and store them into a given node
  99406. * @param node defines where to store the animation ranges
  99407. * @param parsedNode defines the serialization object to read data from
  99408. * @param scene defines the hosting scene
  99409. */
  99410. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  99411. /**
  99412. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  99413. * @param includeDescendants Include bounding info from descendants as well (true by default)
  99414. * @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
  99415. * @returns the new bounding vectors
  99416. */
  99417. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  99418. min: Vector3;
  99419. max: Vector3;
  99420. };
  99421. }
  99422. }
  99423. declare module BABYLON {
  99424. /**
  99425. * @hidden
  99426. */
  99427. export class _IAnimationState {
  99428. key: number;
  99429. repeatCount: number;
  99430. workValue?: any;
  99431. loopMode?: number;
  99432. offsetValue?: any;
  99433. highLimitValue?: any;
  99434. }
  99435. /**
  99436. * Class used to store any kind of animation
  99437. */
  99438. export class Animation {
  99439. /**Name of the animation */
  99440. name: string;
  99441. /**Property to animate */
  99442. targetProperty: string;
  99443. /**The frames per second of the animation */
  99444. framePerSecond: number;
  99445. /**The data type of the animation */
  99446. dataType: number;
  99447. /**The loop mode of the animation */
  99448. loopMode?: number | undefined;
  99449. /**Specifies if blending should be enabled */
  99450. enableBlending?: boolean | undefined;
  99451. /**
  99452. * Use matrix interpolation instead of using direct key value when animating matrices
  99453. */
  99454. static AllowMatricesInterpolation: boolean;
  99455. /**
  99456. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  99457. */
  99458. static AllowMatrixDecomposeForInterpolation: boolean;
  99459. /**
  99460. * Stores the key frames of the animation
  99461. */
  99462. private _keys;
  99463. /**
  99464. * Stores the easing function of the animation
  99465. */
  99466. private _easingFunction;
  99467. /**
  99468. * @hidden Internal use only
  99469. */
  99470. _runtimeAnimations: RuntimeAnimation[];
  99471. /**
  99472. * The set of event that will be linked to this animation
  99473. */
  99474. private _events;
  99475. /**
  99476. * Stores an array of target property paths
  99477. */
  99478. targetPropertyPath: string[];
  99479. /**
  99480. * Stores the blending speed of the animation
  99481. */
  99482. blendingSpeed: number;
  99483. /**
  99484. * Stores the animation ranges for the animation
  99485. */
  99486. private _ranges;
  99487. /**
  99488. * @hidden Internal use
  99489. */
  99490. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  99491. /**
  99492. * Sets up an animation
  99493. * @param property The property to animate
  99494. * @param animationType The animation type to apply
  99495. * @param framePerSecond The frames per second of the animation
  99496. * @param easingFunction The easing function used in the animation
  99497. * @returns The created animation
  99498. */
  99499. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  99500. /**
  99501. * Create and start an animation on a node
  99502. * @param name defines the name of the global animation that will be run on all nodes
  99503. * @param node defines the root node where the animation will take place
  99504. * @param targetProperty defines property to animate
  99505. * @param framePerSecond defines the number of frame per second yo use
  99506. * @param totalFrame defines the number of frames in total
  99507. * @param from defines the initial value
  99508. * @param to defines the final value
  99509. * @param loopMode defines which loop mode you want to use (off by default)
  99510. * @param easingFunction defines the easing function to use (linear by default)
  99511. * @param onAnimationEnd defines the callback to call when animation end
  99512. * @returns the animatable created for this animation
  99513. */
  99514. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99515. /**
  99516. * Create and start an animation on a node and its descendants
  99517. * @param name defines the name of the global animation that will be run on all nodes
  99518. * @param node defines the root node where the animation will take place
  99519. * @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
  99520. * @param targetProperty defines property to animate
  99521. * @param framePerSecond defines the number of frame per second to use
  99522. * @param totalFrame defines the number of frames in total
  99523. * @param from defines the initial value
  99524. * @param to defines the final value
  99525. * @param loopMode defines which loop mode you want to use (off by default)
  99526. * @param easingFunction defines the easing function to use (linear by default)
  99527. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  99528. * @returns the list of animatables created for all nodes
  99529. * @example https://www.babylonjs-playground.com/#MH0VLI
  99530. */
  99531. 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[]>;
  99532. /**
  99533. * Creates a new animation, merges it with the existing animations and starts it
  99534. * @param name Name of the animation
  99535. * @param node Node which contains the scene that begins the animations
  99536. * @param targetProperty Specifies which property to animate
  99537. * @param framePerSecond The frames per second of the animation
  99538. * @param totalFrame The total number of frames
  99539. * @param from The frame at the beginning of the animation
  99540. * @param to The frame at the end of the animation
  99541. * @param loopMode Specifies the loop mode of the animation
  99542. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  99543. * @param onAnimationEnd Callback to run once the animation is complete
  99544. * @returns Nullable animation
  99545. */
  99546. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99547. /**
  99548. * Transition property of an host to the target Value
  99549. * @param property The property to transition
  99550. * @param targetValue The target Value of the property
  99551. * @param host The object where the property to animate belongs
  99552. * @param scene Scene used to run the animation
  99553. * @param frameRate Framerate (in frame/s) to use
  99554. * @param transition The transition type we want to use
  99555. * @param duration The duration of the animation, in milliseconds
  99556. * @param onAnimationEnd Callback trigger at the end of the animation
  99557. * @returns Nullable animation
  99558. */
  99559. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  99560. /**
  99561. * Return the array of runtime animations currently using this animation
  99562. */
  99563. get runtimeAnimations(): RuntimeAnimation[];
  99564. /**
  99565. * Specifies if any of the runtime animations are currently running
  99566. */
  99567. get hasRunningRuntimeAnimations(): boolean;
  99568. /**
  99569. * Initializes the animation
  99570. * @param name Name of the animation
  99571. * @param targetProperty Property to animate
  99572. * @param framePerSecond The frames per second of the animation
  99573. * @param dataType The data type of the animation
  99574. * @param loopMode The loop mode of the animation
  99575. * @param enableBlending Specifies if blending should be enabled
  99576. */
  99577. constructor(
  99578. /**Name of the animation */
  99579. name: string,
  99580. /**Property to animate */
  99581. targetProperty: string,
  99582. /**The frames per second of the animation */
  99583. framePerSecond: number,
  99584. /**The data type of the animation */
  99585. dataType: number,
  99586. /**The loop mode of the animation */
  99587. loopMode?: number | undefined,
  99588. /**Specifies if blending should be enabled */
  99589. enableBlending?: boolean | undefined);
  99590. /**
  99591. * Converts the animation to a string
  99592. * @param fullDetails support for multiple levels of logging within scene loading
  99593. * @returns String form of the animation
  99594. */
  99595. toString(fullDetails?: boolean): string;
  99596. /**
  99597. * Add an event to this animation
  99598. * @param event Event to add
  99599. */
  99600. addEvent(event: AnimationEvent): void;
  99601. /**
  99602. * Remove all events found at the given frame
  99603. * @param frame The frame to remove events from
  99604. */
  99605. removeEvents(frame: number): void;
  99606. /**
  99607. * Retrieves all the events from the animation
  99608. * @returns Events from the animation
  99609. */
  99610. getEvents(): AnimationEvent[];
  99611. /**
  99612. * Creates an animation range
  99613. * @param name Name of the animation range
  99614. * @param from Starting frame of the animation range
  99615. * @param to Ending frame of the animation
  99616. */
  99617. createRange(name: string, from: number, to: number): void;
  99618. /**
  99619. * Deletes an animation range by name
  99620. * @param name Name of the animation range to delete
  99621. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  99622. */
  99623. deleteRange(name: string, deleteFrames?: boolean): void;
  99624. /**
  99625. * Gets the animation range by name, or null if not defined
  99626. * @param name Name of the animation range
  99627. * @returns Nullable animation range
  99628. */
  99629. getRange(name: string): Nullable<AnimationRange>;
  99630. /**
  99631. * Gets the key frames from the animation
  99632. * @returns The key frames of the animation
  99633. */
  99634. getKeys(): Array<IAnimationKey>;
  99635. /**
  99636. * Gets the highest frame rate of the animation
  99637. * @returns Highest frame rate of the animation
  99638. */
  99639. getHighestFrame(): number;
  99640. /**
  99641. * Gets the easing function of the animation
  99642. * @returns Easing function of the animation
  99643. */
  99644. getEasingFunction(): IEasingFunction;
  99645. /**
  99646. * Sets the easing function of the animation
  99647. * @param easingFunction A custom mathematical formula for animation
  99648. */
  99649. setEasingFunction(easingFunction: EasingFunction): void;
  99650. /**
  99651. * Interpolates a scalar linearly
  99652. * @param startValue Start value of the animation curve
  99653. * @param endValue End value of the animation curve
  99654. * @param gradient Scalar amount to interpolate
  99655. * @returns Interpolated scalar value
  99656. */
  99657. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  99658. /**
  99659. * Interpolates a scalar cubically
  99660. * @param startValue Start value of the animation curve
  99661. * @param outTangent End tangent of the animation
  99662. * @param endValue End value of the animation curve
  99663. * @param inTangent Start tangent of the animation curve
  99664. * @param gradient Scalar amount to interpolate
  99665. * @returns Interpolated scalar value
  99666. */
  99667. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  99668. /**
  99669. * Interpolates a quaternion using a spherical linear interpolation
  99670. * @param startValue Start value of the animation curve
  99671. * @param endValue End value of the animation curve
  99672. * @param gradient Scalar amount to interpolate
  99673. * @returns Interpolated quaternion value
  99674. */
  99675. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  99676. /**
  99677. * Interpolates a quaternion cubically
  99678. * @param startValue Start value of the animation curve
  99679. * @param outTangent End tangent of the animation curve
  99680. * @param endValue End value of the animation curve
  99681. * @param inTangent Start tangent of the animation curve
  99682. * @param gradient Scalar amount to interpolate
  99683. * @returns Interpolated quaternion value
  99684. */
  99685. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  99686. /**
  99687. * Interpolates a Vector3 linearl
  99688. * @param startValue Start value of the animation curve
  99689. * @param endValue End value of the animation curve
  99690. * @param gradient Scalar amount to interpolate
  99691. * @returns Interpolated scalar value
  99692. */
  99693. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  99694. /**
  99695. * Interpolates a Vector3 cubically
  99696. * @param startValue Start value of the animation curve
  99697. * @param outTangent End tangent of the animation
  99698. * @param endValue End value of the animation curve
  99699. * @param inTangent Start tangent of the animation curve
  99700. * @param gradient Scalar amount to interpolate
  99701. * @returns InterpolatedVector3 value
  99702. */
  99703. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  99704. /**
  99705. * Interpolates a Vector2 linearly
  99706. * @param startValue Start value of the animation curve
  99707. * @param endValue End value of the animation curve
  99708. * @param gradient Scalar amount to interpolate
  99709. * @returns Interpolated Vector2 value
  99710. */
  99711. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  99712. /**
  99713. * Interpolates a Vector2 cubically
  99714. * @param startValue Start value of the animation curve
  99715. * @param outTangent End tangent of the animation
  99716. * @param endValue End value of the animation curve
  99717. * @param inTangent Start tangent of the animation curve
  99718. * @param gradient Scalar amount to interpolate
  99719. * @returns Interpolated Vector2 value
  99720. */
  99721. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  99722. /**
  99723. * Interpolates a size linearly
  99724. * @param startValue Start value of the animation curve
  99725. * @param endValue End value of the animation curve
  99726. * @param gradient Scalar amount to interpolate
  99727. * @returns Interpolated Size value
  99728. */
  99729. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  99730. /**
  99731. * Interpolates a Color3 linearly
  99732. * @param startValue Start value of the animation curve
  99733. * @param endValue End value of the animation curve
  99734. * @param gradient Scalar amount to interpolate
  99735. * @returns Interpolated Color3 value
  99736. */
  99737. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  99738. /**
  99739. * Interpolates a Color4 linearly
  99740. * @param startValue Start value of the animation curve
  99741. * @param endValue End value of the animation curve
  99742. * @param gradient Scalar amount to interpolate
  99743. * @returns Interpolated Color3 value
  99744. */
  99745. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  99746. /**
  99747. * @hidden Internal use only
  99748. */
  99749. _getKeyValue(value: any): any;
  99750. /**
  99751. * @hidden Internal use only
  99752. */
  99753. _interpolate(currentFrame: number, state: _IAnimationState): any;
  99754. /**
  99755. * Defines the function to use to interpolate matrices
  99756. * @param startValue defines the start matrix
  99757. * @param endValue defines the end matrix
  99758. * @param gradient defines the gradient between both matrices
  99759. * @param result defines an optional target matrix where to store the interpolation
  99760. * @returns the interpolated matrix
  99761. */
  99762. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  99763. /**
  99764. * Makes a copy of the animation
  99765. * @returns Cloned animation
  99766. */
  99767. clone(): Animation;
  99768. /**
  99769. * Sets the key frames of the animation
  99770. * @param values The animation key frames to set
  99771. */
  99772. setKeys(values: Array<IAnimationKey>): void;
  99773. /**
  99774. * Serializes the animation to an object
  99775. * @returns Serialized object
  99776. */
  99777. serialize(): any;
  99778. /**
  99779. * Float animation type
  99780. */
  99781. static readonly ANIMATIONTYPE_FLOAT: number;
  99782. /**
  99783. * Vector3 animation type
  99784. */
  99785. static readonly ANIMATIONTYPE_VECTOR3: number;
  99786. /**
  99787. * Quaternion animation type
  99788. */
  99789. static readonly ANIMATIONTYPE_QUATERNION: number;
  99790. /**
  99791. * Matrix animation type
  99792. */
  99793. static readonly ANIMATIONTYPE_MATRIX: number;
  99794. /**
  99795. * Color3 animation type
  99796. */
  99797. static readonly ANIMATIONTYPE_COLOR3: number;
  99798. /**
  99799. * Color3 animation type
  99800. */
  99801. static readonly ANIMATIONTYPE_COLOR4: number;
  99802. /**
  99803. * Vector2 animation type
  99804. */
  99805. static readonly ANIMATIONTYPE_VECTOR2: number;
  99806. /**
  99807. * Size animation type
  99808. */
  99809. static readonly ANIMATIONTYPE_SIZE: number;
  99810. /**
  99811. * Relative Loop Mode
  99812. */
  99813. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  99814. /**
  99815. * Cycle Loop Mode
  99816. */
  99817. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  99818. /**
  99819. * Constant Loop Mode
  99820. */
  99821. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  99822. /** @hidden */
  99823. static _UniversalLerp(left: any, right: any, amount: number): any;
  99824. /**
  99825. * Parses an animation object and creates an animation
  99826. * @param parsedAnimation Parsed animation object
  99827. * @returns Animation object
  99828. */
  99829. static Parse(parsedAnimation: any): Animation;
  99830. /**
  99831. * Appends the serialized animations from the source animations
  99832. * @param source Source containing the animations
  99833. * @param destination Target to store the animations
  99834. */
  99835. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99836. }
  99837. }
  99838. declare module BABYLON {
  99839. /**
  99840. * Interface containing an array of animations
  99841. */
  99842. export interface IAnimatable {
  99843. /**
  99844. * Array of animations
  99845. */
  99846. animations: Nullable<Array<Animation>>;
  99847. }
  99848. }
  99849. declare module BABYLON {
  99850. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  99851. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99852. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99853. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99854. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99855. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99856. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99857. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99858. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99859. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99860. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99861. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99862. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99863. /**
  99864. * Decorator used to define property that can be serialized as reference to a camera
  99865. * @param sourceName defines the name of the property to decorate
  99866. */
  99867. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99868. /**
  99869. * Class used to help serialization objects
  99870. */
  99871. export class SerializationHelper {
  99872. /** @hidden */
  99873. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  99874. /** @hidden */
  99875. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  99876. /** @hidden */
  99877. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  99878. /** @hidden */
  99879. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  99880. /**
  99881. * Appends the serialized animations from the source animations
  99882. * @param source Source containing the animations
  99883. * @param destination Target to store the animations
  99884. */
  99885. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99886. /**
  99887. * Static function used to serialized a specific entity
  99888. * @param entity defines the entity to serialize
  99889. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  99890. * @returns a JSON compatible object representing the serialization of the entity
  99891. */
  99892. static Serialize<T>(entity: T, serializationObject?: any): any;
  99893. /**
  99894. * Creates a new entity from a serialization data object
  99895. * @param creationFunction defines a function used to instanciated the new entity
  99896. * @param source defines the source serialization data
  99897. * @param scene defines the hosting scene
  99898. * @param rootUrl defines the root url for resources
  99899. * @returns a new entity
  99900. */
  99901. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  99902. /**
  99903. * Clones an object
  99904. * @param creationFunction defines the function used to instanciate the new object
  99905. * @param source defines the source object
  99906. * @returns the cloned object
  99907. */
  99908. static Clone<T>(creationFunction: () => T, source: T): T;
  99909. /**
  99910. * Instanciates a new object based on a source one (some data will be shared between both object)
  99911. * @param creationFunction defines the function used to instanciate the new object
  99912. * @param source defines the source object
  99913. * @returns the new object
  99914. */
  99915. static Instanciate<T>(creationFunction: () => T, source: T): T;
  99916. }
  99917. }
  99918. declare module BABYLON {
  99919. /**
  99920. * Class used to manipulate GUIDs
  99921. */
  99922. export class GUID {
  99923. /**
  99924. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99925. * Be aware Math.random() could cause collisions, but:
  99926. * "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"
  99927. * @returns a pseudo random id
  99928. */
  99929. static RandomId(): string;
  99930. }
  99931. }
  99932. declare module BABYLON {
  99933. /**
  99934. * Base class of all the textures in babylon.
  99935. * It groups all the common properties the materials, post process, lights... might need
  99936. * in order to make a correct use of the texture.
  99937. */
  99938. export class BaseTexture implements IAnimatable {
  99939. /**
  99940. * Default anisotropic filtering level for the application.
  99941. * It is set to 4 as a good tradeoff between perf and quality.
  99942. */
  99943. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  99944. /**
  99945. * Gets or sets the unique id of the texture
  99946. */
  99947. uniqueId: number;
  99948. /**
  99949. * Define the name of the texture.
  99950. */
  99951. name: string;
  99952. /**
  99953. * Gets or sets an object used to store user defined information.
  99954. */
  99955. metadata: any;
  99956. /**
  99957. * For internal use only. Please do not use.
  99958. */
  99959. reservedDataStore: any;
  99960. private _hasAlpha;
  99961. /**
  99962. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  99963. */
  99964. set hasAlpha(value: boolean);
  99965. get hasAlpha(): boolean;
  99966. /**
  99967. * Defines if the alpha value should be determined via the rgb values.
  99968. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  99969. */
  99970. getAlphaFromRGB: boolean;
  99971. /**
  99972. * Intensity or strength of the texture.
  99973. * It is commonly used by materials to fine tune the intensity of the texture
  99974. */
  99975. level: number;
  99976. /**
  99977. * Define the UV chanel to use starting from 0 and defaulting to 0.
  99978. * This is part of the texture as textures usually maps to one uv set.
  99979. */
  99980. coordinatesIndex: number;
  99981. private _coordinatesMode;
  99982. /**
  99983. * How a texture is mapped.
  99984. *
  99985. * | Value | Type | Description |
  99986. * | ----- | ----------------------------------- | ----------- |
  99987. * | 0 | EXPLICIT_MODE | |
  99988. * | 1 | SPHERICAL_MODE | |
  99989. * | 2 | PLANAR_MODE | |
  99990. * | 3 | CUBIC_MODE | |
  99991. * | 4 | PROJECTION_MODE | |
  99992. * | 5 | SKYBOX_MODE | |
  99993. * | 6 | INVCUBIC_MODE | |
  99994. * | 7 | EQUIRECTANGULAR_MODE | |
  99995. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  99996. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  99997. */
  99998. set coordinatesMode(value: number);
  99999. get coordinatesMode(): number;
  100000. /**
  100001. * | Value | Type | Description |
  100002. * | ----- | ------------------ | ----------- |
  100003. * | 0 | CLAMP_ADDRESSMODE | |
  100004. * | 1 | WRAP_ADDRESSMODE | |
  100005. * | 2 | MIRROR_ADDRESSMODE | |
  100006. */
  100007. wrapU: number;
  100008. /**
  100009. * | Value | Type | Description |
  100010. * | ----- | ------------------ | ----------- |
  100011. * | 0 | CLAMP_ADDRESSMODE | |
  100012. * | 1 | WRAP_ADDRESSMODE | |
  100013. * | 2 | MIRROR_ADDRESSMODE | |
  100014. */
  100015. wrapV: number;
  100016. /**
  100017. * | Value | Type | Description |
  100018. * | ----- | ------------------ | ----------- |
  100019. * | 0 | CLAMP_ADDRESSMODE | |
  100020. * | 1 | WRAP_ADDRESSMODE | |
  100021. * | 2 | MIRROR_ADDRESSMODE | |
  100022. */
  100023. wrapR: number;
  100024. /**
  100025. * With compliant hardware and browser (supporting anisotropic filtering)
  100026. * this defines the level of anisotropic filtering in the texture.
  100027. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  100028. */
  100029. anisotropicFilteringLevel: number;
  100030. /**
  100031. * Define if the texture is a cube texture or if false a 2d texture.
  100032. */
  100033. get isCube(): boolean;
  100034. set isCube(value: boolean);
  100035. /**
  100036. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  100037. */
  100038. get is3D(): boolean;
  100039. set is3D(value: boolean);
  100040. /**
  100041. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  100042. */
  100043. get is2DArray(): boolean;
  100044. set is2DArray(value: boolean);
  100045. /**
  100046. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  100047. * HDR texture are usually stored in linear space.
  100048. * This only impacts the PBR and Background materials
  100049. */
  100050. gammaSpace: boolean;
  100051. /**
  100052. * Gets or sets whether or not the texture contains RGBD data.
  100053. */
  100054. get isRGBD(): boolean;
  100055. set isRGBD(value: boolean);
  100056. /**
  100057. * Is Z inverted in the texture (useful in a cube texture).
  100058. */
  100059. invertZ: boolean;
  100060. /**
  100061. * Are mip maps generated for this texture or not.
  100062. */
  100063. get noMipmap(): boolean;
  100064. /**
  100065. * @hidden
  100066. */
  100067. lodLevelInAlpha: boolean;
  100068. /**
  100069. * With prefiltered texture, defined the offset used during the prefiltering steps.
  100070. */
  100071. get lodGenerationOffset(): number;
  100072. set lodGenerationOffset(value: number);
  100073. /**
  100074. * With prefiltered texture, defined the scale used during the prefiltering steps.
  100075. */
  100076. get lodGenerationScale(): number;
  100077. set lodGenerationScale(value: number);
  100078. /**
  100079. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  100080. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  100081. * average roughness values.
  100082. */
  100083. get linearSpecularLOD(): boolean;
  100084. set linearSpecularLOD(value: boolean);
  100085. /**
  100086. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  100087. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  100088. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  100089. */
  100090. get irradianceTexture(): Nullable<BaseTexture>;
  100091. set irradianceTexture(value: Nullable<BaseTexture>);
  100092. /**
  100093. * Define if the texture is a render target.
  100094. */
  100095. isRenderTarget: boolean;
  100096. /**
  100097. * Define the unique id of the texture in the scene.
  100098. */
  100099. get uid(): string;
  100100. /**
  100101. * Return a string representation of the texture.
  100102. * @returns the texture as a string
  100103. */
  100104. toString(): string;
  100105. /**
  100106. * Get the class name of the texture.
  100107. * @returns "BaseTexture"
  100108. */
  100109. getClassName(): string;
  100110. /**
  100111. * Define the list of animation attached to the texture.
  100112. */
  100113. animations: Animation[];
  100114. /**
  100115. * An event triggered when the texture is disposed.
  100116. */
  100117. onDisposeObservable: Observable<BaseTexture>;
  100118. private _onDisposeObserver;
  100119. /**
  100120. * Callback triggered when the texture has been disposed.
  100121. * Kept for back compatibility, you can use the onDisposeObservable instead.
  100122. */
  100123. set onDispose(callback: () => void);
  100124. /**
  100125. * Define the current state of the loading sequence when in delayed load mode.
  100126. */
  100127. delayLoadState: number;
  100128. private _scene;
  100129. /** @hidden */
  100130. _texture: Nullable<InternalTexture>;
  100131. private _uid;
  100132. /**
  100133. * Define if the texture is preventinga material to render or not.
  100134. * If not and the texture is not ready, the engine will use a default black texture instead.
  100135. */
  100136. get isBlocking(): boolean;
  100137. /**
  100138. * Instantiates a new BaseTexture.
  100139. * Base class of all the textures in babylon.
  100140. * It groups all the common properties the materials, post process, lights... might need
  100141. * in order to make a correct use of the texture.
  100142. * @param scene Define the scene the texture blongs to
  100143. */
  100144. constructor(scene: Nullable<Scene>);
  100145. /**
  100146. * Get the scene the texture belongs to.
  100147. * @returns the scene or null if undefined
  100148. */
  100149. getScene(): Nullable<Scene>;
  100150. /**
  100151. * Get the texture transform matrix used to offset tile the texture for istance.
  100152. * @returns the transformation matrix
  100153. */
  100154. getTextureMatrix(): Matrix;
  100155. /**
  100156. * Get the texture reflection matrix used to rotate/transform the reflection.
  100157. * @returns the reflection matrix
  100158. */
  100159. getReflectionTextureMatrix(): Matrix;
  100160. /**
  100161. * Get the underlying lower level texture from Babylon.
  100162. * @returns the insternal texture
  100163. */
  100164. getInternalTexture(): Nullable<InternalTexture>;
  100165. /**
  100166. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  100167. * @returns true if ready or not blocking
  100168. */
  100169. isReadyOrNotBlocking(): boolean;
  100170. /**
  100171. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  100172. * @returns true if fully ready
  100173. */
  100174. isReady(): boolean;
  100175. private _cachedSize;
  100176. /**
  100177. * Get the size of the texture.
  100178. * @returns the texture size.
  100179. */
  100180. getSize(): ISize;
  100181. /**
  100182. * Get the base size of the texture.
  100183. * It can be different from the size if the texture has been resized for POT for instance
  100184. * @returns the base size
  100185. */
  100186. getBaseSize(): ISize;
  100187. /**
  100188. * Update the sampling mode of the texture.
  100189. * Default is Trilinear mode.
  100190. *
  100191. * | Value | Type | Description |
  100192. * | ----- | ------------------ | ----------- |
  100193. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  100194. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  100195. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  100196. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  100197. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  100198. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  100199. * | 7 | NEAREST_LINEAR | |
  100200. * | 8 | NEAREST_NEAREST | |
  100201. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  100202. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  100203. * | 11 | LINEAR_LINEAR | |
  100204. * | 12 | LINEAR_NEAREST | |
  100205. *
  100206. * > _mag_: magnification filter (close to the viewer)
  100207. * > _min_: minification filter (far from the viewer)
  100208. * > _mip_: filter used between mip map levels
  100209. *@param samplingMode Define the new sampling mode of the texture
  100210. */
  100211. updateSamplingMode(samplingMode: number): void;
  100212. /**
  100213. * Scales the texture if is `canRescale()`
  100214. * @param ratio the resize factor we want to use to rescale
  100215. */
  100216. scale(ratio: number): void;
  100217. /**
  100218. * Get if the texture can rescale.
  100219. */
  100220. get canRescale(): boolean;
  100221. /** @hidden */
  100222. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  100223. /** @hidden */
  100224. _rebuild(): void;
  100225. /**
  100226. * Triggers the load sequence in delayed load mode.
  100227. */
  100228. delayLoad(): void;
  100229. /**
  100230. * Clones the texture.
  100231. * @returns the cloned texture
  100232. */
  100233. clone(): Nullable<BaseTexture>;
  100234. /**
  100235. * Get the texture underlying type (INT, FLOAT...)
  100236. */
  100237. get textureType(): number;
  100238. /**
  100239. * Get the texture underlying format (RGB, RGBA...)
  100240. */
  100241. get textureFormat(): number;
  100242. /**
  100243. * Indicates that textures need to be re-calculated for all materials
  100244. */
  100245. protected _markAllSubMeshesAsTexturesDirty(): void;
  100246. /**
  100247. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  100248. * This will returns an RGBA array buffer containing either in values (0-255) or
  100249. * float values (0-1) depending of the underlying buffer type.
  100250. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  100251. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  100252. * @param buffer defines a user defined buffer to fill with data (can be null)
  100253. * @returns The Array buffer containing the pixels data.
  100254. */
  100255. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  100256. /**
  100257. * Release and destroy the underlying lower level texture aka internalTexture.
  100258. */
  100259. releaseInternalTexture(): void;
  100260. /** @hidden */
  100261. get _lodTextureHigh(): Nullable<BaseTexture>;
  100262. /** @hidden */
  100263. get _lodTextureMid(): Nullable<BaseTexture>;
  100264. /** @hidden */
  100265. get _lodTextureLow(): Nullable<BaseTexture>;
  100266. /**
  100267. * Dispose the texture and release its associated resources.
  100268. */
  100269. dispose(): void;
  100270. /**
  100271. * Serialize the texture into a JSON representation that can be parsed later on.
  100272. * @returns the JSON representation of the texture
  100273. */
  100274. serialize(): any;
  100275. /**
  100276. * Helper function to be called back once a list of texture contains only ready textures.
  100277. * @param textures Define the list of textures to wait for
  100278. * @param callback Define the callback triggered once the entire list will be ready
  100279. */
  100280. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  100281. }
  100282. }
  100283. declare module BABYLON {
  100284. /**
  100285. * Options to be used when creating an effect.
  100286. */
  100287. export interface IEffectCreationOptions {
  100288. /**
  100289. * Atrributes that will be used in the shader.
  100290. */
  100291. attributes: string[];
  100292. /**
  100293. * Uniform varible names that will be set in the shader.
  100294. */
  100295. uniformsNames: string[];
  100296. /**
  100297. * Uniform buffer variable names that will be set in the shader.
  100298. */
  100299. uniformBuffersNames: string[];
  100300. /**
  100301. * Sampler texture variable names that will be set in the shader.
  100302. */
  100303. samplers: string[];
  100304. /**
  100305. * Define statements that will be set in the shader.
  100306. */
  100307. defines: any;
  100308. /**
  100309. * Possible fallbacks for this effect to improve performance when needed.
  100310. */
  100311. fallbacks: Nullable<IEffectFallbacks>;
  100312. /**
  100313. * Callback that will be called when the shader is compiled.
  100314. */
  100315. onCompiled: Nullable<(effect: Effect) => void>;
  100316. /**
  100317. * Callback that will be called if an error occurs during shader compilation.
  100318. */
  100319. onError: Nullable<(effect: Effect, errors: string) => void>;
  100320. /**
  100321. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100322. */
  100323. indexParameters?: any;
  100324. /**
  100325. * Max number of lights that can be used in the shader.
  100326. */
  100327. maxSimultaneousLights?: number;
  100328. /**
  100329. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  100330. */
  100331. transformFeedbackVaryings?: Nullable<string[]>;
  100332. }
  100333. /**
  100334. * Effect containing vertex and fragment shader that can be executed on an object.
  100335. */
  100336. export class Effect implements IDisposable {
  100337. /**
  100338. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  100339. */
  100340. static ShadersRepository: string;
  100341. /**
  100342. * Name of the effect.
  100343. */
  100344. name: any;
  100345. /**
  100346. * String container all the define statements that should be set on the shader.
  100347. */
  100348. defines: string;
  100349. /**
  100350. * Callback that will be called when the shader is compiled.
  100351. */
  100352. onCompiled: Nullable<(effect: Effect) => void>;
  100353. /**
  100354. * Callback that will be called if an error occurs during shader compilation.
  100355. */
  100356. onError: Nullable<(effect: Effect, errors: string) => void>;
  100357. /**
  100358. * Callback that will be called when effect is bound.
  100359. */
  100360. onBind: Nullable<(effect: Effect) => void>;
  100361. /**
  100362. * Unique ID of the effect.
  100363. */
  100364. uniqueId: number;
  100365. /**
  100366. * Observable that will be called when the shader is compiled.
  100367. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  100368. */
  100369. onCompileObservable: Observable<Effect>;
  100370. /**
  100371. * Observable that will be called if an error occurs during shader compilation.
  100372. */
  100373. onErrorObservable: Observable<Effect>;
  100374. /** @hidden */
  100375. _onBindObservable: Nullable<Observable<Effect>>;
  100376. /**
  100377. * Observable that will be called when effect is bound.
  100378. */
  100379. get onBindObservable(): Observable<Effect>;
  100380. /** @hidden */
  100381. _bonesComputationForcedToCPU: boolean;
  100382. private static _uniqueIdSeed;
  100383. private _engine;
  100384. private _uniformBuffersNames;
  100385. private _uniformsNames;
  100386. private _samplerList;
  100387. private _samplers;
  100388. private _isReady;
  100389. private _compilationError;
  100390. private _allFallbacksProcessed;
  100391. private _attributesNames;
  100392. private _attributes;
  100393. private _attributeLocationByName;
  100394. private _uniforms;
  100395. /**
  100396. * Key for the effect.
  100397. * @hidden
  100398. */
  100399. _key: string;
  100400. private _indexParameters;
  100401. private _fallbacks;
  100402. private _vertexSourceCode;
  100403. private _fragmentSourceCode;
  100404. private _vertexSourceCodeOverride;
  100405. private _fragmentSourceCodeOverride;
  100406. private _transformFeedbackVaryings;
  100407. /**
  100408. * Compiled shader to webGL program.
  100409. * @hidden
  100410. */
  100411. _pipelineContext: Nullable<IPipelineContext>;
  100412. private _valueCache;
  100413. private static _baseCache;
  100414. /**
  100415. * Instantiates an effect.
  100416. * An effect can be used to create/manage/execute vertex and fragment shaders.
  100417. * @param baseName Name of the effect.
  100418. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  100419. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  100420. * @param samplers List of sampler variables that will be passed to the shader.
  100421. * @param engine Engine to be used to render the effect
  100422. * @param defines Define statements to be added to the shader.
  100423. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  100424. * @param onCompiled Callback that will be called when the shader is compiled.
  100425. * @param onError Callback that will be called if an error occurs during shader compilation.
  100426. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100427. */
  100428. 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);
  100429. private _useFinalCode;
  100430. /**
  100431. * Unique key for this effect
  100432. */
  100433. get key(): string;
  100434. /**
  100435. * If the effect has been compiled and prepared.
  100436. * @returns if the effect is compiled and prepared.
  100437. */
  100438. isReady(): boolean;
  100439. private _isReadyInternal;
  100440. /**
  100441. * The engine the effect was initialized with.
  100442. * @returns the engine.
  100443. */
  100444. getEngine(): Engine;
  100445. /**
  100446. * The pipeline context for this effect
  100447. * @returns the associated pipeline context
  100448. */
  100449. getPipelineContext(): Nullable<IPipelineContext>;
  100450. /**
  100451. * The set of names of attribute variables for the shader.
  100452. * @returns An array of attribute names.
  100453. */
  100454. getAttributesNames(): string[];
  100455. /**
  100456. * Returns the attribute at the given index.
  100457. * @param index The index of the attribute.
  100458. * @returns The location of the attribute.
  100459. */
  100460. getAttributeLocation(index: number): number;
  100461. /**
  100462. * Returns the attribute based on the name of the variable.
  100463. * @param name of the attribute to look up.
  100464. * @returns the attribute location.
  100465. */
  100466. getAttributeLocationByName(name: string): number;
  100467. /**
  100468. * The number of attributes.
  100469. * @returns the numnber of attributes.
  100470. */
  100471. getAttributesCount(): number;
  100472. /**
  100473. * Gets the index of a uniform variable.
  100474. * @param uniformName of the uniform to look up.
  100475. * @returns the index.
  100476. */
  100477. getUniformIndex(uniformName: string): number;
  100478. /**
  100479. * Returns the attribute based on the name of the variable.
  100480. * @param uniformName of the uniform to look up.
  100481. * @returns the location of the uniform.
  100482. */
  100483. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  100484. /**
  100485. * Returns an array of sampler variable names
  100486. * @returns The array of sampler variable neames.
  100487. */
  100488. getSamplers(): string[];
  100489. /**
  100490. * The error from the last compilation.
  100491. * @returns the error string.
  100492. */
  100493. getCompilationError(): string;
  100494. /**
  100495. * Gets a boolean indicating that all fallbacks were used during compilation
  100496. * @returns true if all fallbacks were used
  100497. */
  100498. allFallbacksProcessed(): boolean;
  100499. /**
  100500. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  100501. * @param func The callback to be used.
  100502. */
  100503. executeWhenCompiled(func: (effect: Effect) => void): void;
  100504. private _checkIsReady;
  100505. private _loadShader;
  100506. /**
  100507. * Recompiles the webGL program
  100508. * @param vertexSourceCode The source code for the vertex shader.
  100509. * @param fragmentSourceCode The source code for the fragment shader.
  100510. * @param onCompiled Callback called when completed.
  100511. * @param onError Callback called on error.
  100512. * @hidden
  100513. */
  100514. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  100515. /**
  100516. * Prepares the effect
  100517. * @hidden
  100518. */
  100519. _prepareEffect(): void;
  100520. private _processCompilationErrors;
  100521. /**
  100522. * Checks if the effect is supported. (Must be called after compilation)
  100523. */
  100524. get isSupported(): boolean;
  100525. /**
  100526. * Binds a texture to the engine to be used as output of the shader.
  100527. * @param channel Name of the output variable.
  100528. * @param texture Texture to bind.
  100529. * @hidden
  100530. */
  100531. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  100532. /**
  100533. * Sets a texture on the engine to be used in the shader.
  100534. * @param channel Name of the sampler variable.
  100535. * @param texture Texture to set.
  100536. */
  100537. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  100538. /**
  100539. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  100540. * @param channel Name of the sampler variable.
  100541. * @param texture Texture to set.
  100542. */
  100543. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  100544. /**
  100545. * Sets an array of textures on the engine to be used in the shader.
  100546. * @param channel Name of the variable.
  100547. * @param textures Textures to set.
  100548. */
  100549. setTextureArray(channel: string, textures: BaseTexture[]): void;
  100550. /**
  100551. * 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)
  100552. * @param channel Name of the sampler variable.
  100553. * @param postProcess Post process to get the input texture from.
  100554. */
  100555. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  100556. /**
  100557. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  100558. * 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)
  100559. * @param channel Name of the sampler variable.
  100560. * @param postProcess Post process to get the output texture from.
  100561. */
  100562. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  100563. /** @hidden */
  100564. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  100565. /** @hidden */
  100566. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  100567. /** @hidden */
  100568. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  100569. /** @hidden */
  100570. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  100571. /**
  100572. * Binds a buffer to a uniform.
  100573. * @param buffer Buffer to bind.
  100574. * @param name Name of the uniform variable to bind to.
  100575. */
  100576. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  100577. /**
  100578. * Binds block to a uniform.
  100579. * @param blockName Name of the block to bind.
  100580. * @param index Index to bind.
  100581. */
  100582. bindUniformBlock(blockName: string, index: number): void;
  100583. /**
  100584. * Sets an interger value on a uniform variable.
  100585. * @param uniformName Name of the variable.
  100586. * @param value Value to be set.
  100587. * @returns this effect.
  100588. */
  100589. setInt(uniformName: string, value: number): Effect;
  100590. /**
  100591. * Sets an int array on a uniform variable.
  100592. * @param uniformName Name of the variable.
  100593. * @param array array to be set.
  100594. * @returns this effect.
  100595. */
  100596. setIntArray(uniformName: string, array: Int32Array): Effect;
  100597. /**
  100598. * 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)
  100599. * @param uniformName Name of the variable.
  100600. * @param array array to be set.
  100601. * @returns this effect.
  100602. */
  100603. setIntArray2(uniformName: string, array: Int32Array): Effect;
  100604. /**
  100605. * 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)
  100606. * @param uniformName Name of the variable.
  100607. * @param array array to be set.
  100608. * @returns this effect.
  100609. */
  100610. setIntArray3(uniformName: string, array: Int32Array): Effect;
  100611. /**
  100612. * 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)
  100613. * @param uniformName Name of the variable.
  100614. * @param array array to be set.
  100615. * @returns this effect.
  100616. */
  100617. setIntArray4(uniformName: string, array: Int32Array): Effect;
  100618. /**
  100619. * Sets an float array on a uniform variable.
  100620. * @param uniformName Name of the variable.
  100621. * @param array array to be set.
  100622. * @returns this effect.
  100623. */
  100624. setFloatArray(uniformName: string, array: Float32Array): Effect;
  100625. /**
  100626. * 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)
  100627. * @param uniformName Name of the variable.
  100628. * @param array array to be set.
  100629. * @returns this effect.
  100630. */
  100631. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  100632. /**
  100633. * 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)
  100634. * @param uniformName Name of the variable.
  100635. * @param array array to be set.
  100636. * @returns this effect.
  100637. */
  100638. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  100639. /**
  100640. * 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)
  100641. * @param uniformName Name of the variable.
  100642. * @param array array to be set.
  100643. * @returns this effect.
  100644. */
  100645. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  100646. /**
  100647. * Sets an array on a uniform variable.
  100648. * @param uniformName Name of the variable.
  100649. * @param array array to be set.
  100650. * @returns this effect.
  100651. */
  100652. setArray(uniformName: string, array: number[]): Effect;
  100653. /**
  100654. * 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)
  100655. * @param uniformName Name of the variable.
  100656. * @param array array to be set.
  100657. * @returns this effect.
  100658. */
  100659. setArray2(uniformName: string, array: number[]): Effect;
  100660. /**
  100661. * 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)
  100662. * @param uniformName Name of the variable.
  100663. * @param array array to be set.
  100664. * @returns this effect.
  100665. */
  100666. setArray3(uniformName: string, array: number[]): Effect;
  100667. /**
  100668. * 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)
  100669. * @param uniformName Name of the variable.
  100670. * @param array array to be set.
  100671. * @returns this effect.
  100672. */
  100673. setArray4(uniformName: string, array: number[]): Effect;
  100674. /**
  100675. * Sets matrices on a uniform variable.
  100676. * @param uniformName Name of the variable.
  100677. * @param matrices matrices to be set.
  100678. * @returns this effect.
  100679. */
  100680. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  100681. /**
  100682. * Sets matrix on a uniform variable.
  100683. * @param uniformName Name of the variable.
  100684. * @param matrix matrix to be set.
  100685. * @returns this effect.
  100686. */
  100687. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  100688. /**
  100689. * 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)
  100690. * @param uniformName Name of the variable.
  100691. * @param matrix matrix to be set.
  100692. * @returns this effect.
  100693. */
  100694. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  100695. /**
  100696. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  100697. * @param uniformName Name of the variable.
  100698. * @param matrix matrix to be set.
  100699. * @returns this effect.
  100700. */
  100701. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  100702. /**
  100703. * Sets a float on a uniform variable.
  100704. * @param uniformName Name of the variable.
  100705. * @param value value to be set.
  100706. * @returns this effect.
  100707. */
  100708. setFloat(uniformName: string, value: number): Effect;
  100709. /**
  100710. * Sets a boolean on a uniform variable.
  100711. * @param uniformName Name of the variable.
  100712. * @param bool value to be set.
  100713. * @returns this effect.
  100714. */
  100715. setBool(uniformName: string, bool: boolean): Effect;
  100716. /**
  100717. * Sets a Vector2 on a uniform variable.
  100718. * @param uniformName Name of the variable.
  100719. * @param vector2 vector2 to be set.
  100720. * @returns this effect.
  100721. */
  100722. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  100723. /**
  100724. * Sets a float2 on a uniform variable.
  100725. * @param uniformName Name of the variable.
  100726. * @param x First float in float2.
  100727. * @param y Second float in float2.
  100728. * @returns this effect.
  100729. */
  100730. setFloat2(uniformName: string, x: number, y: number): Effect;
  100731. /**
  100732. * Sets a Vector3 on a uniform variable.
  100733. * @param uniformName Name of the variable.
  100734. * @param vector3 Value to be set.
  100735. * @returns this effect.
  100736. */
  100737. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  100738. /**
  100739. * Sets a float3 on a uniform variable.
  100740. * @param uniformName Name of the variable.
  100741. * @param x First float in float3.
  100742. * @param y Second float in float3.
  100743. * @param z Third float in float3.
  100744. * @returns this effect.
  100745. */
  100746. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  100747. /**
  100748. * Sets a Vector4 on a uniform variable.
  100749. * @param uniformName Name of the variable.
  100750. * @param vector4 Value to be set.
  100751. * @returns this effect.
  100752. */
  100753. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  100754. /**
  100755. * Sets a float4 on a uniform variable.
  100756. * @param uniformName Name of the variable.
  100757. * @param x First float in float4.
  100758. * @param y Second float in float4.
  100759. * @param z Third float in float4.
  100760. * @param w Fourth float in float4.
  100761. * @returns this effect.
  100762. */
  100763. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  100764. /**
  100765. * Sets a Color3 on a uniform variable.
  100766. * @param uniformName Name of the variable.
  100767. * @param color3 Value to be set.
  100768. * @returns this effect.
  100769. */
  100770. setColor3(uniformName: string, color3: IColor3Like): Effect;
  100771. /**
  100772. * Sets a Color4 on a uniform variable.
  100773. * @param uniformName Name of the variable.
  100774. * @param color3 Value to be set.
  100775. * @param alpha Alpha value to be set.
  100776. * @returns this effect.
  100777. */
  100778. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  100779. /**
  100780. * Sets a Color4 on a uniform variable
  100781. * @param uniformName defines the name of the variable
  100782. * @param color4 defines the value to be set
  100783. * @returns this effect.
  100784. */
  100785. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  100786. /** Release all associated resources */
  100787. dispose(): void;
  100788. /**
  100789. * This function will add a new shader to the shader store
  100790. * @param name the name of the shader
  100791. * @param pixelShader optional pixel shader content
  100792. * @param vertexShader optional vertex shader content
  100793. */
  100794. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  100795. /**
  100796. * Store of each shader (The can be looked up using effect.key)
  100797. */
  100798. static ShadersStore: {
  100799. [key: string]: string;
  100800. };
  100801. /**
  100802. * Store of each included file for a shader (The can be looked up using effect.key)
  100803. */
  100804. static IncludesShadersStore: {
  100805. [key: string]: string;
  100806. };
  100807. /**
  100808. * Resets the cache of effects.
  100809. */
  100810. static ResetCache(): void;
  100811. }
  100812. }
  100813. declare module BABYLON {
  100814. /**
  100815. * Interface used to describe the capabilities of the engine relatively to the current browser
  100816. */
  100817. export interface EngineCapabilities {
  100818. /** Maximum textures units per fragment shader */
  100819. maxTexturesImageUnits: number;
  100820. /** Maximum texture units per vertex shader */
  100821. maxVertexTextureImageUnits: number;
  100822. /** Maximum textures units in the entire pipeline */
  100823. maxCombinedTexturesImageUnits: number;
  100824. /** Maximum texture size */
  100825. maxTextureSize: number;
  100826. /** Maximum texture samples */
  100827. maxSamples?: number;
  100828. /** Maximum cube texture size */
  100829. maxCubemapTextureSize: number;
  100830. /** Maximum render texture size */
  100831. maxRenderTextureSize: number;
  100832. /** Maximum number of vertex attributes */
  100833. maxVertexAttribs: number;
  100834. /** Maximum number of varyings */
  100835. maxVaryingVectors: number;
  100836. /** Maximum number of uniforms per vertex shader */
  100837. maxVertexUniformVectors: number;
  100838. /** Maximum number of uniforms per fragment shader */
  100839. maxFragmentUniformVectors: number;
  100840. /** Defines if standard derivates (dx/dy) are supported */
  100841. standardDerivatives: boolean;
  100842. /** Defines if s3tc texture compression is supported */
  100843. s3tc?: WEBGL_compressed_texture_s3tc;
  100844. /** Defines if pvrtc texture compression is supported */
  100845. pvrtc: any;
  100846. /** Defines if etc1 texture compression is supported */
  100847. etc1: any;
  100848. /** Defines if etc2 texture compression is supported */
  100849. etc2: any;
  100850. /** Defines if astc texture compression is supported */
  100851. astc: any;
  100852. /** Defines if float textures are supported */
  100853. textureFloat: boolean;
  100854. /** Defines if vertex array objects are supported */
  100855. vertexArrayObject: boolean;
  100856. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  100857. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  100858. /** Gets the maximum level of anisotropy supported */
  100859. maxAnisotropy: number;
  100860. /** Defines if instancing is supported */
  100861. instancedArrays: boolean;
  100862. /** Defines if 32 bits indices are supported */
  100863. uintIndices: boolean;
  100864. /** Defines if high precision shaders are supported */
  100865. highPrecisionShaderSupported: boolean;
  100866. /** Defines if depth reading in the fragment shader is supported */
  100867. fragmentDepthSupported: boolean;
  100868. /** Defines if float texture linear filtering is supported*/
  100869. textureFloatLinearFiltering: boolean;
  100870. /** Defines if rendering to float textures is supported */
  100871. textureFloatRender: boolean;
  100872. /** Defines if half float textures are supported*/
  100873. textureHalfFloat: boolean;
  100874. /** Defines if half float texture linear filtering is supported*/
  100875. textureHalfFloatLinearFiltering: boolean;
  100876. /** Defines if rendering to half float textures is supported */
  100877. textureHalfFloatRender: boolean;
  100878. /** Defines if textureLOD shader command is supported */
  100879. textureLOD: boolean;
  100880. /** Defines if draw buffers extension is supported */
  100881. drawBuffersExtension: boolean;
  100882. /** Defines if depth textures are supported */
  100883. depthTextureExtension: boolean;
  100884. /** Defines if float color buffer are supported */
  100885. colorBufferFloat: boolean;
  100886. /** Gets disjoint timer query extension (null if not supported) */
  100887. timerQuery?: EXT_disjoint_timer_query;
  100888. /** Defines if timestamp can be used with timer query */
  100889. canUseTimestampForTimerQuery: boolean;
  100890. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  100891. multiview?: any;
  100892. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  100893. oculusMultiview?: any;
  100894. /** Function used to let the system compiles shaders in background */
  100895. parallelShaderCompile?: {
  100896. COMPLETION_STATUS_KHR: number;
  100897. };
  100898. /** Max number of texture samples for MSAA */
  100899. maxMSAASamples: number;
  100900. /** Defines if the blend min max extension is supported */
  100901. blendMinMax: boolean;
  100902. }
  100903. }
  100904. declare module BABYLON {
  100905. /**
  100906. * @hidden
  100907. **/
  100908. export class DepthCullingState {
  100909. private _isDepthTestDirty;
  100910. private _isDepthMaskDirty;
  100911. private _isDepthFuncDirty;
  100912. private _isCullFaceDirty;
  100913. private _isCullDirty;
  100914. private _isZOffsetDirty;
  100915. private _isFrontFaceDirty;
  100916. private _depthTest;
  100917. private _depthMask;
  100918. private _depthFunc;
  100919. private _cull;
  100920. private _cullFace;
  100921. private _zOffset;
  100922. private _frontFace;
  100923. /**
  100924. * Initializes the state.
  100925. */
  100926. constructor();
  100927. get isDirty(): boolean;
  100928. get zOffset(): number;
  100929. set zOffset(value: number);
  100930. get cullFace(): Nullable<number>;
  100931. set cullFace(value: Nullable<number>);
  100932. get cull(): Nullable<boolean>;
  100933. set cull(value: Nullable<boolean>);
  100934. get depthFunc(): Nullable<number>;
  100935. set depthFunc(value: Nullable<number>);
  100936. get depthMask(): boolean;
  100937. set depthMask(value: boolean);
  100938. get depthTest(): boolean;
  100939. set depthTest(value: boolean);
  100940. get frontFace(): Nullable<number>;
  100941. set frontFace(value: Nullable<number>);
  100942. reset(): void;
  100943. apply(gl: WebGLRenderingContext): void;
  100944. }
  100945. }
  100946. declare module BABYLON {
  100947. /**
  100948. * @hidden
  100949. **/
  100950. export class StencilState {
  100951. /** 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 */
  100952. static readonly ALWAYS: number;
  100953. /** Passed to stencilOperation to specify that stencil value must be kept */
  100954. static readonly KEEP: number;
  100955. /** Passed to stencilOperation to specify that stencil value must be replaced */
  100956. static readonly REPLACE: number;
  100957. private _isStencilTestDirty;
  100958. private _isStencilMaskDirty;
  100959. private _isStencilFuncDirty;
  100960. private _isStencilOpDirty;
  100961. private _stencilTest;
  100962. private _stencilMask;
  100963. private _stencilFunc;
  100964. private _stencilFuncRef;
  100965. private _stencilFuncMask;
  100966. private _stencilOpStencilFail;
  100967. private _stencilOpDepthFail;
  100968. private _stencilOpStencilDepthPass;
  100969. get isDirty(): boolean;
  100970. get stencilFunc(): number;
  100971. set stencilFunc(value: number);
  100972. get stencilFuncRef(): number;
  100973. set stencilFuncRef(value: number);
  100974. get stencilFuncMask(): number;
  100975. set stencilFuncMask(value: number);
  100976. get stencilOpStencilFail(): number;
  100977. set stencilOpStencilFail(value: number);
  100978. get stencilOpDepthFail(): number;
  100979. set stencilOpDepthFail(value: number);
  100980. get stencilOpStencilDepthPass(): number;
  100981. set stencilOpStencilDepthPass(value: number);
  100982. get stencilMask(): number;
  100983. set stencilMask(value: number);
  100984. get stencilTest(): boolean;
  100985. set stencilTest(value: boolean);
  100986. constructor();
  100987. reset(): void;
  100988. apply(gl: WebGLRenderingContext): void;
  100989. }
  100990. }
  100991. declare module BABYLON {
  100992. /**
  100993. * @hidden
  100994. **/
  100995. export class AlphaState {
  100996. private _isAlphaBlendDirty;
  100997. private _isBlendFunctionParametersDirty;
  100998. private _isBlendEquationParametersDirty;
  100999. private _isBlendConstantsDirty;
  101000. private _alphaBlend;
  101001. private _blendFunctionParameters;
  101002. private _blendEquationParameters;
  101003. private _blendConstants;
  101004. /**
  101005. * Initializes the state.
  101006. */
  101007. constructor();
  101008. get isDirty(): boolean;
  101009. get alphaBlend(): boolean;
  101010. set alphaBlend(value: boolean);
  101011. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  101012. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  101013. setAlphaEquationParameters(rgb: number, alpha: number): void;
  101014. reset(): void;
  101015. apply(gl: WebGLRenderingContext): void;
  101016. }
  101017. }
  101018. declare module BABYLON {
  101019. /** @hidden */
  101020. export class WebGL2ShaderProcessor implements IShaderProcessor {
  101021. attributeProcessor(attribute: string): string;
  101022. varyingProcessor(varying: string, isFragment: boolean): string;
  101023. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  101024. }
  101025. }
  101026. declare module BABYLON {
  101027. /**
  101028. * Interface for attribute information associated with buffer instanciation
  101029. */
  101030. export interface InstancingAttributeInfo {
  101031. /**
  101032. * Name of the GLSL attribute
  101033. * if attribute index is not specified, this is used to retrieve the index from the effect
  101034. */
  101035. attributeName: string;
  101036. /**
  101037. * Index/offset of the attribute in the vertex shader
  101038. * if not specified, this will be computes from the name.
  101039. */
  101040. index?: number;
  101041. /**
  101042. * size of the attribute, 1, 2, 3 or 4
  101043. */
  101044. attributeSize: number;
  101045. /**
  101046. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  101047. */
  101048. offset: number;
  101049. /**
  101050. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  101051. * default to 1
  101052. */
  101053. divisor?: number;
  101054. /**
  101055. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  101056. * default is FLOAT
  101057. */
  101058. attributeType?: number;
  101059. /**
  101060. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  101061. */
  101062. normalized?: boolean;
  101063. }
  101064. }
  101065. declare module BABYLON {
  101066. interface ThinEngine {
  101067. /**
  101068. * Update a video texture
  101069. * @param texture defines the texture to update
  101070. * @param video defines the video element to use
  101071. * @param invertY defines if data must be stored with Y axis inverted
  101072. */
  101073. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  101074. }
  101075. }
  101076. declare module BABYLON {
  101077. /**
  101078. * Settings for finer control over video usage
  101079. */
  101080. export interface VideoTextureSettings {
  101081. /**
  101082. * Applies `autoplay` to video, if specified
  101083. */
  101084. autoPlay?: boolean;
  101085. /**
  101086. * Applies `loop` to video, if specified
  101087. */
  101088. loop?: boolean;
  101089. /**
  101090. * Automatically updates internal texture from video at every frame in the render loop
  101091. */
  101092. autoUpdateTexture: boolean;
  101093. /**
  101094. * Image src displayed during the video loading or until the user interacts with the video.
  101095. */
  101096. poster?: string;
  101097. }
  101098. /**
  101099. * If you want to display a video in your scene, this is the special texture for that.
  101100. * This special texture works similar to other textures, with the exception of a few parameters.
  101101. * @see https://doc.babylonjs.com/how_to/video_texture
  101102. */
  101103. export class VideoTexture extends Texture {
  101104. /**
  101105. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  101106. */
  101107. readonly autoUpdateTexture: boolean;
  101108. /**
  101109. * The video instance used by the texture internally
  101110. */
  101111. readonly video: HTMLVideoElement;
  101112. private _onUserActionRequestedObservable;
  101113. /**
  101114. * Event triggerd when a dom action is required by the user to play the video.
  101115. * This happens due to recent changes in browser policies preventing video to auto start.
  101116. */
  101117. get onUserActionRequestedObservable(): Observable<Texture>;
  101118. private _generateMipMaps;
  101119. private _engine;
  101120. private _stillImageCaptured;
  101121. private _displayingPosterTexture;
  101122. private _settings;
  101123. private _createInternalTextureOnEvent;
  101124. private _frameId;
  101125. /**
  101126. * Creates a video texture.
  101127. * If you want to display a video in your scene, this is the special texture for that.
  101128. * This special texture works similar to other textures, with the exception of a few parameters.
  101129. * @see https://doc.babylonjs.com/how_to/video_texture
  101130. * @param name optional name, will detect from video source, if not defined
  101131. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  101132. * @param scene is obviously the current scene.
  101133. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  101134. * @param invertY is false by default but can be used to invert video on Y axis
  101135. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  101136. * @param settings allows finer control over video usage
  101137. */
  101138. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  101139. private _getName;
  101140. private _getVideo;
  101141. private _createInternalTexture;
  101142. private reset;
  101143. /**
  101144. * @hidden Internal method to initiate `update`.
  101145. */
  101146. _rebuild(): void;
  101147. /**
  101148. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  101149. */
  101150. update(): void;
  101151. /**
  101152. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  101153. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  101154. */
  101155. updateTexture(isVisible: boolean): void;
  101156. protected _updateInternalTexture: () => void;
  101157. /**
  101158. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  101159. * @param url New url.
  101160. */
  101161. updateURL(url: string): void;
  101162. /**
  101163. * Dispose the texture and release its associated resources.
  101164. */
  101165. dispose(): void;
  101166. /**
  101167. * Creates a video texture straight from a stream.
  101168. * @param scene Define the scene the texture should be created in
  101169. * @param stream Define the stream the texture should be created from
  101170. * @returns The created video texture as a promise
  101171. */
  101172. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  101173. /**
  101174. * Creates a video texture straight from your WebCam video feed.
  101175. * @param scene Define the scene the texture should be created in
  101176. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101177. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101178. * @returns The created video texture as a promise
  101179. */
  101180. static CreateFromWebCamAsync(scene: Scene, constraints: {
  101181. minWidth: number;
  101182. maxWidth: number;
  101183. minHeight: number;
  101184. maxHeight: number;
  101185. deviceId: string;
  101186. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  101187. /**
  101188. * Creates a video texture straight from your WebCam video feed.
  101189. * @param scene Define the scene the texture should be created in
  101190. * @param onReady Define a callback to triggered once the texture will be ready
  101191. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101192. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101193. */
  101194. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  101195. minWidth: number;
  101196. maxWidth: number;
  101197. minHeight: number;
  101198. maxHeight: number;
  101199. deviceId: string;
  101200. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  101201. }
  101202. }
  101203. declare module BABYLON {
  101204. /**
  101205. * Defines the interface used by objects working like Scene
  101206. * @hidden
  101207. */
  101208. interface ISceneLike {
  101209. _addPendingData(data: any): void;
  101210. _removePendingData(data: any): void;
  101211. offlineProvider: IOfflineProvider;
  101212. }
  101213. /** Interface defining initialization parameters for Engine class */
  101214. export interface EngineOptions extends WebGLContextAttributes {
  101215. /**
  101216. * Defines if the engine should no exceed a specified device ratio
  101217. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  101218. */
  101219. limitDeviceRatio?: number;
  101220. /**
  101221. * Defines if webvr should be enabled automatically
  101222. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101223. */
  101224. autoEnableWebVR?: boolean;
  101225. /**
  101226. * Defines if webgl2 should be turned off even if supported
  101227. * @see http://doc.babylonjs.com/features/webgl2
  101228. */
  101229. disableWebGL2Support?: boolean;
  101230. /**
  101231. * Defines if webaudio should be initialized as well
  101232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101233. */
  101234. audioEngine?: boolean;
  101235. /**
  101236. * Defines if animations should run using a deterministic lock step
  101237. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101238. */
  101239. deterministicLockstep?: boolean;
  101240. /** Defines the maximum steps to use with deterministic lock step mode */
  101241. lockstepMaxSteps?: number;
  101242. /** Defines the seconds between each deterministic lock step */
  101243. timeStep?: number;
  101244. /**
  101245. * Defines that engine should ignore context lost events
  101246. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  101247. */
  101248. doNotHandleContextLost?: boolean;
  101249. /**
  101250. * Defines that engine should ignore modifying touch action attribute and style
  101251. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  101252. */
  101253. doNotHandleTouchAction?: boolean;
  101254. /**
  101255. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  101256. */
  101257. useHighPrecisionFloats?: boolean;
  101258. }
  101259. /**
  101260. * The base engine class (root of all engines)
  101261. */
  101262. export class ThinEngine {
  101263. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  101264. static ExceptionList: ({
  101265. key: string;
  101266. capture: string;
  101267. captureConstraint: number;
  101268. targets: string[];
  101269. } | {
  101270. key: string;
  101271. capture: null;
  101272. captureConstraint: null;
  101273. targets: string[];
  101274. })[];
  101275. /** @hidden */
  101276. static _TextureLoaders: IInternalTextureLoader[];
  101277. /**
  101278. * Returns the current npm package of the sdk
  101279. */
  101280. static get NpmPackage(): string;
  101281. /**
  101282. * Returns the current version of the framework
  101283. */
  101284. static get Version(): string;
  101285. /**
  101286. * Returns a string describing the current engine
  101287. */
  101288. get description(): string;
  101289. /**
  101290. * Gets or sets the epsilon value used by collision engine
  101291. */
  101292. static CollisionsEpsilon: number;
  101293. /**
  101294. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  101295. */
  101296. static get ShadersRepository(): string;
  101297. static set ShadersRepository(value: string);
  101298. /**
  101299. * Gets or sets the textures that the engine should not attempt to load as compressed
  101300. */
  101301. protected _excludedCompressedTextures: string[];
  101302. /**
  101303. * Filters the compressed texture formats to only include
  101304. * files that are not included in the skippable list
  101305. *
  101306. * @param url the current extension
  101307. * @param textureFormatInUse the current compressed texture format
  101308. * @returns "format" string
  101309. */
  101310. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  101311. /** @hidden */
  101312. _shaderProcessor: IShaderProcessor;
  101313. /**
  101314. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  101315. */
  101316. forcePOTTextures: boolean;
  101317. /**
  101318. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  101319. */
  101320. isFullscreen: boolean;
  101321. /**
  101322. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  101323. */
  101324. cullBackFaces: boolean;
  101325. /**
  101326. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  101327. */
  101328. renderEvenInBackground: boolean;
  101329. /**
  101330. * Gets or sets a boolean indicating that cache can be kept between frames
  101331. */
  101332. preventCacheWipeBetweenFrames: boolean;
  101333. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  101334. validateShaderPrograms: boolean;
  101335. /**
  101336. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  101337. * This can provide greater z depth for distant objects.
  101338. */
  101339. useReverseDepthBuffer: boolean;
  101340. /**
  101341. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  101342. */
  101343. disableUniformBuffers: boolean;
  101344. /** @hidden */
  101345. _uniformBuffers: UniformBuffer[];
  101346. /**
  101347. * Gets a boolean indicating that the engine supports uniform buffers
  101348. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  101349. */
  101350. get supportsUniformBuffers(): boolean;
  101351. /** @hidden */
  101352. _gl: WebGLRenderingContext;
  101353. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  101354. protected _windowIsBackground: boolean;
  101355. protected _webGLVersion: number;
  101356. protected _creationOptions: EngineOptions;
  101357. protected _highPrecisionShadersAllowed: boolean;
  101358. /** @hidden */
  101359. get _shouldUseHighPrecisionShader(): boolean;
  101360. /**
  101361. * Gets a boolean indicating that only power of 2 textures are supported
  101362. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  101363. */
  101364. get needPOTTextures(): boolean;
  101365. /** @hidden */
  101366. _badOS: boolean;
  101367. /** @hidden */
  101368. _badDesktopOS: boolean;
  101369. private _hardwareScalingLevel;
  101370. /** @hidden */
  101371. _caps: EngineCapabilities;
  101372. private _isStencilEnable;
  101373. private _glVersion;
  101374. private _glRenderer;
  101375. private _glVendor;
  101376. /** @hidden */
  101377. _videoTextureSupported: boolean;
  101378. protected _renderingQueueLaunched: boolean;
  101379. protected _activeRenderLoops: (() => void)[];
  101380. /**
  101381. * Observable signaled when a context lost event is raised
  101382. */
  101383. onContextLostObservable: Observable<ThinEngine>;
  101384. /**
  101385. * Observable signaled when a context restored event is raised
  101386. */
  101387. onContextRestoredObservable: Observable<ThinEngine>;
  101388. private _onContextLost;
  101389. private _onContextRestored;
  101390. protected _contextWasLost: boolean;
  101391. /** @hidden */
  101392. _doNotHandleContextLost: boolean;
  101393. /**
  101394. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  101395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  101396. */
  101397. get doNotHandleContextLost(): boolean;
  101398. set doNotHandleContextLost(value: boolean);
  101399. /**
  101400. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  101401. */
  101402. disableVertexArrayObjects: boolean;
  101403. /** @hidden */
  101404. protected _colorWrite: boolean;
  101405. /** @hidden */
  101406. protected _colorWriteChanged: boolean;
  101407. /** @hidden */
  101408. protected _depthCullingState: DepthCullingState;
  101409. /** @hidden */
  101410. protected _stencilState: StencilState;
  101411. /** @hidden */
  101412. _alphaState: AlphaState;
  101413. /** @hidden */
  101414. _alphaMode: number;
  101415. /** @hidden */
  101416. _alphaEquation: number;
  101417. /** @hidden */
  101418. _internalTexturesCache: InternalTexture[];
  101419. /** @hidden */
  101420. protected _activeChannel: number;
  101421. private _currentTextureChannel;
  101422. /** @hidden */
  101423. protected _boundTexturesCache: {
  101424. [key: string]: Nullable<InternalTexture>;
  101425. };
  101426. /** @hidden */
  101427. protected _currentEffect: Nullable<Effect>;
  101428. /** @hidden */
  101429. protected _currentProgram: Nullable<WebGLProgram>;
  101430. private _compiledEffects;
  101431. private _vertexAttribArraysEnabled;
  101432. /** @hidden */
  101433. protected _cachedViewport: Nullable<IViewportLike>;
  101434. private _cachedVertexArrayObject;
  101435. /** @hidden */
  101436. protected _cachedVertexBuffers: any;
  101437. /** @hidden */
  101438. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  101439. /** @hidden */
  101440. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  101441. /** @hidden */
  101442. _currentRenderTarget: Nullable<InternalTexture>;
  101443. private _uintIndicesCurrentlySet;
  101444. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  101445. /** @hidden */
  101446. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  101447. private _currentBufferPointers;
  101448. private _currentInstanceLocations;
  101449. private _currentInstanceBuffers;
  101450. private _textureUnits;
  101451. /** @hidden */
  101452. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  101453. /** @hidden */
  101454. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  101455. /** @hidden */
  101456. _boundRenderFunction: any;
  101457. private _vaoRecordInProgress;
  101458. private _mustWipeVertexAttributes;
  101459. private _emptyTexture;
  101460. private _emptyCubeTexture;
  101461. private _emptyTexture3D;
  101462. private _emptyTexture2DArray;
  101463. /** @hidden */
  101464. _frameHandler: number;
  101465. private _nextFreeTextureSlots;
  101466. private _maxSimultaneousTextures;
  101467. private _activeRequests;
  101468. protected _texturesSupported: string[];
  101469. /** @hidden */
  101470. _textureFormatInUse: Nullable<string>;
  101471. protected get _supportsHardwareTextureRescaling(): boolean;
  101472. /**
  101473. * Gets the list of texture formats supported
  101474. */
  101475. get texturesSupported(): Array<string>;
  101476. /**
  101477. * Gets the list of texture formats in use
  101478. */
  101479. get textureFormatInUse(): Nullable<string>;
  101480. /**
  101481. * Gets the current viewport
  101482. */
  101483. get currentViewport(): Nullable<IViewportLike>;
  101484. /**
  101485. * Gets the default empty texture
  101486. */
  101487. get emptyTexture(): InternalTexture;
  101488. /**
  101489. * Gets the default empty 3D texture
  101490. */
  101491. get emptyTexture3D(): InternalTexture;
  101492. /**
  101493. * Gets the default empty 2D array texture
  101494. */
  101495. get emptyTexture2DArray(): InternalTexture;
  101496. /**
  101497. * Gets the default empty cube texture
  101498. */
  101499. get emptyCubeTexture(): InternalTexture;
  101500. /**
  101501. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  101502. */
  101503. readonly premultipliedAlpha: boolean;
  101504. /**
  101505. * Observable event triggered before each texture is initialized
  101506. */
  101507. onBeforeTextureInitObservable: Observable<Texture>;
  101508. /**
  101509. * Creates a new engine
  101510. * @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
  101511. * @param antialias defines enable antialiasing (default: false)
  101512. * @param options defines further options to be sent to the getContext() function
  101513. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101514. */
  101515. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101516. private _rebuildInternalTextures;
  101517. private _rebuildEffects;
  101518. /**
  101519. * Gets a boolean indicating if all created effects are ready
  101520. * @returns true if all effects are ready
  101521. */
  101522. areAllEffectsReady(): boolean;
  101523. protected _rebuildBuffers(): void;
  101524. private _initGLContext;
  101525. /**
  101526. * Gets version of the current webGL context
  101527. */
  101528. get webGLVersion(): number;
  101529. /**
  101530. * Gets a string idenfifying the name of the class
  101531. * @returns "Engine" string
  101532. */
  101533. getClassName(): string;
  101534. /**
  101535. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  101536. */
  101537. get isStencilEnable(): boolean;
  101538. /** @hidden */
  101539. _prepareWorkingCanvas(): void;
  101540. /**
  101541. * Reset the texture cache to empty state
  101542. */
  101543. resetTextureCache(): void;
  101544. /**
  101545. * Gets an object containing information about the current webGL context
  101546. * @returns an object containing the vender, the renderer and the version of the current webGL context
  101547. */
  101548. getGlInfo(): {
  101549. vendor: string;
  101550. renderer: string;
  101551. version: string;
  101552. };
  101553. /**
  101554. * Defines the hardware scaling level.
  101555. * By default the hardware scaling level is computed from the window device ratio.
  101556. * 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.
  101557. * @param level defines the level to use
  101558. */
  101559. setHardwareScalingLevel(level: number): void;
  101560. /**
  101561. * Gets the current hardware scaling level.
  101562. * By default the hardware scaling level is computed from the window device ratio.
  101563. * 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.
  101564. * @returns a number indicating the current hardware scaling level
  101565. */
  101566. getHardwareScalingLevel(): number;
  101567. /**
  101568. * Gets the list of loaded textures
  101569. * @returns an array containing all loaded textures
  101570. */
  101571. getLoadedTexturesCache(): InternalTexture[];
  101572. /**
  101573. * Gets the object containing all engine capabilities
  101574. * @returns the EngineCapabilities object
  101575. */
  101576. getCaps(): EngineCapabilities;
  101577. /**
  101578. * stop executing a render loop function and remove it from the execution array
  101579. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  101580. */
  101581. stopRenderLoop(renderFunction?: () => void): void;
  101582. /** @hidden */
  101583. _renderLoop(): void;
  101584. /**
  101585. * Gets the HTML canvas attached with the current webGL context
  101586. * @returns a HTML canvas
  101587. */
  101588. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  101589. /**
  101590. * Gets host window
  101591. * @returns the host window object
  101592. */
  101593. getHostWindow(): Nullable<Window>;
  101594. /**
  101595. * Gets the current render width
  101596. * @param useScreen defines if screen size must be used (or the current render target if any)
  101597. * @returns a number defining the current render width
  101598. */
  101599. getRenderWidth(useScreen?: boolean): number;
  101600. /**
  101601. * Gets the current render height
  101602. * @param useScreen defines if screen size must be used (or the current render target if any)
  101603. * @returns a number defining the current render height
  101604. */
  101605. getRenderHeight(useScreen?: boolean): number;
  101606. /**
  101607. * Can be used to override the current requestAnimationFrame requester.
  101608. * @hidden
  101609. */
  101610. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  101611. /**
  101612. * Register and execute a render loop. The engine can have more than one render function
  101613. * @param renderFunction defines the function to continuously execute
  101614. */
  101615. runRenderLoop(renderFunction: () => void): void;
  101616. /**
  101617. * Clear the current render buffer or the current render target (if any is set up)
  101618. * @param color defines the color to use
  101619. * @param backBuffer defines if the back buffer must be cleared
  101620. * @param depth defines if the depth buffer must be cleared
  101621. * @param stencil defines if the stencil buffer must be cleared
  101622. */
  101623. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101624. private _viewportCached;
  101625. /** @hidden */
  101626. _viewport(x: number, y: number, width: number, height: number): void;
  101627. /**
  101628. * Set the WebGL's viewport
  101629. * @param viewport defines the viewport element to be used
  101630. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  101631. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  101632. */
  101633. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  101634. /**
  101635. * Begin a new frame
  101636. */
  101637. beginFrame(): void;
  101638. /**
  101639. * Enf the current frame
  101640. */
  101641. endFrame(): void;
  101642. /**
  101643. * Resize the view according to the canvas' size
  101644. */
  101645. resize(): void;
  101646. /**
  101647. * Force a specific size of the canvas
  101648. * @param width defines the new canvas' width
  101649. * @param height defines the new canvas' height
  101650. */
  101651. setSize(width: number, height: number): void;
  101652. /**
  101653. * Binds the frame buffer to the specified texture.
  101654. * @param texture The texture to render to or null for the default canvas
  101655. * @param faceIndex The face of the texture to render to in case of cube texture
  101656. * @param requiredWidth The width of the target to render to
  101657. * @param requiredHeight The height of the target to render to
  101658. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  101659. * @param depthStencilTexture The depth stencil texture to use to render
  101660. * @param lodLevel defines le lod level to bind to the frame buffer
  101661. */
  101662. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  101663. /** @hidden */
  101664. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  101665. /**
  101666. * Unbind the current render target texture from the webGL context
  101667. * @param texture defines the render target texture to unbind
  101668. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101669. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101670. */
  101671. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101672. /**
  101673. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  101674. */
  101675. flushFramebuffer(): void;
  101676. /**
  101677. * Unbind the current render target and bind the default framebuffer
  101678. */
  101679. restoreDefaultFramebuffer(): void;
  101680. /** @hidden */
  101681. protected _resetVertexBufferBinding(): void;
  101682. /**
  101683. * Creates a vertex buffer
  101684. * @param data the data for the vertex buffer
  101685. * @returns the new WebGL static buffer
  101686. */
  101687. createVertexBuffer(data: DataArray): DataBuffer;
  101688. private _createVertexBuffer;
  101689. /**
  101690. * Creates a dynamic vertex buffer
  101691. * @param data the data for the dynamic vertex buffer
  101692. * @returns the new WebGL dynamic buffer
  101693. */
  101694. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  101695. protected _resetIndexBufferBinding(): void;
  101696. /**
  101697. * Creates a new index buffer
  101698. * @param indices defines the content of the index buffer
  101699. * @param updatable defines if the index buffer must be updatable
  101700. * @returns a new webGL buffer
  101701. */
  101702. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  101703. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  101704. /**
  101705. * Bind a webGL buffer to the webGL context
  101706. * @param buffer defines the buffer to bind
  101707. */
  101708. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  101709. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  101710. private bindBuffer;
  101711. /**
  101712. * update the bound buffer with the given data
  101713. * @param data defines the data to update
  101714. */
  101715. updateArrayBuffer(data: Float32Array): void;
  101716. private _vertexAttribPointer;
  101717. private _bindIndexBufferWithCache;
  101718. private _bindVertexBuffersAttributes;
  101719. /**
  101720. * Records a vertex array object
  101721. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101722. * @param vertexBuffers defines the list of vertex buffers to store
  101723. * @param indexBuffer defines the index buffer to store
  101724. * @param effect defines the effect to store
  101725. * @returns the new vertex array object
  101726. */
  101727. recordVertexArrayObject(vertexBuffers: {
  101728. [key: string]: VertexBuffer;
  101729. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  101730. /**
  101731. * Bind a specific vertex array object
  101732. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101733. * @param vertexArrayObject defines the vertex array object to bind
  101734. * @param indexBuffer defines the index buffer to bind
  101735. */
  101736. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  101737. /**
  101738. * Bind webGl buffers directly to the webGL context
  101739. * @param vertexBuffer defines the vertex buffer to bind
  101740. * @param indexBuffer defines the index buffer to bind
  101741. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  101742. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  101743. * @param effect defines the effect associated with the vertex buffer
  101744. */
  101745. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  101746. private _unbindVertexArrayObject;
  101747. /**
  101748. * Bind a list of vertex buffers to the webGL context
  101749. * @param vertexBuffers defines the list of vertex buffers to bind
  101750. * @param indexBuffer defines the index buffer to bind
  101751. * @param effect defines the effect associated with the vertex buffers
  101752. */
  101753. bindBuffers(vertexBuffers: {
  101754. [key: string]: Nullable<VertexBuffer>;
  101755. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  101756. /**
  101757. * Unbind all instance attributes
  101758. */
  101759. unbindInstanceAttributes(): void;
  101760. /**
  101761. * Release and free the memory of a vertex array object
  101762. * @param vao defines the vertex array object to delete
  101763. */
  101764. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  101765. /** @hidden */
  101766. _releaseBuffer(buffer: DataBuffer): boolean;
  101767. protected _deleteBuffer(buffer: DataBuffer): void;
  101768. /**
  101769. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  101770. * @param instancesBuffer defines the webGL buffer to update and bind
  101771. * @param data defines the data to store in the buffer
  101772. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  101773. */
  101774. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  101775. /**
  101776. * Bind the content of a webGL buffer used with instanciation
  101777. * @param instancesBuffer defines the webGL buffer to bind
  101778. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  101779. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  101780. */
  101781. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  101782. /**
  101783. * Disable the instance attribute corresponding to the name in parameter
  101784. * @param name defines the name of the attribute to disable
  101785. */
  101786. disableInstanceAttributeByName(name: string): void;
  101787. /**
  101788. * Disable the instance attribute corresponding to the location in parameter
  101789. * @param attributeLocation defines the attribute location of the attribute to disable
  101790. */
  101791. disableInstanceAttribute(attributeLocation: number): void;
  101792. /**
  101793. * Disable the attribute corresponding to the location in parameter
  101794. * @param attributeLocation defines the attribute location of the attribute to disable
  101795. */
  101796. disableAttributeByIndex(attributeLocation: number): void;
  101797. /**
  101798. * Send a draw order
  101799. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101800. * @param indexStart defines the starting index
  101801. * @param indexCount defines the number of index to draw
  101802. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101803. */
  101804. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101805. /**
  101806. * Draw a list of points
  101807. * @param verticesStart defines the index of first vertex to draw
  101808. * @param verticesCount defines the count of vertices to draw
  101809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101810. */
  101811. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101812. /**
  101813. * Draw a list of unindexed primitives
  101814. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101815. * @param verticesStart defines the index of first vertex to draw
  101816. * @param verticesCount defines the count of vertices to draw
  101817. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101818. */
  101819. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101820. /**
  101821. * Draw a list of indexed primitives
  101822. * @param fillMode defines the primitive to use
  101823. * @param indexStart defines the starting index
  101824. * @param indexCount defines the number of index to draw
  101825. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101826. */
  101827. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101828. /**
  101829. * Draw a list of unindexed primitives
  101830. * @param fillMode defines the primitive to use
  101831. * @param verticesStart defines the index of first vertex to draw
  101832. * @param verticesCount defines the count of vertices to draw
  101833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101834. */
  101835. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101836. private _drawMode;
  101837. /** @hidden */
  101838. protected _reportDrawCall(): void;
  101839. /** @hidden */
  101840. _releaseEffect(effect: Effect): void;
  101841. /** @hidden */
  101842. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  101843. /**
  101844. * Create a new effect (used to store vertex/fragment shaders)
  101845. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  101846. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  101847. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  101848. * @param samplers defines an array of string used to represent textures
  101849. * @param defines defines the string containing the defines to use to compile the shaders
  101850. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  101851. * @param onCompiled defines a function to call when the effect creation is successful
  101852. * @param onError defines a function to call when the effect creation has failed
  101853. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  101854. * @returns the new Effect
  101855. */
  101856. 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;
  101857. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  101858. private _compileShader;
  101859. private _compileRawShader;
  101860. /**
  101861. * Directly creates a webGL program
  101862. * @param pipelineContext defines the pipeline context to attach to
  101863. * @param vertexCode defines the vertex shader code to use
  101864. * @param fragmentCode defines the fragment shader code to use
  101865. * @param context defines the webGL context to use (if not set, the current one will be used)
  101866. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101867. * @returns the new webGL program
  101868. */
  101869. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101870. /**
  101871. * Creates a webGL program
  101872. * @param pipelineContext defines the pipeline context to attach to
  101873. * @param vertexCode defines the vertex shader code to use
  101874. * @param fragmentCode defines the fragment shader code to use
  101875. * @param defines defines the string containing the defines to use to compile the shaders
  101876. * @param context defines the webGL context to use (if not set, the current one will be used)
  101877. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101878. * @returns the new webGL program
  101879. */
  101880. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101881. /**
  101882. * Creates a new pipeline context
  101883. * @returns the new pipeline
  101884. */
  101885. createPipelineContext(): IPipelineContext;
  101886. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101887. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  101888. /** @hidden */
  101889. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  101890. /** @hidden */
  101891. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  101892. /** @hidden */
  101893. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  101894. /**
  101895. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  101896. * @param pipelineContext defines the pipeline context to use
  101897. * @param uniformsNames defines the list of uniform names
  101898. * @returns an array of webGL uniform locations
  101899. */
  101900. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101901. /**
  101902. * Gets the lsit of active attributes for a given webGL program
  101903. * @param pipelineContext defines the pipeline context to use
  101904. * @param attributesNames defines the list of attribute names to get
  101905. * @returns an array of indices indicating the offset of each attribute
  101906. */
  101907. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101908. /**
  101909. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  101910. * @param effect defines the effect to activate
  101911. */
  101912. enableEffect(effect: Nullable<Effect>): void;
  101913. /**
  101914. * Set the value of an uniform to a number (int)
  101915. * @param uniform defines the webGL uniform location where to store the value
  101916. * @param value defines the int number to store
  101917. */
  101918. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  101919. /**
  101920. * Set the value of an uniform to an array of int32
  101921. * @param uniform defines the webGL uniform location where to store the value
  101922. * @param array defines the array of int32 to store
  101923. */
  101924. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101925. /**
  101926. * Set the value of an uniform to an array of int32 (stored as vec2)
  101927. * @param uniform defines the webGL uniform location where to store the value
  101928. * @param array defines the array of int32 to store
  101929. */
  101930. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101931. /**
  101932. * Set the value of an uniform to an array of int32 (stored as vec3)
  101933. * @param uniform defines the webGL uniform location where to store the value
  101934. * @param array defines the array of int32 to store
  101935. */
  101936. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101937. /**
  101938. * Set the value of an uniform to an array of int32 (stored as vec4)
  101939. * @param uniform defines the webGL uniform location where to store the value
  101940. * @param array defines the array of int32 to store
  101941. */
  101942. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  101943. /**
  101944. * Set the value of an uniform to an array of number
  101945. * @param uniform defines the webGL uniform location where to store the value
  101946. * @param array defines the array of number to store
  101947. */
  101948. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101949. /**
  101950. * Set the value of an uniform to an array of number (stored as vec2)
  101951. * @param uniform defines the webGL uniform location where to store the value
  101952. * @param array defines the array of number to store
  101953. */
  101954. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101955. /**
  101956. * Set the value of an uniform to an array of number (stored as vec3)
  101957. * @param uniform defines the webGL uniform location where to store the value
  101958. * @param array defines the array of number to store
  101959. */
  101960. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101961. /**
  101962. * Set the value of an uniform to an array of number (stored as vec4)
  101963. * @param uniform defines the webGL uniform location where to store the value
  101964. * @param array defines the array of number to store
  101965. */
  101966. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  101967. /**
  101968. * Set the value of an uniform to an array of float32 (stored as matrices)
  101969. * @param uniform defines the webGL uniform location where to store the value
  101970. * @param matrices defines the array of float32 to store
  101971. */
  101972. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  101973. /**
  101974. * Set the value of an uniform to a matrix (3x3)
  101975. * @param uniform defines the webGL uniform location where to store the value
  101976. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  101977. */
  101978. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  101979. /**
  101980. * Set the value of an uniform to a matrix (2x2)
  101981. * @param uniform defines the webGL uniform location where to store the value
  101982. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  101983. */
  101984. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  101985. /**
  101986. * Set the value of an uniform to a number (float)
  101987. * @param uniform defines the webGL uniform location where to store the value
  101988. * @param value defines the float number to store
  101989. */
  101990. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  101991. /**
  101992. * Set the value of an uniform to a vec2
  101993. * @param uniform defines the webGL uniform location where to store the value
  101994. * @param x defines the 1st component of the value
  101995. * @param y defines the 2nd component of the value
  101996. */
  101997. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  101998. /**
  101999. * Set the value of an uniform to a vec3
  102000. * @param uniform defines the webGL uniform location where to store the value
  102001. * @param x defines the 1st component of the value
  102002. * @param y defines the 2nd component of the value
  102003. * @param z defines the 3rd component of the value
  102004. */
  102005. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  102006. /**
  102007. * Set the value of an uniform to a vec4
  102008. * @param uniform defines the webGL uniform location where to store the value
  102009. * @param x defines the 1st component of the value
  102010. * @param y defines the 2nd component of the value
  102011. * @param z defines the 3rd component of the value
  102012. * @param w defines the 4th component of the value
  102013. */
  102014. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  102015. /**
  102016. * Apply all cached states (depth, culling, stencil and alpha)
  102017. */
  102018. applyStates(): void;
  102019. /**
  102020. * Enable or disable color writing
  102021. * @param enable defines the state to set
  102022. */
  102023. setColorWrite(enable: boolean): void;
  102024. /**
  102025. * Gets a boolean indicating if color writing is enabled
  102026. * @returns the current color writing state
  102027. */
  102028. getColorWrite(): boolean;
  102029. /**
  102030. * Gets the depth culling state manager
  102031. */
  102032. get depthCullingState(): DepthCullingState;
  102033. /**
  102034. * Gets the alpha state manager
  102035. */
  102036. get alphaState(): AlphaState;
  102037. /**
  102038. * Gets the stencil state manager
  102039. */
  102040. get stencilState(): StencilState;
  102041. /**
  102042. * Clears the list of texture accessible through engine.
  102043. * This can help preventing texture load conflict due to name collision.
  102044. */
  102045. clearInternalTexturesCache(): void;
  102046. /**
  102047. * Force the entire cache to be cleared
  102048. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  102049. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  102050. */
  102051. wipeCaches(bruteForce?: boolean): void;
  102052. /** @hidden */
  102053. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  102054. min: number;
  102055. mag: number;
  102056. };
  102057. /** @hidden */
  102058. _createTexture(): WebGLTexture;
  102059. /**
  102060. * Usually called from Texture.ts.
  102061. * Passed information to create a WebGLTexture
  102062. * @param urlArg defines a value which contains one of the following:
  102063. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  102064. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  102065. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  102066. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  102067. * @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)
  102068. * @param scene needed for loading to the correct scene
  102069. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  102070. * @param onLoad optional callback to be called upon successful completion
  102071. * @param onError optional callback to be called upon failure
  102072. * @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
  102073. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  102074. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  102075. * @param forcedExtension defines the extension to use to pick the right loader
  102076. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  102077. * @param mimeType defines an optional mime type
  102078. * @returns a InternalTexture for assignment back into BABYLON.Texture
  102079. */
  102080. 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;
  102081. /**
  102082. * @hidden
  102083. */
  102084. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102085. /**
  102086. * Creates a raw texture
  102087. * @param data defines the data to store in the texture
  102088. * @param width defines the width of the texture
  102089. * @param height defines the height of the texture
  102090. * @param format defines the format of the data
  102091. * @param generateMipMaps defines if the engine should generate the mip levels
  102092. * @param invertY defines if data must be stored with Y axis inverted
  102093. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  102094. * @param compression defines the compression used (null by default)
  102095. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102096. * @returns the raw texture inside an InternalTexture
  102097. */
  102098. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  102099. /**
  102100. * Creates a new raw cube texture
  102101. * @param data defines the array of data to use to create each face
  102102. * @param size defines the size of the textures
  102103. * @param format defines the format of the data
  102104. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102105. * @param generateMipMaps defines if the engine should generate the mip levels
  102106. * @param invertY defines if data must be stored with Y axis inverted
  102107. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102108. * @param compression defines the compression used (null by default)
  102109. * @returns the cube texture as an InternalTexture
  102110. */
  102111. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  102112. /**
  102113. * Creates a new raw 3D texture
  102114. * @param data defines the data used to create the texture
  102115. * @param width defines the width of the texture
  102116. * @param height defines the height of the texture
  102117. * @param depth defines the depth of the texture
  102118. * @param format defines the format of the texture
  102119. * @param generateMipMaps defines if the engine must generate mip levels
  102120. * @param invertY defines if data must be stored with Y axis inverted
  102121. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102122. * @param compression defines the compressed used (can be null)
  102123. * @param textureType defines the compressed used (can be null)
  102124. * @returns a new raw 3D texture (stored in an InternalTexture)
  102125. */
  102126. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102127. /**
  102128. * Creates a new raw 2D array texture
  102129. * @param data defines the data used to create the texture
  102130. * @param width defines the width of the texture
  102131. * @param height defines the height of the texture
  102132. * @param depth defines the number of layers of the texture
  102133. * @param format defines the format of the texture
  102134. * @param generateMipMaps defines if the engine must generate mip levels
  102135. * @param invertY defines if data must be stored with Y axis inverted
  102136. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102137. * @param compression defines the compressed used (can be null)
  102138. * @param textureType defines the compressed used (can be null)
  102139. * @returns a new raw 2D array texture (stored in an InternalTexture)
  102140. */
  102141. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102142. private _unpackFlipYCached;
  102143. /**
  102144. * In case you are sharing the context with other applications, it might
  102145. * be interested to not cache the unpack flip y state to ensure a consistent
  102146. * value would be set.
  102147. */
  102148. enableUnpackFlipYCached: boolean;
  102149. /** @hidden */
  102150. _unpackFlipY(value: boolean): void;
  102151. /** @hidden */
  102152. _getUnpackAlignement(): number;
  102153. private _getTextureTarget;
  102154. /**
  102155. * Update the sampling mode of a given texture
  102156. * @param samplingMode defines the required sampling mode
  102157. * @param texture defines the texture to update
  102158. * @param generateMipMaps defines whether to generate mipmaps for the texture
  102159. */
  102160. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  102161. /**
  102162. * Update the sampling mode of a given texture
  102163. * @param texture defines the texture to update
  102164. * @param wrapU defines the texture wrap mode of the u coordinates
  102165. * @param wrapV defines the texture wrap mode of the v coordinates
  102166. * @param wrapR defines the texture wrap mode of the r coordinates
  102167. */
  102168. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  102169. /** @hidden */
  102170. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  102171. width: number;
  102172. height: number;
  102173. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  102174. /** @hidden */
  102175. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102176. /** @hidden */
  102177. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  102178. /** @hidden */
  102179. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102180. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  102181. private _prepareWebGLTexture;
  102182. /** @hidden */
  102183. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  102184. private _getDepthStencilBuffer;
  102185. /** @hidden */
  102186. _releaseFramebufferObjects(texture: InternalTexture): void;
  102187. /** @hidden */
  102188. _releaseTexture(texture: InternalTexture): void;
  102189. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  102190. protected _setProgram(program: WebGLProgram): void;
  102191. protected _boundUniforms: {
  102192. [key: number]: WebGLUniformLocation;
  102193. };
  102194. /**
  102195. * Binds an effect to the webGL context
  102196. * @param effect defines the effect to bind
  102197. */
  102198. bindSamplers(effect: Effect): void;
  102199. private _activateCurrentTexture;
  102200. /** @hidden */
  102201. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  102202. /** @hidden */
  102203. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  102204. /**
  102205. * Unbind all textures from the webGL context
  102206. */
  102207. unbindAllTextures(): void;
  102208. /**
  102209. * Sets a texture to the according uniform.
  102210. * @param channel The texture channel
  102211. * @param uniform The uniform to set
  102212. * @param texture The texture to apply
  102213. */
  102214. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  102215. private _bindSamplerUniformToChannel;
  102216. private _getTextureWrapMode;
  102217. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  102218. /**
  102219. * Sets an array of texture to the webGL context
  102220. * @param channel defines the channel where the texture array must be set
  102221. * @param uniform defines the associated uniform location
  102222. * @param textures defines the array of textures to bind
  102223. */
  102224. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  102225. /** @hidden */
  102226. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  102227. private _setTextureParameterFloat;
  102228. private _setTextureParameterInteger;
  102229. /**
  102230. * Unbind all vertex attributes from the webGL context
  102231. */
  102232. unbindAllAttributes(): void;
  102233. /**
  102234. * 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
  102235. */
  102236. releaseEffects(): void;
  102237. /**
  102238. * Dispose and release all associated resources
  102239. */
  102240. dispose(): void;
  102241. /**
  102242. * Attach a new callback raised when context lost event is fired
  102243. * @param callback defines the callback to call
  102244. */
  102245. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102246. /**
  102247. * Attach a new callback raised when context restored event is fired
  102248. * @param callback defines the callback to call
  102249. */
  102250. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102251. /**
  102252. * Get the current error code of the webGL context
  102253. * @returns the error code
  102254. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  102255. */
  102256. getError(): number;
  102257. private _canRenderToFloatFramebuffer;
  102258. private _canRenderToHalfFloatFramebuffer;
  102259. private _canRenderToFramebuffer;
  102260. /** @hidden */
  102261. _getWebGLTextureType(type: number): number;
  102262. /** @hidden */
  102263. _getInternalFormat(format: number): number;
  102264. /** @hidden */
  102265. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  102266. /** @hidden */
  102267. _getRGBAMultiSampleBufferFormat(type: number): number;
  102268. /** @hidden */
  102269. _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;
  102270. /**
  102271. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102272. * @param x defines the x coordinate of the rectangle where pixels must be read
  102273. * @param y defines the y coordinate of the rectangle where pixels must be read
  102274. * @param width defines the width of the rectangle where pixels must be read
  102275. * @param height defines the height of the rectangle where pixels must be read
  102276. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  102277. * @returns a Uint8Array containing RGBA colors
  102278. */
  102279. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  102280. private static _isSupported;
  102281. /**
  102282. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  102283. * @returns true if the engine can be created
  102284. * @ignorenaming
  102285. */
  102286. static isSupported(): boolean;
  102287. /**
  102288. * Find the next highest power of two.
  102289. * @param x Number to start search from.
  102290. * @return Next highest power of two.
  102291. */
  102292. static CeilingPOT(x: number): number;
  102293. /**
  102294. * Find the next lowest power of two.
  102295. * @param x Number to start search from.
  102296. * @return Next lowest power of two.
  102297. */
  102298. static FloorPOT(x: number): number;
  102299. /**
  102300. * Find the nearest power of two.
  102301. * @param x Number to start search from.
  102302. * @return Next nearest power of two.
  102303. */
  102304. static NearestPOT(x: number): number;
  102305. /**
  102306. * Get the closest exponent of two
  102307. * @param value defines the value to approximate
  102308. * @param max defines the maximum value to return
  102309. * @param mode defines how to define the closest value
  102310. * @returns closest exponent of two of the given value
  102311. */
  102312. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  102313. /**
  102314. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  102315. * @param func - the function to be called
  102316. * @param requester - the object that will request the next frame. Falls back to window.
  102317. * @returns frame number
  102318. */
  102319. static QueueNewFrame(func: () => void, requester?: any): number;
  102320. /**
  102321. * Gets host document
  102322. * @returns the host document object
  102323. */
  102324. getHostDocument(): Nullable<Document>;
  102325. }
  102326. }
  102327. declare module BABYLON {
  102328. /**
  102329. * Class representing spherical harmonics coefficients to the 3rd degree
  102330. */
  102331. export class SphericalHarmonics {
  102332. /**
  102333. * Defines whether or not the harmonics have been prescaled for rendering.
  102334. */
  102335. preScaled: boolean;
  102336. /**
  102337. * The l0,0 coefficients of the spherical harmonics
  102338. */
  102339. l00: Vector3;
  102340. /**
  102341. * The l1,-1 coefficients of the spherical harmonics
  102342. */
  102343. l1_1: Vector3;
  102344. /**
  102345. * The l1,0 coefficients of the spherical harmonics
  102346. */
  102347. l10: Vector3;
  102348. /**
  102349. * The l1,1 coefficients of the spherical harmonics
  102350. */
  102351. l11: Vector3;
  102352. /**
  102353. * The l2,-2 coefficients of the spherical harmonics
  102354. */
  102355. l2_2: Vector3;
  102356. /**
  102357. * The l2,-1 coefficients of the spherical harmonics
  102358. */
  102359. l2_1: Vector3;
  102360. /**
  102361. * The l2,0 coefficients of the spherical harmonics
  102362. */
  102363. l20: Vector3;
  102364. /**
  102365. * The l2,1 coefficients of the spherical harmonics
  102366. */
  102367. l21: Vector3;
  102368. /**
  102369. * The l2,2 coefficients of the spherical harmonics
  102370. */
  102371. l22: Vector3;
  102372. /**
  102373. * Adds a light to the spherical harmonics
  102374. * @param direction the direction of the light
  102375. * @param color the color of the light
  102376. * @param deltaSolidAngle the delta solid angle of the light
  102377. */
  102378. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  102379. /**
  102380. * Scales the spherical harmonics by the given amount
  102381. * @param scale the amount to scale
  102382. */
  102383. scaleInPlace(scale: number): void;
  102384. /**
  102385. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  102386. *
  102387. * ```
  102388. * E_lm = A_l * L_lm
  102389. * ```
  102390. *
  102391. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  102392. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  102393. * the scaling factors are given in equation 9.
  102394. */
  102395. convertIncidentRadianceToIrradiance(): void;
  102396. /**
  102397. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  102398. *
  102399. * ```
  102400. * L = (1/pi) * E * rho
  102401. * ```
  102402. *
  102403. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  102404. */
  102405. convertIrradianceToLambertianRadiance(): void;
  102406. /**
  102407. * Integrates the reconstruction coefficients directly in to the SH preventing further
  102408. * required operations at run time.
  102409. *
  102410. * This is simply done by scaling back the SH with Ylm constants parameter.
  102411. * The trigonometric part being applied by the shader at run time.
  102412. */
  102413. preScaleForRendering(): void;
  102414. /**
  102415. * Constructs a spherical harmonics from an array.
  102416. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  102417. * @returns the spherical harmonics
  102418. */
  102419. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  102420. /**
  102421. * Gets the spherical harmonics from polynomial
  102422. * @param polynomial the spherical polynomial
  102423. * @returns the spherical harmonics
  102424. */
  102425. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  102426. }
  102427. /**
  102428. * Class representing spherical polynomial coefficients to the 3rd degree
  102429. */
  102430. export class SphericalPolynomial {
  102431. private _harmonics;
  102432. /**
  102433. * The spherical harmonics used to create the polynomials.
  102434. */
  102435. get preScaledHarmonics(): SphericalHarmonics;
  102436. /**
  102437. * The x coefficients of the spherical polynomial
  102438. */
  102439. x: Vector3;
  102440. /**
  102441. * The y coefficients of the spherical polynomial
  102442. */
  102443. y: Vector3;
  102444. /**
  102445. * The z coefficients of the spherical polynomial
  102446. */
  102447. z: Vector3;
  102448. /**
  102449. * The xx coefficients of the spherical polynomial
  102450. */
  102451. xx: Vector3;
  102452. /**
  102453. * The yy coefficients of the spherical polynomial
  102454. */
  102455. yy: Vector3;
  102456. /**
  102457. * The zz coefficients of the spherical polynomial
  102458. */
  102459. zz: Vector3;
  102460. /**
  102461. * The xy coefficients of the spherical polynomial
  102462. */
  102463. xy: Vector3;
  102464. /**
  102465. * The yz coefficients of the spherical polynomial
  102466. */
  102467. yz: Vector3;
  102468. /**
  102469. * The zx coefficients of the spherical polynomial
  102470. */
  102471. zx: Vector3;
  102472. /**
  102473. * Adds an ambient color to the spherical polynomial
  102474. * @param color the color to add
  102475. */
  102476. addAmbient(color: Color3): void;
  102477. /**
  102478. * Scales the spherical polynomial by the given amount
  102479. * @param scale the amount to scale
  102480. */
  102481. scaleInPlace(scale: number): void;
  102482. /**
  102483. * Gets the spherical polynomial from harmonics
  102484. * @param harmonics the spherical harmonics
  102485. * @returns the spherical polynomial
  102486. */
  102487. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  102488. /**
  102489. * Constructs a spherical polynomial from an array.
  102490. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  102491. * @returns the spherical polynomial
  102492. */
  102493. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  102494. }
  102495. }
  102496. declare module BABYLON {
  102497. /**
  102498. * Defines the source of the internal texture
  102499. */
  102500. export enum InternalTextureSource {
  102501. /**
  102502. * The source of the texture data is unknown
  102503. */
  102504. Unknown = 0,
  102505. /**
  102506. * Texture data comes from an URL
  102507. */
  102508. Url = 1,
  102509. /**
  102510. * Texture data is only used for temporary storage
  102511. */
  102512. Temp = 2,
  102513. /**
  102514. * Texture data comes from raw data (ArrayBuffer)
  102515. */
  102516. Raw = 3,
  102517. /**
  102518. * Texture content is dynamic (video or dynamic texture)
  102519. */
  102520. Dynamic = 4,
  102521. /**
  102522. * Texture content is generated by rendering to it
  102523. */
  102524. RenderTarget = 5,
  102525. /**
  102526. * Texture content is part of a multi render target process
  102527. */
  102528. MultiRenderTarget = 6,
  102529. /**
  102530. * Texture data comes from a cube data file
  102531. */
  102532. Cube = 7,
  102533. /**
  102534. * Texture data comes from a raw cube data
  102535. */
  102536. CubeRaw = 8,
  102537. /**
  102538. * Texture data come from a prefiltered cube data file
  102539. */
  102540. CubePrefiltered = 9,
  102541. /**
  102542. * Texture content is raw 3D data
  102543. */
  102544. Raw3D = 10,
  102545. /**
  102546. * Texture content is raw 2D array data
  102547. */
  102548. Raw2DArray = 11,
  102549. /**
  102550. * Texture content is a depth texture
  102551. */
  102552. Depth = 12,
  102553. /**
  102554. * Texture data comes from a raw cube data encoded with RGBD
  102555. */
  102556. CubeRawRGBD = 13
  102557. }
  102558. /**
  102559. * Class used to store data associated with WebGL texture data for the engine
  102560. * This class should not be used directly
  102561. */
  102562. export class InternalTexture {
  102563. /** @hidden */
  102564. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  102565. /**
  102566. * Defines if the texture is ready
  102567. */
  102568. isReady: boolean;
  102569. /**
  102570. * Defines if the texture is a cube texture
  102571. */
  102572. isCube: boolean;
  102573. /**
  102574. * Defines if the texture contains 3D data
  102575. */
  102576. is3D: boolean;
  102577. /**
  102578. * Defines if the texture contains 2D array data
  102579. */
  102580. is2DArray: boolean;
  102581. /**
  102582. * Defines if the texture contains multiview data
  102583. */
  102584. isMultiview: boolean;
  102585. /**
  102586. * Gets the URL used to load this texture
  102587. */
  102588. url: string;
  102589. /**
  102590. * Gets the sampling mode of the texture
  102591. */
  102592. samplingMode: number;
  102593. /**
  102594. * Gets a boolean indicating if the texture needs mipmaps generation
  102595. */
  102596. generateMipMaps: boolean;
  102597. /**
  102598. * Gets the number of samples used by the texture (WebGL2+ only)
  102599. */
  102600. samples: number;
  102601. /**
  102602. * Gets the type of the texture (int, float...)
  102603. */
  102604. type: number;
  102605. /**
  102606. * Gets the format of the texture (RGB, RGBA...)
  102607. */
  102608. format: number;
  102609. /**
  102610. * Observable called when the texture is loaded
  102611. */
  102612. onLoadedObservable: Observable<InternalTexture>;
  102613. /**
  102614. * Gets the width of the texture
  102615. */
  102616. width: number;
  102617. /**
  102618. * Gets the height of the texture
  102619. */
  102620. height: number;
  102621. /**
  102622. * Gets the depth of the texture
  102623. */
  102624. depth: number;
  102625. /**
  102626. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  102627. */
  102628. baseWidth: number;
  102629. /**
  102630. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  102631. */
  102632. baseHeight: number;
  102633. /**
  102634. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  102635. */
  102636. baseDepth: number;
  102637. /**
  102638. * Gets a boolean indicating if the texture is inverted on Y axis
  102639. */
  102640. invertY: boolean;
  102641. /** @hidden */
  102642. _invertVScale: boolean;
  102643. /** @hidden */
  102644. _associatedChannel: number;
  102645. /** @hidden */
  102646. _source: InternalTextureSource;
  102647. /** @hidden */
  102648. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102649. /** @hidden */
  102650. _bufferView: Nullable<ArrayBufferView>;
  102651. /** @hidden */
  102652. _bufferViewArray: Nullable<ArrayBufferView[]>;
  102653. /** @hidden */
  102654. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  102655. /** @hidden */
  102656. _size: number;
  102657. /** @hidden */
  102658. _extension: string;
  102659. /** @hidden */
  102660. _files: Nullable<string[]>;
  102661. /** @hidden */
  102662. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  102663. /** @hidden */
  102664. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  102665. /** @hidden */
  102666. _framebuffer: Nullable<WebGLFramebuffer>;
  102667. /** @hidden */
  102668. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  102669. /** @hidden */
  102670. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  102671. /** @hidden */
  102672. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  102673. /** @hidden */
  102674. _attachments: Nullable<number[]>;
  102675. /** @hidden */
  102676. _cachedCoordinatesMode: Nullable<number>;
  102677. /** @hidden */
  102678. _cachedWrapU: Nullable<number>;
  102679. /** @hidden */
  102680. _cachedWrapV: Nullable<number>;
  102681. /** @hidden */
  102682. _cachedWrapR: Nullable<number>;
  102683. /** @hidden */
  102684. _cachedAnisotropicFilteringLevel: Nullable<number>;
  102685. /** @hidden */
  102686. _isDisabled: boolean;
  102687. /** @hidden */
  102688. _compression: Nullable<string>;
  102689. /** @hidden */
  102690. _generateStencilBuffer: boolean;
  102691. /** @hidden */
  102692. _generateDepthBuffer: boolean;
  102693. /** @hidden */
  102694. _comparisonFunction: number;
  102695. /** @hidden */
  102696. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  102697. /** @hidden */
  102698. _lodGenerationScale: number;
  102699. /** @hidden */
  102700. _lodGenerationOffset: number;
  102701. /** @hidden */
  102702. _colorTextureArray: Nullable<WebGLTexture>;
  102703. /** @hidden */
  102704. _depthStencilTextureArray: Nullable<WebGLTexture>;
  102705. /** @hidden */
  102706. _lodTextureHigh: Nullable<BaseTexture>;
  102707. /** @hidden */
  102708. _lodTextureMid: Nullable<BaseTexture>;
  102709. /** @hidden */
  102710. _lodTextureLow: Nullable<BaseTexture>;
  102711. /** @hidden */
  102712. _isRGBD: boolean;
  102713. /** @hidden */
  102714. _linearSpecularLOD: boolean;
  102715. /** @hidden */
  102716. _irradianceTexture: Nullable<BaseTexture>;
  102717. /** @hidden */
  102718. _webGLTexture: Nullable<WebGLTexture>;
  102719. /** @hidden */
  102720. _references: number;
  102721. private _engine;
  102722. /**
  102723. * Gets the Engine the texture belongs to.
  102724. * @returns The babylon engine
  102725. */
  102726. getEngine(): ThinEngine;
  102727. /**
  102728. * Gets the data source type of the texture
  102729. */
  102730. get source(): InternalTextureSource;
  102731. /**
  102732. * Creates a new InternalTexture
  102733. * @param engine defines the engine to use
  102734. * @param source defines the type of data that will be used
  102735. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102736. */
  102737. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  102738. /**
  102739. * Increments the number of references (ie. the number of Texture that point to it)
  102740. */
  102741. incrementReferences(): void;
  102742. /**
  102743. * Change the size of the texture (not the size of the content)
  102744. * @param width defines the new width
  102745. * @param height defines the new height
  102746. * @param depth defines the new depth (1 by default)
  102747. */
  102748. updateSize(width: int, height: int, depth?: int): void;
  102749. /** @hidden */
  102750. _rebuild(): void;
  102751. /** @hidden */
  102752. _swapAndDie(target: InternalTexture): void;
  102753. /**
  102754. * Dispose the current allocated resources
  102755. */
  102756. dispose(): void;
  102757. }
  102758. }
  102759. declare module BABYLON {
  102760. /**
  102761. * Class used to work with sound analyzer using fast fourier transform (FFT)
  102762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102763. */
  102764. export class Analyser {
  102765. /**
  102766. * Gets or sets the smoothing
  102767. * @ignorenaming
  102768. */
  102769. SMOOTHING: number;
  102770. /**
  102771. * Gets or sets the FFT table size
  102772. * @ignorenaming
  102773. */
  102774. FFT_SIZE: number;
  102775. /**
  102776. * Gets or sets the bar graph amplitude
  102777. * @ignorenaming
  102778. */
  102779. BARGRAPHAMPLITUDE: number;
  102780. /**
  102781. * Gets or sets the position of the debug canvas
  102782. * @ignorenaming
  102783. */
  102784. DEBUGCANVASPOS: {
  102785. x: number;
  102786. y: number;
  102787. };
  102788. /**
  102789. * Gets or sets the debug canvas size
  102790. * @ignorenaming
  102791. */
  102792. DEBUGCANVASSIZE: {
  102793. width: number;
  102794. height: number;
  102795. };
  102796. private _byteFreqs;
  102797. private _byteTime;
  102798. private _floatFreqs;
  102799. private _webAudioAnalyser;
  102800. private _debugCanvas;
  102801. private _debugCanvasContext;
  102802. private _scene;
  102803. private _registerFunc;
  102804. private _audioEngine;
  102805. /**
  102806. * Creates a new analyser
  102807. * @param scene defines hosting scene
  102808. */
  102809. constructor(scene: Scene);
  102810. /**
  102811. * Get the number of data values you will have to play with for the visualization
  102812. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  102813. * @returns a number
  102814. */
  102815. getFrequencyBinCount(): number;
  102816. /**
  102817. * Gets the current frequency data as a byte array
  102818. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102819. * @returns a Uint8Array
  102820. */
  102821. getByteFrequencyData(): Uint8Array;
  102822. /**
  102823. * Gets the current waveform as a byte array
  102824. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  102825. * @returns a Uint8Array
  102826. */
  102827. getByteTimeDomainData(): Uint8Array;
  102828. /**
  102829. * Gets the current frequency data as a float array
  102830. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102831. * @returns a Float32Array
  102832. */
  102833. getFloatFrequencyData(): Float32Array;
  102834. /**
  102835. * Renders the debug canvas
  102836. */
  102837. drawDebugCanvas(): void;
  102838. /**
  102839. * Stops rendering the debug canvas and removes it
  102840. */
  102841. stopDebugCanvas(): void;
  102842. /**
  102843. * Connects two audio nodes
  102844. * @param inputAudioNode defines first node to connect
  102845. * @param outputAudioNode defines second node to connect
  102846. */
  102847. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  102848. /**
  102849. * Releases all associated resources
  102850. */
  102851. dispose(): void;
  102852. }
  102853. }
  102854. declare module BABYLON {
  102855. /**
  102856. * This represents an audio engine and it is responsible
  102857. * to play, synchronize and analyse sounds throughout the application.
  102858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102859. */
  102860. export interface IAudioEngine extends IDisposable {
  102861. /**
  102862. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102863. */
  102864. readonly canUseWebAudio: boolean;
  102865. /**
  102866. * Gets the current AudioContext if available.
  102867. */
  102868. readonly audioContext: Nullable<AudioContext>;
  102869. /**
  102870. * The master gain node defines the global audio volume of your audio engine.
  102871. */
  102872. readonly masterGain: GainNode;
  102873. /**
  102874. * Gets whether or not mp3 are supported by your browser.
  102875. */
  102876. readonly isMP3supported: boolean;
  102877. /**
  102878. * Gets whether or not ogg are supported by your browser.
  102879. */
  102880. readonly isOGGsupported: boolean;
  102881. /**
  102882. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102883. * @ignoreNaming
  102884. */
  102885. WarnedWebAudioUnsupported: boolean;
  102886. /**
  102887. * Defines if the audio engine relies on a custom unlocked button.
  102888. * In this case, the embedded button will not be displayed.
  102889. */
  102890. useCustomUnlockedButton: boolean;
  102891. /**
  102892. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  102893. */
  102894. readonly unlocked: boolean;
  102895. /**
  102896. * Event raised when audio has been unlocked on the browser.
  102897. */
  102898. onAudioUnlockedObservable: Observable<AudioEngine>;
  102899. /**
  102900. * Event raised when audio has been locked on the browser.
  102901. */
  102902. onAudioLockedObservable: Observable<AudioEngine>;
  102903. /**
  102904. * Flags the audio engine in Locked state.
  102905. * This happens due to new browser policies preventing audio to autoplay.
  102906. */
  102907. lock(): void;
  102908. /**
  102909. * Unlocks the audio engine once a user action has been done on the dom.
  102910. * This is helpful to resume play once browser policies have been satisfied.
  102911. */
  102912. unlock(): void;
  102913. }
  102914. /**
  102915. * This represents the default audio engine used in babylon.
  102916. * It is responsible to play, synchronize and analyse sounds throughout the application.
  102917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102918. */
  102919. export class AudioEngine implements IAudioEngine {
  102920. private _audioContext;
  102921. private _audioContextInitialized;
  102922. private _muteButton;
  102923. private _hostElement;
  102924. /**
  102925. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102926. */
  102927. canUseWebAudio: boolean;
  102928. /**
  102929. * The master gain node defines the global audio volume of your audio engine.
  102930. */
  102931. masterGain: GainNode;
  102932. /**
  102933. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102934. * @ignoreNaming
  102935. */
  102936. WarnedWebAudioUnsupported: boolean;
  102937. /**
  102938. * Gets whether or not mp3 are supported by your browser.
  102939. */
  102940. isMP3supported: boolean;
  102941. /**
  102942. * Gets whether or not ogg are supported by your browser.
  102943. */
  102944. isOGGsupported: boolean;
  102945. /**
  102946. * Gets whether audio has been unlocked on the device.
  102947. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  102948. * a user interaction has happened.
  102949. */
  102950. unlocked: boolean;
  102951. /**
  102952. * Defines if the audio engine relies on a custom unlocked button.
  102953. * In this case, the embedded button will not be displayed.
  102954. */
  102955. useCustomUnlockedButton: boolean;
  102956. /**
  102957. * Event raised when audio has been unlocked on the browser.
  102958. */
  102959. onAudioUnlockedObservable: Observable<AudioEngine>;
  102960. /**
  102961. * Event raised when audio has been locked on the browser.
  102962. */
  102963. onAudioLockedObservable: Observable<AudioEngine>;
  102964. /**
  102965. * Gets the current AudioContext if available.
  102966. */
  102967. get audioContext(): Nullable<AudioContext>;
  102968. private _connectedAnalyser;
  102969. /**
  102970. * Instantiates a new audio engine.
  102971. *
  102972. * There should be only one per page as some browsers restrict the number
  102973. * of audio contexts you can create.
  102974. * @param hostElement defines the host element where to display the mute icon if necessary
  102975. */
  102976. constructor(hostElement?: Nullable<HTMLElement>);
  102977. /**
  102978. * Flags the audio engine in Locked state.
  102979. * This happens due to new browser policies preventing audio to autoplay.
  102980. */
  102981. lock(): void;
  102982. /**
  102983. * Unlocks the audio engine once a user action has been done on the dom.
  102984. * This is helpful to resume play once browser policies have been satisfied.
  102985. */
  102986. unlock(): void;
  102987. private _resumeAudioContext;
  102988. private _initializeAudioContext;
  102989. private _tryToRun;
  102990. private _triggerRunningState;
  102991. private _triggerSuspendedState;
  102992. private _displayMuteButton;
  102993. private _moveButtonToTopLeft;
  102994. private _onResize;
  102995. private _hideMuteButton;
  102996. /**
  102997. * Destroy and release the resources associated with the audio ccontext.
  102998. */
  102999. dispose(): void;
  103000. /**
  103001. * Gets the global volume sets on the master gain.
  103002. * @returns the global volume if set or -1 otherwise
  103003. */
  103004. getGlobalVolume(): number;
  103005. /**
  103006. * Sets the global volume of your experience (sets on the master gain).
  103007. * @param newVolume Defines the new global volume of the application
  103008. */
  103009. setGlobalVolume(newVolume: number): void;
  103010. /**
  103011. * Connect the audio engine to an audio analyser allowing some amazing
  103012. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103013. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103014. * @param analyser The analyser to connect to the engine
  103015. */
  103016. connectToAnalyser(analyser: Analyser): void;
  103017. }
  103018. }
  103019. declare module BABYLON {
  103020. /**
  103021. * Interface used to present a loading screen while loading a scene
  103022. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103023. */
  103024. export interface ILoadingScreen {
  103025. /**
  103026. * Function called to display the loading screen
  103027. */
  103028. displayLoadingUI: () => void;
  103029. /**
  103030. * Function called to hide the loading screen
  103031. */
  103032. hideLoadingUI: () => void;
  103033. /**
  103034. * Gets or sets the color to use for the background
  103035. */
  103036. loadingUIBackgroundColor: string;
  103037. /**
  103038. * Gets or sets the text to display while loading
  103039. */
  103040. loadingUIText: string;
  103041. }
  103042. /**
  103043. * Class used for the default loading screen
  103044. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103045. */
  103046. export class DefaultLoadingScreen implements ILoadingScreen {
  103047. private _renderingCanvas;
  103048. private _loadingText;
  103049. private _loadingDivBackgroundColor;
  103050. private _loadingDiv;
  103051. private _loadingTextDiv;
  103052. /** Gets or sets the logo url to use for the default loading screen */
  103053. static DefaultLogoUrl: string;
  103054. /** Gets or sets the spinner url to use for the default loading screen */
  103055. static DefaultSpinnerUrl: string;
  103056. /**
  103057. * Creates a new default loading screen
  103058. * @param _renderingCanvas defines the canvas used to render the scene
  103059. * @param _loadingText defines the default text to display
  103060. * @param _loadingDivBackgroundColor defines the default background color
  103061. */
  103062. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  103063. /**
  103064. * Function called to display the loading screen
  103065. */
  103066. displayLoadingUI(): void;
  103067. /**
  103068. * Function called to hide the loading screen
  103069. */
  103070. hideLoadingUI(): void;
  103071. /**
  103072. * Gets or sets the text to display while loading
  103073. */
  103074. set loadingUIText(text: string);
  103075. get loadingUIText(): string;
  103076. /**
  103077. * Gets or sets the color to use for the background
  103078. */
  103079. get loadingUIBackgroundColor(): string;
  103080. set loadingUIBackgroundColor(color: string);
  103081. private _resizeLoadingUI;
  103082. }
  103083. }
  103084. declare module BABYLON {
  103085. /**
  103086. * Interface for any object that can request an animation frame
  103087. */
  103088. export interface ICustomAnimationFrameRequester {
  103089. /**
  103090. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  103091. */
  103092. renderFunction?: Function;
  103093. /**
  103094. * Called to request the next frame to render to
  103095. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  103096. */
  103097. requestAnimationFrame: Function;
  103098. /**
  103099. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  103100. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  103101. */
  103102. requestID?: number;
  103103. }
  103104. }
  103105. declare module BABYLON {
  103106. /**
  103107. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  103108. */
  103109. export class PerformanceMonitor {
  103110. private _enabled;
  103111. private _rollingFrameTime;
  103112. private _lastFrameTimeMs;
  103113. /**
  103114. * constructor
  103115. * @param frameSampleSize The number of samples required to saturate the sliding window
  103116. */
  103117. constructor(frameSampleSize?: number);
  103118. /**
  103119. * Samples current frame
  103120. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  103121. */
  103122. sampleFrame(timeMs?: number): void;
  103123. /**
  103124. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103125. */
  103126. get averageFrameTime(): number;
  103127. /**
  103128. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103129. */
  103130. get averageFrameTimeVariance(): number;
  103131. /**
  103132. * Returns the frame time of the most recent frame
  103133. */
  103134. get instantaneousFrameTime(): number;
  103135. /**
  103136. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  103137. */
  103138. get averageFPS(): number;
  103139. /**
  103140. * Returns the average framerate in frames per second using the most recent frame time
  103141. */
  103142. get instantaneousFPS(): number;
  103143. /**
  103144. * Returns true if enough samples have been taken to completely fill the sliding window
  103145. */
  103146. get isSaturated(): boolean;
  103147. /**
  103148. * Enables contributions to the sliding window sample set
  103149. */
  103150. enable(): void;
  103151. /**
  103152. * Disables contributions to the sliding window sample set
  103153. * Samples will not be interpolated over the disabled period
  103154. */
  103155. disable(): void;
  103156. /**
  103157. * Returns true if sampling is enabled
  103158. */
  103159. get isEnabled(): boolean;
  103160. /**
  103161. * Resets performance monitor
  103162. */
  103163. reset(): void;
  103164. }
  103165. /**
  103166. * RollingAverage
  103167. *
  103168. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  103169. */
  103170. export class RollingAverage {
  103171. /**
  103172. * Current average
  103173. */
  103174. average: number;
  103175. /**
  103176. * Current variance
  103177. */
  103178. variance: number;
  103179. protected _samples: Array<number>;
  103180. protected _sampleCount: number;
  103181. protected _pos: number;
  103182. protected _m2: number;
  103183. /**
  103184. * constructor
  103185. * @param length The number of samples required to saturate the sliding window
  103186. */
  103187. constructor(length: number);
  103188. /**
  103189. * Adds a sample to the sample set
  103190. * @param v The sample value
  103191. */
  103192. add(v: number): void;
  103193. /**
  103194. * Returns previously added values or null if outside of history or outside the sliding window domain
  103195. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  103196. * @return Value previously recorded with add() or null if outside of range
  103197. */
  103198. history(i: number): number;
  103199. /**
  103200. * Returns true if enough samples have been taken to completely fill the sliding window
  103201. * @return true if sample-set saturated
  103202. */
  103203. isSaturated(): boolean;
  103204. /**
  103205. * Resets the rolling average (equivalent to 0 samples taken so far)
  103206. */
  103207. reset(): void;
  103208. /**
  103209. * Wraps a value around the sample range boundaries
  103210. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  103211. * @return Wrapped position in sample range
  103212. */
  103213. protected _wrapPosition(i: number): number;
  103214. }
  103215. }
  103216. declare module BABYLON {
  103217. /**
  103218. * This class is used to track a performance counter which is number based.
  103219. * The user has access to many properties which give statistics of different nature.
  103220. *
  103221. * The implementer can track two kinds of Performance Counter: time and count.
  103222. * 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.
  103223. * 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.
  103224. */
  103225. export class PerfCounter {
  103226. /**
  103227. * Gets or sets a global boolean to turn on and off all the counters
  103228. */
  103229. static Enabled: boolean;
  103230. /**
  103231. * Returns the smallest value ever
  103232. */
  103233. get min(): number;
  103234. /**
  103235. * Returns the biggest value ever
  103236. */
  103237. get max(): number;
  103238. /**
  103239. * Returns the average value since the performance counter is running
  103240. */
  103241. get average(): number;
  103242. /**
  103243. * Returns the average value of the last second the counter was monitored
  103244. */
  103245. get lastSecAverage(): number;
  103246. /**
  103247. * Returns the current value
  103248. */
  103249. get current(): number;
  103250. /**
  103251. * Gets the accumulated total
  103252. */
  103253. get total(): number;
  103254. /**
  103255. * Gets the total value count
  103256. */
  103257. get count(): number;
  103258. /**
  103259. * Creates a new counter
  103260. */
  103261. constructor();
  103262. /**
  103263. * Call this method to start monitoring a new frame.
  103264. * 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.
  103265. */
  103266. fetchNewFrame(): void;
  103267. /**
  103268. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  103269. * @param newCount the count value to add to the monitored count
  103270. * @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.
  103271. */
  103272. addCount(newCount: number, fetchResult: boolean): void;
  103273. /**
  103274. * Start monitoring this performance counter
  103275. */
  103276. beginMonitoring(): void;
  103277. /**
  103278. * Compute the time lapsed since the previous beginMonitoring() call.
  103279. * @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
  103280. */
  103281. endMonitoring(newFrame?: boolean): void;
  103282. private _fetchResult;
  103283. private _startMonitoringTime;
  103284. private _min;
  103285. private _max;
  103286. private _average;
  103287. private _current;
  103288. private _totalValueCount;
  103289. private _totalAccumulated;
  103290. private _lastSecAverage;
  103291. private _lastSecAccumulated;
  103292. private _lastSecTime;
  103293. private _lastSecValueCount;
  103294. }
  103295. }
  103296. declare module BABYLON {
  103297. interface ThinEngine {
  103298. /**
  103299. * Sets alpha constants used by some alpha blending modes
  103300. * @param r defines the red component
  103301. * @param g defines the green component
  103302. * @param b defines the blue component
  103303. * @param a defines the alpha component
  103304. */
  103305. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  103306. /**
  103307. * Sets the current alpha mode
  103308. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  103309. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  103310. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103311. */
  103312. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  103313. /**
  103314. * Gets the current alpha mode
  103315. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103316. * @returns the current alpha mode
  103317. */
  103318. getAlphaMode(): number;
  103319. /**
  103320. * Sets the current alpha equation
  103321. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  103322. */
  103323. setAlphaEquation(equation: number): void;
  103324. /**
  103325. * Gets the current alpha equation.
  103326. * @returns the current alpha equation
  103327. */
  103328. getAlphaEquation(): number;
  103329. }
  103330. }
  103331. declare module BABYLON {
  103332. /**
  103333. * Defines the interface used by display changed events
  103334. */
  103335. export interface IDisplayChangedEventArgs {
  103336. /** Gets the vrDisplay object (if any) */
  103337. vrDisplay: Nullable<any>;
  103338. /** Gets a boolean indicating if webVR is supported */
  103339. vrSupported: boolean;
  103340. }
  103341. /**
  103342. * Defines the interface used by objects containing a viewport (like a camera)
  103343. */
  103344. interface IViewportOwnerLike {
  103345. /**
  103346. * Gets or sets the viewport
  103347. */
  103348. viewport: IViewportLike;
  103349. }
  103350. /**
  103351. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  103352. */
  103353. export class Engine extends ThinEngine {
  103354. /** Defines that alpha blending is disabled */
  103355. static readonly ALPHA_DISABLE: number;
  103356. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  103357. static readonly ALPHA_ADD: number;
  103358. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  103359. static readonly ALPHA_COMBINE: number;
  103360. /** Defines that alpha blending to DEST - SRC * DEST */
  103361. static readonly ALPHA_SUBTRACT: number;
  103362. /** Defines that alpha blending to SRC * DEST */
  103363. static readonly ALPHA_MULTIPLY: number;
  103364. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  103365. static readonly ALPHA_MAXIMIZED: number;
  103366. /** Defines that alpha blending to SRC + DEST */
  103367. static readonly ALPHA_ONEONE: number;
  103368. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  103369. static readonly ALPHA_PREMULTIPLIED: number;
  103370. /**
  103371. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  103372. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  103373. */
  103374. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  103375. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  103376. static readonly ALPHA_INTERPOLATE: number;
  103377. /**
  103378. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  103379. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  103380. */
  103381. static readonly ALPHA_SCREENMODE: number;
  103382. /** Defines that the ressource is not delayed*/
  103383. static readonly DELAYLOADSTATE_NONE: number;
  103384. /** Defines that the ressource was successfully delay loaded */
  103385. static readonly DELAYLOADSTATE_LOADED: number;
  103386. /** Defines that the ressource is currently delay loading */
  103387. static readonly DELAYLOADSTATE_LOADING: number;
  103388. /** Defines that the ressource is delayed and has not started loading */
  103389. static readonly DELAYLOADSTATE_NOTLOADED: number;
  103390. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  103391. static readonly NEVER: number;
  103392. /** 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 */
  103393. static readonly ALWAYS: number;
  103394. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  103395. static readonly LESS: number;
  103396. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  103397. static readonly EQUAL: number;
  103398. /** 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 */
  103399. static readonly LEQUAL: number;
  103400. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  103401. static readonly GREATER: number;
  103402. /** 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 */
  103403. static readonly GEQUAL: number;
  103404. /** 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 */
  103405. static readonly NOTEQUAL: number;
  103406. /** Passed to stencilOperation to specify that stencil value must be kept */
  103407. static readonly KEEP: number;
  103408. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103409. static readonly REPLACE: number;
  103410. /** Passed to stencilOperation to specify that stencil value must be incremented */
  103411. static readonly INCR: number;
  103412. /** Passed to stencilOperation to specify that stencil value must be decremented */
  103413. static readonly DECR: number;
  103414. /** Passed to stencilOperation to specify that stencil value must be inverted */
  103415. static readonly INVERT: number;
  103416. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  103417. static readonly INCR_WRAP: number;
  103418. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  103419. static readonly DECR_WRAP: number;
  103420. /** Texture is not repeating outside of 0..1 UVs */
  103421. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  103422. /** Texture is repeating outside of 0..1 UVs */
  103423. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  103424. /** Texture is repeating and mirrored */
  103425. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  103426. /** ALPHA */
  103427. static readonly TEXTUREFORMAT_ALPHA: number;
  103428. /** LUMINANCE */
  103429. static readonly TEXTUREFORMAT_LUMINANCE: number;
  103430. /** LUMINANCE_ALPHA */
  103431. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  103432. /** RGB */
  103433. static readonly TEXTUREFORMAT_RGB: number;
  103434. /** RGBA */
  103435. static readonly TEXTUREFORMAT_RGBA: number;
  103436. /** RED */
  103437. static readonly TEXTUREFORMAT_RED: number;
  103438. /** RED (2nd reference) */
  103439. static readonly TEXTUREFORMAT_R: number;
  103440. /** RG */
  103441. static readonly TEXTUREFORMAT_RG: number;
  103442. /** RED_INTEGER */
  103443. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  103444. /** RED_INTEGER (2nd reference) */
  103445. static readonly TEXTUREFORMAT_R_INTEGER: number;
  103446. /** RG_INTEGER */
  103447. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  103448. /** RGB_INTEGER */
  103449. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  103450. /** RGBA_INTEGER */
  103451. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  103452. /** UNSIGNED_BYTE */
  103453. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  103454. /** UNSIGNED_BYTE (2nd reference) */
  103455. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  103456. /** FLOAT */
  103457. static readonly TEXTURETYPE_FLOAT: number;
  103458. /** HALF_FLOAT */
  103459. static readonly TEXTURETYPE_HALF_FLOAT: number;
  103460. /** BYTE */
  103461. static readonly TEXTURETYPE_BYTE: number;
  103462. /** SHORT */
  103463. static readonly TEXTURETYPE_SHORT: number;
  103464. /** UNSIGNED_SHORT */
  103465. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  103466. /** INT */
  103467. static readonly TEXTURETYPE_INT: number;
  103468. /** UNSIGNED_INT */
  103469. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  103470. /** UNSIGNED_SHORT_4_4_4_4 */
  103471. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  103472. /** UNSIGNED_SHORT_5_5_5_1 */
  103473. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  103474. /** UNSIGNED_SHORT_5_6_5 */
  103475. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  103476. /** UNSIGNED_INT_2_10_10_10_REV */
  103477. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  103478. /** UNSIGNED_INT_24_8 */
  103479. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  103480. /** UNSIGNED_INT_10F_11F_11F_REV */
  103481. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  103482. /** UNSIGNED_INT_5_9_9_9_REV */
  103483. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  103484. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  103485. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  103486. /** nearest is mag = nearest and min = nearest and mip = linear */
  103487. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  103488. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103489. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  103490. /** Trilinear is mag = linear and min = linear and mip = linear */
  103491. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  103492. /** nearest is mag = nearest and min = nearest and mip = linear */
  103493. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  103494. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103495. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  103496. /** Trilinear is mag = linear and min = linear and mip = linear */
  103497. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  103498. /** mag = nearest and min = nearest and mip = nearest */
  103499. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  103500. /** mag = nearest and min = linear and mip = nearest */
  103501. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  103502. /** mag = nearest and min = linear and mip = linear */
  103503. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  103504. /** mag = nearest and min = linear and mip = none */
  103505. static readonly TEXTURE_NEAREST_LINEAR: number;
  103506. /** mag = nearest and min = nearest and mip = none */
  103507. static readonly TEXTURE_NEAREST_NEAREST: number;
  103508. /** mag = linear and min = nearest and mip = nearest */
  103509. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  103510. /** mag = linear and min = nearest and mip = linear */
  103511. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  103512. /** mag = linear and min = linear and mip = none */
  103513. static readonly TEXTURE_LINEAR_LINEAR: number;
  103514. /** mag = linear and min = nearest and mip = none */
  103515. static readonly TEXTURE_LINEAR_NEAREST: number;
  103516. /** Explicit coordinates mode */
  103517. static readonly TEXTURE_EXPLICIT_MODE: number;
  103518. /** Spherical coordinates mode */
  103519. static readonly TEXTURE_SPHERICAL_MODE: number;
  103520. /** Planar coordinates mode */
  103521. static readonly TEXTURE_PLANAR_MODE: number;
  103522. /** Cubic coordinates mode */
  103523. static readonly TEXTURE_CUBIC_MODE: number;
  103524. /** Projection coordinates mode */
  103525. static readonly TEXTURE_PROJECTION_MODE: number;
  103526. /** Skybox coordinates mode */
  103527. static readonly TEXTURE_SKYBOX_MODE: number;
  103528. /** Inverse Cubic coordinates mode */
  103529. static readonly TEXTURE_INVCUBIC_MODE: number;
  103530. /** Equirectangular coordinates mode */
  103531. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  103532. /** Equirectangular Fixed coordinates mode */
  103533. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  103534. /** Equirectangular Fixed Mirrored coordinates mode */
  103535. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103536. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  103537. static readonly SCALEMODE_FLOOR: number;
  103538. /** Defines that texture rescaling will look for the nearest power of 2 size */
  103539. static readonly SCALEMODE_NEAREST: number;
  103540. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  103541. static readonly SCALEMODE_CEILING: number;
  103542. /**
  103543. * Returns the current npm package of the sdk
  103544. */
  103545. static get NpmPackage(): string;
  103546. /**
  103547. * Returns the current version of the framework
  103548. */
  103549. static get Version(): string;
  103550. /** Gets the list of created engines */
  103551. static get Instances(): Engine[];
  103552. /**
  103553. * Gets the latest created engine
  103554. */
  103555. static get LastCreatedEngine(): Nullable<Engine>;
  103556. /**
  103557. * Gets the latest created scene
  103558. */
  103559. static get LastCreatedScene(): Nullable<Scene>;
  103560. /**
  103561. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  103562. * @param flag defines which part of the materials must be marked as dirty
  103563. * @param predicate defines a predicate used to filter which materials should be affected
  103564. */
  103565. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103566. /**
  103567. * Method called to create the default loading screen.
  103568. * This can be overriden in your own app.
  103569. * @param canvas The rendering canvas element
  103570. * @returns The loading screen
  103571. */
  103572. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  103573. /**
  103574. * Method called to create the default rescale post process on each engine.
  103575. */
  103576. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  103577. /**
  103578. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  103579. **/
  103580. enableOfflineSupport: boolean;
  103581. /**
  103582. * 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)
  103583. **/
  103584. disableManifestCheck: boolean;
  103585. /**
  103586. * Gets the list of created scenes
  103587. */
  103588. scenes: Scene[];
  103589. /**
  103590. * Event raised when a new scene is created
  103591. */
  103592. onNewSceneAddedObservable: Observable<Scene>;
  103593. /**
  103594. * Gets the list of created postprocesses
  103595. */
  103596. postProcesses: PostProcess[];
  103597. /**
  103598. * Gets a boolean indicating if the pointer is currently locked
  103599. */
  103600. isPointerLock: boolean;
  103601. /**
  103602. * Observable event triggered each time the rendering canvas is resized
  103603. */
  103604. onResizeObservable: Observable<Engine>;
  103605. /**
  103606. * Observable event triggered each time the canvas loses focus
  103607. */
  103608. onCanvasBlurObservable: Observable<Engine>;
  103609. /**
  103610. * Observable event triggered each time the canvas gains focus
  103611. */
  103612. onCanvasFocusObservable: Observable<Engine>;
  103613. /**
  103614. * Observable event triggered each time the canvas receives pointerout event
  103615. */
  103616. onCanvasPointerOutObservable: Observable<PointerEvent>;
  103617. /**
  103618. * Observable raised when the engine begins a new frame
  103619. */
  103620. onBeginFrameObservable: Observable<Engine>;
  103621. /**
  103622. * If set, will be used to request the next animation frame for the render loop
  103623. */
  103624. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  103625. /**
  103626. * Observable raised when the engine ends the current frame
  103627. */
  103628. onEndFrameObservable: Observable<Engine>;
  103629. /**
  103630. * Observable raised when the engine is about to compile a shader
  103631. */
  103632. onBeforeShaderCompilationObservable: Observable<Engine>;
  103633. /**
  103634. * Observable raised when the engine has jsut compiled a shader
  103635. */
  103636. onAfterShaderCompilationObservable: Observable<Engine>;
  103637. /**
  103638. * Gets the audio engine
  103639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103640. * @ignorenaming
  103641. */
  103642. static audioEngine: IAudioEngine;
  103643. /**
  103644. * Default AudioEngine factory responsible of creating the Audio Engine.
  103645. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  103646. */
  103647. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  103648. /**
  103649. * Default offline support factory responsible of creating a tool used to store data locally.
  103650. * By default, this will create a Database object if the workload has been embedded.
  103651. */
  103652. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  103653. private _loadingScreen;
  103654. private _pointerLockRequested;
  103655. private _dummyFramebuffer;
  103656. private _rescalePostProcess;
  103657. private _deterministicLockstep;
  103658. private _lockstepMaxSteps;
  103659. private _timeStep;
  103660. protected get _supportsHardwareTextureRescaling(): boolean;
  103661. private _fps;
  103662. private _deltaTime;
  103663. /** @hidden */
  103664. _drawCalls: PerfCounter;
  103665. /**
  103666. * Turn this value on if you want to pause FPS computation when in background
  103667. */
  103668. disablePerformanceMonitorInBackground: boolean;
  103669. private _performanceMonitor;
  103670. /**
  103671. * Gets the performance monitor attached to this engine
  103672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103673. */
  103674. get performanceMonitor(): PerformanceMonitor;
  103675. private _onFocus;
  103676. private _onBlur;
  103677. private _onCanvasPointerOut;
  103678. private _onCanvasBlur;
  103679. private _onCanvasFocus;
  103680. private _onFullscreenChange;
  103681. private _onPointerLockChange;
  103682. /**
  103683. * Gets the HTML element used to attach event listeners
  103684. * @returns a HTML element
  103685. */
  103686. getInputElement(): Nullable<HTMLElement>;
  103687. /**
  103688. * Creates a new engine
  103689. * @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
  103690. * @param antialias defines enable antialiasing (default: false)
  103691. * @param options defines further options to be sent to the getContext() function
  103692. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103693. */
  103694. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103695. /**
  103696. * Gets current aspect ratio
  103697. * @param viewportOwner defines the camera to use to get the aspect ratio
  103698. * @param useScreen defines if screen size must be used (or the current render target if any)
  103699. * @returns a number defining the aspect ratio
  103700. */
  103701. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  103702. /**
  103703. * Gets current screen aspect ratio
  103704. * @returns a number defining the aspect ratio
  103705. */
  103706. getScreenAspectRatio(): number;
  103707. /**
  103708. * Gets the client rect of the HTML canvas attached with the current webGL context
  103709. * @returns a client rectanglee
  103710. */
  103711. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  103712. /**
  103713. * Gets the client rect of the HTML element used for events
  103714. * @returns a client rectanglee
  103715. */
  103716. getInputElementClientRect(): Nullable<ClientRect>;
  103717. /**
  103718. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  103719. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103720. * @returns true if engine is in deterministic lock step mode
  103721. */
  103722. isDeterministicLockStep(): boolean;
  103723. /**
  103724. * Gets the max steps when engine is running in deterministic lock step
  103725. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103726. * @returns the max steps
  103727. */
  103728. getLockstepMaxSteps(): number;
  103729. /**
  103730. * Returns the time in ms between steps when using deterministic lock step.
  103731. * @returns time step in (ms)
  103732. */
  103733. getTimeStep(): number;
  103734. /**
  103735. * Force the mipmap generation for the given render target texture
  103736. * @param texture defines the render target texture to use
  103737. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  103738. */
  103739. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  103740. /** States */
  103741. /**
  103742. * Set various states to the webGL context
  103743. * @param culling defines backface culling state
  103744. * @param zOffset defines the value to apply to zOffset (0 by default)
  103745. * @param force defines if states must be applied even if cache is up to date
  103746. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  103747. */
  103748. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  103749. /**
  103750. * Set the z offset to apply to current rendering
  103751. * @param value defines the offset to apply
  103752. */
  103753. setZOffset(value: number): void;
  103754. /**
  103755. * Gets the current value of the zOffset
  103756. * @returns the current zOffset state
  103757. */
  103758. getZOffset(): number;
  103759. /**
  103760. * Enable or disable depth buffering
  103761. * @param enable defines the state to set
  103762. */
  103763. setDepthBuffer(enable: boolean): void;
  103764. /**
  103765. * Gets a boolean indicating if depth writing is enabled
  103766. * @returns the current depth writing state
  103767. */
  103768. getDepthWrite(): boolean;
  103769. /**
  103770. * Enable or disable depth writing
  103771. * @param enable defines the state to set
  103772. */
  103773. setDepthWrite(enable: boolean): void;
  103774. /**
  103775. * Gets a boolean indicating if stencil buffer is enabled
  103776. * @returns the current stencil buffer state
  103777. */
  103778. getStencilBuffer(): boolean;
  103779. /**
  103780. * Enable or disable the stencil buffer
  103781. * @param enable defines if the stencil buffer must be enabled or disabled
  103782. */
  103783. setStencilBuffer(enable: boolean): void;
  103784. /**
  103785. * Gets the current stencil mask
  103786. * @returns a number defining the new stencil mask to use
  103787. */
  103788. getStencilMask(): number;
  103789. /**
  103790. * Sets the current stencil mask
  103791. * @param mask defines the new stencil mask to use
  103792. */
  103793. setStencilMask(mask: number): void;
  103794. /**
  103795. * Gets the current stencil function
  103796. * @returns a number defining the stencil function to use
  103797. */
  103798. getStencilFunction(): number;
  103799. /**
  103800. * Gets the current stencil reference value
  103801. * @returns a number defining the stencil reference value to use
  103802. */
  103803. getStencilFunctionReference(): number;
  103804. /**
  103805. * Gets the current stencil mask
  103806. * @returns a number defining the stencil mask to use
  103807. */
  103808. getStencilFunctionMask(): number;
  103809. /**
  103810. * Sets the current stencil function
  103811. * @param stencilFunc defines the new stencil function to use
  103812. */
  103813. setStencilFunction(stencilFunc: number): void;
  103814. /**
  103815. * Sets the current stencil reference
  103816. * @param reference defines the new stencil reference to use
  103817. */
  103818. setStencilFunctionReference(reference: number): void;
  103819. /**
  103820. * Sets the current stencil mask
  103821. * @param mask defines the new stencil mask to use
  103822. */
  103823. setStencilFunctionMask(mask: number): void;
  103824. /**
  103825. * Gets the current stencil operation when stencil fails
  103826. * @returns a number defining stencil operation to use when stencil fails
  103827. */
  103828. getStencilOperationFail(): number;
  103829. /**
  103830. * Gets the current stencil operation when depth fails
  103831. * @returns a number defining stencil operation to use when depth fails
  103832. */
  103833. getStencilOperationDepthFail(): number;
  103834. /**
  103835. * Gets the current stencil operation when stencil passes
  103836. * @returns a number defining stencil operation to use when stencil passes
  103837. */
  103838. getStencilOperationPass(): number;
  103839. /**
  103840. * Sets the stencil operation to use when stencil fails
  103841. * @param operation defines the stencil operation to use when stencil fails
  103842. */
  103843. setStencilOperationFail(operation: number): void;
  103844. /**
  103845. * Sets the stencil operation to use when depth fails
  103846. * @param operation defines the stencil operation to use when depth fails
  103847. */
  103848. setStencilOperationDepthFail(operation: number): void;
  103849. /**
  103850. * Sets the stencil operation to use when stencil passes
  103851. * @param operation defines the stencil operation to use when stencil passes
  103852. */
  103853. setStencilOperationPass(operation: number): void;
  103854. /**
  103855. * Sets a boolean indicating if the dithering state is enabled or disabled
  103856. * @param value defines the dithering state
  103857. */
  103858. setDitheringState(value: boolean): void;
  103859. /**
  103860. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  103861. * @param value defines the rasterizer state
  103862. */
  103863. setRasterizerState(value: boolean): void;
  103864. /**
  103865. * Gets the current depth function
  103866. * @returns a number defining the depth function
  103867. */
  103868. getDepthFunction(): Nullable<number>;
  103869. /**
  103870. * Sets the current depth function
  103871. * @param depthFunc defines the function to use
  103872. */
  103873. setDepthFunction(depthFunc: number): void;
  103874. /**
  103875. * Sets the current depth function to GREATER
  103876. */
  103877. setDepthFunctionToGreater(): void;
  103878. /**
  103879. * Sets the current depth function to GEQUAL
  103880. */
  103881. setDepthFunctionToGreaterOrEqual(): void;
  103882. /**
  103883. * Sets the current depth function to LESS
  103884. */
  103885. setDepthFunctionToLess(): void;
  103886. /**
  103887. * Sets the current depth function to LEQUAL
  103888. */
  103889. setDepthFunctionToLessOrEqual(): void;
  103890. private _cachedStencilBuffer;
  103891. private _cachedStencilFunction;
  103892. private _cachedStencilMask;
  103893. private _cachedStencilOperationPass;
  103894. private _cachedStencilOperationFail;
  103895. private _cachedStencilOperationDepthFail;
  103896. private _cachedStencilReference;
  103897. /**
  103898. * Caches the the state of the stencil buffer
  103899. */
  103900. cacheStencilState(): void;
  103901. /**
  103902. * Restores the state of the stencil buffer
  103903. */
  103904. restoreStencilState(): void;
  103905. /**
  103906. * Directly set the WebGL Viewport
  103907. * @param x defines the x coordinate of the viewport (in screen space)
  103908. * @param y defines the y coordinate of the viewport (in screen space)
  103909. * @param width defines the width of the viewport (in screen space)
  103910. * @param height defines the height of the viewport (in screen space)
  103911. * @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
  103912. */
  103913. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  103914. /**
  103915. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  103916. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  103917. * @param y defines the y-coordinate of the corner of the clear rectangle
  103918. * @param width defines the width of the clear rectangle
  103919. * @param height defines the height of the clear rectangle
  103920. * @param clearColor defines the clear color
  103921. */
  103922. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  103923. /**
  103924. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  103925. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  103926. * @param y defines the y-coordinate of the corner of the clear rectangle
  103927. * @param width defines the width of the clear rectangle
  103928. * @param height defines the height of the clear rectangle
  103929. */
  103930. enableScissor(x: number, y: number, width: number, height: number): void;
  103931. /**
  103932. * Disable previously set scissor test rectangle
  103933. */
  103934. disableScissor(): void;
  103935. protected _reportDrawCall(): void;
  103936. /**
  103937. * Initializes a webVR display and starts listening to display change events
  103938. * The onVRDisplayChangedObservable will be notified upon these changes
  103939. * @returns The onVRDisplayChangedObservable
  103940. */
  103941. initWebVR(): Observable<IDisplayChangedEventArgs>;
  103942. /** @hidden */
  103943. _prepareVRComponent(): void;
  103944. /** @hidden */
  103945. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  103946. /** @hidden */
  103947. _submitVRFrame(): void;
  103948. /**
  103949. * Call this function to leave webVR mode
  103950. * Will do nothing if webVR is not supported or if there is no webVR device
  103951. * @see http://doc.babylonjs.com/how_to/webvr_camera
  103952. */
  103953. disableVR(): void;
  103954. /**
  103955. * Gets a boolean indicating that the system is in VR mode and is presenting
  103956. * @returns true if VR mode is engaged
  103957. */
  103958. isVRPresenting(): boolean;
  103959. /** @hidden */
  103960. _requestVRFrame(): void;
  103961. /** @hidden */
  103962. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103963. /**
  103964. * Gets the source code of the vertex shader associated with a specific webGL program
  103965. * @param program defines the program to use
  103966. * @returns a string containing the source code of the vertex shader associated with the program
  103967. */
  103968. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  103969. /**
  103970. * Gets the source code of the fragment shader associated with a specific webGL program
  103971. * @param program defines the program to use
  103972. * @returns a string containing the source code of the fragment shader associated with the program
  103973. */
  103974. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  103975. /**
  103976. * Sets a depth stencil texture from a render target to the according uniform.
  103977. * @param channel The texture channel
  103978. * @param uniform The uniform to set
  103979. * @param texture The render target texture containing the depth stencil texture to apply
  103980. */
  103981. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  103982. /**
  103983. * Sets a texture to the webGL context from a postprocess
  103984. * @param channel defines the channel to use
  103985. * @param postProcess defines the source postprocess
  103986. */
  103987. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  103988. /**
  103989. * Binds the output of the passed in post process to the texture channel specified
  103990. * @param channel The channel the texture should be bound to
  103991. * @param postProcess The post process which's output should be bound
  103992. */
  103993. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  103994. /** @hidden */
  103995. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  103996. protected _rebuildBuffers(): void;
  103997. /** @hidden */
  103998. _renderFrame(): void;
  103999. _renderLoop(): void;
  104000. /** @hidden */
  104001. _renderViews(): boolean;
  104002. /**
  104003. * Toggle full screen mode
  104004. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104005. */
  104006. switchFullscreen(requestPointerLock: boolean): void;
  104007. /**
  104008. * Enters full screen mode
  104009. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104010. */
  104011. enterFullscreen(requestPointerLock: boolean): void;
  104012. /**
  104013. * Exits full screen mode
  104014. */
  104015. exitFullscreen(): void;
  104016. /**
  104017. * Enters Pointerlock mode
  104018. */
  104019. enterPointerlock(): void;
  104020. /**
  104021. * Exits Pointerlock mode
  104022. */
  104023. exitPointerlock(): void;
  104024. /**
  104025. * Begin a new frame
  104026. */
  104027. beginFrame(): void;
  104028. /**
  104029. * Enf the current frame
  104030. */
  104031. endFrame(): void;
  104032. resize(): void;
  104033. /**
  104034. * Set the compressed texture format to use, based on the formats you have, and the formats
  104035. * supported by the hardware / browser.
  104036. *
  104037. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  104038. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  104039. * to API arguments needed to compressed textures. This puts the burden on the container
  104040. * generator to house the arcane code for determining these for current & future formats.
  104041. *
  104042. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104043. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104044. *
  104045. * Note: The result of this call is not taken into account when a texture is base64.
  104046. *
  104047. * @param formatsAvailable defines the list of those format families you have created
  104048. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  104049. *
  104050. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  104051. * @returns The extension selected.
  104052. */
  104053. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  104054. /**
  104055. * Set the compressed texture extensions or file names to skip.
  104056. *
  104057. * @param skippedFiles defines the list of those texture files you want to skip
  104058. * Example: [".dds", ".env", "myfile.png"]
  104059. */
  104060. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  104061. /**
  104062. * Force a specific size of the canvas
  104063. * @param width defines the new canvas' width
  104064. * @param height defines the new canvas' height
  104065. */
  104066. setSize(width: number, height: number): void;
  104067. /**
  104068. * Updates a dynamic vertex buffer.
  104069. * @param vertexBuffer the vertex buffer to update
  104070. * @param data the data used to update the vertex buffer
  104071. * @param byteOffset the byte offset of the data
  104072. * @param byteLength the byte length of the data
  104073. */
  104074. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  104075. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104076. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104077. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104078. _releaseTexture(texture: InternalTexture): void;
  104079. /**
  104080. * @hidden
  104081. * Rescales a texture
  104082. * @param source input texutre
  104083. * @param destination destination texture
  104084. * @param scene scene to use to render the resize
  104085. * @param internalFormat format to use when resizing
  104086. * @param onComplete callback to be called when resize has completed
  104087. */
  104088. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104089. /**
  104090. * Gets the current framerate
  104091. * @returns a number representing the framerate
  104092. */
  104093. getFps(): number;
  104094. /**
  104095. * Gets the time spent between current and previous frame
  104096. * @returns a number representing the delta time in ms
  104097. */
  104098. getDeltaTime(): number;
  104099. private _measureFps;
  104100. /** @hidden */
  104101. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  104102. /**
  104103. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  104104. * @param renderTarget The render target to set the frame buffer for
  104105. */
  104106. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  104107. /**
  104108. * Update a dynamic index buffer
  104109. * @param indexBuffer defines the target index buffer
  104110. * @param indices defines the data to update
  104111. * @param offset defines the offset in the target index buffer where update should start
  104112. */
  104113. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  104114. /**
  104115. * Updates the sample count of a render target texture
  104116. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104117. * @param texture defines the texture to update
  104118. * @param samples defines the sample count to set
  104119. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104120. */
  104121. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  104122. /**
  104123. * Updates a depth texture Comparison Mode and Function.
  104124. * If the comparison Function is equal to 0, the mode will be set to none.
  104125. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  104126. * @param texture The texture to set the comparison function for
  104127. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  104128. */
  104129. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  104130. /**
  104131. * Creates a webGL buffer to use with instanciation
  104132. * @param capacity defines the size of the buffer
  104133. * @returns the webGL buffer
  104134. */
  104135. createInstancesBuffer(capacity: number): DataBuffer;
  104136. /**
  104137. * Delete a webGL buffer used with instanciation
  104138. * @param buffer defines the webGL buffer to delete
  104139. */
  104140. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  104141. /** @hidden */
  104142. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  104143. dispose(): void;
  104144. private _disableTouchAction;
  104145. /**
  104146. * Display the loading screen
  104147. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104148. */
  104149. displayLoadingUI(): void;
  104150. /**
  104151. * Hide the loading screen
  104152. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104153. */
  104154. hideLoadingUI(): void;
  104155. /**
  104156. * Gets the current loading screen object
  104157. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104158. */
  104159. get loadingScreen(): ILoadingScreen;
  104160. /**
  104161. * Sets the current loading screen object
  104162. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104163. */
  104164. set loadingScreen(loadingScreen: ILoadingScreen);
  104165. /**
  104166. * Sets the current loading screen text
  104167. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104168. */
  104169. set loadingUIText(text: string);
  104170. /**
  104171. * Sets the current loading screen background color
  104172. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104173. */
  104174. set loadingUIBackgroundColor(color: string);
  104175. /** Pointerlock and fullscreen */
  104176. /**
  104177. * Ask the browser to promote the current element to pointerlock mode
  104178. * @param element defines the DOM element to promote
  104179. */
  104180. static _RequestPointerlock(element: HTMLElement): void;
  104181. /**
  104182. * Asks the browser to exit pointerlock mode
  104183. */
  104184. static _ExitPointerlock(): void;
  104185. /**
  104186. * Ask the browser to promote the current element to fullscreen rendering mode
  104187. * @param element defines the DOM element to promote
  104188. */
  104189. static _RequestFullscreen(element: HTMLElement): void;
  104190. /**
  104191. * Asks the browser to exit fullscreen mode
  104192. */
  104193. static _ExitFullscreen(): void;
  104194. }
  104195. }
  104196. declare module BABYLON {
  104197. /**
  104198. * The engine store class is responsible to hold all the instances of Engine and Scene created
  104199. * during the life time of the application.
  104200. */
  104201. export class EngineStore {
  104202. /** Gets the list of created engines */
  104203. static Instances: Engine[];
  104204. /** @hidden */
  104205. static _LastCreatedScene: Nullable<Scene>;
  104206. /**
  104207. * Gets the latest created engine
  104208. */
  104209. static get LastCreatedEngine(): Nullable<Engine>;
  104210. /**
  104211. * Gets the latest created scene
  104212. */
  104213. static get LastCreatedScene(): Nullable<Scene>;
  104214. /**
  104215. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104216. * @ignorenaming
  104217. */
  104218. static UseFallbackTexture: boolean;
  104219. /**
  104220. * Texture content used if a texture cannot loaded
  104221. * @ignorenaming
  104222. */
  104223. static FallbackTexture: string;
  104224. }
  104225. }
  104226. declare module BABYLON {
  104227. /**
  104228. * Helper class that provides a small promise polyfill
  104229. */
  104230. export class PromisePolyfill {
  104231. /**
  104232. * Static function used to check if the polyfill is required
  104233. * If this is the case then the function will inject the polyfill to window.Promise
  104234. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  104235. */
  104236. static Apply(force?: boolean): void;
  104237. }
  104238. }
  104239. declare module BABYLON {
  104240. /**
  104241. * Interface for screenshot methods with describe argument called `size` as object with options
  104242. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  104243. */
  104244. export interface IScreenshotSize {
  104245. /**
  104246. * number in pixels for canvas height
  104247. */
  104248. height?: number;
  104249. /**
  104250. * multiplier allowing render at a higher or lower resolution
  104251. * If value is defined then height and width will be ignored and taken from camera
  104252. */
  104253. precision?: number;
  104254. /**
  104255. * number in pixels for canvas width
  104256. */
  104257. width?: number;
  104258. }
  104259. }
  104260. declare module BABYLON {
  104261. interface IColor4Like {
  104262. r: float;
  104263. g: float;
  104264. b: float;
  104265. a: float;
  104266. }
  104267. /**
  104268. * Class containing a set of static utilities functions
  104269. */
  104270. export class Tools {
  104271. /**
  104272. * Gets or sets the base URL to use to load assets
  104273. */
  104274. static get BaseUrl(): string;
  104275. static set BaseUrl(value: string);
  104276. /**
  104277. * Enable/Disable Custom HTTP Request Headers globally.
  104278. * default = false
  104279. * @see CustomRequestHeaders
  104280. */
  104281. static UseCustomRequestHeaders: boolean;
  104282. /**
  104283. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104284. * i.e. when loading files, where the server/service expects an Authorization header
  104285. */
  104286. static CustomRequestHeaders: {
  104287. [key: string]: string;
  104288. };
  104289. /**
  104290. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  104291. */
  104292. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  104293. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  104294. /**
  104295. * Default behaviour for cors in the application.
  104296. * It can be a string if the expected behavior is identical in the entire app.
  104297. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  104298. */
  104299. static CorsBehavior: string | ((url: string | string[]) => string);
  104300. /**
  104301. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104302. * @ignorenaming
  104303. */
  104304. static get UseFallbackTexture(): boolean;
  104305. static set UseFallbackTexture(value: boolean);
  104306. /**
  104307. * Use this object to register external classes like custom textures or material
  104308. * to allow the laoders to instantiate them
  104309. */
  104310. static get RegisteredExternalClasses(): {
  104311. [key: string]: Object;
  104312. };
  104313. static set RegisteredExternalClasses(classes: {
  104314. [key: string]: Object;
  104315. });
  104316. /**
  104317. * Texture content used if a texture cannot loaded
  104318. * @ignorenaming
  104319. */
  104320. static get fallbackTexture(): string;
  104321. static set fallbackTexture(value: string);
  104322. /**
  104323. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  104324. * @param u defines the coordinate on X axis
  104325. * @param v defines the coordinate on Y axis
  104326. * @param width defines the width of the source data
  104327. * @param height defines the height of the source data
  104328. * @param pixels defines the source byte array
  104329. * @param color defines the output color
  104330. */
  104331. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  104332. /**
  104333. * Interpolates between a and b via alpha
  104334. * @param a The lower value (returned when alpha = 0)
  104335. * @param b The upper value (returned when alpha = 1)
  104336. * @param alpha The interpolation-factor
  104337. * @return The mixed value
  104338. */
  104339. static Mix(a: number, b: number, alpha: number): number;
  104340. /**
  104341. * Tries to instantiate a new object from a given class name
  104342. * @param className defines the class name to instantiate
  104343. * @returns the new object or null if the system was not able to do the instantiation
  104344. */
  104345. static Instantiate(className: string): any;
  104346. /**
  104347. * Provides a slice function that will work even on IE
  104348. * @param data defines the array to slice
  104349. * @param start defines the start of the data (optional)
  104350. * @param end defines the end of the data (optional)
  104351. * @returns the new sliced array
  104352. */
  104353. static Slice<T>(data: T, start?: number, end?: number): T;
  104354. /**
  104355. * Polyfill for setImmediate
  104356. * @param action defines the action to execute after the current execution block
  104357. */
  104358. static SetImmediate(action: () => void): void;
  104359. /**
  104360. * Function indicating if a number is an exponent of 2
  104361. * @param value defines the value to test
  104362. * @returns true if the value is an exponent of 2
  104363. */
  104364. static IsExponentOfTwo(value: number): boolean;
  104365. private static _tmpFloatArray;
  104366. /**
  104367. * Returns the nearest 32-bit single precision float representation of a Number
  104368. * @param value A Number. If the parameter is of a different type, it will get converted
  104369. * to a number or to NaN if it cannot be converted
  104370. * @returns number
  104371. */
  104372. static FloatRound(value: number): number;
  104373. /**
  104374. * Extracts the filename from a path
  104375. * @param path defines the path to use
  104376. * @returns the filename
  104377. */
  104378. static GetFilename(path: string): string;
  104379. /**
  104380. * Extracts the "folder" part of a path (everything before the filename).
  104381. * @param uri The URI to extract the info from
  104382. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  104383. * @returns The "folder" part of the path
  104384. */
  104385. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  104386. /**
  104387. * Extracts text content from a DOM element hierarchy
  104388. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  104389. */
  104390. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  104391. /**
  104392. * Convert an angle in radians to degrees
  104393. * @param angle defines the angle to convert
  104394. * @returns the angle in degrees
  104395. */
  104396. static ToDegrees(angle: number): number;
  104397. /**
  104398. * Convert an angle in degrees to radians
  104399. * @param angle defines the angle to convert
  104400. * @returns the angle in radians
  104401. */
  104402. static ToRadians(angle: number): number;
  104403. /**
  104404. * Returns an array if obj is not an array
  104405. * @param obj defines the object to evaluate as an array
  104406. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  104407. * @returns either obj directly if obj is an array or a new array containing obj
  104408. */
  104409. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  104410. /**
  104411. * Gets the pointer prefix to use
  104412. * @returns "pointer" if touch is enabled. Else returns "mouse"
  104413. */
  104414. static GetPointerPrefix(): string;
  104415. /**
  104416. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  104417. * @param url define the url we are trying
  104418. * @param element define the dom element where to configure the cors policy
  104419. */
  104420. static SetCorsBehavior(url: string | string[], element: {
  104421. crossOrigin: string | null;
  104422. }): void;
  104423. /**
  104424. * Removes unwanted characters from an url
  104425. * @param url defines the url to clean
  104426. * @returns the cleaned url
  104427. */
  104428. static CleanUrl(url: string): string;
  104429. /**
  104430. * Gets or sets a function used to pre-process url before using them to load assets
  104431. */
  104432. static get PreprocessUrl(): (url: string) => string;
  104433. static set PreprocessUrl(processor: (url: string) => string);
  104434. /**
  104435. * Loads an image as an HTMLImageElement.
  104436. * @param input url string, ArrayBuffer, or Blob to load
  104437. * @param onLoad callback called when the image successfully loads
  104438. * @param onError callback called when the image fails to load
  104439. * @param offlineProvider offline provider for caching
  104440. * @param mimeType optional mime type
  104441. * @returns the HTMLImageElement of the loaded image
  104442. */
  104443. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  104444. /**
  104445. * Loads a file from a url
  104446. * @param url url string, ArrayBuffer, or Blob to load
  104447. * @param onSuccess callback called when the file successfully loads
  104448. * @param onProgress callback called while file is loading (if the server supports this mode)
  104449. * @param offlineProvider defines the offline provider for caching
  104450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104451. * @param onError callback called when the file fails to load
  104452. * @returns a file request object
  104453. */
  104454. 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;
  104455. /**
  104456. * Loads a file from a url
  104457. * @param url the file url to load
  104458. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  104459. */
  104460. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  104461. /**
  104462. * Load a script (identified by an url). When the url returns, the
  104463. * content of this file is added into a new script element, attached to the DOM (body element)
  104464. * @param scriptUrl defines the url of the script to laod
  104465. * @param onSuccess defines the callback called when the script is loaded
  104466. * @param onError defines the callback to call if an error occurs
  104467. * @param scriptId defines the id of the script element
  104468. */
  104469. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  104470. /**
  104471. * Load an asynchronous script (identified by an url). When the url returns, the
  104472. * content of this file is added into a new script element, attached to the DOM (body element)
  104473. * @param scriptUrl defines the url of the script to laod
  104474. * @param scriptId defines the id of the script element
  104475. * @returns a promise request object
  104476. */
  104477. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  104478. /**
  104479. * Loads a file from a blob
  104480. * @param fileToLoad defines the blob to use
  104481. * @param callback defines the callback to call when data is loaded
  104482. * @param progressCallback defines the callback to call during loading process
  104483. * @returns a file request object
  104484. */
  104485. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  104486. /**
  104487. * Reads a file from a File object
  104488. * @param file defines the file to load
  104489. * @param onSuccess defines the callback to call when data is loaded
  104490. * @param onProgress defines the callback to call during loading process
  104491. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  104492. * @param onError defines the callback to call when an error occurs
  104493. * @returns a file request object
  104494. */
  104495. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  104496. /**
  104497. * Creates a data url from a given string content
  104498. * @param content defines the content to convert
  104499. * @returns the new data url link
  104500. */
  104501. static FileAsURL(content: string): string;
  104502. /**
  104503. * Format the given number to a specific decimal format
  104504. * @param value defines the number to format
  104505. * @param decimals defines the number of decimals to use
  104506. * @returns the formatted string
  104507. */
  104508. static Format(value: number, decimals?: number): string;
  104509. /**
  104510. * Tries to copy an object by duplicating every property
  104511. * @param source defines the source object
  104512. * @param destination defines the target object
  104513. * @param doNotCopyList defines a list of properties to avoid
  104514. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  104515. */
  104516. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  104517. /**
  104518. * Gets a boolean indicating if the given object has no own property
  104519. * @param obj defines the object to test
  104520. * @returns true if object has no own property
  104521. */
  104522. static IsEmpty(obj: any): boolean;
  104523. /**
  104524. * Function used to register events at window level
  104525. * @param windowElement defines the Window object to use
  104526. * @param events defines the events to register
  104527. */
  104528. static RegisterTopRootEvents(windowElement: Window, events: {
  104529. name: string;
  104530. handler: Nullable<(e: FocusEvent) => any>;
  104531. }[]): void;
  104532. /**
  104533. * Function used to unregister events from window level
  104534. * @param windowElement defines the Window object to use
  104535. * @param events defines the events to unregister
  104536. */
  104537. static UnregisterTopRootEvents(windowElement: Window, events: {
  104538. name: string;
  104539. handler: Nullable<(e: FocusEvent) => any>;
  104540. }[]): void;
  104541. /**
  104542. * @ignore
  104543. */
  104544. static _ScreenshotCanvas: HTMLCanvasElement;
  104545. /**
  104546. * Dumps the current bound framebuffer
  104547. * @param width defines the rendering width
  104548. * @param height defines the rendering height
  104549. * @param engine defines the hosting engine
  104550. * @param successCallback defines the callback triggered once the data are available
  104551. * @param mimeType defines the mime type of the result
  104552. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  104553. */
  104554. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104555. /**
  104556. * Converts the canvas data to blob.
  104557. * This acts as a polyfill for browsers not supporting the to blob function.
  104558. * @param canvas Defines the canvas to extract the data from
  104559. * @param successCallback Defines the callback triggered once the data are available
  104560. * @param mimeType Defines the mime type of the result
  104561. */
  104562. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  104563. /**
  104564. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  104565. * @param successCallback defines the callback triggered once the data are available
  104566. * @param mimeType defines the mime type of the result
  104567. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  104568. */
  104569. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104570. /**
  104571. * Downloads a blob in the browser
  104572. * @param blob defines the blob to download
  104573. * @param fileName defines the name of the downloaded file
  104574. */
  104575. static Download(blob: Blob, fileName: string): void;
  104576. /**
  104577. * Captures a screenshot of the current rendering
  104578. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104579. * @param engine defines the rendering engine
  104580. * @param camera defines the source camera
  104581. * @param size This parameter can be set to a single number or to an object with the
  104582. * following (optional) properties: precision, width, height. If a single number is passed,
  104583. * it will be used for both width and height. If an object is passed, the screenshot size
  104584. * will be derived from the parameters. The precision property is a multiplier allowing
  104585. * rendering at a higher or lower resolution
  104586. * @param successCallback defines the callback receives a single parameter which contains the
  104587. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104588. * src parameter of an <img> to display it
  104589. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104590. * Check your browser for supported MIME types
  104591. */
  104592. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  104593. /**
  104594. * Captures a screenshot of the current rendering
  104595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104596. * @param engine defines the rendering engine
  104597. * @param camera defines the source camera
  104598. * @param size This parameter can be set to a single number or to an object with the
  104599. * following (optional) properties: precision, width, height. If a single number is passed,
  104600. * it will be used for both width and height. If an object is passed, the screenshot size
  104601. * will be derived from the parameters. The precision property is a multiplier allowing
  104602. * rendering at a higher or lower resolution
  104603. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104604. * Check your browser for supported MIME types
  104605. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104606. * to the src parameter of an <img> to display it
  104607. */
  104608. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  104609. /**
  104610. * Generates an image screenshot from the specified camera.
  104611. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104612. * @param engine The engine to use for rendering
  104613. * @param camera The camera to use for rendering
  104614. * @param size This parameter can be set to a single number or to an object with the
  104615. * following (optional) properties: precision, width, height. If a single number is passed,
  104616. * it will be used for both width and height. If an object is passed, the screenshot size
  104617. * will be derived from the parameters. The precision property is a multiplier allowing
  104618. * rendering at a higher or lower resolution
  104619. * @param successCallback The callback receives a single parameter which contains the
  104620. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104621. * src parameter of an <img> to display it
  104622. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104623. * Check your browser for supported MIME types
  104624. * @param samples Texture samples (default: 1)
  104625. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104626. * @param fileName A name for for the downloaded file.
  104627. */
  104628. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  104629. /**
  104630. * Generates an image screenshot from the specified camera.
  104631. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104632. * @param engine The engine to use for rendering
  104633. * @param camera The camera to use for rendering
  104634. * @param size This parameter can be set to a single number or to an object with the
  104635. * following (optional) properties: precision, width, height. If a single number is passed,
  104636. * it will be used for both width and height. If an object is passed, the screenshot size
  104637. * will be derived from the parameters. The precision property is a multiplier allowing
  104638. * rendering at a higher or lower resolution
  104639. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104640. * Check your browser for supported MIME types
  104641. * @param samples Texture samples (default: 1)
  104642. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104643. * @param fileName A name for for the downloaded file.
  104644. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104645. * to the src parameter of an <img> to display it
  104646. */
  104647. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  104648. /**
  104649. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104650. * Be aware Math.random() could cause collisions, but:
  104651. * "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"
  104652. * @returns a pseudo random id
  104653. */
  104654. static RandomId(): string;
  104655. /**
  104656. * Test if the given uri is a base64 string
  104657. * @param uri The uri to test
  104658. * @return True if the uri is a base64 string or false otherwise
  104659. */
  104660. static IsBase64(uri: string): boolean;
  104661. /**
  104662. * Decode the given base64 uri.
  104663. * @param uri The uri to decode
  104664. * @return The decoded base64 data.
  104665. */
  104666. static DecodeBase64(uri: string): ArrayBuffer;
  104667. /**
  104668. * Gets the absolute url.
  104669. * @param url the input url
  104670. * @return the absolute url
  104671. */
  104672. static GetAbsoluteUrl(url: string): string;
  104673. /**
  104674. * No log
  104675. */
  104676. static readonly NoneLogLevel: number;
  104677. /**
  104678. * Only message logs
  104679. */
  104680. static readonly MessageLogLevel: number;
  104681. /**
  104682. * Only warning logs
  104683. */
  104684. static readonly WarningLogLevel: number;
  104685. /**
  104686. * Only error logs
  104687. */
  104688. static readonly ErrorLogLevel: number;
  104689. /**
  104690. * All logs
  104691. */
  104692. static readonly AllLogLevel: number;
  104693. /**
  104694. * Gets a value indicating the number of loading errors
  104695. * @ignorenaming
  104696. */
  104697. static get errorsCount(): number;
  104698. /**
  104699. * Callback called when a new log is added
  104700. */
  104701. static OnNewCacheEntry: (entry: string) => void;
  104702. /**
  104703. * Log a message to the console
  104704. * @param message defines the message to log
  104705. */
  104706. static Log(message: string): void;
  104707. /**
  104708. * Write a warning message to the console
  104709. * @param message defines the message to log
  104710. */
  104711. static Warn(message: string): void;
  104712. /**
  104713. * Write an error message to the console
  104714. * @param message defines the message to log
  104715. */
  104716. static Error(message: string): void;
  104717. /**
  104718. * Gets current log cache (list of logs)
  104719. */
  104720. static get LogCache(): string;
  104721. /**
  104722. * Clears the log cache
  104723. */
  104724. static ClearLogCache(): void;
  104725. /**
  104726. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  104727. */
  104728. static set LogLevels(level: number);
  104729. /**
  104730. * Checks if the window object exists
  104731. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  104732. */
  104733. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  104734. /**
  104735. * No performance log
  104736. */
  104737. static readonly PerformanceNoneLogLevel: number;
  104738. /**
  104739. * Use user marks to log performance
  104740. */
  104741. static readonly PerformanceUserMarkLogLevel: number;
  104742. /**
  104743. * Log performance to the console
  104744. */
  104745. static readonly PerformanceConsoleLogLevel: number;
  104746. private static _performance;
  104747. /**
  104748. * Sets the current performance log level
  104749. */
  104750. static set PerformanceLogLevel(level: number);
  104751. private static _StartPerformanceCounterDisabled;
  104752. private static _EndPerformanceCounterDisabled;
  104753. private static _StartUserMark;
  104754. private static _EndUserMark;
  104755. private static _StartPerformanceConsole;
  104756. private static _EndPerformanceConsole;
  104757. /**
  104758. * Starts a performance counter
  104759. */
  104760. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104761. /**
  104762. * Ends a specific performance coutner
  104763. */
  104764. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104765. /**
  104766. * Gets either window.performance.now() if supported or Date.now() else
  104767. */
  104768. static get Now(): number;
  104769. /**
  104770. * This method will return the name of the class used to create the instance of the given object.
  104771. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  104772. * @param object the object to get the class name from
  104773. * @param isType defines if the object is actually a type
  104774. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  104775. */
  104776. static GetClassName(object: any, isType?: boolean): string;
  104777. /**
  104778. * Gets the first element of an array satisfying a given predicate
  104779. * @param array defines the array to browse
  104780. * @param predicate defines the predicate to use
  104781. * @returns null if not found or the element
  104782. */
  104783. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  104784. /**
  104785. * This method will return the name of the full name of the class, including its owning module (if any).
  104786. * 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).
  104787. * @param object the object to get the class name from
  104788. * @param isType defines if the object is actually a type
  104789. * @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.
  104790. * @ignorenaming
  104791. */
  104792. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  104793. /**
  104794. * Returns a promise that resolves after the given amount of time.
  104795. * @param delay Number of milliseconds to delay
  104796. * @returns Promise that resolves after the given amount of time
  104797. */
  104798. static DelayAsync(delay: number): Promise<void>;
  104799. }
  104800. /**
  104801. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  104802. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  104803. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  104804. * @param name The name of the class, case should be preserved
  104805. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  104806. */
  104807. export function className(name: string, module?: string): (target: Object) => void;
  104808. /**
  104809. * An implementation of a loop for asynchronous functions.
  104810. */
  104811. export class AsyncLoop {
  104812. /**
  104813. * Defines the number of iterations for the loop
  104814. */
  104815. iterations: number;
  104816. /**
  104817. * Defines the current index of the loop.
  104818. */
  104819. index: number;
  104820. private _done;
  104821. private _fn;
  104822. private _successCallback;
  104823. /**
  104824. * Constructor.
  104825. * @param iterations the number of iterations.
  104826. * @param func the function to run each iteration
  104827. * @param successCallback the callback that will be called upon succesful execution
  104828. * @param offset starting offset.
  104829. */
  104830. constructor(
  104831. /**
  104832. * Defines the number of iterations for the loop
  104833. */
  104834. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  104835. /**
  104836. * Execute the next iteration. Must be called after the last iteration was finished.
  104837. */
  104838. executeNext(): void;
  104839. /**
  104840. * Break the loop and run the success callback.
  104841. */
  104842. breakLoop(): void;
  104843. /**
  104844. * Create and run an async loop.
  104845. * @param iterations the number of iterations.
  104846. * @param fn the function to run each iteration
  104847. * @param successCallback the callback that will be called upon succesful execution
  104848. * @param offset starting offset.
  104849. * @returns the created async loop object
  104850. */
  104851. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  104852. /**
  104853. * A for-loop that will run a given number of iterations synchronous and the rest async.
  104854. * @param iterations total number of iterations
  104855. * @param syncedIterations number of synchronous iterations in each async iteration.
  104856. * @param fn the function to call each iteration.
  104857. * @param callback a success call back that will be called when iterating stops.
  104858. * @param breakFunction a break condition (optional)
  104859. * @param timeout timeout settings for the setTimeout function. default - 0.
  104860. * @returns the created async loop object
  104861. */
  104862. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  104863. }
  104864. }
  104865. declare module BABYLON {
  104866. /**
  104867. * This class implement a typical dictionary using a string as key and the generic type T as value.
  104868. * The underlying implementation relies on an associative array to ensure the best performances.
  104869. * The value can be anything including 'null' but except 'undefined'
  104870. */
  104871. export class StringDictionary<T> {
  104872. /**
  104873. * This will clear this dictionary and copy the content from the 'source' one.
  104874. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  104875. * @param source the dictionary to take the content from and copy to this dictionary
  104876. */
  104877. copyFrom(source: StringDictionary<T>): void;
  104878. /**
  104879. * Get a value based from its key
  104880. * @param key the given key to get the matching value from
  104881. * @return the value if found, otherwise undefined is returned
  104882. */
  104883. get(key: string): T | undefined;
  104884. /**
  104885. * Get a value from its key or add it if it doesn't exist.
  104886. * This method will ensure you that a given key/data will be present in the dictionary.
  104887. * @param key the given key to get the matching value from
  104888. * @param factory the factory that will create the value if the key is not present in the dictionary.
  104889. * The factory will only be invoked if there's no data for the given key.
  104890. * @return the value corresponding to the key.
  104891. */
  104892. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  104893. /**
  104894. * Get a value from its key if present in the dictionary otherwise add it
  104895. * @param key the key to get the value from
  104896. * @param val if there's no such key/value pair in the dictionary add it with this value
  104897. * @return the value corresponding to the key
  104898. */
  104899. getOrAdd(key: string, val: T): T;
  104900. /**
  104901. * Check if there's a given key in the dictionary
  104902. * @param key the key to check for
  104903. * @return true if the key is present, false otherwise
  104904. */
  104905. contains(key: string): boolean;
  104906. /**
  104907. * Add a new key and its corresponding value
  104908. * @param key the key to add
  104909. * @param value the value corresponding to the key
  104910. * @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
  104911. */
  104912. add(key: string, value: T): boolean;
  104913. /**
  104914. * Update a specific value associated to a key
  104915. * @param key defines the key to use
  104916. * @param value defines the value to store
  104917. * @returns true if the value was updated (or false if the key was not found)
  104918. */
  104919. set(key: string, value: T): boolean;
  104920. /**
  104921. * Get the element of the given key and remove it from the dictionary
  104922. * @param key defines the key to search
  104923. * @returns the value associated with the key or null if not found
  104924. */
  104925. getAndRemove(key: string): Nullable<T>;
  104926. /**
  104927. * Remove a key/value from the dictionary.
  104928. * @param key the key to remove
  104929. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  104930. */
  104931. remove(key: string): boolean;
  104932. /**
  104933. * Clear the whole content of the dictionary
  104934. */
  104935. clear(): void;
  104936. /**
  104937. * Gets the current count
  104938. */
  104939. get count(): number;
  104940. /**
  104941. * Execute a callback on each key/val of the dictionary.
  104942. * Note that you can remove any element in this dictionary in the callback implementation
  104943. * @param callback the callback to execute on a given key/value pair
  104944. */
  104945. forEach(callback: (key: string, val: T) => void): void;
  104946. /**
  104947. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  104948. * If the callback returns null or undefined the method will iterate to the next key/value pair
  104949. * Note that you can remove any element in this dictionary in the callback implementation
  104950. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  104951. * @returns the first item
  104952. */
  104953. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  104954. private _count;
  104955. private _data;
  104956. }
  104957. }
  104958. declare module BABYLON {
  104959. /** @hidden */
  104960. export interface ICollisionCoordinator {
  104961. createCollider(): Collider;
  104962. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  104963. init(scene: Scene): void;
  104964. }
  104965. /** @hidden */
  104966. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  104967. private _scene;
  104968. private _scaledPosition;
  104969. private _scaledVelocity;
  104970. private _finalPosition;
  104971. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  104972. createCollider(): Collider;
  104973. init(scene: Scene): void;
  104974. private _collideWithWorld;
  104975. }
  104976. }
  104977. declare module BABYLON {
  104978. /**
  104979. * Class used to manage all inputs for the scene.
  104980. */
  104981. export class InputManager {
  104982. /** The distance in pixel that you have to move to prevent some events */
  104983. static DragMovementThreshold: number;
  104984. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  104985. static LongPressDelay: number;
  104986. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  104987. static DoubleClickDelay: number;
  104988. /** If you need to check double click without raising a single click at first click, enable this flag */
  104989. static ExclusiveDoubleClickMode: boolean;
  104990. private _wheelEventName;
  104991. private _onPointerMove;
  104992. private _onPointerDown;
  104993. private _onPointerUp;
  104994. private _initClickEvent;
  104995. private _initActionManager;
  104996. private _delayedSimpleClick;
  104997. private _delayedSimpleClickTimeout;
  104998. private _previousDelayedSimpleClickTimeout;
  104999. private _meshPickProceed;
  105000. private _previousButtonPressed;
  105001. private _currentPickResult;
  105002. private _previousPickResult;
  105003. private _totalPointersPressed;
  105004. private _doubleClickOccured;
  105005. private _pointerOverMesh;
  105006. private _pickedDownMesh;
  105007. private _pickedUpMesh;
  105008. private _pointerX;
  105009. private _pointerY;
  105010. private _unTranslatedPointerX;
  105011. private _unTranslatedPointerY;
  105012. private _startingPointerPosition;
  105013. private _previousStartingPointerPosition;
  105014. private _startingPointerTime;
  105015. private _previousStartingPointerTime;
  105016. private _pointerCaptures;
  105017. private _onKeyDown;
  105018. private _onKeyUp;
  105019. private _onCanvasFocusObserver;
  105020. private _onCanvasBlurObserver;
  105021. private _scene;
  105022. /**
  105023. * Creates a new InputManager
  105024. * @param scene defines the hosting scene
  105025. */
  105026. constructor(scene: Scene);
  105027. /**
  105028. * Gets the mesh that is currently under the pointer
  105029. */
  105030. get meshUnderPointer(): Nullable<AbstractMesh>;
  105031. /**
  105032. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  105033. */
  105034. get unTranslatedPointer(): Vector2;
  105035. /**
  105036. * Gets or sets the current on-screen X position of the pointer
  105037. */
  105038. get pointerX(): number;
  105039. set pointerX(value: number);
  105040. /**
  105041. * Gets or sets the current on-screen Y position of the pointer
  105042. */
  105043. get pointerY(): number;
  105044. set pointerY(value: number);
  105045. private _updatePointerPosition;
  105046. private _processPointerMove;
  105047. private _setRayOnPointerInfo;
  105048. private _checkPrePointerObservable;
  105049. /**
  105050. * Use this method to simulate a pointer move on a mesh
  105051. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105052. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105053. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105054. */
  105055. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105056. /**
  105057. * Use this method to simulate a pointer down on a mesh
  105058. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105059. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105060. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105061. */
  105062. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105063. private _processPointerDown;
  105064. /** @hidden */
  105065. _isPointerSwiping(): boolean;
  105066. /**
  105067. * Use this method to simulate a pointer up on a mesh
  105068. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105069. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105070. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105071. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105072. */
  105073. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  105074. private _processPointerUp;
  105075. /**
  105076. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105077. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105078. * @returns true if the pointer was captured
  105079. */
  105080. isPointerCaptured(pointerId?: number): boolean;
  105081. /**
  105082. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105083. * @param attachUp defines if you want to attach events to pointerup
  105084. * @param attachDown defines if you want to attach events to pointerdown
  105085. * @param attachMove defines if you want to attach events to pointermove
  105086. */
  105087. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105088. /**
  105089. * Detaches all event handlers
  105090. */
  105091. detachControl(): void;
  105092. /**
  105093. * Force the value of meshUnderPointer
  105094. * @param mesh defines the mesh to use
  105095. */
  105096. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105097. /**
  105098. * Gets the mesh under the pointer
  105099. * @returns a Mesh or null if no mesh is under the pointer
  105100. */
  105101. getPointerOverMesh(): Nullable<AbstractMesh>;
  105102. }
  105103. }
  105104. declare module BABYLON {
  105105. /**
  105106. * Helper class used to generate session unique ID
  105107. */
  105108. export class UniqueIdGenerator {
  105109. private static _UniqueIdCounter;
  105110. /**
  105111. * Gets an unique (relatively to the current scene) Id
  105112. */
  105113. static get UniqueId(): number;
  105114. }
  105115. }
  105116. declare module BABYLON {
  105117. /**
  105118. * This class defines the direct association between an animation and a target
  105119. */
  105120. export class TargetedAnimation {
  105121. /**
  105122. * Animation to perform
  105123. */
  105124. animation: Animation;
  105125. /**
  105126. * Target to animate
  105127. */
  105128. target: any;
  105129. /**
  105130. * Serialize the object
  105131. * @returns the JSON object representing the current entity
  105132. */
  105133. serialize(): any;
  105134. }
  105135. /**
  105136. * Use this class to create coordinated animations on multiple targets
  105137. */
  105138. export class AnimationGroup implements IDisposable {
  105139. /** The name of the animation group */
  105140. name: string;
  105141. private _scene;
  105142. private _targetedAnimations;
  105143. private _animatables;
  105144. private _from;
  105145. private _to;
  105146. private _isStarted;
  105147. private _isPaused;
  105148. private _speedRatio;
  105149. private _loopAnimation;
  105150. /**
  105151. * Gets or sets the unique id of the node
  105152. */
  105153. uniqueId: number;
  105154. /**
  105155. * This observable will notify when one animation have ended
  105156. */
  105157. onAnimationEndObservable: Observable<TargetedAnimation>;
  105158. /**
  105159. * Observer raised when one animation loops
  105160. */
  105161. onAnimationLoopObservable: Observable<TargetedAnimation>;
  105162. /**
  105163. * Observer raised when all animations have looped
  105164. */
  105165. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  105166. /**
  105167. * This observable will notify when all animations have ended.
  105168. */
  105169. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  105170. /**
  105171. * This observable will notify when all animations have paused.
  105172. */
  105173. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  105174. /**
  105175. * This observable will notify when all animations are playing.
  105176. */
  105177. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  105178. /**
  105179. * Gets the first frame
  105180. */
  105181. get from(): number;
  105182. /**
  105183. * Gets the last frame
  105184. */
  105185. get to(): number;
  105186. /**
  105187. * Define if the animations are started
  105188. */
  105189. get isStarted(): boolean;
  105190. /**
  105191. * Gets a value indicating that the current group is playing
  105192. */
  105193. get isPlaying(): boolean;
  105194. /**
  105195. * Gets or sets the speed ratio to use for all animations
  105196. */
  105197. get speedRatio(): number;
  105198. /**
  105199. * Gets or sets the speed ratio to use for all animations
  105200. */
  105201. set speedRatio(value: number);
  105202. /**
  105203. * Gets or sets if all animations should loop or not
  105204. */
  105205. get loopAnimation(): boolean;
  105206. set loopAnimation(value: boolean);
  105207. /**
  105208. * Gets the targeted animations for this animation group
  105209. */
  105210. get targetedAnimations(): Array<TargetedAnimation>;
  105211. /**
  105212. * returning the list of animatables controlled by this animation group.
  105213. */
  105214. get animatables(): Array<Animatable>;
  105215. /**
  105216. * Instantiates a new Animation Group.
  105217. * This helps managing several animations at once.
  105218. * @see http://doc.babylonjs.com/how_to/group
  105219. * @param name Defines the name of the group
  105220. * @param scene Defines the scene the group belongs to
  105221. */
  105222. constructor(
  105223. /** The name of the animation group */
  105224. name: string, scene?: Nullable<Scene>);
  105225. /**
  105226. * Add an animation (with its target) in the group
  105227. * @param animation defines the animation we want to add
  105228. * @param target defines the target of the animation
  105229. * @returns the TargetedAnimation object
  105230. */
  105231. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  105232. /**
  105233. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  105234. * It can add constant keys at begin or end
  105235. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  105236. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  105237. * @returns the animation group
  105238. */
  105239. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  105240. private _animationLoopCount;
  105241. private _animationLoopFlags;
  105242. private _processLoop;
  105243. /**
  105244. * Start all animations on given targets
  105245. * @param loop defines if animations must loop
  105246. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  105247. * @param from defines the from key (optional)
  105248. * @param to defines the to key (optional)
  105249. * @returns the current animation group
  105250. */
  105251. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  105252. /**
  105253. * Pause all animations
  105254. * @returns the animation group
  105255. */
  105256. pause(): AnimationGroup;
  105257. /**
  105258. * Play all animations to initial state
  105259. * This function will start() the animations if they were not started or will restart() them if they were paused
  105260. * @param loop defines if animations must loop
  105261. * @returns the animation group
  105262. */
  105263. play(loop?: boolean): AnimationGroup;
  105264. /**
  105265. * Reset all animations to initial state
  105266. * @returns the animation group
  105267. */
  105268. reset(): AnimationGroup;
  105269. /**
  105270. * Restart animations from key 0
  105271. * @returns the animation group
  105272. */
  105273. restart(): AnimationGroup;
  105274. /**
  105275. * Stop all animations
  105276. * @returns the animation group
  105277. */
  105278. stop(): AnimationGroup;
  105279. /**
  105280. * Set animation weight for all animatables
  105281. * @param weight defines the weight to use
  105282. * @return the animationGroup
  105283. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105284. */
  105285. setWeightForAllAnimatables(weight: number): AnimationGroup;
  105286. /**
  105287. * Synchronize and normalize all animatables with a source animatable
  105288. * @param root defines the root animatable to synchronize with
  105289. * @return the animationGroup
  105290. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105291. */
  105292. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  105293. /**
  105294. * Goes to a specific frame in this animation group
  105295. * @param frame the frame number to go to
  105296. * @return the animationGroup
  105297. */
  105298. goToFrame(frame: number): AnimationGroup;
  105299. /**
  105300. * Dispose all associated resources
  105301. */
  105302. dispose(): void;
  105303. private _checkAnimationGroupEnded;
  105304. /**
  105305. * Clone the current animation group and returns a copy
  105306. * @param newName defines the name of the new group
  105307. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  105308. * @returns the new aniamtion group
  105309. */
  105310. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  105311. /**
  105312. * Serializes the animationGroup to an object
  105313. * @returns Serialized object
  105314. */
  105315. serialize(): any;
  105316. /**
  105317. * Returns a new AnimationGroup object parsed from the source provided.
  105318. * @param parsedAnimationGroup defines the source
  105319. * @param scene defines the scene that will receive the animationGroup
  105320. * @returns a new AnimationGroup
  105321. */
  105322. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  105323. /**
  105324. * Returns the string "AnimationGroup"
  105325. * @returns "AnimationGroup"
  105326. */
  105327. getClassName(): string;
  105328. /**
  105329. * Creates a detailled string about the object
  105330. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  105331. * @returns a string representing the object
  105332. */
  105333. toString(fullDetails?: boolean): string;
  105334. }
  105335. }
  105336. declare module BABYLON {
  105337. /**
  105338. * Define an interface for all classes that will hold resources
  105339. */
  105340. export interface IDisposable {
  105341. /**
  105342. * Releases all held resources
  105343. */
  105344. dispose(): void;
  105345. }
  105346. /** Interface defining initialization parameters for Scene class */
  105347. export interface SceneOptions {
  105348. /**
  105349. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  105350. * It will improve performance when the number of geometries becomes important.
  105351. */
  105352. useGeometryUniqueIdsMap?: boolean;
  105353. /**
  105354. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  105355. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105356. */
  105357. useMaterialMeshMap?: boolean;
  105358. /**
  105359. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  105360. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105361. */
  105362. useClonedMeshhMap?: boolean;
  105363. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  105364. virtual?: boolean;
  105365. }
  105366. /**
  105367. * Represents a scene to be rendered by the engine.
  105368. * @see http://doc.babylonjs.com/features/scene
  105369. */
  105370. export class Scene extends AbstractScene implements IAnimatable {
  105371. /** The fog is deactivated */
  105372. static readonly FOGMODE_NONE: number;
  105373. /** The fog density is following an exponential function */
  105374. static readonly FOGMODE_EXP: number;
  105375. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  105376. static readonly FOGMODE_EXP2: number;
  105377. /** The fog density is following a linear function. */
  105378. static readonly FOGMODE_LINEAR: number;
  105379. /**
  105380. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  105381. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105382. */
  105383. static MinDeltaTime: number;
  105384. /**
  105385. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  105386. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105387. */
  105388. static MaxDeltaTime: number;
  105389. /**
  105390. * Factory used to create the default material.
  105391. * @param name The name of the material to create
  105392. * @param scene The scene to create the material for
  105393. * @returns The default material
  105394. */
  105395. static DefaultMaterialFactory(scene: Scene): Material;
  105396. /**
  105397. * Factory used to create the a collision coordinator.
  105398. * @returns The collision coordinator
  105399. */
  105400. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  105401. /** @hidden */
  105402. _inputManager: InputManager;
  105403. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  105404. cameraToUseForPointers: Nullable<Camera>;
  105405. /** @hidden */
  105406. readonly _isScene: boolean;
  105407. /**
  105408. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  105409. */
  105410. autoClear: boolean;
  105411. /**
  105412. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  105413. */
  105414. autoClearDepthAndStencil: boolean;
  105415. /**
  105416. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  105417. */
  105418. clearColor: Color4;
  105419. /**
  105420. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  105421. */
  105422. ambientColor: Color3;
  105423. /**
  105424. * This is use to store the default BRDF lookup for PBR materials in your scene.
  105425. * It should only be one of the following (if not the default embedded one):
  105426. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105427. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  105428. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105429. * The material properties need to be setup according to the type of texture in use.
  105430. */
  105431. environmentBRDFTexture: BaseTexture;
  105432. /** @hidden */
  105433. protected _environmentTexture: Nullable<BaseTexture>;
  105434. /**
  105435. * Texture used in all pbr material as the reflection texture.
  105436. * As in the majority of the scene they are the same (exception for multi room and so on),
  105437. * this is easier to reference from here than from all the materials.
  105438. */
  105439. get environmentTexture(): Nullable<BaseTexture>;
  105440. /**
  105441. * Texture used in all pbr material as the reflection texture.
  105442. * As in the majority of the scene they are the same (exception for multi room and so on),
  105443. * this is easier to set here than in all the materials.
  105444. */
  105445. set environmentTexture(value: Nullable<BaseTexture>);
  105446. /** @hidden */
  105447. protected _environmentIntensity: number;
  105448. /**
  105449. * Intensity of the environment in all pbr material.
  105450. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105451. * As in the majority of the scene they are the same (exception for multi room and so on),
  105452. * this is easier to reference from here than from all the materials.
  105453. */
  105454. get environmentIntensity(): number;
  105455. /**
  105456. * Intensity of the environment in all pbr material.
  105457. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105458. * As in the majority of the scene they are the same (exception for multi room and so on),
  105459. * this is easier to set here than in all the materials.
  105460. */
  105461. set environmentIntensity(value: number);
  105462. /** @hidden */
  105463. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105464. /**
  105465. * Default image processing configuration used either in the rendering
  105466. * Forward main pass or through the imageProcessingPostProcess if present.
  105467. * As in the majority of the scene they are the same (exception for multi camera),
  105468. * this is easier to reference from here than from all the materials and post process.
  105469. *
  105470. * No setter as we it is a shared configuration, you can set the values instead.
  105471. */
  105472. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105473. private _forceWireframe;
  105474. /**
  105475. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  105476. */
  105477. set forceWireframe(value: boolean);
  105478. get forceWireframe(): boolean;
  105479. private _forcePointsCloud;
  105480. /**
  105481. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  105482. */
  105483. set forcePointsCloud(value: boolean);
  105484. get forcePointsCloud(): boolean;
  105485. /**
  105486. * Gets or sets the active clipplane 1
  105487. */
  105488. clipPlane: Nullable<Plane>;
  105489. /**
  105490. * Gets or sets the active clipplane 2
  105491. */
  105492. clipPlane2: Nullable<Plane>;
  105493. /**
  105494. * Gets or sets the active clipplane 3
  105495. */
  105496. clipPlane3: Nullable<Plane>;
  105497. /**
  105498. * Gets or sets the active clipplane 4
  105499. */
  105500. clipPlane4: Nullable<Plane>;
  105501. /**
  105502. * Gets or sets the active clipplane 5
  105503. */
  105504. clipPlane5: Nullable<Plane>;
  105505. /**
  105506. * Gets or sets the active clipplane 6
  105507. */
  105508. clipPlane6: Nullable<Plane>;
  105509. /**
  105510. * Gets or sets a boolean indicating if animations are enabled
  105511. */
  105512. animationsEnabled: boolean;
  105513. private _animationPropertiesOverride;
  105514. /**
  105515. * Gets or sets the animation properties override
  105516. */
  105517. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105518. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105519. /**
  105520. * Gets or sets a boolean indicating if a constant deltatime has to be used
  105521. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  105522. */
  105523. useConstantAnimationDeltaTime: boolean;
  105524. /**
  105525. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  105526. * Please note that it requires to run a ray cast through the scene on every frame
  105527. */
  105528. constantlyUpdateMeshUnderPointer: boolean;
  105529. /**
  105530. * Defines the HTML cursor to use when hovering over interactive elements
  105531. */
  105532. hoverCursor: string;
  105533. /**
  105534. * Defines the HTML default cursor to use (empty by default)
  105535. */
  105536. defaultCursor: string;
  105537. /**
  105538. * Defines wether cursors are handled by the scene.
  105539. */
  105540. doNotHandleCursors: boolean;
  105541. /**
  105542. * This is used to call preventDefault() on pointer down
  105543. * in order to block unwanted artifacts like system double clicks
  105544. */
  105545. preventDefaultOnPointerDown: boolean;
  105546. /**
  105547. * This is used to call preventDefault() on pointer up
  105548. * in order to block unwanted artifacts like system double clicks
  105549. */
  105550. preventDefaultOnPointerUp: boolean;
  105551. /**
  105552. * Gets or sets user defined metadata
  105553. */
  105554. metadata: any;
  105555. /**
  105556. * For internal use only. Please do not use.
  105557. */
  105558. reservedDataStore: any;
  105559. /**
  105560. * Gets the name of the plugin used to load this scene (null by default)
  105561. */
  105562. loadingPluginName: string;
  105563. /**
  105564. * Use this array to add regular expressions used to disable offline support for specific urls
  105565. */
  105566. disableOfflineSupportExceptionRules: RegExp[];
  105567. /**
  105568. * An event triggered when the scene is disposed.
  105569. */
  105570. onDisposeObservable: Observable<Scene>;
  105571. private _onDisposeObserver;
  105572. /** Sets a function to be executed when this scene is disposed. */
  105573. set onDispose(callback: () => void);
  105574. /**
  105575. * An event triggered before rendering the scene (right after animations and physics)
  105576. */
  105577. onBeforeRenderObservable: Observable<Scene>;
  105578. private _onBeforeRenderObserver;
  105579. /** Sets a function to be executed before rendering this scene */
  105580. set beforeRender(callback: Nullable<() => void>);
  105581. /**
  105582. * An event triggered after rendering the scene
  105583. */
  105584. onAfterRenderObservable: Observable<Scene>;
  105585. /**
  105586. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  105587. */
  105588. onAfterRenderCameraObservable: Observable<Camera>;
  105589. private _onAfterRenderObserver;
  105590. /** Sets a function to be executed after rendering this scene */
  105591. set afterRender(callback: Nullable<() => void>);
  105592. /**
  105593. * An event triggered before animating the scene
  105594. */
  105595. onBeforeAnimationsObservable: Observable<Scene>;
  105596. /**
  105597. * An event triggered after animations processing
  105598. */
  105599. onAfterAnimationsObservable: Observable<Scene>;
  105600. /**
  105601. * An event triggered before draw calls are ready to be sent
  105602. */
  105603. onBeforeDrawPhaseObservable: Observable<Scene>;
  105604. /**
  105605. * An event triggered after draw calls have been sent
  105606. */
  105607. onAfterDrawPhaseObservable: Observable<Scene>;
  105608. /**
  105609. * An event triggered when the scene is ready
  105610. */
  105611. onReadyObservable: Observable<Scene>;
  105612. /**
  105613. * An event triggered before rendering a camera
  105614. */
  105615. onBeforeCameraRenderObservable: Observable<Camera>;
  105616. private _onBeforeCameraRenderObserver;
  105617. /** Sets a function to be executed before rendering a camera*/
  105618. set beforeCameraRender(callback: () => void);
  105619. /**
  105620. * An event triggered after rendering a camera
  105621. */
  105622. onAfterCameraRenderObservable: Observable<Camera>;
  105623. private _onAfterCameraRenderObserver;
  105624. /** Sets a function to be executed after rendering a camera*/
  105625. set afterCameraRender(callback: () => void);
  105626. /**
  105627. * An event triggered when active meshes evaluation is about to start
  105628. */
  105629. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  105630. /**
  105631. * An event triggered when active meshes evaluation is done
  105632. */
  105633. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  105634. /**
  105635. * An event triggered when particles rendering is about to start
  105636. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105637. */
  105638. onBeforeParticlesRenderingObservable: Observable<Scene>;
  105639. /**
  105640. * An event triggered when particles rendering is done
  105641. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105642. */
  105643. onAfterParticlesRenderingObservable: Observable<Scene>;
  105644. /**
  105645. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  105646. */
  105647. onDataLoadedObservable: Observable<Scene>;
  105648. /**
  105649. * An event triggered when a camera is created
  105650. */
  105651. onNewCameraAddedObservable: Observable<Camera>;
  105652. /**
  105653. * An event triggered when a camera is removed
  105654. */
  105655. onCameraRemovedObservable: Observable<Camera>;
  105656. /**
  105657. * An event triggered when a light is created
  105658. */
  105659. onNewLightAddedObservable: Observable<Light>;
  105660. /**
  105661. * An event triggered when a light is removed
  105662. */
  105663. onLightRemovedObservable: Observable<Light>;
  105664. /**
  105665. * An event triggered when a geometry is created
  105666. */
  105667. onNewGeometryAddedObservable: Observable<Geometry>;
  105668. /**
  105669. * An event triggered when a geometry is removed
  105670. */
  105671. onGeometryRemovedObservable: Observable<Geometry>;
  105672. /**
  105673. * An event triggered when a transform node is created
  105674. */
  105675. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  105676. /**
  105677. * An event triggered when a transform node is removed
  105678. */
  105679. onTransformNodeRemovedObservable: Observable<TransformNode>;
  105680. /**
  105681. * An event triggered when a mesh is created
  105682. */
  105683. onNewMeshAddedObservable: Observable<AbstractMesh>;
  105684. /**
  105685. * An event triggered when a mesh is removed
  105686. */
  105687. onMeshRemovedObservable: Observable<AbstractMesh>;
  105688. /**
  105689. * An event triggered when a skeleton is created
  105690. */
  105691. onNewSkeletonAddedObservable: Observable<Skeleton>;
  105692. /**
  105693. * An event triggered when a skeleton is removed
  105694. */
  105695. onSkeletonRemovedObservable: Observable<Skeleton>;
  105696. /**
  105697. * An event triggered when a material is created
  105698. */
  105699. onNewMaterialAddedObservable: Observable<Material>;
  105700. /**
  105701. * An event triggered when a material is removed
  105702. */
  105703. onMaterialRemovedObservable: Observable<Material>;
  105704. /**
  105705. * An event triggered when a texture is created
  105706. */
  105707. onNewTextureAddedObservable: Observable<BaseTexture>;
  105708. /**
  105709. * An event triggered when a texture is removed
  105710. */
  105711. onTextureRemovedObservable: Observable<BaseTexture>;
  105712. /**
  105713. * An event triggered when render targets are about to be rendered
  105714. * Can happen multiple times per frame.
  105715. */
  105716. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  105717. /**
  105718. * An event triggered when render targets were rendered.
  105719. * Can happen multiple times per frame.
  105720. */
  105721. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  105722. /**
  105723. * An event triggered before calculating deterministic simulation step
  105724. */
  105725. onBeforeStepObservable: Observable<Scene>;
  105726. /**
  105727. * An event triggered after calculating deterministic simulation step
  105728. */
  105729. onAfterStepObservable: Observable<Scene>;
  105730. /**
  105731. * An event triggered when the activeCamera property is updated
  105732. */
  105733. onActiveCameraChanged: Observable<Scene>;
  105734. /**
  105735. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  105736. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105737. * 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)
  105738. */
  105739. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105740. /**
  105741. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  105742. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105743. * 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)
  105744. */
  105745. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105746. /**
  105747. * This Observable will when a mesh has been imported into the scene.
  105748. */
  105749. onMeshImportedObservable: Observable<AbstractMesh>;
  105750. /**
  105751. * This Observable will when an animation file has been imported into the scene.
  105752. */
  105753. onAnimationFileImportedObservable: Observable<Scene>;
  105754. /**
  105755. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  105756. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  105757. */
  105758. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  105759. /** @hidden */
  105760. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  105761. /**
  105762. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  105763. */
  105764. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  105765. /**
  105766. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  105767. */
  105768. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  105769. /**
  105770. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  105771. */
  105772. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  105773. /** Callback called when a pointer move is detected */
  105774. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105775. /** Callback called when a pointer down is detected */
  105776. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105777. /** Callback called when a pointer up is detected */
  105778. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  105779. /** Callback called when a pointer pick is detected */
  105780. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  105781. /**
  105782. * 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).
  105783. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  105784. */
  105785. onPrePointerObservable: Observable<PointerInfoPre>;
  105786. /**
  105787. * Observable event triggered each time an input event is received from the rendering canvas
  105788. */
  105789. onPointerObservable: Observable<PointerInfo>;
  105790. /**
  105791. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  105792. */
  105793. get unTranslatedPointer(): Vector2;
  105794. /**
  105795. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  105796. */
  105797. static get DragMovementThreshold(): number;
  105798. static set DragMovementThreshold(value: number);
  105799. /**
  105800. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  105801. */
  105802. static get LongPressDelay(): number;
  105803. static set LongPressDelay(value: number);
  105804. /**
  105805. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  105806. */
  105807. static get DoubleClickDelay(): number;
  105808. static set DoubleClickDelay(value: number);
  105809. /** If you need to check double click without raising a single click at first click, enable this flag */
  105810. static get ExclusiveDoubleClickMode(): boolean;
  105811. static set ExclusiveDoubleClickMode(value: boolean);
  105812. /** @hidden */
  105813. _mirroredCameraPosition: Nullable<Vector3>;
  105814. /**
  105815. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  105816. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  105817. */
  105818. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  105819. /**
  105820. * Observable event triggered each time an keyboard event is received from the hosting window
  105821. */
  105822. onKeyboardObservable: Observable<KeyboardInfo>;
  105823. private _useRightHandedSystem;
  105824. /**
  105825. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  105826. */
  105827. set useRightHandedSystem(value: boolean);
  105828. get useRightHandedSystem(): boolean;
  105829. private _timeAccumulator;
  105830. private _currentStepId;
  105831. private _currentInternalStep;
  105832. /**
  105833. * Sets the step Id used by deterministic lock step
  105834. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105835. * @param newStepId defines the step Id
  105836. */
  105837. setStepId(newStepId: number): void;
  105838. /**
  105839. * Gets the step Id used by deterministic lock step
  105840. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105841. * @returns the step Id
  105842. */
  105843. getStepId(): number;
  105844. /**
  105845. * Gets the internal step used by deterministic lock step
  105846. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105847. * @returns the internal step
  105848. */
  105849. getInternalStep(): number;
  105850. private _fogEnabled;
  105851. /**
  105852. * Gets or sets a boolean indicating if fog is enabled on this scene
  105853. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105854. * (Default is true)
  105855. */
  105856. set fogEnabled(value: boolean);
  105857. get fogEnabled(): boolean;
  105858. private _fogMode;
  105859. /**
  105860. * Gets or sets the fog mode to use
  105861. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105862. * | mode | value |
  105863. * | --- | --- |
  105864. * | FOGMODE_NONE | 0 |
  105865. * | FOGMODE_EXP | 1 |
  105866. * | FOGMODE_EXP2 | 2 |
  105867. * | FOGMODE_LINEAR | 3 |
  105868. */
  105869. set fogMode(value: number);
  105870. get fogMode(): number;
  105871. /**
  105872. * Gets or sets the fog color to use
  105873. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105874. * (Default is Color3(0.2, 0.2, 0.3))
  105875. */
  105876. fogColor: Color3;
  105877. /**
  105878. * Gets or sets the fog density to use
  105879. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105880. * (Default is 0.1)
  105881. */
  105882. fogDensity: number;
  105883. /**
  105884. * Gets or sets the fog start distance to use
  105885. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105886. * (Default is 0)
  105887. */
  105888. fogStart: number;
  105889. /**
  105890. * Gets or sets the fog end distance to use
  105891. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105892. * (Default is 1000)
  105893. */
  105894. fogEnd: number;
  105895. private _shadowsEnabled;
  105896. /**
  105897. * Gets or sets a boolean indicating if shadows are enabled on this scene
  105898. */
  105899. set shadowsEnabled(value: boolean);
  105900. get shadowsEnabled(): boolean;
  105901. private _lightsEnabled;
  105902. /**
  105903. * Gets or sets a boolean indicating if lights are enabled on this scene
  105904. */
  105905. set lightsEnabled(value: boolean);
  105906. get lightsEnabled(): boolean;
  105907. /** All of the active cameras added to this scene. */
  105908. activeCameras: Camera[];
  105909. /** @hidden */
  105910. _activeCamera: Nullable<Camera>;
  105911. /** Gets or sets the current active camera */
  105912. get activeCamera(): Nullable<Camera>;
  105913. set activeCamera(value: Nullable<Camera>);
  105914. private _defaultMaterial;
  105915. /** The default material used on meshes when no material is affected */
  105916. get defaultMaterial(): Material;
  105917. /** The default material used on meshes when no material is affected */
  105918. set defaultMaterial(value: Material);
  105919. private _texturesEnabled;
  105920. /**
  105921. * Gets or sets a boolean indicating if textures are enabled on this scene
  105922. */
  105923. set texturesEnabled(value: boolean);
  105924. get texturesEnabled(): boolean;
  105925. /**
  105926. * Gets or sets a boolean indicating if particles are enabled on this scene
  105927. */
  105928. particlesEnabled: boolean;
  105929. /**
  105930. * Gets or sets a boolean indicating if sprites are enabled on this scene
  105931. */
  105932. spritesEnabled: boolean;
  105933. private _skeletonsEnabled;
  105934. /**
  105935. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  105936. */
  105937. set skeletonsEnabled(value: boolean);
  105938. get skeletonsEnabled(): boolean;
  105939. /**
  105940. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  105941. */
  105942. lensFlaresEnabled: boolean;
  105943. /**
  105944. * Gets or sets a boolean indicating if collisions are enabled on this scene
  105945. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105946. */
  105947. collisionsEnabled: boolean;
  105948. private _collisionCoordinator;
  105949. /** @hidden */
  105950. get collisionCoordinator(): ICollisionCoordinator;
  105951. /**
  105952. * Defines the gravity applied to this scene (used only for collisions)
  105953. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  105954. */
  105955. gravity: Vector3;
  105956. /**
  105957. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  105958. */
  105959. postProcessesEnabled: boolean;
  105960. /**
  105961. * The list of postprocesses added to the scene
  105962. */
  105963. postProcesses: PostProcess[];
  105964. /**
  105965. * Gets the current postprocess manager
  105966. */
  105967. postProcessManager: PostProcessManager;
  105968. /**
  105969. * Gets or sets a boolean indicating if render targets are enabled on this scene
  105970. */
  105971. renderTargetsEnabled: boolean;
  105972. /**
  105973. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  105974. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  105975. */
  105976. dumpNextRenderTargets: boolean;
  105977. /**
  105978. * The list of user defined render targets added to the scene
  105979. */
  105980. customRenderTargets: RenderTargetTexture[];
  105981. /**
  105982. * Defines if texture loading must be delayed
  105983. * If true, textures will only be loaded when they need to be rendered
  105984. */
  105985. useDelayedTextureLoading: boolean;
  105986. /**
  105987. * Gets the list of meshes imported to the scene through SceneLoader
  105988. */
  105989. importedMeshesFiles: String[];
  105990. /**
  105991. * Gets or sets a boolean indicating if probes are enabled on this scene
  105992. */
  105993. probesEnabled: boolean;
  105994. /**
  105995. * Gets or sets the current offline provider to use to store scene data
  105996. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  105997. */
  105998. offlineProvider: IOfflineProvider;
  105999. /**
  106000. * Gets or sets the action manager associated with the scene
  106001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106002. */
  106003. actionManager: AbstractActionManager;
  106004. private _meshesForIntersections;
  106005. /**
  106006. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  106007. */
  106008. proceduralTexturesEnabled: boolean;
  106009. private _engine;
  106010. private _totalVertices;
  106011. /** @hidden */
  106012. _activeIndices: PerfCounter;
  106013. /** @hidden */
  106014. _activeParticles: PerfCounter;
  106015. /** @hidden */
  106016. _activeBones: PerfCounter;
  106017. private _animationRatio;
  106018. /** @hidden */
  106019. _animationTimeLast: number;
  106020. /** @hidden */
  106021. _animationTime: number;
  106022. /**
  106023. * Gets or sets a general scale for animation speed
  106024. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  106025. */
  106026. animationTimeScale: number;
  106027. /** @hidden */
  106028. _cachedMaterial: Nullable<Material>;
  106029. /** @hidden */
  106030. _cachedEffect: Nullable<Effect>;
  106031. /** @hidden */
  106032. _cachedVisibility: Nullable<number>;
  106033. private _renderId;
  106034. private _frameId;
  106035. private _executeWhenReadyTimeoutId;
  106036. private _intermediateRendering;
  106037. private _viewUpdateFlag;
  106038. private _projectionUpdateFlag;
  106039. /** @hidden */
  106040. _toBeDisposed: Nullable<IDisposable>[];
  106041. private _activeRequests;
  106042. /** @hidden */
  106043. _pendingData: any[];
  106044. private _isDisposed;
  106045. /**
  106046. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  106047. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  106048. */
  106049. dispatchAllSubMeshesOfActiveMeshes: boolean;
  106050. private _activeMeshes;
  106051. private _processedMaterials;
  106052. private _renderTargets;
  106053. /** @hidden */
  106054. _activeParticleSystems: SmartArray<IParticleSystem>;
  106055. private _activeSkeletons;
  106056. private _softwareSkinnedMeshes;
  106057. private _renderingManager;
  106058. /** @hidden */
  106059. _activeAnimatables: Animatable[];
  106060. private _transformMatrix;
  106061. private _sceneUbo;
  106062. /** @hidden */
  106063. _viewMatrix: Matrix;
  106064. private _projectionMatrix;
  106065. /** @hidden */
  106066. _forcedViewPosition: Nullable<Vector3>;
  106067. /** @hidden */
  106068. _frustumPlanes: Plane[];
  106069. /**
  106070. * Gets the list of frustum planes (built from the active camera)
  106071. */
  106072. get frustumPlanes(): Plane[];
  106073. /**
  106074. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  106075. * This is useful if there are more lights that the maximum simulteanous authorized
  106076. */
  106077. requireLightSorting: boolean;
  106078. /** @hidden */
  106079. readonly useMaterialMeshMap: boolean;
  106080. /** @hidden */
  106081. readonly useClonedMeshhMap: boolean;
  106082. private _externalData;
  106083. private _uid;
  106084. /**
  106085. * @hidden
  106086. * Backing store of defined scene components.
  106087. */
  106088. _components: ISceneComponent[];
  106089. /**
  106090. * @hidden
  106091. * Backing store of defined scene components.
  106092. */
  106093. _serializableComponents: ISceneSerializableComponent[];
  106094. /**
  106095. * List of components to register on the next registration step.
  106096. */
  106097. private _transientComponents;
  106098. /**
  106099. * Registers the transient components if needed.
  106100. */
  106101. private _registerTransientComponents;
  106102. /**
  106103. * @hidden
  106104. * Add a component to the scene.
  106105. * Note that the ccomponent could be registered on th next frame if this is called after
  106106. * the register component stage.
  106107. * @param component Defines the component to add to the scene
  106108. */
  106109. _addComponent(component: ISceneComponent): void;
  106110. /**
  106111. * @hidden
  106112. * Gets a component from the scene.
  106113. * @param name defines the name of the component to retrieve
  106114. * @returns the component or null if not present
  106115. */
  106116. _getComponent(name: string): Nullable<ISceneComponent>;
  106117. /**
  106118. * @hidden
  106119. * Defines the actions happening before camera updates.
  106120. */
  106121. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  106122. /**
  106123. * @hidden
  106124. * Defines the actions happening before clear the canvas.
  106125. */
  106126. _beforeClearStage: Stage<SimpleStageAction>;
  106127. /**
  106128. * @hidden
  106129. * Defines the actions when collecting render targets for the frame.
  106130. */
  106131. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106132. /**
  106133. * @hidden
  106134. * Defines the actions happening for one camera in the frame.
  106135. */
  106136. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106137. /**
  106138. * @hidden
  106139. * Defines the actions happening during the per mesh ready checks.
  106140. */
  106141. _isReadyForMeshStage: Stage<MeshStageAction>;
  106142. /**
  106143. * @hidden
  106144. * Defines the actions happening before evaluate active mesh checks.
  106145. */
  106146. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  106147. /**
  106148. * @hidden
  106149. * Defines the actions happening during the evaluate sub mesh checks.
  106150. */
  106151. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  106152. /**
  106153. * @hidden
  106154. * Defines the actions happening during the active mesh stage.
  106155. */
  106156. _activeMeshStage: Stage<ActiveMeshStageAction>;
  106157. /**
  106158. * @hidden
  106159. * Defines the actions happening during the per camera render target step.
  106160. */
  106161. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  106162. /**
  106163. * @hidden
  106164. * Defines the actions happening just before the active camera is drawing.
  106165. */
  106166. _beforeCameraDrawStage: Stage<CameraStageAction>;
  106167. /**
  106168. * @hidden
  106169. * Defines the actions happening just before a render target is drawing.
  106170. */
  106171. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106172. /**
  106173. * @hidden
  106174. * Defines the actions happening just before a rendering group is drawing.
  106175. */
  106176. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106177. /**
  106178. * @hidden
  106179. * Defines the actions happening just before a mesh is drawing.
  106180. */
  106181. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106182. /**
  106183. * @hidden
  106184. * Defines the actions happening just after a mesh has been drawn.
  106185. */
  106186. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106187. /**
  106188. * @hidden
  106189. * Defines the actions happening just after a rendering group has been drawn.
  106190. */
  106191. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106192. /**
  106193. * @hidden
  106194. * Defines the actions happening just after the active camera has been drawn.
  106195. */
  106196. _afterCameraDrawStage: Stage<CameraStageAction>;
  106197. /**
  106198. * @hidden
  106199. * Defines the actions happening just after a render target has been drawn.
  106200. */
  106201. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106202. /**
  106203. * @hidden
  106204. * Defines the actions happening just after rendering all cameras and computing intersections.
  106205. */
  106206. _afterRenderStage: Stage<SimpleStageAction>;
  106207. /**
  106208. * @hidden
  106209. * Defines the actions happening when a pointer move event happens.
  106210. */
  106211. _pointerMoveStage: Stage<PointerMoveStageAction>;
  106212. /**
  106213. * @hidden
  106214. * Defines the actions happening when a pointer down event happens.
  106215. */
  106216. _pointerDownStage: Stage<PointerUpDownStageAction>;
  106217. /**
  106218. * @hidden
  106219. * Defines the actions happening when a pointer up event happens.
  106220. */
  106221. _pointerUpStage: Stage<PointerUpDownStageAction>;
  106222. /**
  106223. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  106224. */
  106225. private geometriesByUniqueId;
  106226. /**
  106227. * Creates a new Scene
  106228. * @param engine defines the engine to use to render this scene
  106229. * @param options defines the scene options
  106230. */
  106231. constructor(engine: Engine, options?: SceneOptions);
  106232. /**
  106233. * Gets a string idenfifying the name of the class
  106234. * @returns "Scene" string
  106235. */
  106236. getClassName(): string;
  106237. private _defaultMeshCandidates;
  106238. /**
  106239. * @hidden
  106240. */
  106241. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106242. private _defaultSubMeshCandidates;
  106243. /**
  106244. * @hidden
  106245. */
  106246. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106247. /**
  106248. * Sets the default candidate providers for the scene.
  106249. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  106250. * and getCollidingSubMeshCandidates to their default function
  106251. */
  106252. setDefaultCandidateProviders(): void;
  106253. /**
  106254. * Gets the mesh that is currently under the pointer
  106255. */
  106256. get meshUnderPointer(): Nullable<AbstractMesh>;
  106257. /**
  106258. * Gets or sets the current on-screen X position of the pointer
  106259. */
  106260. get pointerX(): number;
  106261. set pointerX(value: number);
  106262. /**
  106263. * Gets or sets the current on-screen Y position of the pointer
  106264. */
  106265. get pointerY(): number;
  106266. set pointerY(value: number);
  106267. /**
  106268. * Gets the cached material (ie. the latest rendered one)
  106269. * @returns the cached material
  106270. */
  106271. getCachedMaterial(): Nullable<Material>;
  106272. /**
  106273. * Gets the cached effect (ie. the latest rendered one)
  106274. * @returns the cached effect
  106275. */
  106276. getCachedEffect(): Nullable<Effect>;
  106277. /**
  106278. * Gets the cached visibility state (ie. the latest rendered one)
  106279. * @returns the cached visibility state
  106280. */
  106281. getCachedVisibility(): Nullable<number>;
  106282. /**
  106283. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  106284. * @param material defines the current material
  106285. * @param effect defines the current effect
  106286. * @param visibility defines the current visibility state
  106287. * @returns true if one parameter is not cached
  106288. */
  106289. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  106290. /**
  106291. * Gets the engine associated with the scene
  106292. * @returns an Engine
  106293. */
  106294. getEngine(): Engine;
  106295. /**
  106296. * Gets the total number of vertices rendered per frame
  106297. * @returns the total number of vertices rendered per frame
  106298. */
  106299. getTotalVertices(): number;
  106300. /**
  106301. * Gets the performance counter for total vertices
  106302. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106303. */
  106304. get totalVerticesPerfCounter(): PerfCounter;
  106305. /**
  106306. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  106307. * @returns the total number of active indices rendered per frame
  106308. */
  106309. getActiveIndices(): number;
  106310. /**
  106311. * Gets the performance counter for active indices
  106312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106313. */
  106314. get totalActiveIndicesPerfCounter(): PerfCounter;
  106315. /**
  106316. * Gets the total number of active particles rendered per frame
  106317. * @returns the total number of active particles rendered per frame
  106318. */
  106319. getActiveParticles(): number;
  106320. /**
  106321. * Gets the performance counter for active particles
  106322. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106323. */
  106324. get activeParticlesPerfCounter(): PerfCounter;
  106325. /**
  106326. * Gets the total number of active bones rendered per frame
  106327. * @returns the total number of active bones rendered per frame
  106328. */
  106329. getActiveBones(): number;
  106330. /**
  106331. * Gets the performance counter for active bones
  106332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106333. */
  106334. get activeBonesPerfCounter(): PerfCounter;
  106335. /**
  106336. * Gets the array of active meshes
  106337. * @returns an array of AbstractMesh
  106338. */
  106339. getActiveMeshes(): SmartArray<AbstractMesh>;
  106340. /**
  106341. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  106342. * @returns a number
  106343. */
  106344. getAnimationRatio(): number;
  106345. /**
  106346. * Gets an unique Id for the current render phase
  106347. * @returns a number
  106348. */
  106349. getRenderId(): number;
  106350. /**
  106351. * Gets an unique Id for the current frame
  106352. * @returns a number
  106353. */
  106354. getFrameId(): number;
  106355. /** Call this function if you want to manually increment the render Id*/
  106356. incrementRenderId(): void;
  106357. private _createUbo;
  106358. /**
  106359. * Use this method to simulate a pointer move on a mesh
  106360. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106361. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106362. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106363. * @returns the current scene
  106364. */
  106365. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106366. /**
  106367. * Use this method to simulate a pointer down on a mesh
  106368. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106369. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106370. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106371. * @returns the current scene
  106372. */
  106373. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106374. /**
  106375. * Use this method to simulate a pointer up on a mesh
  106376. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106377. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106378. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106379. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  106380. * @returns the current scene
  106381. */
  106382. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  106383. /**
  106384. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  106385. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  106386. * @returns true if the pointer was captured
  106387. */
  106388. isPointerCaptured(pointerId?: number): boolean;
  106389. /**
  106390. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  106391. * @param attachUp defines if you want to attach events to pointerup
  106392. * @param attachDown defines if you want to attach events to pointerdown
  106393. * @param attachMove defines if you want to attach events to pointermove
  106394. */
  106395. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  106396. /** Detaches all event handlers*/
  106397. detachControl(): void;
  106398. /**
  106399. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  106400. * Delay loaded resources are not taking in account
  106401. * @return true if all required resources are ready
  106402. */
  106403. isReady(): boolean;
  106404. /** Resets all cached information relative to material (including effect and visibility) */
  106405. resetCachedMaterial(): void;
  106406. /**
  106407. * Registers a function to be called before every frame render
  106408. * @param func defines the function to register
  106409. */
  106410. registerBeforeRender(func: () => void): void;
  106411. /**
  106412. * Unregisters a function called before every frame render
  106413. * @param func defines the function to unregister
  106414. */
  106415. unregisterBeforeRender(func: () => void): void;
  106416. /**
  106417. * Registers a function to be called after every frame render
  106418. * @param func defines the function to register
  106419. */
  106420. registerAfterRender(func: () => void): void;
  106421. /**
  106422. * Unregisters a function called after every frame render
  106423. * @param func defines the function to unregister
  106424. */
  106425. unregisterAfterRender(func: () => void): void;
  106426. private _executeOnceBeforeRender;
  106427. /**
  106428. * The provided function will run before render once and will be disposed afterwards.
  106429. * A timeout delay can be provided so that the function will be executed in N ms.
  106430. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  106431. * @param func The function to be executed.
  106432. * @param timeout optional delay in ms
  106433. */
  106434. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  106435. /** @hidden */
  106436. _addPendingData(data: any): void;
  106437. /** @hidden */
  106438. _removePendingData(data: any): void;
  106439. /**
  106440. * Returns the number of items waiting to be loaded
  106441. * @returns the number of items waiting to be loaded
  106442. */
  106443. getWaitingItemsCount(): number;
  106444. /**
  106445. * Returns a boolean indicating if the scene is still loading data
  106446. */
  106447. get isLoading(): boolean;
  106448. /**
  106449. * Registers a function to be executed when the scene is ready
  106450. * @param {Function} func - the function to be executed
  106451. */
  106452. executeWhenReady(func: () => void): void;
  106453. /**
  106454. * Returns a promise that resolves when the scene is ready
  106455. * @returns A promise that resolves when the scene is ready
  106456. */
  106457. whenReadyAsync(): Promise<void>;
  106458. /** @hidden */
  106459. _checkIsReady(): void;
  106460. /**
  106461. * Gets all animatable attached to the scene
  106462. */
  106463. get animatables(): Animatable[];
  106464. /**
  106465. * Resets the last animation time frame.
  106466. * Useful to override when animations start running when loading a scene for the first time.
  106467. */
  106468. resetLastAnimationTimeFrame(): void;
  106469. /**
  106470. * Gets the current view matrix
  106471. * @returns a Matrix
  106472. */
  106473. getViewMatrix(): Matrix;
  106474. /**
  106475. * Gets the current projection matrix
  106476. * @returns a Matrix
  106477. */
  106478. getProjectionMatrix(): Matrix;
  106479. /**
  106480. * Gets the current transform matrix
  106481. * @returns a Matrix made of View * Projection
  106482. */
  106483. getTransformMatrix(): Matrix;
  106484. /**
  106485. * Sets the current transform matrix
  106486. * @param viewL defines the View matrix to use
  106487. * @param projectionL defines the Projection matrix to use
  106488. * @param viewR defines the right View matrix to use (if provided)
  106489. * @param projectionR defines the right Projection matrix to use (if provided)
  106490. */
  106491. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  106492. /**
  106493. * Gets the uniform buffer used to store scene data
  106494. * @returns a UniformBuffer
  106495. */
  106496. getSceneUniformBuffer(): UniformBuffer;
  106497. /**
  106498. * Gets an unique (relatively to the current scene) Id
  106499. * @returns an unique number for the scene
  106500. */
  106501. getUniqueId(): number;
  106502. /**
  106503. * Add a mesh to the list of scene's meshes
  106504. * @param newMesh defines the mesh to add
  106505. * @param recursive if all child meshes should also be added to the scene
  106506. */
  106507. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  106508. /**
  106509. * Remove a mesh for the list of scene's meshes
  106510. * @param toRemove defines the mesh to remove
  106511. * @param recursive if all child meshes should also be removed from the scene
  106512. * @returns the index where the mesh was in the mesh list
  106513. */
  106514. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  106515. /**
  106516. * Add a transform node to the list of scene's transform nodes
  106517. * @param newTransformNode defines the transform node to add
  106518. */
  106519. addTransformNode(newTransformNode: TransformNode): void;
  106520. /**
  106521. * Remove a transform node for the list of scene's transform nodes
  106522. * @param toRemove defines the transform node to remove
  106523. * @returns the index where the transform node was in the transform node list
  106524. */
  106525. removeTransformNode(toRemove: TransformNode): number;
  106526. /**
  106527. * Remove a skeleton for the list of scene's skeletons
  106528. * @param toRemove defines the skeleton to remove
  106529. * @returns the index where the skeleton was in the skeleton list
  106530. */
  106531. removeSkeleton(toRemove: Skeleton): number;
  106532. /**
  106533. * Remove a morph target for the list of scene's morph targets
  106534. * @param toRemove defines the morph target to remove
  106535. * @returns the index where the morph target was in the morph target list
  106536. */
  106537. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  106538. /**
  106539. * Remove a light for the list of scene's lights
  106540. * @param toRemove defines the light to remove
  106541. * @returns the index where the light was in the light list
  106542. */
  106543. removeLight(toRemove: Light): number;
  106544. /**
  106545. * Remove a camera for the list of scene's cameras
  106546. * @param toRemove defines the camera to remove
  106547. * @returns the index where the camera was in the camera list
  106548. */
  106549. removeCamera(toRemove: Camera): number;
  106550. /**
  106551. * Remove a particle system for the list of scene's particle systems
  106552. * @param toRemove defines the particle system to remove
  106553. * @returns the index where the particle system was in the particle system list
  106554. */
  106555. removeParticleSystem(toRemove: IParticleSystem): number;
  106556. /**
  106557. * Remove a animation for the list of scene's animations
  106558. * @param toRemove defines the animation to remove
  106559. * @returns the index where the animation was in the animation list
  106560. */
  106561. removeAnimation(toRemove: Animation): number;
  106562. /**
  106563. * Will stop the animation of the given target
  106564. * @param target - the target
  106565. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  106566. * @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)
  106567. */
  106568. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  106569. /**
  106570. * Removes the given animation group from this scene.
  106571. * @param toRemove The animation group to remove
  106572. * @returns The index of the removed animation group
  106573. */
  106574. removeAnimationGroup(toRemove: AnimationGroup): number;
  106575. /**
  106576. * Removes the given multi-material from this scene.
  106577. * @param toRemove The multi-material to remove
  106578. * @returns The index of the removed multi-material
  106579. */
  106580. removeMultiMaterial(toRemove: MultiMaterial): number;
  106581. /**
  106582. * Removes the given material from this scene.
  106583. * @param toRemove The material to remove
  106584. * @returns The index of the removed material
  106585. */
  106586. removeMaterial(toRemove: Material): number;
  106587. /**
  106588. * Removes the given action manager from this scene.
  106589. * @param toRemove The action manager to remove
  106590. * @returns The index of the removed action manager
  106591. */
  106592. removeActionManager(toRemove: AbstractActionManager): number;
  106593. /**
  106594. * Removes the given texture from this scene.
  106595. * @param toRemove The texture to remove
  106596. * @returns The index of the removed texture
  106597. */
  106598. removeTexture(toRemove: BaseTexture): number;
  106599. /**
  106600. * Adds the given light to this scene
  106601. * @param newLight The light to add
  106602. */
  106603. addLight(newLight: Light): void;
  106604. /**
  106605. * Sorts the list list based on light priorities
  106606. */
  106607. sortLightsByPriority(): void;
  106608. /**
  106609. * Adds the given camera to this scene
  106610. * @param newCamera The camera to add
  106611. */
  106612. addCamera(newCamera: Camera): void;
  106613. /**
  106614. * Adds the given skeleton to this scene
  106615. * @param newSkeleton The skeleton to add
  106616. */
  106617. addSkeleton(newSkeleton: Skeleton): void;
  106618. /**
  106619. * Adds the given particle system to this scene
  106620. * @param newParticleSystem The particle system to add
  106621. */
  106622. addParticleSystem(newParticleSystem: IParticleSystem): void;
  106623. /**
  106624. * Adds the given animation to this scene
  106625. * @param newAnimation The animation to add
  106626. */
  106627. addAnimation(newAnimation: Animation): void;
  106628. /**
  106629. * Adds the given animation group to this scene.
  106630. * @param newAnimationGroup The animation group to add
  106631. */
  106632. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  106633. /**
  106634. * Adds the given multi-material to this scene
  106635. * @param newMultiMaterial The multi-material to add
  106636. */
  106637. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  106638. /**
  106639. * Adds the given material to this scene
  106640. * @param newMaterial The material to add
  106641. */
  106642. addMaterial(newMaterial: Material): void;
  106643. /**
  106644. * Adds the given morph target to this scene
  106645. * @param newMorphTargetManager The morph target to add
  106646. */
  106647. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  106648. /**
  106649. * Adds the given geometry to this scene
  106650. * @param newGeometry The geometry to add
  106651. */
  106652. addGeometry(newGeometry: Geometry): void;
  106653. /**
  106654. * Adds the given action manager to this scene
  106655. * @param newActionManager The action manager to add
  106656. */
  106657. addActionManager(newActionManager: AbstractActionManager): void;
  106658. /**
  106659. * Adds the given texture to this scene.
  106660. * @param newTexture The texture to add
  106661. */
  106662. addTexture(newTexture: BaseTexture): void;
  106663. /**
  106664. * Switch active camera
  106665. * @param newCamera defines the new active camera
  106666. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  106667. */
  106668. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  106669. /**
  106670. * sets the active camera of the scene using its ID
  106671. * @param id defines the camera's ID
  106672. * @return the new active camera or null if none found.
  106673. */
  106674. setActiveCameraByID(id: string): Nullable<Camera>;
  106675. /**
  106676. * sets the active camera of the scene using its name
  106677. * @param name defines the camera's name
  106678. * @returns the new active camera or null if none found.
  106679. */
  106680. setActiveCameraByName(name: string): Nullable<Camera>;
  106681. /**
  106682. * get an animation group using its name
  106683. * @param name defines the material's name
  106684. * @return the animation group or null if none found.
  106685. */
  106686. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  106687. /**
  106688. * Get a material using its unique id
  106689. * @param uniqueId defines the material's unique id
  106690. * @return the material or null if none found.
  106691. */
  106692. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  106693. /**
  106694. * get a material using its id
  106695. * @param id defines the material's ID
  106696. * @return the material or null if none found.
  106697. */
  106698. getMaterialByID(id: string): Nullable<Material>;
  106699. /**
  106700. * Gets a the last added material using a given id
  106701. * @param id defines the material's ID
  106702. * @return the last material with the given id or null if none found.
  106703. */
  106704. getLastMaterialByID(id: string): Nullable<Material>;
  106705. /**
  106706. * Gets a material using its name
  106707. * @param name defines the material's name
  106708. * @return the material or null if none found.
  106709. */
  106710. getMaterialByName(name: string): Nullable<Material>;
  106711. /**
  106712. * Get a texture using its unique id
  106713. * @param uniqueId defines the texture's unique id
  106714. * @return the texture or null if none found.
  106715. */
  106716. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  106717. /**
  106718. * Gets a camera using its id
  106719. * @param id defines the id to look for
  106720. * @returns the camera or null if not found
  106721. */
  106722. getCameraByID(id: string): Nullable<Camera>;
  106723. /**
  106724. * Gets a camera using its unique id
  106725. * @param uniqueId defines the unique id to look for
  106726. * @returns the camera or null if not found
  106727. */
  106728. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  106729. /**
  106730. * Gets a camera using its name
  106731. * @param name defines the camera's name
  106732. * @return the camera or null if none found.
  106733. */
  106734. getCameraByName(name: string): Nullable<Camera>;
  106735. /**
  106736. * Gets a bone using its id
  106737. * @param id defines the bone's id
  106738. * @return the bone or null if not found
  106739. */
  106740. getBoneByID(id: string): Nullable<Bone>;
  106741. /**
  106742. * Gets a bone using its id
  106743. * @param name defines the bone's name
  106744. * @return the bone or null if not found
  106745. */
  106746. getBoneByName(name: string): Nullable<Bone>;
  106747. /**
  106748. * Gets a light node using its name
  106749. * @param name defines the the light's name
  106750. * @return the light or null if none found.
  106751. */
  106752. getLightByName(name: string): Nullable<Light>;
  106753. /**
  106754. * Gets a light node using its id
  106755. * @param id defines the light's id
  106756. * @return the light or null if none found.
  106757. */
  106758. getLightByID(id: string): Nullable<Light>;
  106759. /**
  106760. * Gets a light node using its scene-generated unique ID
  106761. * @param uniqueId defines the light's unique id
  106762. * @return the light or null if none found.
  106763. */
  106764. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  106765. /**
  106766. * Gets a particle system by id
  106767. * @param id defines the particle system id
  106768. * @return the corresponding system or null if none found
  106769. */
  106770. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  106771. /**
  106772. * Gets a geometry using its ID
  106773. * @param id defines the geometry's id
  106774. * @return the geometry or null if none found.
  106775. */
  106776. getGeometryByID(id: string): Nullable<Geometry>;
  106777. private _getGeometryByUniqueID;
  106778. /**
  106779. * Add a new geometry to this scene
  106780. * @param geometry defines the geometry to be added to the scene.
  106781. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  106782. * @return a boolean defining if the geometry was added or not
  106783. */
  106784. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  106785. /**
  106786. * Removes an existing geometry
  106787. * @param geometry defines the geometry to be removed from the scene
  106788. * @return a boolean defining if the geometry was removed or not
  106789. */
  106790. removeGeometry(geometry: Geometry): boolean;
  106791. /**
  106792. * Gets the list of geometries attached to the scene
  106793. * @returns an array of Geometry
  106794. */
  106795. getGeometries(): Geometry[];
  106796. /**
  106797. * Gets the first added mesh found of a given ID
  106798. * @param id defines the id to search for
  106799. * @return the mesh found or null if not found at all
  106800. */
  106801. getMeshByID(id: string): Nullable<AbstractMesh>;
  106802. /**
  106803. * Gets a list of meshes using their id
  106804. * @param id defines the id to search for
  106805. * @returns a list of meshes
  106806. */
  106807. getMeshesByID(id: string): Array<AbstractMesh>;
  106808. /**
  106809. * Gets the first added transform node found of a given ID
  106810. * @param id defines the id to search for
  106811. * @return the found transform node or null if not found at all.
  106812. */
  106813. getTransformNodeByID(id: string): Nullable<TransformNode>;
  106814. /**
  106815. * Gets a transform node with its auto-generated unique id
  106816. * @param uniqueId efines the unique id to search for
  106817. * @return the found transform node or null if not found at all.
  106818. */
  106819. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  106820. /**
  106821. * Gets a list of transform nodes using their id
  106822. * @param id defines the id to search for
  106823. * @returns a list of transform nodes
  106824. */
  106825. getTransformNodesByID(id: string): Array<TransformNode>;
  106826. /**
  106827. * Gets a mesh with its auto-generated unique id
  106828. * @param uniqueId defines the unique id to search for
  106829. * @return the found mesh or null if not found at all.
  106830. */
  106831. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  106832. /**
  106833. * Gets a the last added mesh using a given id
  106834. * @param id defines the id to search for
  106835. * @return the found mesh or null if not found at all.
  106836. */
  106837. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  106838. /**
  106839. * Gets a the last added node (Mesh, Camera, Light) using a given id
  106840. * @param id defines the id to search for
  106841. * @return the found node or null if not found at all
  106842. */
  106843. getLastEntryByID(id: string): Nullable<Node>;
  106844. /**
  106845. * Gets a node (Mesh, Camera, Light) using a given id
  106846. * @param id defines the id to search for
  106847. * @return the found node or null if not found at all
  106848. */
  106849. getNodeByID(id: string): Nullable<Node>;
  106850. /**
  106851. * Gets a node (Mesh, Camera, Light) using a given name
  106852. * @param name defines the name to search for
  106853. * @return the found node or null if not found at all.
  106854. */
  106855. getNodeByName(name: string): Nullable<Node>;
  106856. /**
  106857. * Gets a mesh using a given name
  106858. * @param name defines the name to search for
  106859. * @return the found mesh or null if not found at all.
  106860. */
  106861. getMeshByName(name: string): Nullable<AbstractMesh>;
  106862. /**
  106863. * Gets a transform node using a given name
  106864. * @param name defines the name to search for
  106865. * @return the found transform node or null if not found at all.
  106866. */
  106867. getTransformNodeByName(name: string): Nullable<TransformNode>;
  106868. /**
  106869. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  106870. * @param id defines the id to search for
  106871. * @return the found skeleton or null if not found at all.
  106872. */
  106873. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  106874. /**
  106875. * Gets a skeleton using a given auto generated unique id
  106876. * @param uniqueId defines the unique id to search for
  106877. * @return the found skeleton or null if not found at all.
  106878. */
  106879. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  106880. /**
  106881. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  106882. * @param id defines the id to search for
  106883. * @return the found skeleton or null if not found at all.
  106884. */
  106885. getSkeletonById(id: string): Nullable<Skeleton>;
  106886. /**
  106887. * Gets a skeleton using a given name
  106888. * @param name defines the name to search for
  106889. * @return the found skeleton or null if not found at all.
  106890. */
  106891. getSkeletonByName(name: string): Nullable<Skeleton>;
  106892. /**
  106893. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  106894. * @param id defines the id to search for
  106895. * @return the found morph target manager or null if not found at all.
  106896. */
  106897. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  106898. /**
  106899. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  106900. * @param id defines the id to search for
  106901. * @return the found morph target or null if not found at all.
  106902. */
  106903. getMorphTargetById(id: string): Nullable<MorphTarget>;
  106904. /**
  106905. * Gets a boolean indicating if the given mesh is active
  106906. * @param mesh defines the mesh to look for
  106907. * @returns true if the mesh is in the active list
  106908. */
  106909. isActiveMesh(mesh: AbstractMesh): boolean;
  106910. /**
  106911. * Return a unique id as a string which can serve as an identifier for the scene
  106912. */
  106913. get uid(): string;
  106914. /**
  106915. * Add an externaly attached data from its key.
  106916. * This method call will fail and return false, if such key already exists.
  106917. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  106918. * @param key the unique key that identifies the data
  106919. * @param data the data object to associate to the key for this Engine instance
  106920. * @return true if no such key were already present and the data was added successfully, false otherwise
  106921. */
  106922. addExternalData<T>(key: string, data: T): boolean;
  106923. /**
  106924. * Get an externaly attached data from its key
  106925. * @param key the unique key that identifies the data
  106926. * @return the associated data, if present (can be null), or undefined if not present
  106927. */
  106928. getExternalData<T>(key: string): Nullable<T>;
  106929. /**
  106930. * Get an externaly attached data from its key, create it using a factory if it's not already present
  106931. * @param key the unique key that identifies the data
  106932. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  106933. * @return the associated data, can be null if the factory returned null.
  106934. */
  106935. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  106936. /**
  106937. * Remove an externaly attached data from the Engine instance
  106938. * @param key the unique key that identifies the data
  106939. * @return true if the data was successfully removed, false if it doesn't exist
  106940. */
  106941. removeExternalData(key: string): boolean;
  106942. private _evaluateSubMesh;
  106943. /**
  106944. * Clear the processed materials smart array preventing retention point in material dispose.
  106945. */
  106946. freeProcessedMaterials(): void;
  106947. private _preventFreeActiveMeshesAndRenderingGroups;
  106948. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  106949. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  106950. * when disposing several meshes in a row or a hierarchy of meshes.
  106951. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  106952. */
  106953. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  106954. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  106955. /**
  106956. * Clear the active meshes smart array preventing retention point in mesh dispose.
  106957. */
  106958. freeActiveMeshes(): void;
  106959. /**
  106960. * Clear the info related to rendering groups preventing retention points during dispose.
  106961. */
  106962. freeRenderingGroups(): void;
  106963. /** @hidden */
  106964. _isInIntermediateRendering(): boolean;
  106965. /**
  106966. * Lambda returning the list of potentially active meshes.
  106967. */
  106968. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  106969. /**
  106970. * Lambda returning the list of potentially active sub meshes.
  106971. */
  106972. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  106973. /**
  106974. * Lambda returning the list of potentially intersecting sub meshes.
  106975. */
  106976. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  106977. /**
  106978. * Lambda returning the list of potentially colliding sub meshes.
  106979. */
  106980. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  106981. private _activeMeshesFrozen;
  106982. private _skipEvaluateActiveMeshesCompletely;
  106983. /**
  106984. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  106985. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  106986. * @returns the current scene
  106987. */
  106988. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  106989. /**
  106990. * Use this function to restart evaluating active meshes on every frame
  106991. * @returns the current scene
  106992. */
  106993. unfreezeActiveMeshes(): Scene;
  106994. private _evaluateActiveMeshes;
  106995. private _activeMesh;
  106996. /**
  106997. * Update the transform matrix to update from the current active camera
  106998. * @param force defines a boolean used to force the update even if cache is up to date
  106999. */
  107000. updateTransformMatrix(force?: boolean): void;
  107001. private _bindFrameBuffer;
  107002. /** @hidden */
  107003. _allowPostProcessClearColor: boolean;
  107004. /** @hidden */
  107005. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  107006. private _processSubCameras;
  107007. private _checkIntersections;
  107008. /** @hidden */
  107009. _advancePhysicsEngineStep(step: number): void;
  107010. /**
  107011. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  107012. */
  107013. getDeterministicFrameTime: () => number;
  107014. /** @hidden */
  107015. _animate(): void;
  107016. /** Execute all animations (for a frame) */
  107017. animate(): void;
  107018. /**
  107019. * Render the scene
  107020. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  107021. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  107022. */
  107023. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  107024. /**
  107025. * Freeze all materials
  107026. * A frozen material will not be updatable but should be faster to render
  107027. */
  107028. freezeMaterials(): void;
  107029. /**
  107030. * Unfreeze all materials
  107031. * A frozen material will not be updatable but should be faster to render
  107032. */
  107033. unfreezeMaterials(): void;
  107034. /**
  107035. * Releases all held ressources
  107036. */
  107037. dispose(): void;
  107038. /**
  107039. * Gets if the scene is already disposed
  107040. */
  107041. get isDisposed(): boolean;
  107042. /**
  107043. * Call this function to reduce memory footprint of the scene.
  107044. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  107045. */
  107046. clearCachedVertexData(): void;
  107047. /**
  107048. * This function will remove the local cached buffer data from texture.
  107049. * It will save memory but will prevent the texture from being rebuilt
  107050. */
  107051. cleanCachedTextureBuffer(): void;
  107052. /**
  107053. * Get the world extend vectors with an optional filter
  107054. *
  107055. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  107056. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  107057. */
  107058. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  107059. min: Vector3;
  107060. max: Vector3;
  107061. };
  107062. /**
  107063. * Creates a ray that can be used to pick in the scene
  107064. * @param x defines the x coordinate of the origin (on-screen)
  107065. * @param y defines the y coordinate of the origin (on-screen)
  107066. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107067. * @param camera defines the camera to use for the picking
  107068. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107069. * @returns a Ray
  107070. */
  107071. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  107072. /**
  107073. * Creates a ray that can be used to pick in the scene
  107074. * @param x defines the x coordinate of the origin (on-screen)
  107075. * @param y defines the y coordinate of the origin (on-screen)
  107076. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107077. * @param result defines the ray where to store the picking ray
  107078. * @param camera defines the camera to use for the picking
  107079. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107080. * @returns the current scene
  107081. */
  107082. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  107083. /**
  107084. * Creates a ray that can be used to pick in the scene
  107085. * @param x defines the x coordinate of the origin (on-screen)
  107086. * @param y defines the y coordinate of the origin (on-screen)
  107087. * @param camera defines the camera to use for the picking
  107088. * @returns a Ray
  107089. */
  107090. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  107091. /**
  107092. * Creates a ray that can be used to pick in the scene
  107093. * @param x defines the x coordinate of the origin (on-screen)
  107094. * @param y defines the y coordinate of the origin (on-screen)
  107095. * @param result defines the ray where to store the picking ray
  107096. * @param camera defines the camera to use for the picking
  107097. * @returns the current scene
  107098. */
  107099. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  107100. /** Launch a ray to try to pick a mesh in the scene
  107101. * @param x position on screen
  107102. * @param y position on screen
  107103. * @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
  107104. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  107105. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107106. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107107. * @returns a PickingInfo
  107108. */
  107109. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107110. /** Use the given ray to pick a mesh in the scene
  107111. * @param ray The ray to use to pick meshes
  107112. * @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
  107113. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  107114. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107115. * @returns a PickingInfo
  107116. */
  107117. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107118. /**
  107119. * Launch a ray to try to pick a mesh in the scene
  107120. * @param x X position on screen
  107121. * @param y Y position on screen
  107122. * @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
  107123. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107124. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107125. * @returns an array of PickingInfo
  107126. */
  107127. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107128. /**
  107129. * Launch a ray to try to pick a mesh in the scene
  107130. * @param ray Ray to use
  107131. * @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
  107132. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107133. * @returns an array of PickingInfo
  107134. */
  107135. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107136. /**
  107137. * Force the value of meshUnderPointer
  107138. * @param mesh defines the mesh to use
  107139. */
  107140. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107141. /**
  107142. * Gets the mesh under the pointer
  107143. * @returns a Mesh or null if no mesh is under the pointer
  107144. */
  107145. getPointerOverMesh(): Nullable<AbstractMesh>;
  107146. /** @hidden */
  107147. _rebuildGeometries(): void;
  107148. /** @hidden */
  107149. _rebuildTextures(): void;
  107150. private _getByTags;
  107151. /**
  107152. * Get a list of meshes by tags
  107153. * @param tagsQuery defines the tags query to use
  107154. * @param forEach defines a predicate used to filter results
  107155. * @returns an array of Mesh
  107156. */
  107157. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  107158. /**
  107159. * Get a list of cameras by tags
  107160. * @param tagsQuery defines the tags query to use
  107161. * @param forEach defines a predicate used to filter results
  107162. * @returns an array of Camera
  107163. */
  107164. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  107165. /**
  107166. * Get a list of lights by tags
  107167. * @param tagsQuery defines the tags query to use
  107168. * @param forEach defines a predicate used to filter results
  107169. * @returns an array of Light
  107170. */
  107171. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  107172. /**
  107173. * Get a list of materials by tags
  107174. * @param tagsQuery defines the tags query to use
  107175. * @param forEach defines a predicate used to filter results
  107176. * @returns an array of Material
  107177. */
  107178. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  107179. /**
  107180. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  107181. * This allowed control for front to back rendering or reversly depending of the special needs.
  107182. *
  107183. * @param renderingGroupId The rendering group id corresponding to its index
  107184. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  107185. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  107186. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  107187. */
  107188. 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;
  107189. /**
  107190. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  107191. *
  107192. * @param renderingGroupId The rendering group id corresponding to its index
  107193. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107194. * @param depth Automatically clears depth between groups if true and autoClear is true.
  107195. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  107196. */
  107197. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  107198. /**
  107199. * Gets the current auto clear configuration for one rendering group of the rendering
  107200. * manager.
  107201. * @param index the rendering group index to get the information for
  107202. * @returns The auto clear setup for the requested rendering group
  107203. */
  107204. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  107205. private _blockMaterialDirtyMechanism;
  107206. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  107207. get blockMaterialDirtyMechanism(): boolean;
  107208. set blockMaterialDirtyMechanism(value: boolean);
  107209. /**
  107210. * Will flag all materials as dirty to trigger new shader compilation
  107211. * @param flag defines the flag used to specify which material part must be marked as dirty
  107212. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  107213. */
  107214. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107215. /** @hidden */
  107216. _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;
  107217. /** @hidden */
  107218. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107219. /** @hidden */
  107220. _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;
  107221. /** @hidden */
  107222. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  107223. /** @hidden */
  107224. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107225. /** @hidden */
  107226. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107227. }
  107228. }
  107229. declare module BABYLON {
  107230. /**
  107231. * Set of assets to keep when moving a scene into an asset container.
  107232. */
  107233. export class KeepAssets extends AbstractScene {
  107234. }
  107235. /**
  107236. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  107237. */
  107238. export class InstantiatedEntries {
  107239. /**
  107240. * List of new root nodes (eg. nodes with no parent)
  107241. */
  107242. rootNodes: TransformNode[];
  107243. /**
  107244. * List of new skeletons
  107245. */
  107246. skeletons: Skeleton[];
  107247. /**
  107248. * List of new animation groups
  107249. */
  107250. animationGroups: AnimationGroup[];
  107251. }
  107252. /**
  107253. * Container with a set of assets that can be added or removed from a scene.
  107254. */
  107255. export class AssetContainer extends AbstractScene {
  107256. /**
  107257. * The scene the AssetContainer belongs to.
  107258. */
  107259. scene: Scene;
  107260. /**
  107261. * Instantiates an AssetContainer.
  107262. * @param scene The scene the AssetContainer belongs to.
  107263. */
  107264. constructor(scene: Scene);
  107265. /**
  107266. * Instantiate or clone all meshes and add the new ones to the scene.
  107267. * Skeletons and animation groups will all be cloned
  107268. * @param nameFunction defines an optional function used to get new names for clones
  107269. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  107270. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  107271. */
  107272. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  107273. /**
  107274. * Adds all the assets from the container to the scene.
  107275. */
  107276. addAllToScene(): void;
  107277. /**
  107278. * Removes all the assets in the container from the scene
  107279. */
  107280. removeAllFromScene(): void;
  107281. /**
  107282. * Disposes all the assets in the container
  107283. */
  107284. dispose(): void;
  107285. private _moveAssets;
  107286. /**
  107287. * Removes all the assets contained in the scene and adds them to the container.
  107288. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  107289. */
  107290. moveAllFromScene(keepAssets?: KeepAssets): void;
  107291. /**
  107292. * 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.
  107293. * @returns the root mesh
  107294. */
  107295. createRootMesh(): Mesh;
  107296. /**
  107297. * Merge animations from this asset container into a scene
  107298. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107299. * @param animatables set of animatables to retarget to a node from the scene
  107300. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  107301. */
  107302. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  107303. }
  107304. }
  107305. declare module BABYLON {
  107306. /**
  107307. * Defines how the parser contract is defined.
  107308. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  107309. */
  107310. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  107311. /**
  107312. * Defines how the individual parser contract is defined.
  107313. * These parser can parse an individual asset
  107314. */
  107315. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  107316. /**
  107317. * Base class of the scene acting as a container for the different elements composing a scene.
  107318. * This class is dynamically extended by the different components of the scene increasing
  107319. * flexibility and reducing coupling
  107320. */
  107321. export abstract class AbstractScene {
  107322. /**
  107323. * Stores the list of available parsers in the application.
  107324. */
  107325. private static _BabylonFileParsers;
  107326. /**
  107327. * Stores the list of available individual parsers in the application.
  107328. */
  107329. private static _IndividualBabylonFileParsers;
  107330. /**
  107331. * Adds a parser in the list of available ones
  107332. * @param name Defines the name of the parser
  107333. * @param parser Defines the parser to add
  107334. */
  107335. static AddParser(name: string, parser: BabylonFileParser): void;
  107336. /**
  107337. * Gets a general parser from the list of avaialble ones
  107338. * @param name Defines the name of the parser
  107339. * @returns the requested parser or null
  107340. */
  107341. static GetParser(name: string): Nullable<BabylonFileParser>;
  107342. /**
  107343. * Adds n individual parser in the list of available ones
  107344. * @param name Defines the name of the parser
  107345. * @param parser Defines the parser to add
  107346. */
  107347. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  107348. /**
  107349. * Gets an individual parser from the list of avaialble ones
  107350. * @param name Defines the name of the parser
  107351. * @returns the requested parser or null
  107352. */
  107353. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  107354. /**
  107355. * Parser json data and populate both a scene and its associated container object
  107356. * @param jsonData Defines the data to parse
  107357. * @param scene Defines the scene to parse the data for
  107358. * @param container Defines the container attached to the parsing sequence
  107359. * @param rootUrl Defines the root url of the data
  107360. */
  107361. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  107362. /**
  107363. * Gets the list of root nodes (ie. nodes with no parent)
  107364. */
  107365. rootNodes: Node[];
  107366. /** All of the cameras added to this scene
  107367. * @see http://doc.babylonjs.com/babylon101/cameras
  107368. */
  107369. cameras: Camera[];
  107370. /**
  107371. * All of the lights added to this scene
  107372. * @see http://doc.babylonjs.com/babylon101/lights
  107373. */
  107374. lights: Light[];
  107375. /**
  107376. * All of the (abstract) meshes added to this scene
  107377. */
  107378. meshes: AbstractMesh[];
  107379. /**
  107380. * The list of skeletons added to the scene
  107381. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107382. */
  107383. skeletons: Skeleton[];
  107384. /**
  107385. * All of the particle systems added to this scene
  107386. * @see http://doc.babylonjs.com/babylon101/particles
  107387. */
  107388. particleSystems: IParticleSystem[];
  107389. /**
  107390. * Gets a list of Animations associated with the scene
  107391. */
  107392. animations: Animation[];
  107393. /**
  107394. * All of the animation groups added to this scene
  107395. * @see http://doc.babylonjs.com/how_to/group
  107396. */
  107397. animationGroups: AnimationGroup[];
  107398. /**
  107399. * All of the multi-materials added to this scene
  107400. * @see http://doc.babylonjs.com/how_to/multi_materials
  107401. */
  107402. multiMaterials: MultiMaterial[];
  107403. /**
  107404. * All of the materials added to this scene
  107405. * In the context of a Scene, it is not supposed to be modified manually.
  107406. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  107407. * Note also that the order of the Material within the array is not significant and might change.
  107408. * @see http://doc.babylonjs.com/babylon101/materials
  107409. */
  107410. materials: Material[];
  107411. /**
  107412. * The list of morph target managers added to the scene
  107413. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  107414. */
  107415. morphTargetManagers: MorphTargetManager[];
  107416. /**
  107417. * The list of geometries used in the scene.
  107418. */
  107419. geometries: Geometry[];
  107420. /**
  107421. * All of the tranform nodes added to this scene
  107422. * In the context of a Scene, it is not supposed to be modified manually.
  107423. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  107424. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  107425. * @see http://doc.babylonjs.com/how_to/transformnode
  107426. */
  107427. transformNodes: TransformNode[];
  107428. /**
  107429. * ActionManagers available on the scene.
  107430. */
  107431. actionManagers: AbstractActionManager[];
  107432. /**
  107433. * Textures to keep.
  107434. */
  107435. textures: BaseTexture[];
  107436. /**
  107437. * Environment texture for the scene
  107438. */
  107439. environmentTexture: Nullable<BaseTexture>;
  107440. /**
  107441. * @returns all meshes, lights, cameras, transformNodes and bones
  107442. */
  107443. getNodes(): Array<Node>;
  107444. }
  107445. }
  107446. declare module BABYLON {
  107447. /**
  107448. * Interface used to define options for Sound class
  107449. */
  107450. export interface ISoundOptions {
  107451. /**
  107452. * Does the sound autoplay once loaded.
  107453. */
  107454. autoplay?: boolean;
  107455. /**
  107456. * Does the sound loop after it finishes playing once.
  107457. */
  107458. loop?: boolean;
  107459. /**
  107460. * Sound's volume
  107461. */
  107462. volume?: number;
  107463. /**
  107464. * Is it a spatial sound?
  107465. */
  107466. spatialSound?: boolean;
  107467. /**
  107468. * Maximum distance to hear that sound
  107469. */
  107470. maxDistance?: number;
  107471. /**
  107472. * Uses user defined attenuation function
  107473. */
  107474. useCustomAttenuation?: boolean;
  107475. /**
  107476. * Define the roll off factor of spatial sounds.
  107477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107478. */
  107479. rolloffFactor?: number;
  107480. /**
  107481. * Define the reference distance the sound should be heard perfectly.
  107482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107483. */
  107484. refDistance?: number;
  107485. /**
  107486. * Define the distance attenuation model the sound will follow.
  107487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107488. */
  107489. distanceModel?: string;
  107490. /**
  107491. * Defines the playback speed (1 by default)
  107492. */
  107493. playbackRate?: number;
  107494. /**
  107495. * Defines if the sound is from a streaming source
  107496. */
  107497. streaming?: boolean;
  107498. /**
  107499. * Defines an optional length (in seconds) inside the sound file
  107500. */
  107501. length?: number;
  107502. /**
  107503. * Defines an optional offset (in seconds) inside the sound file
  107504. */
  107505. offset?: number;
  107506. /**
  107507. * If true, URLs will not be required to state the audio file codec to use.
  107508. */
  107509. skipCodecCheck?: boolean;
  107510. }
  107511. /**
  107512. * Defines a sound that can be played in the application.
  107513. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  107514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107515. */
  107516. export class Sound {
  107517. /**
  107518. * The name of the sound in the scene.
  107519. */
  107520. name: string;
  107521. /**
  107522. * Does the sound autoplay once loaded.
  107523. */
  107524. autoplay: boolean;
  107525. /**
  107526. * Does the sound loop after it finishes playing once.
  107527. */
  107528. loop: boolean;
  107529. /**
  107530. * Does the sound use a custom attenuation curve to simulate the falloff
  107531. * happening when the source gets further away from the camera.
  107532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107533. */
  107534. useCustomAttenuation: boolean;
  107535. /**
  107536. * The sound track id this sound belongs to.
  107537. */
  107538. soundTrackId: number;
  107539. /**
  107540. * Is this sound currently played.
  107541. */
  107542. isPlaying: boolean;
  107543. /**
  107544. * Is this sound currently paused.
  107545. */
  107546. isPaused: boolean;
  107547. /**
  107548. * Does this sound enables spatial sound.
  107549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107550. */
  107551. spatialSound: boolean;
  107552. /**
  107553. * Define the reference distance the sound should be heard perfectly.
  107554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107555. */
  107556. refDistance: number;
  107557. /**
  107558. * Define the roll off factor of spatial sounds.
  107559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107560. */
  107561. rolloffFactor: number;
  107562. /**
  107563. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  107564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107565. */
  107566. maxDistance: number;
  107567. /**
  107568. * Define the distance attenuation model the sound will follow.
  107569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107570. */
  107571. distanceModel: string;
  107572. /**
  107573. * @hidden
  107574. * Back Compat
  107575. **/
  107576. onended: () => any;
  107577. /**
  107578. * Observable event when the current playing sound finishes.
  107579. */
  107580. onEndedObservable: Observable<Sound>;
  107581. private _panningModel;
  107582. private _playbackRate;
  107583. private _streaming;
  107584. private _startTime;
  107585. private _startOffset;
  107586. private _position;
  107587. /** @hidden */
  107588. _positionInEmitterSpace: boolean;
  107589. private _localDirection;
  107590. private _volume;
  107591. private _isReadyToPlay;
  107592. private _isDirectional;
  107593. private _readyToPlayCallback;
  107594. private _audioBuffer;
  107595. private _soundSource;
  107596. private _streamingSource;
  107597. private _soundPanner;
  107598. private _soundGain;
  107599. private _inputAudioNode;
  107600. private _outputAudioNode;
  107601. private _coneInnerAngle;
  107602. private _coneOuterAngle;
  107603. private _coneOuterGain;
  107604. private _scene;
  107605. private _connectedTransformNode;
  107606. private _customAttenuationFunction;
  107607. private _registerFunc;
  107608. private _isOutputConnected;
  107609. private _htmlAudioElement;
  107610. private _urlType;
  107611. private _length?;
  107612. private _offset?;
  107613. /** @hidden */
  107614. static _SceneComponentInitialization: (scene: Scene) => void;
  107615. /**
  107616. * Create a sound and attach it to a scene
  107617. * @param name Name of your sound
  107618. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  107619. * @param scene defines the scene the sound belongs to
  107620. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  107621. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  107622. */
  107623. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  107624. /**
  107625. * Release the sound and its associated resources
  107626. */
  107627. dispose(): void;
  107628. /**
  107629. * Gets if the sounds is ready to be played or not.
  107630. * @returns true if ready, otherwise false
  107631. */
  107632. isReady(): boolean;
  107633. private _soundLoaded;
  107634. /**
  107635. * Sets the data of the sound from an audiobuffer
  107636. * @param audioBuffer The audioBuffer containing the data
  107637. */
  107638. setAudioBuffer(audioBuffer: AudioBuffer): void;
  107639. /**
  107640. * Updates the current sounds options such as maxdistance, loop...
  107641. * @param options A JSON object containing values named as the object properties
  107642. */
  107643. updateOptions(options: ISoundOptions): void;
  107644. private _createSpatialParameters;
  107645. private _updateSpatialParameters;
  107646. /**
  107647. * Switch the panning model to HRTF:
  107648. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107650. */
  107651. switchPanningModelToHRTF(): void;
  107652. /**
  107653. * Switch the panning model to Equal Power:
  107654. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107656. */
  107657. switchPanningModelToEqualPower(): void;
  107658. private _switchPanningModel;
  107659. /**
  107660. * Connect this sound to a sound track audio node like gain...
  107661. * @param soundTrackAudioNode the sound track audio node to connect to
  107662. */
  107663. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  107664. /**
  107665. * Transform this sound into a directional source
  107666. * @param coneInnerAngle Size of the inner cone in degree
  107667. * @param coneOuterAngle Size of the outer cone in degree
  107668. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  107669. */
  107670. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  107671. /**
  107672. * Gets or sets the inner angle for the directional cone.
  107673. */
  107674. get directionalConeInnerAngle(): number;
  107675. /**
  107676. * Gets or sets the inner angle for the directional cone.
  107677. */
  107678. set directionalConeInnerAngle(value: number);
  107679. /**
  107680. * Gets or sets the outer angle for the directional cone.
  107681. */
  107682. get directionalConeOuterAngle(): number;
  107683. /**
  107684. * Gets or sets the outer angle for the directional cone.
  107685. */
  107686. set directionalConeOuterAngle(value: number);
  107687. /**
  107688. * Sets the position of the emitter if spatial sound is enabled
  107689. * @param newPosition Defines the new posisiton
  107690. */
  107691. setPosition(newPosition: Vector3): void;
  107692. /**
  107693. * Sets the local direction of the emitter if spatial sound is enabled
  107694. * @param newLocalDirection Defines the new local direction
  107695. */
  107696. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  107697. private _updateDirection;
  107698. /** @hidden */
  107699. updateDistanceFromListener(): void;
  107700. /**
  107701. * Sets a new custom attenuation function for the sound.
  107702. * @param callback Defines the function used for the attenuation
  107703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107704. */
  107705. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  107706. /**
  107707. * Play the sound
  107708. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  107709. * @param offset (optional) Start the sound at a specific time in seconds
  107710. * @param length (optional) Sound duration (in seconds)
  107711. */
  107712. play(time?: number, offset?: number, length?: number): void;
  107713. private _onended;
  107714. /**
  107715. * Stop the sound
  107716. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  107717. */
  107718. stop(time?: number): void;
  107719. /**
  107720. * Put the sound in pause
  107721. */
  107722. pause(): void;
  107723. /**
  107724. * Sets a dedicated volume for this sounds
  107725. * @param newVolume Define the new volume of the sound
  107726. * @param time Define time for gradual change to new volume
  107727. */
  107728. setVolume(newVolume: number, time?: number): void;
  107729. /**
  107730. * Set the sound play back rate
  107731. * @param newPlaybackRate Define the playback rate the sound should be played at
  107732. */
  107733. setPlaybackRate(newPlaybackRate: number): void;
  107734. /**
  107735. * Gets the volume of the sound.
  107736. * @returns the volume of the sound
  107737. */
  107738. getVolume(): number;
  107739. /**
  107740. * Attach the sound to a dedicated mesh
  107741. * @param transformNode The transform node to connect the sound with
  107742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107743. */
  107744. attachToMesh(transformNode: TransformNode): void;
  107745. /**
  107746. * Detach the sound from the previously attached mesh
  107747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107748. */
  107749. detachFromMesh(): void;
  107750. private _onRegisterAfterWorldMatrixUpdate;
  107751. /**
  107752. * Clone the current sound in the scene.
  107753. * @returns the new sound clone
  107754. */
  107755. clone(): Nullable<Sound>;
  107756. /**
  107757. * Gets the current underlying audio buffer containing the data
  107758. * @returns the audio buffer
  107759. */
  107760. getAudioBuffer(): Nullable<AudioBuffer>;
  107761. /**
  107762. * Serializes the Sound in a JSON representation
  107763. * @returns the JSON representation of the sound
  107764. */
  107765. serialize(): any;
  107766. /**
  107767. * Parse a JSON representation of a sound to innstantiate in a given scene
  107768. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  107769. * @param scene Define the scene the new parsed sound should be created in
  107770. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  107771. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  107772. * @returns the newly parsed sound
  107773. */
  107774. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  107775. }
  107776. }
  107777. declare module BABYLON {
  107778. /**
  107779. * This defines an action helpful to play a defined sound on a triggered action.
  107780. */
  107781. export class PlaySoundAction extends Action {
  107782. private _sound;
  107783. /**
  107784. * Instantiate the action
  107785. * @param triggerOptions defines the trigger options
  107786. * @param sound defines the sound to play
  107787. * @param condition defines the trigger related conditions
  107788. */
  107789. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107790. /** @hidden */
  107791. _prepare(): void;
  107792. /**
  107793. * Execute the action and play the sound.
  107794. */
  107795. execute(): void;
  107796. /**
  107797. * Serializes the actions and its related information.
  107798. * @param parent defines the object to serialize in
  107799. * @returns the serialized object
  107800. */
  107801. serialize(parent: any): any;
  107802. }
  107803. /**
  107804. * This defines an action helpful to stop a defined sound on a triggered action.
  107805. */
  107806. export class StopSoundAction extends Action {
  107807. private _sound;
  107808. /**
  107809. * Instantiate the action
  107810. * @param triggerOptions defines the trigger options
  107811. * @param sound defines the sound to stop
  107812. * @param condition defines the trigger related conditions
  107813. */
  107814. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107815. /** @hidden */
  107816. _prepare(): void;
  107817. /**
  107818. * Execute the action and stop the sound.
  107819. */
  107820. execute(): void;
  107821. /**
  107822. * Serializes the actions and its related information.
  107823. * @param parent defines the object to serialize in
  107824. * @returns the serialized object
  107825. */
  107826. serialize(parent: any): any;
  107827. }
  107828. }
  107829. declare module BABYLON {
  107830. /**
  107831. * This defines an action responsible to change the value of a property
  107832. * by interpolating between its current value and the newly set one once triggered.
  107833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  107834. */
  107835. export class InterpolateValueAction extends Action {
  107836. /**
  107837. * Defines the path of the property where the value should be interpolated
  107838. */
  107839. propertyPath: string;
  107840. /**
  107841. * Defines the target value at the end of the interpolation.
  107842. */
  107843. value: any;
  107844. /**
  107845. * Defines the time it will take for the property to interpolate to the value.
  107846. */
  107847. duration: number;
  107848. /**
  107849. * Defines if the other scene animations should be stopped when the action has been triggered
  107850. */
  107851. stopOtherAnimations?: boolean;
  107852. /**
  107853. * Defines a callback raised once the interpolation animation has been done.
  107854. */
  107855. onInterpolationDone?: () => void;
  107856. /**
  107857. * Observable triggered once the interpolation animation has been done.
  107858. */
  107859. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  107860. private _target;
  107861. private _effectiveTarget;
  107862. private _property;
  107863. /**
  107864. * Instantiate the action
  107865. * @param triggerOptions defines the trigger options
  107866. * @param target defines the object containing the value to interpolate
  107867. * @param propertyPath defines the path to the property in the target object
  107868. * @param value defines the target value at the end of the interpolation
  107869. * @param duration deines the time it will take for the property to interpolate to the value.
  107870. * @param condition defines the trigger related conditions
  107871. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  107872. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  107873. */
  107874. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  107875. /** @hidden */
  107876. _prepare(): void;
  107877. /**
  107878. * Execute the action starts the value interpolation.
  107879. */
  107880. execute(): void;
  107881. /**
  107882. * Serializes the actions and its related information.
  107883. * @param parent defines the object to serialize in
  107884. * @returns the serialized object
  107885. */
  107886. serialize(parent: any): any;
  107887. }
  107888. }
  107889. declare module BABYLON {
  107890. /**
  107891. * Options allowed during the creation of a sound track.
  107892. */
  107893. export interface ISoundTrackOptions {
  107894. /**
  107895. * The volume the sound track should take during creation
  107896. */
  107897. volume?: number;
  107898. /**
  107899. * Define if the sound track is the main sound track of the scene
  107900. */
  107901. mainTrack?: boolean;
  107902. }
  107903. /**
  107904. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  107905. * It will be also used in a future release to apply effects on a specific track.
  107906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  107907. */
  107908. export class SoundTrack {
  107909. /**
  107910. * The unique identifier of the sound track in the scene.
  107911. */
  107912. id: number;
  107913. /**
  107914. * The list of sounds included in the sound track.
  107915. */
  107916. soundCollection: Array<Sound>;
  107917. private _outputAudioNode;
  107918. private _scene;
  107919. private _connectedAnalyser;
  107920. private _options;
  107921. private _isInitialized;
  107922. /**
  107923. * Creates a new sound track.
  107924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  107925. * @param scene Define the scene the sound track belongs to
  107926. * @param options
  107927. */
  107928. constructor(scene: Scene, options?: ISoundTrackOptions);
  107929. private _initializeSoundTrackAudioGraph;
  107930. /**
  107931. * Release the sound track and its associated resources
  107932. */
  107933. dispose(): void;
  107934. /**
  107935. * Adds a sound to this sound track
  107936. * @param sound define the cound to add
  107937. * @ignoreNaming
  107938. */
  107939. AddSound(sound: Sound): void;
  107940. /**
  107941. * Removes a sound to this sound track
  107942. * @param sound define the cound to remove
  107943. * @ignoreNaming
  107944. */
  107945. RemoveSound(sound: Sound): void;
  107946. /**
  107947. * Set a global volume for the full sound track.
  107948. * @param newVolume Define the new volume of the sound track
  107949. */
  107950. setVolume(newVolume: number): void;
  107951. /**
  107952. * Switch the panning model to HRTF:
  107953. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107955. */
  107956. switchPanningModelToHRTF(): void;
  107957. /**
  107958. * Switch the panning model to Equal Power:
  107959. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107961. */
  107962. switchPanningModelToEqualPower(): void;
  107963. /**
  107964. * Connect the sound track to an audio analyser allowing some amazing
  107965. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107967. * @param analyser The analyser to connect to the engine
  107968. */
  107969. connectToAnalyser(analyser: Analyser): void;
  107970. }
  107971. }
  107972. declare module BABYLON {
  107973. interface AbstractScene {
  107974. /**
  107975. * The list of sounds used in the scene.
  107976. */
  107977. sounds: Nullable<Array<Sound>>;
  107978. }
  107979. interface Scene {
  107980. /**
  107981. * @hidden
  107982. * Backing field
  107983. */
  107984. _mainSoundTrack: SoundTrack;
  107985. /**
  107986. * The main sound track played by the scene.
  107987. * It cotains your primary collection of sounds.
  107988. */
  107989. mainSoundTrack: SoundTrack;
  107990. /**
  107991. * The list of sound tracks added to the scene
  107992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107993. */
  107994. soundTracks: Nullable<Array<SoundTrack>>;
  107995. /**
  107996. * Gets a sound using a given name
  107997. * @param name defines the name to search for
  107998. * @return the found sound or null if not found at all.
  107999. */
  108000. getSoundByName(name: string): Nullable<Sound>;
  108001. /**
  108002. * Gets or sets if audio support is enabled
  108003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108004. */
  108005. audioEnabled: boolean;
  108006. /**
  108007. * Gets or sets if audio will be output to headphones
  108008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108009. */
  108010. headphone: boolean;
  108011. /**
  108012. * Gets or sets custom audio listener position provider
  108013. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108014. */
  108015. audioListenerPositionProvider: Nullable<() => Vector3>;
  108016. /**
  108017. * Gets or sets a refresh rate when using 3D audio positioning
  108018. */
  108019. audioPositioningRefreshRate: number;
  108020. }
  108021. /**
  108022. * Defines the sound scene component responsible to manage any sounds
  108023. * in a given scene.
  108024. */
  108025. export class AudioSceneComponent implements ISceneSerializableComponent {
  108026. /**
  108027. * The component name helpfull to identify the component in the list of scene components.
  108028. */
  108029. readonly name: string;
  108030. /**
  108031. * The scene the component belongs to.
  108032. */
  108033. scene: Scene;
  108034. private _audioEnabled;
  108035. /**
  108036. * Gets whether audio is enabled or not.
  108037. * Please use related enable/disable method to switch state.
  108038. */
  108039. get audioEnabled(): boolean;
  108040. private _headphone;
  108041. /**
  108042. * Gets whether audio is outputing to headphone or not.
  108043. * Please use the according Switch methods to change output.
  108044. */
  108045. get headphone(): boolean;
  108046. /**
  108047. * Gets or sets a refresh rate when using 3D audio positioning
  108048. */
  108049. audioPositioningRefreshRate: number;
  108050. private _audioListenerPositionProvider;
  108051. /**
  108052. * Gets the current audio listener position provider
  108053. */
  108054. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  108055. /**
  108056. * Sets a custom listener position for all sounds in the scene
  108057. * By default, this is the position of the first active camera
  108058. */
  108059. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  108060. /**
  108061. * Creates a new instance of the component for the given scene
  108062. * @param scene Defines the scene to register the component in
  108063. */
  108064. constructor(scene: Scene);
  108065. /**
  108066. * Registers the component in a given scene
  108067. */
  108068. register(): void;
  108069. /**
  108070. * Rebuilds the elements related to this component in case of
  108071. * context lost for instance.
  108072. */
  108073. rebuild(): void;
  108074. /**
  108075. * Serializes the component data to the specified json object
  108076. * @param serializationObject The object to serialize to
  108077. */
  108078. serialize(serializationObject: any): void;
  108079. /**
  108080. * Adds all the elements from the container to the scene
  108081. * @param container the container holding the elements
  108082. */
  108083. addFromContainer(container: AbstractScene): void;
  108084. /**
  108085. * Removes all the elements in the container from the scene
  108086. * @param container contains the elements to remove
  108087. * @param dispose if the removed element should be disposed (default: false)
  108088. */
  108089. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108090. /**
  108091. * Disposes the component and the associated ressources.
  108092. */
  108093. dispose(): void;
  108094. /**
  108095. * Disables audio in the associated scene.
  108096. */
  108097. disableAudio(): void;
  108098. /**
  108099. * Enables audio in the associated scene.
  108100. */
  108101. enableAudio(): void;
  108102. /**
  108103. * Switch audio to headphone output.
  108104. */
  108105. switchAudioModeForHeadphones(): void;
  108106. /**
  108107. * Switch audio to normal speakers.
  108108. */
  108109. switchAudioModeForNormalSpeakers(): void;
  108110. private _cachedCameraDirection;
  108111. private _cachedCameraPosition;
  108112. private _lastCheck;
  108113. private _afterRender;
  108114. }
  108115. }
  108116. declare module BABYLON {
  108117. /**
  108118. * Wraps one or more Sound objects and selects one with random weight for playback.
  108119. */
  108120. export class WeightedSound {
  108121. /** When true a Sound will be selected and played when the current playing Sound completes. */
  108122. loop: boolean;
  108123. private _coneInnerAngle;
  108124. private _coneOuterAngle;
  108125. private _volume;
  108126. /** A Sound is currently playing. */
  108127. isPlaying: boolean;
  108128. /** A Sound is currently paused. */
  108129. isPaused: boolean;
  108130. private _sounds;
  108131. private _weights;
  108132. private _currentIndex?;
  108133. /**
  108134. * Creates a new WeightedSound from the list of sounds given.
  108135. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  108136. * @param sounds Array of Sounds that will be selected from.
  108137. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  108138. */
  108139. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  108140. /**
  108141. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  108142. */
  108143. get directionalConeInnerAngle(): number;
  108144. /**
  108145. * The size of cone in degress for a directional sound in which there will be no attenuation.
  108146. */
  108147. set directionalConeInnerAngle(value: number);
  108148. /**
  108149. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108150. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108151. */
  108152. get directionalConeOuterAngle(): number;
  108153. /**
  108154. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108155. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108156. */
  108157. set directionalConeOuterAngle(value: number);
  108158. /**
  108159. * Playback volume.
  108160. */
  108161. get volume(): number;
  108162. /**
  108163. * Playback volume.
  108164. */
  108165. set volume(value: number);
  108166. private _onended;
  108167. /**
  108168. * Suspend playback
  108169. */
  108170. pause(): void;
  108171. /**
  108172. * Stop playback
  108173. */
  108174. stop(): void;
  108175. /**
  108176. * Start playback.
  108177. * @param startOffset Position the clip head at a specific time in seconds.
  108178. */
  108179. play(startOffset?: number): void;
  108180. }
  108181. }
  108182. declare module BABYLON {
  108183. /**
  108184. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  108185. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  108186. */
  108187. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  108188. /**
  108189. * Gets the name of the behavior.
  108190. */
  108191. get name(): string;
  108192. /**
  108193. * The easing function used by animations
  108194. */
  108195. static EasingFunction: BackEase;
  108196. /**
  108197. * The easing mode used by animations
  108198. */
  108199. static EasingMode: number;
  108200. /**
  108201. * The duration of the animation, in milliseconds
  108202. */
  108203. transitionDuration: number;
  108204. /**
  108205. * Length of the distance animated by the transition when lower radius is reached
  108206. */
  108207. lowerRadiusTransitionRange: number;
  108208. /**
  108209. * Length of the distance animated by the transition when upper radius is reached
  108210. */
  108211. upperRadiusTransitionRange: number;
  108212. private _autoTransitionRange;
  108213. /**
  108214. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108215. */
  108216. get autoTransitionRange(): boolean;
  108217. /**
  108218. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108219. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  108220. */
  108221. set autoTransitionRange(value: boolean);
  108222. private _attachedCamera;
  108223. private _onAfterCheckInputsObserver;
  108224. private _onMeshTargetChangedObserver;
  108225. /**
  108226. * Initializes the behavior.
  108227. */
  108228. init(): void;
  108229. /**
  108230. * Attaches the behavior to its arc rotate camera.
  108231. * @param camera Defines the camera to attach the behavior to
  108232. */
  108233. attach(camera: ArcRotateCamera): void;
  108234. /**
  108235. * Detaches the behavior from its current arc rotate camera.
  108236. */
  108237. detach(): void;
  108238. private _radiusIsAnimating;
  108239. private _radiusBounceTransition;
  108240. private _animatables;
  108241. private _cachedWheelPrecision;
  108242. /**
  108243. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  108244. * @param radiusLimit The limit to check against.
  108245. * @return Bool to indicate if at limit.
  108246. */
  108247. private _isRadiusAtLimit;
  108248. /**
  108249. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  108250. * @param radiusDelta The delta by which to animate to. Can be negative.
  108251. */
  108252. private _applyBoundRadiusAnimation;
  108253. /**
  108254. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  108255. */
  108256. protected _clearAnimationLocks(): void;
  108257. /**
  108258. * Stops and removes all animations that have been applied to the camera
  108259. */
  108260. stopAllAnimations(): void;
  108261. }
  108262. }
  108263. declare module BABYLON {
  108264. /**
  108265. * 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.
  108266. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  108267. */
  108268. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  108269. /**
  108270. * Gets the name of the behavior.
  108271. */
  108272. get name(): string;
  108273. private _mode;
  108274. private _radiusScale;
  108275. private _positionScale;
  108276. private _defaultElevation;
  108277. private _elevationReturnTime;
  108278. private _elevationReturnWaitTime;
  108279. private _zoomStopsAnimation;
  108280. private _framingTime;
  108281. /**
  108282. * The easing function used by animations
  108283. */
  108284. static EasingFunction: ExponentialEase;
  108285. /**
  108286. * The easing mode used by animations
  108287. */
  108288. static EasingMode: number;
  108289. /**
  108290. * Sets the current mode used by the behavior
  108291. */
  108292. set mode(mode: number);
  108293. /**
  108294. * Gets current mode used by the behavior.
  108295. */
  108296. get mode(): number;
  108297. /**
  108298. * Sets the scale applied to the radius (1 by default)
  108299. */
  108300. set radiusScale(radius: number);
  108301. /**
  108302. * Gets the scale applied to the radius
  108303. */
  108304. get radiusScale(): number;
  108305. /**
  108306. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108307. */
  108308. set positionScale(scale: number);
  108309. /**
  108310. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108311. */
  108312. get positionScale(): number;
  108313. /**
  108314. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108315. * behaviour is triggered, in radians.
  108316. */
  108317. set defaultElevation(elevation: number);
  108318. /**
  108319. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108320. * behaviour is triggered, in radians.
  108321. */
  108322. get defaultElevation(): number;
  108323. /**
  108324. * Sets the time (in milliseconds) taken to return to the default beta position.
  108325. * Negative value indicates camera should not return to default.
  108326. */
  108327. set elevationReturnTime(speed: number);
  108328. /**
  108329. * Gets the time (in milliseconds) taken to return to the default beta position.
  108330. * Negative value indicates camera should not return to default.
  108331. */
  108332. get elevationReturnTime(): number;
  108333. /**
  108334. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108335. */
  108336. set elevationReturnWaitTime(time: number);
  108337. /**
  108338. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108339. */
  108340. get elevationReturnWaitTime(): number;
  108341. /**
  108342. * Sets the flag that indicates if user zooming should stop animation.
  108343. */
  108344. set zoomStopsAnimation(flag: boolean);
  108345. /**
  108346. * Gets the flag that indicates if user zooming should stop animation.
  108347. */
  108348. get zoomStopsAnimation(): boolean;
  108349. /**
  108350. * Sets the transition time when framing the mesh, in milliseconds
  108351. */
  108352. set framingTime(time: number);
  108353. /**
  108354. * Gets the transition time when framing the mesh, in milliseconds
  108355. */
  108356. get framingTime(): number;
  108357. /**
  108358. * Define if the behavior should automatically change the configured
  108359. * camera limits and sensibilities.
  108360. */
  108361. autoCorrectCameraLimitsAndSensibility: boolean;
  108362. private _onPrePointerObservableObserver;
  108363. private _onAfterCheckInputsObserver;
  108364. private _onMeshTargetChangedObserver;
  108365. private _attachedCamera;
  108366. private _isPointerDown;
  108367. private _lastInteractionTime;
  108368. /**
  108369. * Initializes the behavior.
  108370. */
  108371. init(): void;
  108372. /**
  108373. * Attaches the behavior to its arc rotate camera.
  108374. * @param camera Defines the camera to attach the behavior to
  108375. */
  108376. attach(camera: ArcRotateCamera): void;
  108377. /**
  108378. * Detaches the behavior from its current arc rotate camera.
  108379. */
  108380. detach(): void;
  108381. private _animatables;
  108382. private _betaIsAnimating;
  108383. private _betaTransition;
  108384. private _radiusTransition;
  108385. private _vectorTransition;
  108386. /**
  108387. * Targets the given mesh and updates zoom level accordingly.
  108388. * @param mesh The mesh to target.
  108389. * @param radius Optional. If a cached radius position already exists, overrides default.
  108390. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108391. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108392. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108393. */
  108394. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108395. /**
  108396. * Targets the given mesh with its children and updates zoom level accordingly.
  108397. * @param mesh The mesh to target.
  108398. * @param radius Optional. If a cached radius position already exists, overrides default.
  108399. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108400. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108401. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108402. */
  108403. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108404. /**
  108405. * Targets the given meshes with their children and updates zoom level accordingly.
  108406. * @param meshes The mesh to target.
  108407. * @param radius Optional. If a cached radius position already exists, overrides default.
  108408. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108409. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108410. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108411. */
  108412. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108413. /**
  108414. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  108415. * @param minimumWorld Determines the smaller position of the bounding box extend
  108416. * @param maximumWorld Determines the bigger position of the bounding box extend
  108417. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108418. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108419. */
  108420. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108421. /**
  108422. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  108423. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  108424. * frustum width.
  108425. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  108426. * to fully enclose the mesh in the viewing frustum.
  108427. */
  108428. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  108429. /**
  108430. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  108431. * is automatically returned to its default position (expected to be above ground plane).
  108432. */
  108433. private _maintainCameraAboveGround;
  108434. /**
  108435. * Returns the frustum slope based on the canvas ratio and camera FOV
  108436. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  108437. */
  108438. private _getFrustumSlope;
  108439. /**
  108440. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  108441. */
  108442. private _clearAnimationLocks;
  108443. /**
  108444. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  108445. */
  108446. private _applyUserInteraction;
  108447. /**
  108448. * Stops and removes all animations that have been applied to the camera
  108449. */
  108450. stopAllAnimations(): void;
  108451. /**
  108452. * Gets a value indicating if the user is moving the camera
  108453. */
  108454. get isUserIsMoving(): boolean;
  108455. /**
  108456. * The camera can move all the way towards the mesh.
  108457. */
  108458. static IgnoreBoundsSizeMode: number;
  108459. /**
  108460. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  108461. */
  108462. static FitFrustumSidesMode: number;
  108463. }
  108464. }
  108465. declare module BABYLON {
  108466. /**
  108467. * Base class for Camera Pointer Inputs.
  108468. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  108469. * for example usage.
  108470. */
  108471. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  108472. /**
  108473. * Defines the camera the input is attached to.
  108474. */
  108475. abstract camera: Camera;
  108476. /**
  108477. * Whether keyboard modifier keys are pressed at time of last mouse event.
  108478. */
  108479. protected _altKey: boolean;
  108480. protected _ctrlKey: boolean;
  108481. protected _metaKey: boolean;
  108482. protected _shiftKey: boolean;
  108483. /**
  108484. * Which mouse buttons were pressed at time of last mouse event.
  108485. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  108486. */
  108487. protected _buttonsPressed: number;
  108488. /**
  108489. * Defines the buttons associated with the input to handle camera move.
  108490. */
  108491. buttons: number[];
  108492. /**
  108493. * Attach the input controls to a specific dom element to get the input from.
  108494. * @param element Defines the element the controls should be listened from
  108495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108496. */
  108497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108498. /**
  108499. * Detach the current controls from the specified dom element.
  108500. * @param element Defines the element to stop listening the inputs from
  108501. */
  108502. detachControl(element: Nullable<HTMLElement>): void;
  108503. /**
  108504. * Gets the class name of the current input.
  108505. * @returns the class name
  108506. */
  108507. getClassName(): string;
  108508. /**
  108509. * Get the friendly name associated with the input class.
  108510. * @returns the input friendly name
  108511. */
  108512. getSimpleName(): string;
  108513. /**
  108514. * Called on pointer POINTERDOUBLETAP event.
  108515. * Override this method to provide functionality on POINTERDOUBLETAP event.
  108516. */
  108517. protected onDoubleTap(type: string): void;
  108518. /**
  108519. * Called on pointer POINTERMOVE event if only a single touch is active.
  108520. * Override this method to provide functionality.
  108521. */
  108522. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108523. /**
  108524. * Called on pointer POINTERMOVE event if multiple touches are active.
  108525. * Override this method to provide functionality.
  108526. */
  108527. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108528. /**
  108529. * Called on JS contextmenu event.
  108530. * Override this method to provide functionality.
  108531. */
  108532. protected onContextMenu(evt: PointerEvent): void;
  108533. /**
  108534. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108535. * press.
  108536. * Override this method to provide functionality.
  108537. */
  108538. protected onButtonDown(evt: PointerEvent): void;
  108539. /**
  108540. * Called each time a new POINTERUP event occurs. Ie, for each button
  108541. * release.
  108542. * Override this method to provide functionality.
  108543. */
  108544. protected onButtonUp(evt: PointerEvent): void;
  108545. /**
  108546. * Called when window becomes inactive.
  108547. * Override this method to provide functionality.
  108548. */
  108549. protected onLostFocus(): void;
  108550. private _pointerInput;
  108551. private _observer;
  108552. private _onLostFocus;
  108553. private pointA;
  108554. private pointB;
  108555. }
  108556. }
  108557. declare module BABYLON {
  108558. /**
  108559. * Manage the pointers inputs to control an arc rotate camera.
  108560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108561. */
  108562. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  108563. /**
  108564. * Defines the camera the input is attached to.
  108565. */
  108566. camera: ArcRotateCamera;
  108567. /**
  108568. * Gets the class name of the current input.
  108569. * @returns the class name
  108570. */
  108571. getClassName(): string;
  108572. /**
  108573. * Defines the buttons associated with the input to handle camera move.
  108574. */
  108575. buttons: number[];
  108576. /**
  108577. * Defines the pointer angular sensibility along the X axis or how fast is
  108578. * the camera rotating.
  108579. */
  108580. angularSensibilityX: number;
  108581. /**
  108582. * Defines the pointer angular sensibility along the Y axis or how fast is
  108583. * the camera rotating.
  108584. */
  108585. angularSensibilityY: number;
  108586. /**
  108587. * Defines the pointer pinch precision or how fast is the camera zooming.
  108588. */
  108589. pinchPrecision: number;
  108590. /**
  108591. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108592. * from 0.
  108593. * It defines the percentage of current camera.radius to use as delta when
  108594. * pinch zoom is used.
  108595. */
  108596. pinchDeltaPercentage: number;
  108597. /**
  108598. * Defines the pointer panning sensibility or how fast is the camera moving.
  108599. */
  108600. panningSensibility: number;
  108601. /**
  108602. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  108603. */
  108604. multiTouchPanning: boolean;
  108605. /**
  108606. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  108607. * zoom (pinch) through multitouch.
  108608. */
  108609. multiTouchPanAndZoom: boolean;
  108610. /**
  108611. * Revers pinch action direction.
  108612. */
  108613. pinchInwards: boolean;
  108614. private _isPanClick;
  108615. private _twoFingerActivityCount;
  108616. private _isPinching;
  108617. /**
  108618. * Called on pointer POINTERMOVE event if only a single touch is active.
  108619. */
  108620. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108621. /**
  108622. * Called on pointer POINTERDOUBLETAP event.
  108623. */
  108624. protected onDoubleTap(type: string): void;
  108625. /**
  108626. * Called on pointer POINTERMOVE event if multiple touches are active.
  108627. */
  108628. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108629. /**
  108630. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108631. * press.
  108632. */
  108633. protected onButtonDown(evt: PointerEvent): void;
  108634. /**
  108635. * Called each time a new POINTERUP event occurs. Ie, for each button
  108636. * release.
  108637. */
  108638. protected onButtonUp(evt: PointerEvent): void;
  108639. /**
  108640. * Called when window becomes inactive.
  108641. */
  108642. protected onLostFocus(): void;
  108643. }
  108644. }
  108645. declare module BABYLON {
  108646. /**
  108647. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  108648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108649. */
  108650. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  108651. /**
  108652. * Defines the camera the input is attached to.
  108653. */
  108654. camera: ArcRotateCamera;
  108655. /**
  108656. * Defines the list of key codes associated with the up action (increase alpha)
  108657. */
  108658. keysUp: number[];
  108659. /**
  108660. * Defines the list of key codes associated with the down action (decrease alpha)
  108661. */
  108662. keysDown: number[];
  108663. /**
  108664. * Defines the list of key codes associated with the left action (increase beta)
  108665. */
  108666. keysLeft: number[];
  108667. /**
  108668. * Defines the list of key codes associated with the right action (decrease beta)
  108669. */
  108670. keysRight: number[];
  108671. /**
  108672. * Defines the list of key codes associated with the reset action.
  108673. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  108674. */
  108675. keysReset: number[];
  108676. /**
  108677. * Defines the panning sensibility of the inputs.
  108678. * (How fast is the camera paning)
  108679. */
  108680. panningSensibility: number;
  108681. /**
  108682. * Defines the zooming sensibility of the inputs.
  108683. * (How fast is the camera zooming)
  108684. */
  108685. zoomingSensibility: number;
  108686. /**
  108687. * Defines wether maintaining the alt key down switch the movement mode from
  108688. * orientation to zoom.
  108689. */
  108690. useAltToZoom: boolean;
  108691. /**
  108692. * Rotation speed of the camera
  108693. */
  108694. angularSpeed: number;
  108695. private _keys;
  108696. private _ctrlPressed;
  108697. private _altPressed;
  108698. private _onCanvasBlurObserver;
  108699. private _onKeyboardObserver;
  108700. private _engine;
  108701. private _scene;
  108702. /**
  108703. * Attach the input controls to a specific dom element to get the input from.
  108704. * @param element Defines the element the controls should be listened from
  108705. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108706. */
  108707. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108708. /**
  108709. * Detach the current controls from the specified dom element.
  108710. * @param element Defines the element to stop listening the inputs from
  108711. */
  108712. detachControl(element: Nullable<HTMLElement>): void;
  108713. /**
  108714. * Update the current camera state depending on the inputs that have been used this frame.
  108715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108716. */
  108717. checkInputs(): void;
  108718. /**
  108719. * Gets the class name of the current intput.
  108720. * @returns the class name
  108721. */
  108722. getClassName(): string;
  108723. /**
  108724. * Get the friendly name associated with the input class.
  108725. * @returns the input friendly name
  108726. */
  108727. getSimpleName(): string;
  108728. }
  108729. }
  108730. declare module BABYLON {
  108731. /**
  108732. * Manage the mouse wheel inputs to control an arc rotate camera.
  108733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108734. */
  108735. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  108736. /**
  108737. * Defines the camera the input is attached to.
  108738. */
  108739. camera: ArcRotateCamera;
  108740. /**
  108741. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108742. */
  108743. wheelPrecision: number;
  108744. /**
  108745. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108746. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108747. */
  108748. wheelDeltaPercentage: number;
  108749. private _wheel;
  108750. private _observer;
  108751. private computeDeltaFromMouseWheelLegacyEvent;
  108752. /**
  108753. * Attach the input controls to a specific dom element to get the input from.
  108754. * @param element Defines the element the controls should be listened from
  108755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108756. */
  108757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108758. /**
  108759. * Detach the current controls from the specified dom element.
  108760. * @param element Defines the element to stop listening the inputs from
  108761. */
  108762. detachControl(element: Nullable<HTMLElement>): void;
  108763. /**
  108764. * Gets the class name of the current intput.
  108765. * @returns the class name
  108766. */
  108767. getClassName(): string;
  108768. /**
  108769. * Get the friendly name associated with the input class.
  108770. * @returns the input friendly name
  108771. */
  108772. getSimpleName(): string;
  108773. }
  108774. }
  108775. declare module BABYLON {
  108776. /**
  108777. * Default Inputs manager for the ArcRotateCamera.
  108778. * It groups all the default supported inputs for ease of use.
  108779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108780. */
  108781. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  108782. /**
  108783. * Instantiates a new ArcRotateCameraInputsManager.
  108784. * @param camera Defines the camera the inputs belong to
  108785. */
  108786. constructor(camera: ArcRotateCamera);
  108787. /**
  108788. * Add mouse wheel input support to the input manager.
  108789. * @returns the current input manager
  108790. */
  108791. addMouseWheel(): ArcRotateCameraInputsManager;
  108792. /**
  108793. * Add pointers input support to the input manager.
  108794. * @returns the current input manager
  108795. */
  108796. addPointers(): ArcRotateCameraInputsManager;
  108797. /**
  108798. * Add keyboard input support to the input manager.
  108799. * @returns the current input manager
  108800. */
  108801. addKeyboard(): ArcRotateCameraInputsManager;
  108802. }
  108803. }
  108804. declare module BABYLON {
  108805. /**
  108806. * This represents an orbital type of camera.
  108807. *
  108808. * 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.
  108809. * 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.
  108810. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  108811. */
  108812. export class ArcRotateCamera extends TargetCamera {
  108813. /**
  108814. * Defines the rotation angle of the camera along the longitudinal axis.
  108815. */
  108816. alpha: number;
  108817. /**
  108818. * Defines the rotation angle of the camera along the latitudinal axis.
  108819. */
  108820. beta: number;
  108821. /**
  108822. * Defines the radius of the camera from it s target point.
  108823. */
  108824. radius: number;
  108825. protected _target: Vector3;
  108826. protected _targetHost: Nullable<AbstractMesh>;
  108827. /**
  108828. * Defines the target point of the camera.
  108829. * The camera looks towards it form the radius distance.
  108830. */
  108831. get target(): Vector3;
  108832. set target(value: Vector3);
  108833. /**
  108834. * Define the current local position of the camera in the scene
  108835. */
  108836. get position(): Vector3;
  108837. set position(newPosition: Vector3);
  108838. protected _upVector: Vector3;
  108839. protected _upToYMatrix: Matrix;
  108840. protected _YToUpMatrix: Matrix;
  108841. /**
  108842. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  108843. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  108844. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  108845. */
  108846. set upVector(vec: Vector3);
  108847. get upVector(): Vector3;
  108848. /**
  108849. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  108850. */
  108851. setMatUp(): void;
  108852. /**
  108853. * Current inertia value on the longitudinal axis.
  108854. * The bigger this number the longer it will take for the camera to stop.
  108855. */
  108856. inertialAlphaOffset: number;
  108857. /**
  108858. * Current inertia value on the latitudinal axis.
  108859. * The bigger this number the longer it will take for the camera to stop.
  108860. */
  108861. inertialBetaOffset: number;
  108862. /**
  108863. * Current inertia value on the radius axis.
  108864. * The bigger this number the longer it will take for the camera to stop.
  108865. */
  108866. inertialRadiusOffset: number;
  108867. /**
  108868. * Minimum allowed angle on the longitudinal axis.
  108869. * This can help limiting how the Camera is able to move in the scene.
  108870. */
  108871. lowerAlphaLimit: Nullable<number>;
  108872. /**
  108873. * Maximum allowed angle on the longitudinal axis.
  108874. * This can help limiting how the Camera is able to move in the scene.
  108875. */
  108876. upperAlphaLimit: Nullable<number>;
  108877. /**
  108878. * Minimum allowed angle on the latitudinal axis.
  108879. * This can help limiting how the Camera is able to move in the scene.
  108880. */
  108881. lowerBetaLimit: number;
  108882. /**
  108883. * Maximum allowed angle on the latitudinal axis.
  108884. * This can help limiting how the Camera is able to move in the scene.
  108885. */
  108886. upperBetaLimit: number;
  108887. /**
  108888. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  108889. * This can help limiting how the Camera is able to move in the scene.
  108890. */
  108891. lowerRadiusLimit: Nullable<number>;
  108892. /**
  108893. * Maximum allowed distance of the camera to the target (The camera can not get further).
  108894. * This can help limiting how the Camera is able to move in the scene.
  108895. */
  108896. upperRadiusLimit: Nullable<number>;
  108897. /**
  108898. * Defines the current inertia value used during panning of the camera along the X axis.
  108899. */
  108900. inertialPanningX: number;
  108901. /**
  108902. * Defines the current inertia value used during panning of the camera along the Y axis.
  108903. */
  108904. inertialPanningY: number;
  108905. /**
  108906. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  108907. * Basically if your fingers moves away from more than this distance you will be considered
  108908. * in pinch mode.
  108909. */
  108910. pinchToPanMaxDistance: number;
  108911. /**
  108912. * Defines the maximum distance the camera can pan.
  108913. * This could help keeping the cammera always in your scene.
  108914. */
  108915. panningDistanceLimit: Nullable<number>;
  108916. /**
  108917. * Defines the target of the camera before paning.
  108918. */
  108919. panningOriginTarget: Vector3;
  108920. /**
  108921. * Defines the value of the inertia used during panning.
  108922. * 0 would mean stop inertia and one would mean no decelleration at all.
  108923. */
  108924. panningInertia: number;
  108925. /**
  108926. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  108927. */
  108928. get angularSensibilityX(): number;
  108929. set angularSensibilityX(value: number);
  108930. /**
  108931. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  108932. */
  108933. get angularSensibilityY(): number;
  108934. set angularSensibilityY(value: number);
  108935. /**
  108936. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  108937. */
  108938. get pinchPrecision(): number;
  108939. set pinchPrecision(value: number);
  108940. /**
  108941. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  108942. * It will be used instead of pinchDeltaPrecision if different from 0.
  108943. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  108944. */
  108945. get pinchDeltaPercentage(): number;
  108946. set pinchDeltaPercentage(value: number);
  108947. /**
  108948. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  108949. */
  108950. get panningSensibility(): number;
  108951. set panningSensibility(value: number);
  108952. /**
  108953. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  108954. */
  108955. get keysUp(): number[];
  108956. set keysUp(value: number[]);
  108957. /**
  108958. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  108959. */
  108960. get keysDown(): number[];
  108961. set keysDown(value: number[]);
  108962. /**
  108963. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  108964. */
  108965. get keysLeft(): number[];
  108966. set keysLeft(value: number[]);
  108967. /**
  108968. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  108969. */
  108970. get keysRight(): number[];
  108971. set keysRight(value: number[]);
  108972. /**
  108973. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108974. */
  108975. get wheelPrecision(): number;
  108976. set wheelPrecision(value: number);
  108977. /**
  108978. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  108979. * It will be used instead of pinchDeltaPrecision if different from 0.
  108980. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  108981. */
  108982. get wheelDeltaPercentage(): number;
  108983. set wheelDeltaPercentage(value: number);
  108984. /**
  108985. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  108986. */
  108987. zoomOnFactor: number;
  108988. /**
  108989. * Defines a screen offset for the camera position.
  108990. */
  108991. targetScreenOffset: Vector2;
  108992. /**
  108993. * Allows the camera to be completely reversed.
  108994. * If false the camera can not arrive upside down.
  108995. */
  108996. allowUpsideDown: boolean;
  108997. /**
  108998. * Define if double tap/click is used to restore the previously saved state of the camera.
  108999. */
  109000. useInputToRestoreState: boolean;
  109001. /** @hidden */
  109002. _viewMatrix: Matrix;
  109003. /** @hidden */
  109004. _useCtrlForPanning: boolean;
  109005. /** @hidden */
  109006. _panningMouseButton: number;
  109007. /**
  109008. * Defines the input associated to the camera.
  109009. */
  109010. inputs: ArcRotateCameraInputsManager;
  109011. /** @hidden */
  109012. _reset: () => void;
  109013. /**
  109014. * Defines the allowed panning axis.
  109015. */
  109016. panningAxis: Vector3;
  109017. protected _localDirection: Vector3;
  109018. protected _transformedDirection: Vector3;
  109019. private _bouncingBehavior;
  109020. /**
  109021. * Gets the bouncing behavior of the camera if it has been enabled.
  109022. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109023. */
  109024. get bouncingBehavior(): Nullable<BouncingBehavior>;
  109025. /**
  109026. * Defines if the bouncing behavior of the camera is enabled on the camera.
  109027. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109028. */
  109029. get useBouncingBehavior(): boolean;
  109030. set useBouncingBehavior(value: boolean);
  109031. private _framingBehavior;
  109032. /**
  109033. * Gets the framing behavior of the camera if it has been enabled.
  109034. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109035. */
  109036. get framingBehavior(): Nullable<FramingBehavior>;
  109037. /**
  109038. * Defines if the framing behavior of the camera is enabled on the camera.
  109039. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109040. */
  109041. get useFramingBehavior(): boolean;
  109042. set useFramingBehavior(value: boolean);
  109043. private _autoRotationBehavior;
  109044. /**
  109045. * Gets the auto rotation behavior of the camera if it has been enabled.
  109046. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109047. */
  109048. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  109049. /**
  109050. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  109051. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109052. */
  109053. get useAutoRotationBehavior(): boolean;
  109054. set useAutoRotationBehavior(value: boolean);
  109055. /**
  109056. * Observable triggered when the mesh target has been changed on the camera.
  109057. */
  109058. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  109059. /**
  109060. * Event raised when the camera is colliding with a mesh.
  109061. */
  109062. onCollide: (collidedMesh: AbstractMesh) => void;
  109063. /**
  109064. * Defines whether the camera should check collision with the objects oh the scene.
  109065. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  109066. */
  109067. checkCollisions: boolean;
  109068. /**
  109069. * Defines the collision radius of the camera.
  109070. * This simulates a sphere around the camera.
  109071. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109072. */
  109073. collisionRadius: Vector3;
  109074. protected _collider: Collider;
  109075. protected _previousPosition: Vector3;
  109076. protected _collisionVelocity: Vector3;
  109077. protected _newPosition: Vector3;
  109078. protected _previousAlpha: number;
  109079. protected _previousBeta: number;
  109080. protected _previousRadius: number;
  109081. protected _collisionTriggered: boolean;
  109082. protected _targetBoundingCenter: Nullable<Vector3>;
  109083. private _computationVector;
  109084. /**
  109085. * Instantiates a new ArcRotateCamera in a given scene
  109086. * @param name Defines the name of the camera
  109087. * @param alpha Defines the camera rotation along the logitudinal axis
  109088. * @param beta Defines the camera rotation along the latitudinal axis
  109089. * @param radius Defines the camera distance from its target
  109090. * @param target Defines the camera target
  109091. * @param scene Defines the scene the camera belongs to
  109092. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109093. */
  109094. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109095. /** @hidden */
  109096. _initCache(): void;
  109097. /** @hidden */
  109098. _updateCache(ignoreParentClass?: boolean): void;
  109099. protected _getTargetPosition(): Vector3;
  109100. private _storedAlpha;
  109101. private _storedBeta;
  109102. private _storedRadius;
  109103. private _storedTarget;
  109104. private _storedTargetScreenOffset;
  109105. /**
  109106. * Stores the current state of the camera (alpha, beta, radius and target)
  109107. * @returns the camera itself
  109108. */
  109109. storeState(): Camera;
  109110. /**
  109111. * @hidden
  109112. * Restored camera state. You must call storeState() first
  109113. */
  109114. _restoreStateValues(): boolean;
  109115. /** @hidden */
  109116. _isSynchronizedViewMatrix(): boolean;
  109117. /**
  109118. * Attached controls to the current camera.
  109119. * @param element Defines the element the controls should be listened from
  109120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109121. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  109122. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  109123. */
  109124. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  109125. /**
  109126. * Detach the current controls from the camera.
  109127. * The camera will stop reacting to inputs.
  109128. * @param element Defines the element to stop listening the inputs from
  109129. */
  109130. detachControl(element: HTMLElement): void;
  109131. /** @hidden */
  109132. _checkInputs(): void;
  109133. protected _checkLimits(): void;
  109134. /**
  109135. * Rebuilds angles (alpha, beta) and radius from the give position and target
  109136. */
  109137. rebuildAnglesAndRadius(): void;
  109138. /**
  109139. * Use a position to define the current camera related information like alpha, beta and radius
  109140. * @param position Defines the position to set the camera at
  109141. */
  109142. setPosition(position: Vector3): void;
  109143. /**
  109144. * Defines the target the camera should look at.
  109145. * This will automatically adapt alpha beta and radius to fit within the new target.
  109146. * @param target Defines the new target as a Vector or a mesh
  109147. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  109148. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  109149. */
  109150. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  109151. /** @hidden */
  109152. _getViewMatrix(): Matrix;
  109153. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  109154. /**
  109155. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  109156. * @param meshes Defines the mesh to zoom on
  109157. * @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)
  109158. */
  109159. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  109160. /**
  109161. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  109162. * The target will be changed but the radius
  109163. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  109164. * @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)
  109165. */
  109166. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  109167. min: Vector3;
  109168. max: Vector3;
  109169. distance: number;
  109170. }, doNotUpdateMaxZ?: boolean): void;
  109171. /**
  109172. * @override
  109173. * Override Camera.createRigCamera
  109174. */
  109175. createRigCamera(name: string, cameraIndex: number): Camera;
  109176. /**
  109177. * @hidden
  109178. * @override
  109179. * Override Camera._updateRigCameras
  109180. */
  109181. _updateRigCameras(): void;
  109182. /**
  109183. * Destroy the camera and release the current resources hold by it.
  109184. */
  109185. dispose(): void;
  109186. /**
  109187. * Gets the current object class name.
  109188. * @return the class name
  109189. */
  109190. getClassName(): string;
  109191. }
  109192. }
  109193. declare module BABYLON {
  109194. /**
  109195. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  109196. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109197. */
  109198. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  109199. /**
  109200. * Gets the name of the behavior.
  109201. */
  109202. get name(): string;
  109203. private _zoomStopsAnimation;
  109204. private _idleRotationSpeed;
  109205. private _idleRotationWaitTime;
  109206. private _idleRotationSpinupTime;
  109207. /**
  109208. * Sets the flag that indicates if user zooming should stop animation.
  109209. */
  109210. set zoomStopsAnimation(flag: boolean);
  109211. /**
  109212. * Gets the flag that indicates if user zooming should stop animation.
  109213. */
  109214. get zoomStopsAnimation(): boolean;
  109215. /**
  109216. * Sets the default speed at which the camera rotates around the model.
  109217. */
  109218. set idleRotationSpeed(speed: number);
  109219. /**
  109220. * Gets the default speed at which the camera rotates around the model.
  109221. */
  109222. get idleRotationSpeed(): number;
  109223. /**
  109224. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  109225. */
  109226. set idleRotationWaitTime(time: number);
  109227. /**
  109228. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  109229. */
  109230. get idleRotationWaitTime(): number;
  109231. /**
  109232. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109233. */
  109234. set idleRotationSpinupTime(time: number);
  109235. /**
  109236. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109237. */
  109238. get idleRotationSpinupTime(): number;
  109239. /**
  109240. * Gets a value indicating if the camera is currently rotating because of this behavior
  109241. */
  109242. get rotationInProgress(): boolean;
  109243. private _onPrePointerObservableObserver;
  109244. private _onAfterCheckInputsObserver;
  109245. private _attachedCamera;
  109246. private _isPointerDown;
  109247. private _lastFrameTime;
  109248. private _lastInteractionTime;
  109249. private _cameraRotationSpeed;
  109250. /**
  109251. * Initializes the behavior.
  109252. */
  109253. init(): void;
  109254. /**
  109255. * Attaches the behavior to its arc rotate camera.
  109256. * @param camera Defines the camera to attach the behavior to
  109257. */
  109258. attach(camera: ArcRotateCamera): void;
  109259. /**
  109260. * Detaches the behavior from its current arc rotate camera.
  109261. */
  109262. detach(): void;
  109263. /**
  109264. * Returns true if user is scrolling.
  109265. * @return true if user is scrolling.
  109266. */
  109267. private _userIsZooming;
  109268. private _lastFrameRadius;
  109269. private _shouldAnimationStopForInteraction;
  109270. /**
  109271. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  109272. */
  109273. private _applyUserInteraction;
  109274. private _userIsMoving;
  109275. }
  109276. }
  109277. declare module BABYLON {
  109278. /**
  109279. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  109280. */
  109281. export class AttachToBoxBehavior implements Behavior<Mesh> {
  109282. private ui;
  109283. /**
  109284. * The name of the behavior
  109285. */
  109286. name: string;
  109287. /**
  109288. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  109289. */
  109290. distanceAwayFromFace: number;
  109291. /**
  109292. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  109293. */
  109294. distanceAwayFromBottomOfFace: number;
  109295. private _faceVectors;
  109296. private _target;
  109297. private _scene;
  109298. private _onRenderObserver;
  109299. private _tmpMatrix;
  109300. private _tmpVector;
  109301. /**
  109302. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  109303. * @param ui The transform node that should be attched to the mesh
  109304. */
  109305. constructor(ui: TransformNode);
  109306. /**
  109307. * Initializes the behavior
  109308. */
  109309. init(): void;
  109310. private _closestFace;
  109311. private _zeroVector;
  109312. private _lookAtTmpMatrix;
  109313. private _lookAtToRef;
  109314. /**
  109315. * Attaches the AttachToBoxBehavior to the passed in mesh
  109316. * @param target The mesh that the specified node will be attached to
  109317. */
  109318. attach(target: Mesh): void;
  109319. /**
  109320. * Detaches the behavior from the mesh
  109321. */
  109322. detach(): void;
  109323. }
  109324. }
  109325. declare module BABYLON {
  109326. /**
  109327. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  109328. */
  109329. export class FadeInOutBehavior implements Behavior<Mesh> {
  109330. /**
  109331. * Time in milliseconds to delay before fading in (Default: 0)
  109332. */
  109333. delay: number;
  109334. /**
  109335. * Time in milliseconds for the mesh to fade in (Default: 300)
  109336. */
  109337. fadeInTime: number;
  109338. private _millisecondsPerFrame;
  109339. private _hovered;
  109340. private _hoverValue;
  109341. private _ownerNode;
  109342. /**
  109343. * Instatiates the FadeInOutBehavior
  109344. */
  109345. constructor();
  109346. /**
  109347. * The name of the behavior
  109348. */
  109349. get name(): string;
  109350. /**
  109351. * Initializes the behavior
  109352. */
  109353. init(): void;
  109354. /**
  109355. * Attaches the fade behavior on the passed in mesh
  109356. * @param ownerNode The mesh that will be faded in/out once attached
  109357. */
  109358. attach(ownerNode: Mesh): void;
  109359. /**
  109360. * Detaches the behavior from the mesh
  109361. */
  109362. detach(): void;
  109363. /**
  109364. * Triggers the mesh to begin fading in or out
  109365. * @param value if the object should fade in or out (true to fade in)
  109366. */
  109367. fadeIn(value: boolean): void;
  109368. private _update;
  109369. private _setAllVisibility;
  109370. }
  109371. }
  109372. declare module BABYLON {
  109373. /**
  109374. * Class containing a set of static utilities functions for managing Pivots
  109375. * @hidden
  109376. */
  109377. export class PivotTools {
  109378. private static _PivotCached;
  109379. private static _OldPivotPoint;
  109380. private static _PivotTranslation;
  109381. private static _PivotTmpVector;
  109382. /** @hidden */
  109383. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  109384. /** @hidden */
  109385. static _RestorePivotPoint(mesh: AbstractMesh): void;
  109386. }
  109387. }
  109388. declare module BABYLON {
  109389. /**
  109390. * Class containing static functions to help procedurally build meshes
  109391. */
  109392. export class PlaneBuilder {
  109393. /**
  109394. * Creates a plane mesh
  109395. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109396. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109397. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109401. * @param name defines the name of the mesh
  109402. * @param options defines the options used to create the mesh
  109403. * @param scene defines the hosting scene
  109404. * @returns the plane mesh
  109405. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109406. */
  109407. static CreatePlane(name: string, options: {
  109408. size?: number;
  109409. width?: number;
  109410. height?: number;
  109411. sideOrientation?: number;
  109412. frontUVs?: Vector4;
  109413. backUVs?: Vector4;
  109414. updatable?: boolean;
  109415. sourcePlane?: Plane;
  109416. }, scene?: Nullable<Scene>): Mesh;
  109417. }
  109418. }
  109419. declare module BABYLON {
  109420. /**
  109421. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  109422. */
  109423. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  109424. private static _AnyMouseID;
  109425. /**
  109426. * Abstract mesh the behavior is set on
  109427. */
  109428. attachedNode: AbstractMesh;
  109429. private _dragPlane;
  109430. private _scene;
  109431. private _pointerObserver;
  109432. private _beforeRenderObserver;
  109433. private static _planeScene;
  109434. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  109435. /**
  109436. * 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)
  109437. */
  109438. maxDragAngle: number;
  109439. /**
  109440. * @hidden
  109441. */
  109442. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  109443. /**
  109444. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109445. */
  109446. currentDraggingPointerID: number;
  109447. /**
  109448. * The last position where the pointer hit the drag plane in world space
  109449. */
  109450. lastDragPosition: Vector3;
  109451. /**
  109452. * If the behavior is currently in a dragging state
  109453. */
  109454. dragging: boolean;
  109455. /**
  109456. * 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)
  109457. */
  109458. dragDeltaRatio: number;
  109459. /**
  109460. * If the drag plane orientation should be updated during the dragging (Default: true)
  109461. */
  109462. updateDragPlane: boolean;
  109463. private _debugMode;
  109464. private _moving;
  109465. /**
  109466. * Fires each time the attached mesh is dragged with the pointer
  109467. * * delta between last drag position and current drag position in world space
  109468. * * dragDistance along the drag axis
  109469. * * dragPlaneNormal normal of the current drag plane used during the drag
  109470. * * dragPlanePoint in world space where the drag intersects the drag plane
  109471. */
  109472. onDragObservable: Observable<{
  109473. delta: Vector3;
  109474. dragPlanePoint: Vector3;
  109475. dragPlaneNormal: Vector3;
  109476. dragDistance: number;
  109477. pointerId: number;
  109478. }>;
  109479. /**
  109480. * Fires each time a drag begins (eg. mouse down on mesh)
  109481. */
  109482. onDragStartObservable: Observable<{
  109483. dragPlanePoint: Vector3;
  109484. pointerId: number;
  109485. }>;
  109486. /**
  109487. * Fires each time a drag ends (eg. mouse release after drag)
  109488. */
  109489. onDragEndObservable: Observable<{
  109490. dragPlanePoint: Vector3;
  109491. pointerId: number;
  109492. }>;
  109493. /**
  109494. * If the attached mesh should be moved when dragged
  109495. */
  109496. moveAttached: boolean;
  109497. /**
  109498. * If the drag behavior will react to drag events (Default: true)
  109499. */
  109500. enabled: boolean;
  109501. /**
  109502. * If pointer events should start and release the drag (Default: true)
  109503. */
  109504. startAndReleaseDragOnPointerEvents: boolean;
  109505. /**
  109506. * If camera controls should be detached during the drag
  109507. */
  109508. detachCameraControls: boolean;
  109509. /**
  109510. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  109511. */
  109512. useObjectOrienationForDragging: boolean;
  109513. private _options;
  109514. /**
  109515. * Gets the options used by the behavior
  109516. */
  109517. get options(): {
  109518. dragAxis?: Vector3;
  109519. dragPlaneNormal?: Vector3;
  109520. };
  109521. /**
  109522. * Sets the options used by the behavior
  109523. */
  109524. set options(options: {
  109525. dragAxis?: Vector3;
  109526. dragPlaneNormal?: Vector3;
  109527. });
  109528. /**
  109529. * Creates a pointer drag behavior that can be attached to a mesh
  109530. * @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)
  109531. */
  109532. constructor(options?: {
  109533. dragAxis?: Vector3;
  109534. dragPlaneNormal?: Vector3;
  109535. });
  109536. /**
  109537. * Predicate to determine if it is valid to move the object to a new position when it is moved
  109538. */
  109539. validateDrag: (targetPosition: Vector3) => boolean;
  109540. /**
  109541. * The name of the behavior
  109542. */
  109543. get name(): string;
  109544. /**
  109545. * Initializes the behavior
  109546. */
  109547. init(): void;
  109548. private _tmpVector;
  109549. private _alternatePickedPoint;
  109550. private _worldDragAxis;
  109551. private _targetPosition;
  109552. private _attachedElement;
  109553. /**
  109554. * Attaches the drag behavior the passed in mesh
  109555. * @param ownerNode The mesh that will be dragged around once attached
  109556. * @param predicate Predicate to use for pick filtering
  109557. */
  109558. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  109559. /**
  109560. * Force relase the drag action by code.
  109561. */
  109562. releaseDrag(): void;
  109563. private _startDragRay;
  109564. private _lastPointerRay;
  109565. /**
  109566. * Simulates the start of a pointer drag event on the behavior
  109567. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  109568. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  109569. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  109570. */
  109571. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  109572. private _startDrag;
  109573. private _dragDelta;
  109574. private _moveDrag;
  109575. private _pickWithRayOnDragPlane;
  109576. private _pointA;
  109577. private _pointB;
  109578. private _pointC;
  109579. private _lineA;
  109580. private _lineB;
  109581. private _localAxis;
  109582. private _lookAt;
  109583. private _updateDragPlanePosition;
  109584. /**
  109585. * Detaches the behavior from the mesh
  109586. */
  109587. detach(): void;
  109588. }
  109589. }
  109590. declare module BABYLON {
  109591. /**
  109592. * A behavior that when attached to a mesh will allow the mesh to be scaled
  109593. */
  109594. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  109595. private _dragBehaviorA;
  109596. private _dragBehaviorB;
  109597. private _startDistance;
  109598. private _initialScale;
  109599. private _targetScale;
  109600. private _ownerNode;
  109601. private _sceneRenderObserver;
  109602. /**
  109603. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  109604. */
  109605. constructor();
  109606. /**
  109607. * The name of the behavior
  109608. */
  109609. get name(): string;
  109610. /**
  109611. * Initializes the behavior
  109612. */
  109613. init(): void;
  109614. private _getCurrentDistance;
  109615. /**
  109616. * Attaches the scale behavior the passed in mesh
  109617. * @param ownerNode The mesh that will be scaled around once attached
  109618. */
  109619. attach(ownerNode: Mesh): void;
  109620. /**
  109621. * Detaches the behavior from the mesh
  109622. */
  109623. detach(): void;
  109624. }
  109625. }
  109626. declare module BABYLON {
  109627. /**
  109628. * 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
  109629. */
  109630. export class SixDofDragBehavior implements Behavior<Mesh> {
  109631. private static _virtualScene;
  109632. private _ownerNode;
  109633. private _sceneRenderObserver;
  109634. private _scene;
  109635. private _targetPosition;
  109636. private _virtualOriginMesh;
  109637. private _virtualDragMesh;
  109638. private _pointerObserver;
  109639. private _moving;
  109640. private _startingOrientation;
  109641. /**
  109642. * 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)
  109643. */
  109644. private zDragFactor;
  109645. /**
  109646. * If the object should rotate to face the drag origin
  109647. */
  109648. rotateDraggedObject: boolean;
  109649. /**
  109650. * If the behavior is currently in a dragging state
  109651. */
  109652. dragging: boolean;
  109653. /**
  109654. * 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)
  109655. */
  109656. dragDeltaRatio: number;
  109657. /**
  109658. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109659. */
  109660. currentDraggingPointerID: number;
  109661. /**
  109662. * If camera controls should be detached during the drag
  109663. */
  109664. detachCameraControls: boolean;
  109665. /**
  109666. * Fires each time a drag starts
  109667. */
  109668. onDragStartObservable: Observable<{}>;
  109669. /**
  109670. * Fires each time a drag ends (eg. mouse release after drag)
  109671. */
  109672. onDragEndObservable: Observable<{}>;
  109673. /**
  109674. * 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
  109675. */
  109676. constructor();
  109677. /**
  109678. * The name of the behavior
  109679. */
  109680. get name(): string;
  109681. /**
  109682. * Initializes the behavior
  109683. */
  109684. init(): void;
  109685. /**
  109686. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  109687. */
  109688. private get _pointerCamera();
  109689. /**
  109690. * Attaches the scale behavior the passed in mesh
  109691. * @param ownerNode The mesh that will be scaled around once attached
  109692. */
  109693. attach(ownerNode: Mesh): void;
  109694. /**
  109695. * Detaches the behavior from the mesh
  109696. */
  109697. detach(): void;
  109698. }
  109699. }
  109700. declare module BABYLON {
  109701. /**
  109702. * Class used to apply inverse kinematics to bones
  109703. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  109704. */
  109705. export class BoneIKController {
  109706. private static _tmpVecs;
  109707. private static _tmpQuat;
  109708. private static _tmpMats;
  109709. /**
  109710. * Gets or sets the target mesh
  109711. */
  109712. targetMesh: AbstractMesh;
  109713. /** Gets or sets the mesh used as pole */
  109714. poleTargetMesh: AbstractMesh;
  109715. /**
  109716. * Gets or sets the bone used as pole
  109717. */
  109718. poleTargetBone: Nullable<Bone>;
  109719. /**
  109720. * Gets or sets the target position
  109721. */
  109722. targetPosition: Vector3;
  109723. /**
  109724. * Gets or sets the pole target position
  109725. */
  109726. poleTargetPosition: Vector3;
  109727. /**
  109728. * Gets or sets the pole target local offset
  109729. */
  109730. poleTargetLocalOffset: Vector3;
  109731. /**
  109732. * Gets or sets the pole angle
  109733. */
  109734. poleAngle: number;
  109735. /**
  109736. * Gets or sets the mesh associated with the controller
  109737. */
  109738. mesh: AbstractMesh;
  109739. /**
  109740. * 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)
  109741. */
  109742. slerpAmount: number;
  109743. private _bone1Quat;
  109744. private _bone1Mat;
  109745. private _bone2Ang;
  109746. private _bone1;
  109747. private _bone2;
  109748. private _bone1Length;
  109749. private _bone2Length;
  109750. private _maxAngle;
  109751. private _maxReach;
  109752. private _rightHandedSystem;
  109753. private _bendAxis;
  109754. private _slerping;
  109755. private _adjustRoll;
  109756. /**
  109757. * Gets or sets maximum allowed angle
  109758. */
  109759. get maxAngle(): number;
  109760. set maxAngle(value: number);
  109761. /**
  109762. * Creates a new BoneIKController
  109763. * @param mesh defines the mesh to control
  109764. * @param bone defines the bone to control
  109765. * @param options defines options to set up the controller
  109766. */
  109767. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  109768. targetMesh?: AbstractMesh;
  109769. poleTargetMesh?: AbstractMesh;
  109770. poleTargetBone?: Bone;
  109771. poleTargetLocalOffset?: Vector3;
  109772. poleAngle?: number;
  109773. bendAxis?: Vector3;
  109774. maxAngle?: number;
  109775. slerpAmount?: number;
  109776. });
  109777. private _setMaxAngle;
  109778. /**
  109779. * Force the controller to update the bones
  109780. */
  109781. update(): void;
  109782. }
  109783. }
  109784. declare module BABYLON {
  109785. /**
  109786. * Class used to make a bone look toward a point in space
  109787. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  109788. */
  109789. export class BoneLookController {
  109790. private static _tmpVecs;
  109791. private static _tmpQuat;
  109792. private static _tmpMats;
  109793. /**
  109794. * The target Vector3 that the bone will look at
  109795. */
  109796. target: Vector3;
  109797. /**
  109798. * The mesh that the bone is attached to
  109799. */
  109800. mesh: AbstractMesh;
  109801. /**
  109802. * The bone that will be looking to the target
  109803. */
  109804. bone: Bone;
  109805. /**
  109806. * The up axis of the coordinate system that is used when the bone is rotated
  109807. */
  109808. upAxis: Vector3;
  109809. /**
  109810. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  109811. */
  109812. upAxisSpace: Space;
  109813. /**
  109814. * Used to make an adjustment to the yaw of the bone
  109815. */
  109816. adjustYaw: number;
  109817. /**
  109818. * Used to make an adjustment to the pitch of the bone
  109819. */
  109820. adjustPitch: number;
  109821. /**
  109822. * Used to make an adjustment to the roll of the bone
  109823. */
  109824. adjustRoll: number;
  109825. /**
  109826. * 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)
  109827. */
  109828. slerpAmount: number;
  109829. private _minYaw;
  109830. private _maxYaw;
  109831. private _minPitch;
  109832. private _maxPitch;
  109833. private _minYawSin;
  109834. private _minYawCos;
  109835. private _maxYawSin;
  109836. private _maxYawCos;
  109837. private _midYawConstraint;
  109838. private _minPitchTan;
  109839. private _maxPitchTan;
  109840. private _boneQuat;
  109841. private _slerping;
  109842. private _transformYawPitch;
  109843. private _transformYawPitchInv;
  109844. private _firstFrameSkipped;
  109845. private _yawRange;
  109846. private _fowardAxis;
  109847. /**
  109848. * Gets or sets the minimum yaw angle that the bone can look to
  109849. */
  109850. get minYaw(): number;
  109851. set minYaw(value: number);
  109852. /**
  109853. * Gets or sets the maximum yaw angle that the bone can look to
  109854. */
  109855. get maxYaw(): number;
  109856. set maxYaw(value: number);
  109857. /**
  109858. * Gets or sets the minimum pitch angle that the bone can look to
  109859. */
  109860. get minPitch(): number;
  109861. set minPitch(value: number);
  109862. /**
  109863. * Gets or sets the maximum pitch angle that the bone can look to
  109864. */
  109865. get maxPitch(): number;
  109866. set maxPitch(value: number);
  109867. /**
  109868. * Create a BoneLookController
  109869. * @param mesh the mesh that the bone belongs to
  109870. * @param bone the bone that will be looking to the target
  109871. * @param target the target Vector3 to look at
  109872. * @param options optional settings:
  109873. * * maxYaw: the maximum angle the bone will yaw to
  109874. * * minYaw: the minimum angle the bone will yaw to
  109875. * * maxPitch: the maximum angle the bone will pitch to
  109876. * * minPitch: the minimum angle the bone will yaw to
  109877. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  109878. * * upAxis: the up axis of the coordinate system
  109879. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  109880. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  109881. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  109882. * * adjustYaw: used to make an adjustment to the yaw of the bone
  109883. * * adjustPitch: used to make an adjustment to the pitch of the bone
  109884. * * adjustRoll: used to make an adjustment to the roll of the bone
  109885. **/
  109886. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  109887. maxYaw?: number;
  109888. minYaw?: number;
  109889. maxPitch?: number;
  109890. minPitch?: number;
  109891. slerpAmount?: number;
  109892. upAxis?: Vector3;
  109893. upAxisSpace?: Space;
  109894. yawAxis?: Vector3;
  109895. pitchAxis?: Vector3;
  109896. adjustYaw?: number;
  109897. adjustPitch?: number;
  109898. adjustRoll?: number;
  109899. });
  109900. /**
  109901. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  109902. */
  109903. update(): void;
  109904. private _getAngleDiff;
  109905. private _getAngleBetween;
  109906. private _isAngleBetween;
  109907. }
  109908. }
  109909. declare module BABYLON {
  109910. /**
  109911. * Manage the gamepad inputs to control an arc rotate camera.
  109912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109913. */
  109914. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  109915. /**
  109916. * Defines the camera the input is attached to.
  109917. */
  109918. camera: ArcRotateCamera;
  109919. /**
  109920. * Defines the gamepad the input is gathering event from.
  109921. */
  109922. gamepad: Nullable<Gamepad>;
  109923. /**
  109924. * Defines the gamepad rotation sensiblity.
  109925. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109926. */
  109927. gamepadRotationSensibility: number;
  109928. /**
  109929. * Defines the gamepad move sensiblity.
  109930. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109931. */
  109932. gamepadMoveSensibility: number;
  109933. private _yAxisScale;
  109934. /**
  109935. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  109936. */
  109937. get invertYAxis(): boolean;
  109938. set invertYAxis(value: boolean);
  109939. private _onGamepadConnectedObserver;
  109940. private _onGamepadDisconnectedObserver;
  109941. /**
  109942. * Attach the input controls to a specific dom element to get the input from.
  109943. * @param element Defines the element the controls should be listened from
  109944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109945. */
  109946. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109947. /**
  109948. * Detach the current controls from the specified dom element.
  109949. * @param element Defines the element to stop listening the inputs from
  109950. */
  109951. detachControl(element: Nullable<HTMLElement>): void;
  109952. /**
  109953. * Update the current camera state depending on the inputs that have been used this frame.
  109954. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109955. */
  109956. checkInputs(): void;
  109957. /**
  109958. * Gets the class name of the current intput.
  109959. * @returns the class name
  109960. */
  109961. getClassName(): string;
  109962. /**
  109963. * Get the friendly name associated with the input class.
  109964. * @returns the input friendly name
  109965. */
  109966. getSimpleName(): string;
  109967. }
  109968. }
  109969. declare module BABYLON {
  109970. interface ArcRotateCameraInputsManager {
  109971. /**
  109972. * Add orientation input support to the input manager.
  109973. * @returns the current input manager
  109974. */
  109975. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  109976. }
  109977. /**
  109978. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  109979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109980. */
  109981. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  109982. /**
  109983. * Defines the camera the input is attached to.
  109984. */
  109985. camera: ArcRotateCamera;
  109986. /**
  109987. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  109988. */
  109989. alphaCorrection: number;
  109990. /**
  109991. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  109992. */
  109993. gammaCorrection: number;
  109994. private _alpha;
  109995. private _gamma;
  109996. private _dirty;
  109997. private _deviceOrientationHandler;
  109998. /**
  109999. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  110000. */
  110001. constructor();
  110002. /**
  110003. * Attach the input controls to a specific dom element to get the input from.
  110004. * @param element Defines the element the controls should be listened from
  110005. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110006. */
  110007. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110008. /** @hidden */
  110009. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  110010. /**
  110011. * Update the current camera state depending on the inputs that have been used this frame.
  110012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110013. */
  110014. checkInputs(): void;
  110015. /**
  110016. * Detach the current controls from the specified dom element.
  110017. * @param element Defines the element to stop listening the inputs from
  110018. */
  110019. detachControl(element: Nullable<HTMLElement>): void;
  110020. /**
  110021. * Gets the class name of the current intput.
  110022. * @returns the class name
  110023. */
  110024. getClassName(): string;
  110025. /**
  110026. * Get the friendly name associated with the input class.
  110027. * @returns the input friendly name
  110028. */
  110029. getSimpleName(): string;
  110030. }
  110031. }
  110032. declare module BABYLON {
  110033. /**
  110034. * Listen to mouse events to control the camera.
  110035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110036. */
  110037. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  110038. /**
  110039. * Defines the camera the input is attached to.
  110040. */
  110041. camera: FlyCamera;
  110042. /**
  110043. * Defines if touch is enabled. (Default is true.)
  110044. */
  110045. touchEnabled: boolean;
  110046. /**
  110047. * Defines the buttons associated with the input to handle camera rotation.
  110048. */
  110049. buttons: number[];
  110050. /**
  110051. * Assign buttons for Yaw control.
  110052. */
  110053. buttonsYaw: number[];
  110054. /**
  110055. * Assign buttons for Pitch control.
  110056. */
  110057. buttonsPitch: number[];
  110058. /**
  110059. * Assign buttons for Roll control.
  110060. */
  110061. buttonsRoll: number[];
  110062. /**
  110063. * Detect if any button is being pressed while mouse is moved.
  110064. * -1 = Mouse locked.
  110065. * 0 = Left button.
  110066. * 1 = Middle Button.
  110067. * 2 = Right Button.
  110068. */
  110069. activeButton: number;
  110070. /**
  110071. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  110072. * Higher values reduce its sensitivity.
  110073. */
  110074. angularSensibility: number;
  110075. private _mousemoveCallback;
  110076. private _observer;
  110077. private _rollObserver;
  110078. private previousPosition;
  110079. private noPreventDefault;
  110080. private element;
  110081. /**
  110082. * Listen to mouse events to control the camera.
  110083. * @param touchEnabled Define if touch is enabled. (Default is true.)
  110084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110085. */
  110086. constructor(touchEnabled?: boolean);
  110087. /**
  110088. * Attach the mouse control to the HTML DOM element.
  110089. * @param element Defines the element that listens to the input events.
  110090. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  110091. */
  110092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110093. /**
  110094. * Detach the current controls from the specified dom element.
  110095. * @param element Defines the element to stop listening the inputs from
  110096. */
  110097. detachControl(element: Nullable<HTMLElement>): void;
  110098. /**
  110099. * Gets the class name of the current input.
  110100. * @returns the class name.
  110101. */
  110102. getClassName(): string;
  110103. /**
  110104. * Get the friendly name associated with the input class.
  110105. * @returns the input's friendly name.
  110106. */
  110107. getSimpleName(): string;
  110108. private _pointerInput;
  110109. private _onMouseMove;
  110110. /**
  110111. * Rotate camera by mouse offset.
  110112. */
  110113. private rotateCamera;
  110114. }
  110115. }
  110116. declare module BABYLON {
  110117. /**
  110118. * Default Inputs manager for the FlyCamera.
  110119. * It groups all the default supported inputs for ease of use.
  110120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110121. */
  110122. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  110123. /**
  110124. * Instantiates a new FlyCameraInputsManager.
  110125. * @param camera Defines the camera the inputs belong to.
  110126. */
  110127. constructor(camera: FlyCamera);
  110128. /**
  110129. * Add keyboard input support to the input manager.
  110130. * @returns the new FlyCameraKeyboardMoveInput().
  110131. */
  110132. addKeyboard(): FlyCameraInputsManager;
  110133. /**
  110134. * Add mouse input support to the input manager.
  110135. * @param touchEnabled Enable touch screen support.
  110136. * @returns the new FlyCameraMouseInput().
  110137. */
  110138. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  110139. }
  110140. }
  110141. declare module BABYLON {
  110142. /**
  110143. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110144. * such as in a 3D Space Shooter or a Flight Simulator.
  110145. */
  110146. export class FlyCamera extends TargetCamera {
  110147. /**
  110148. * Define the collision ellipsoid of the camera.
  110149. * This is helpful for simulating a camera body, like a player's body.
  110150. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  110151. */
  110152. ellipsoid: Vector3;
  110153. /**
  110154. * Define an offset for the position of the ellipsoid around the camera.
  110155. * This can be helpful if the camera is attached away from the player's body center,
  110156. * such as at its head.
  110157. */
  110158. ellipsoidOffset: Vector3;
  110159. /**
  110160. * Enable or disable collisions of the camera with the rest of the scene objects.
  110161. */
  110162. checkCollisions: boolean;
  110163. /**
  110164. * Enable or disable gravity on the camera.
  110165. */
  110166. applyGravity: boolean;
  110167. /**
  110168. * Define the current direction the camera is moving to.
  110169. */
  110170. cameraDirection: Vector3;
  110171. /**
  110172. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  110173. * This overrides and empties cameraRotation.
  110174. */
  110175. rotationQuaternion: Quaternion;
  110176. /**
  110177. * Track Roll to maintain the wanted Rolling when looking around.
  110178. */
  110179. _trackRoll: number;
  110180. /**
  110181. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  110182. */
  110183. rollCorrect: number;
  110184. /**
  110185. * Mimic a banked turn, Rolling the camera when Yawing.
  110186. * It's recommended to use rollCorrect = 10 for faster banking correction.
  110187. */
  110188. bankedTurn: boolean;
  110189. /**
  110190. * Limit in radians for how much Roll banking will add. (Default: 90°)
  110191. */
  110192. bankedTurnLimit: number;
  110193. /**
  110194. * Value of 0 disables the banked Roll.
  110195. * Value of 1 is equal to the Yaw angle in radians.
  110196. */
  110197. bankedTurnMultiplier: number;
  110198. /**
  110199. * The inputs manager loads all the input sources, such as keyboard and mouse.
  110200. */
  110201. inputs: FlyCameraInputsManager;
  110202. /**
  110203. * Gets the input sensibility for mouse input.
  110204. * Higher values reduce sensitivity.
  110205. */
  110206. get angularSensibility(): number;
  110207. /**
  110208. * Sets the input sensibility for a mouse input.
  110209. * Higher values reduce sensitivity.
  110210. */
  110211. set angularSensibility(value: number);
  110212. /**
  110213. * Get the keys for camera movement forward.
  110214. */
  110215. get keysForward(): number[];
  110216. /**
  110217. * Set the keys for camera movement forward.
  110218. */
  110219. set keysForward(value: number[]);
  110220. /**
  110221. * Get the keys for camera movement backward.
  110222. */
  110223. get keysBackward(): number[];
  110224. set keysBackward(value: number[]);
  110225. /**
  110226. * Get the keys for camera movement up.
  110227. */
  110228. get keysUp(): number[];
  110229. /**
  110230. * Set the keys for camera movement up.
  110231. */
  110232. set keysUp(value: number[]);
  110233. /**
  110234. * Get the keys for camera movement down.
  110235. */
  110236. get keysDown(): number[];
  110237. /**
  110238. * Set the keys for camera movement down.
  110239. */
  110240. set keysDown(value: number[]);
  110241. /**
  110242. * Get the keys for camera movement left.
  110243. */
  110244. get keysLeft(): number[];
  110245. /**
  110246. * Set the keys for camera movement left.
  110247. */
  110248. set keysLeft(value: number[]);
  110249. /**
  110250. * Set the keys for camera movement right.
  110251. */
  110252. get keysRight(): number[];
  110253. /**
  110254. * Set the keys for camera movement right.
  110255. */
  110256. set keysRight(value: number[]);
  110257. /**
  110258. * Event raised when the camera collides with a mesh in the scene.
  110259. */
  110260. onCollide: (collidedMesh: AbstractMesh) => void;
  110261. private _collider;
  110262. private _needMoveForGravity;
  110263. private _oldPosition;
  110264. private _diffPosition;
  110265. private _newPosition;
  110266. /** @hidden */
  110267. _localDirection: Vector3;
  110268. /** @hidden */
  110269. _transformedDirection: Vector3;
  110270. /**
  110271. * Instantiates a FlyCamera.
  110272. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110273. * such as in a 3D Space Shooter or a Flight Simulator.
  110274. * @param name Define the name of the camera in the scene.
  110275. * @param position Define the starting position of the camera in the scene.
  110276. * @param scene Define the scene the camera belongs to.
  110277. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  110278. */
  110279. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110280. /**
  110281. * Attach a control to the HTML DOM element.
  110282. * @param element Defines the element that listens to the input events.
  110283. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  110284. */
  110285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110286. /**
  110287. * Detach a control from the HTML DOM element.
  110288. * The camera will stop reacting to that input.
  110289. * @param element Defines the element that listens to the input events.
  110290. */
  110291. detachControl(element: HTMLElement): void;
  110292. private _collisionMask;
  110293. /**
  110294. * Get the mask that the camera ignores in collision events.
  110295. */
  110296. get collisionMask(): number;
  110297. /**
  110298. * Set the mask that the camera ignores in collision events.
  110299. */
  110300. set collisionMask(mask: number);
  110301. /** @hidden */
  110302. _collideWithWorld(displacement: Vector3): void;
  110303. /** @hidden */
  110304. private _onCollisionPositionChange;
  110305. /** @hidden */
  110306. _checkInputs(): void;
  110307. /** @hidden */
  110308. _decideIfNeedsToMove(): boolean;
  110309. /** @hidden */
  110310. _updatePosition(): void;
  110311. /**
  110312. * Restore the Roll to its target value at the rate specified.
  110313. * @param rate - Higher means slower restoring.
  110314. * @hidden
  110315. */
  110316. restoreRoll(rate: number): void;
  110317. /**
  110318. * Destroy the camera and release the current resources held by it.
  110319. */
  110320. dispose(): void;
  110321. /**
  110322. * Get the current object class name.
  110323. * @returns the class name.
  110324. */
  110325. getClassName(): string;
  110326. }
  110327. }
  110328. declare module BABYLON {
  110329. /**
  110330. * Listen to keyboard events to control the camera.
  110331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110332. */
  110333. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  110334. /**
  110335. * Defines the camera the input is attached to.
  110336. */
  110337. camera: FlyCamera;
  110338. /**
  110339. * The list of keyboard keys used to control the forward move of the camera.
  110340. */
  110341. keysForward: number[];
  110342. /**
  110343. * The list of keyboard keys used to control the backward move of the camera.
  110344. */
  110345. keysBackward: number[];
  110346. /**
  110347. * The list of keyboard keys used to control the forward move of the camera.
  110348. */
  110349. keysUp: number[];
  110350. /**
  110351. * The list of keyboard keys used to control the backward move of the camera.
  110352. */
  110353. keysDown: number[];
  110354. /**
  110355. * The list of keyboard keys used to control the right strafe move of the camera.
  110356. */
  110357. keysRight: number[];
  110358. /**
  110359. * The list of keyboard keys used to control the left strafe move of the camera.
  110360. */
  110361. keysLeft: number[];
  110362. private _keys;
  110363. private _onCanvasBlurObserver;
  110364. private _onKeyboardObserver;
  110365. private _engine;
  110366. private _scene;
  110367. /**
  110368. * Attach the input controls to a specific dom element to get the input from.
  110369. * @param element Defines the element the controls should be listened from
  110370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110371. */
  110372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110373. /**
  110374. * Detach the current controls from the specified dom element.
  110375. * @param element Defines the element to stop listening the inputs from
  110376. */
  110377. detachControl(element: Nullable<HTMLElement>): void;
  110378. /**
  110379. * Gets the class name of the current intput.
  110380. * @returns the class name
  110381. */
  110382. getClassName(): string;
  110383. /** @hidden */
  110384. _onLostFocus(e: FocusEvent): void;
  110385. /**
  110386. * Get the friendly name associated with the input class.
  110387. * @returns the input friendly name
  110388. */
  110389. getSimpleName(): string;
  110390. /**
  110391. * Update the current camera state depending on the inputs that have been used this frame.
  110392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110393. */
  110394. checkInputs(): void;
  110395. }
  110396. }
  110397. declare module BABYLON {
  110398. /**
  110399. * Manage the mouse wheel inputs to control a follow camera.
  110400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110401. */
  110402. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  110403. /**
  110404. * Defines the camera the input is attached to.
  110405. */
  110406. camera: FollowCamera;
  110407. /**
  110408. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  110409. */
  110410. axisControlRadius: boolean;
  110411. /**
  110412. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  110413. */
  110414. axisControlHeight: boolean;
  110415. /**
  110416. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  110417. */
  110418. axisControlRotation: boolean;
  110419. /**
  110420. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  110421. * relation to mouseWheel events.
  110422. */
  110423. wheelPrecision: number;
  110424. /**
  110425. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110426. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110427. */
  110428. wheelDeltaPercentage: number;
  110429. private _wheel;
  110430. private _observer;
  110431. /**
  110432. * Attach the input controls to a specific dom element to get the input from.
  110433. * @param element Defines the element the controls should be listened from
  110434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110435. */
  110436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110437. /**
  110438. * Detach the current controls from the specified dom element.
  110439. * @param element Defines the element to stop listening the inputs from
  110440. */
  110441. detachControl(element: Nullable<HTMLElement>): void;
  110442. /**
  110443. * Gets the class name of the current intput.
  110444. * @returns the class name
  110445. */
  110446. getClassName(): string;
  110447. /**
  110448. * Get the friendly name associated with the input class.
  110449. * @returns the input friendly name
  110450. */
  110451. getSimpleName(): string;
  110452. }
  110453. }
  110454. declare module BABYLON {
  110455. /**
  110456. * Manage the pointers inputs to control an follow camera.
  110457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110458. */
  110459. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  110460. /**
  110461. * Defines the camera the input is attached to.
  110462. */
  110463. camera: FollowCamera;
  110464. /**
  110465. * Gets the class name of the current input.
  110466. * @returns the class name
  110467. */
  110468. getClassName(): string;
  110469. /**
  110470. * Defines the pointer angular sensibility along the X axis or how fast is
  110471. * the camera rotating.
  110472. * A negative number will reverse the axis direction.
  110473. */
  110474. angularSensibilityX: number;
  110475. /**
  110476. * Defines the pointer angular sensibility along the Y axis or how fast is
  110477. * the camera rotating.
  110478. * A negative number will reverse the axis direction.
  110479. */
  110480. angularSensibilityY: number;
  110481. /**
  110482. * Defines the pointer pinch precision or how fast is the camera zooming.
  110483. * A negative number will reverse the axis direction.
  110484. */
  110485. pinchPrecision: number;
  110486. /**
  110487. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110488. * from 0.
  110489. * It defines the percentage of current camera.radius to use as delta when
  110490. * pinch zoom is used.
  110491. */
  110492. pinchDeltaPercentage: number;
  110493. /**
  110494. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  110495. */
  110496. axisXControlRadius: boolean;
  110497. /**
  110498. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  110499. */
  110500. axisXControlHeight: boolean;
  110501. /**
  110502. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  110503. */
  110504. axisXControlRotation: boolean;
  110505. /**
  110506. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  110507. */
  110508. axisYControlRadius: boolean;
  110509. /**
  110510. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  110511. */
  110512. axisYControlHeight: boolean;
  110513. /**
  110514. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  110515. */
  110516. axisYControlRotation: boolean;
  110517. /**
  110518. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  110519. */
  110520. axisPinchControlRadius: boolean;
  110521. /**
  110522. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  110523. */
  110524. axisPinchControlHeight: boolean;
  110525. /**
  110526. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  110527. */
  110528. axisPinchControlRotation: boolean;
  110529. /**
  110530. * Log error messages if basic misconfiguration has occurred.
  110531. */
  110532. warningEnable: boolean;
  110533. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110534. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110535. private _warningCounter;
  110536. private _warning;
  110537. }
  110538. }
  110539. declare module BABYLON {
  110540. /**
  110541. * Default Inputs manager for the FollowCamera.
  110542. * It groups all the default supported inputs for ease of use.
  110543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110544. */
  110545. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  110546. /**
  110547. * Instantiates a new FollowCameraInputsManager.
  110548. * @param camera Defines the camera the inputs belong to
  110549. */
  110550. constructor(camera: FollowCamera);
  110551. /**
  110552. * Add keyboard input support to the input manager.
  110553. * @returns the current input manager
  110554. */
  110555. addKeyboard(): FollowCameraInputsManager;
  110556. /**
  110557. * Add mouse wheel input support to the input manager.
  110558. * @returns the current input manager
  110559. */
  110560. addMouseWheel(): FollowCameraInputsManager;
  110561. /**
  110562. * Add pointers input support to the input manager.
  110563. * @returns the current input manager
  110564. */
  110565. addPointers(): FollowCameraInputsManager;
  110566. /**
  110567. * Add orientation input support to the input manager.
  110568. * @returns the current input manager
  110569. */
  110570. addVRDeviceOrientation(): FollowCameraInputsManager;
  110571. }
  110572. }
  110573. declare module BABYLON {
  110574. /**
  110575. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  110576. * an arc rotate version arcFollowCamera are available.
  110577. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110578. */
  110579. export class FollowCamera extends TargetCamera {
  110580. /**
  110581. * Distance the follow camera should follow an object at
  110582. */
  110583. radius: number;
  110584. /**
  110585. * Minimum allowed distance of the camera to the axis of rotation
  110586. * (The camera can not get closer).
  110587. * This can help limiting how the Camera is able to move in the scene.
  110588. */
  110589. lowerRadiusLimit: Nullable<number>;
  110590. /**
  110591. * Maximum allowed distance of the camera to the axis of rotation
  110592. * (The camera can not get further).
  110593. * This can help limiting how the Camera is able to move in the scene.
  110594. */
  110595. upperRadiusLimit: Nullable<number>;
  110596. /**
  110597. * Define a rotation offset between the camera and the object it follows
  110598. */
  110599. rotationOffset: number;
  110600. /**
  110601. * Minimum allowed angle to camera position relative to target object.
  110602. * This can help limiting how the Camera is able to move in the scene.
  110603. */
  110604. lowerRotationOffsetLimit: Nullable<number>;
  110605. /**
  110606. * Maximum allowed angle to camera position relative to target object.
  110607. * This can help limiting how the Camera is able to move in the scene.
  110608. */
  110609. upperRotationOffsetLimit: Nullable<number>;
  110610. /**
  110611. * Define a height offset between the camera and the object it follows.
  110612. * It can help following an object from the top (like a car chaing a plane)
  110613. */
  110614. heightOffset: number;
  110615. /**
  110616. * Minimum allowed height of camera position relative to target object.
  110617. * This can help limiting how the Camera is able to move in the scene.
  110618. */
  110619. lowerHeightOffsetLimit: Nullable<number>;
  110620. /**
  110621. * Maximum allowed height of camera position relative to target object.
  110622. * This can help limiting how the Camera is able to move in the scene.
  110623. */
  110624. upperHeightOffsetLimit: Nullable<number>;
  110625. /**
  110626. * Define how fast the camera can accelerate to follow it s target.
  110627. */
  110628. cameraAcceleration: number;
  110629. /**
  110630. * Define the speed limit of the camera following an object.
  110631. */
  110632. maxCameraSpeed: number;
  110633. /**
  110634. * Define the target of the camera.
  110635. */
  110636. lockedTarget: Nullable<AbstractMesh>;
  110637. /**
  110638. * Defines the input associated with the camera.
  110639. */
  110640. inputs: FollowCameraInputsManager;
  110641. /**
  110642. * Instantiates the follow camera.
  110643. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110644. * @param name Define the name of the camera in the scene
  110645. * @param position Define the position of the camera
  110646. * @param scene Define the scene the camera belong to
  110647. * @param lockedTarget Define the target of the camera
  110648. */
  110649. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  110650. private _follow;
  110651. /**
  110652. * Attached controls to the current camera.
  110653. * @param element Defines the element the controls should be listened from
  110654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110655. */
  110656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110657. /**
  110658. * Detach the current controls from the camera.
  110659. * The camera will stop reacting to inputs.
  110660. * @param element Defines the element to stop listening the inputs from
  110661. */
  110662. detachControl(element: HTMLElement): void;
  110663. /** @hidden */
  110664. _checkInputs(): void;
  110665. private _checkLimits;
  110666. /**
  110667. * Gets the camera class name.
  110668. * @returns the class name
  110669. */
  110670. getClassName(): string;
  110671. }
  110672. /**
  110673. * Arc Rotate version of the follow camera.
  110674. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  110675. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110676. */
  110677. export class ArcFollowCamera extends TargetCamera {
  110678. /** The longitudinal angle of the camera */
  110679. alpha: number;
  110680. /** The latitudinal angle of the camera */
  110681. beta: number;
  110682. /** The radius of the camera from its target */
  110683. radius: number;
  110684. /** Define the camera target (the messh it should follow) */
  110685. target: Nullable<AbstractMesh>;
  110686. private _cartesianCoordinates;
  110687. /**
  110688. * Instantiates a new ArcFollowCamera
  110689. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110690. * @param name Define the name of the camera
  110691. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  110692. * @param beta Define the rotation angle of the camera around the elevation axis
  110693. * @param radius Define the radius of the camera from its target point
  110694. * @param target Define the target of the camera
  110695. * @param scene Define the scene the camera belongs to
  110696. */
  110697. constructor(name: string,
  110698. /** The longitudinal angle of the camera */
  110699. alpha: number,
  110700. /** The latitudinal angle of the camera */
  110701. beta: number,
  110702. /** The radius of the camera from its target */
  110703. radius: number,
  110704. /** Define the camera target (the messh it should follow) */
  110705. target: Nullable<AbstractMesh>, scene: Scene);
  110706. private _follow;
  110707. /** @hidden */
  110708. _checkInputs(): void;
  110709. /**
  110710. * Returns the class name of the object.
  110711. * It is mostly used internally for serialization purposes.
  110712. */
  110713. getClassName(): string;
  110714. }
  110715. }
  110716. declare module BABYLON {
  110717. /**
  110718. * Manage the keyboard inputs to control the movement of a follow camera.
  110719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110720. */
  110721. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  110722. /**
  110723. * Defines the camera the input is attached to.
  110724. */
  110725. camera: FollowCamera;
  110726. /**
  110727. * Defines the list of key codes associated with the up action (increase heightOffset)
  110728. */
  110729. keysHeightOffsetIncr: number[];
  110730. /**
  110731. * Defines the list of key codes associated with the down action (decrease heightOffset)
  110732. */
  110733. keysHeightOffsetDecr: number[];
  110734. /**
  110735. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  110736. */
  110737. keysHeightOffsetModifierAlt: boolean;
  110738. /**
  110739. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  110740. */
  110741. keysHeightOffsetModifierCtrl: boolean;
  110742. /**
  110743. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  110744. */
  110745. keysHeightOffsetModifierShift: boolean;
  110746. /**
  110747. * Defines the list of key codes associated with the left action (increase rotationOffset)
  110748. */
  110749. keysRotationOffsetIncr: number[];
  110750. /**
  110751. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  110752. */
  110753. keysRotationOffsetDecr: number[];
  110754. /**
  110755. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  110756. */
  110757. keysRotationOffsetModifierAlt: boolean;
  110758. /**
  110759. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  110760. */
  110761. keysRotationOffsetModifierCtrl: boolean;
  110762. /**
  110763. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  110764. */
  110765. keysRotationOffsetModifierShift: boolean;
  110766. /**
  110767. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  110768. */
  110769. keysRadiusIncr: number[];
  110770. /**
  110771. * Defines the list of key codes associated with the zoom-out action (increase radius)
  110772. */
  110773. keysRadiusDecr: number[];
  110774. /**
  110775. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  110776. */
  110777. keysRadiusModifierAlt: boolean;
  110778. /**
  110779. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  110780. */
  110781. keysRadiusModifierCtrl: boolean;
  110782. /**
  110783. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  110784. */
  110785. keysRadiusModifierShift: boolean;
  110786. /**
  110787. * Defines the rate of change of heightOffset.
  110788. */
  110789. heightSensibility: number;
  110790. /**
  110791. * Defines the rate of change of rotationOffset.
  110792. */
  110793. rotationSensibility: number;
  110794. /**
  110795. * Defines the rate of change of radius.
  110796. */
  110797. radiusSensibility: number;
  110798. private _keys;
  110799. private _ctrlPressed;
  110800. private _altPressed;
  110801. private _shiftPressed;
  110802. private _onCanvasBlurObserver;
  110803. private _onKeyboardObserver;
  110804. private _engine;
  110805. private _scene;
  110806. /**
  110807. * Attach the input controls to a specific dom element to get the input from.
  110808. * @param element Defines the element the controls should be listened from
  110809. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110810. */
  110811. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110812. /**
  110813. * Detach the current controls from the specified dom element.
  110814. * @param element Defines the element to stop listening the inputs from
  110815. */
  110816. detachControl(element: Nullable<HTMLElement>): void;
  110817. /**
  110818. * Update the current camera state depending on the inputs that have been used this frame.
  110819. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110820. */
  110821. checkInputs(): void;
  110822. /**
  110823. * Gets the class name of the current input.
  110824. * @returns the class name
  110825. */
  110826. getClassName(): string;
  110827. /**
  110828. * Get the friendly name associated with the input class.
  110829. * @returns the input friendly name
  110830. */
  110831. getSimpleName(): string;
  110832. /**
  110833. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110834. * allow modification of the heightOffset value.
  110835. */
  110836. private _modifierHeightOffset;
  110837. /**
  110838. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110839. * allow modification of the rotationOffset value.
  110840. */
  110841. private _modifierRotationOffset;
  110842. /**
  110843. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110844. * allow modification of the radius value.
  110845. */
  110846. private _modifierRadius;
  110847. }
  110848. }
  110849. declare module BABYLON {
  110850. interface FreeCameraInputsManager {
  110851. /**
  110852. * @hidden
  110853. */
  110854. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  110855. /**
  110856. * Add orientation input support to the input manager.
  110857. * @returns the current input manager
  110858. */
  110859. addDeviceOrientation(): FreeCameraInputsManager;
  110860. }
  110861. /**
  110862. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  110863. * Screen rotation is taken into account.
  110864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110865. */
  110866. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  110867. private _camera;
  110868. private _screenOrientationAngle;
  110869. private _constantTranform;
  110870. private _screenQuaternion;
  110871. private _alpha;
  110872. private _beta;
  110873. private _gamma;
  110874. /**
  110875. * Can be used to detect if a device orientation sensor is available on a device
  110876. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  110877. * @returns a promise that will resolve on orientation change
  110878. */
  110879. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  110880. /**
  110881. * @hidden
  110882. */
  110883. _onDeviceOrientationChangedObservable: Observable<void>;
  110884. /**
  110885. * Instantiates a new input
  110886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110887. */
  110888. constructor();
  110889. /**
  110890. * Define the camera controlled by the input.
  110891. */
  110892. get camera(): FreeCamera;
  110893. set camera(camera: FreeCamera);
  110894. /**
  110895. * Attach the input controls to a specific dom element to get the input from.
  110896. * @param element Defines the element the controls should be listened from
  110897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110898. */
  110899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110900. private _orientationChanged;
  110901. private _deviceOrientation;
  110902. /**
  110903. * Detach the current controls from the specified dom element.
  110904. * @param element Defines the element to stop listening the inputs from
  110905. */
  110906. detachControl(element: Nullable<HTMLElement>): void;
  110907. /**
  110908. * Update the current camera state depending on the inputs that have been used this frame.
  110909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110910. */
  110911. checkInputs(): void;
  110912. /**
  110913. * Gets the class name of the current intput.
  110914. * @returns the class name
  110915. */
  110916. getClassName(): string;
  110917. /**
  110918. * Get the friendly name associated with the input class.
  110919. * @returns the input friendly name
  110920. */
  110921. getSimpleName(): string;
  110922. }
  110923. }
  110924. declare module BABYLON {
  110925. /**
  110926. * Manage the gamepad inputs to control a free camera.
  110927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110928. */
  110929. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  110930. /**
  110931. * Define the camera the input is attached to.
  110932. */
  110933. camera: FreeCamera;
  110934. /**
  110935. * Define the Gamepad controlling the input
  110936. */
  110937. gamepad: Nullable<Gamepad>;
  110938. /**
  110939. * Defines the gamepad rotation sensiblity.
  110940. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110941. */
  110942. gamepadAngularSensibility: number;
  110943. /**
  110944. * Defines the gamepad move sensiblity.
  110945. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110946. */
  110947. gamepadMoveSensibility: number;
  110948. private _yAxisScale;
  110949. /**
  110950. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  110951. */
  110952. get invertYAxis(): boolean;
  110953. set invertYAxis(value: boolean);
  110954. private _onGamepadConnectedObserver;
  110955. private _onGamepadDisconnectedObserver;
  110956. private _cameraTransform;
  110957. private _deltaTransform;
  110958. private _vector3;
  110959. private _vector2;
  110960. /**
  110961. * Attach the input controls to a specific dom element to get the input from.
  110962. * @param element Defines the element the controls should be listened from
  110963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110964. */
  110965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110966. /**
  110967. * Detach the current controls from the specified dom element.
  110968. * @param element Defines the element to stop listening the inputs from
  110969. */
  110970. detachControl(element: Nullable<HTMLElement>): void;
  110971. /**
  110972. * Update the current camera state depending on the inputs that have been used this frame.
  110973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110974. */
  110975. checkInputs(): void;
  110976. /**
  110977. * Gets the class name of the current intput.
  110978. * @returns the class name
  110979. */
  110980. getClassName(): string;
  110981. /**
  110982. * Get the friendly name associated with the input class.
  110983. * @returns the input friendly name
  110984. */
  110985. getSimpleName(): string;
  110986. }
  110987. }
  110988. declare module BABYLON {
  110989. /**
  110990. * Defines the potential axis of a Joystick
  110991. */
  110992. export enum JoystickAxis {
  110993. /** X axis */
  110994. X = 0,
  110995. /** Y axis */
  110996. Y = 1,
  110997. /** Z axis */
  110998. Z = 2
  110999. }
  111000. /**
  111001. * Class used to define virtual joystick (used in touch mode)
  111002. */
  111003. export class VirtualJoystick {
  111004. /**
  111005. * Gets or sets a boolean indicating that left and right values must be inverted
  111006. */
  111007. reverseLeftRight: boolean;
  111008. /**
  111009. * Gets or sets a boolean indicating that up and down values must be inverted
  111010. */
  111011. reverseUpDown: boolean;
  111012. /**
  111013. * Gets the offset value for the position (ie. the change of the position value)
  111014. */
  111015. deltaPosition: Vector3;
  111016. /**
  111017. * Gets a boolean indicating if the virtual joystick was pressed
  111018. */
  111019. pressed: boolean;
  111020. /**
  111021. * Canvas the virtual joystick will render onto, default z-index of this is 5
  111022. */
  111023. static Canvas: Nullable<HTMLCanvasElement>;
  111024. private static _globalJoystickIndex;
  111025. private static vjCanvasContext;
  111026. private static vjCanvasWidth;
  111027. private static vjCanvasHeight;
  111028. private static halfWidth;
  111029. private _action;
  111030. private _axisTargetedByLeftAndRight;
  111031. private _axisTargetedByUpAndDown;
  111032. private _joystickSensibility;
  111033. private _inversedSensibility;
  111034. private _joystickPointerID;
  111035. private _joystickColor;
  111036. private _joystickPointerPos;
  111037. private _joystickPreviousPointerPos;
  111038. private _joystickPointerStartPos;
  111039. private _deltaJoystickVector;
  111040. private _leftJoystick;
  111041. private _touches;
  111042. private _onPointerDownHandlerRef;
  111043. private _onPointerMoveHandlerRef;
  111044. private _onPointerUpHandlerRef;
  111045. private _onResize;
  111046. /**
  111047. * Creates a new virtual joystick
  111048. * @param leftJoystick defines that the joystick is for left hand (false by default)
  111049. */
  111050. constructor(leftJoystick?: boolean);
  111051. /**
  111052. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  111053. * @param newJoystickSensibility defines the new sensibility
  111054. */
  111055. setJoystickSensibility(newJoystickSensibility: number): void;
  111056. private _onPointerDown;
  111057. private _onPointerMove;
  111058. private _onPointerUp;
  111059. /**
  111060. * Change the color of the virtual joystick
  111061. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  111062. */
  111063. setJoystickColor(newColor: string): void;
  111064. /**
  111065. * Defines a callback to call when the joystick is touched
  111066. * @param action defines the callback
  111067. */
  111068. setActionOnTouch(action: () => any): void;
  111069. /**
  111070. * Defines which axis you'd like to control for left & right
  111071. * @param axis defines the axis to use
  111072. */
  111073. setAxisForLeftRight(axis: JoystickAxis): void;
  111074. /**
  111075. * Defines which axis you'd like to control for up & down
  111076. * @param axis defines the axis to use
  111077. */
  111078. setAxisForUpDown(axis: JoystickAxis): void;
  111079. private _drawVirtualJoystick;
  111080. /**
  111081. * Release internal HTML canvas
  111082. */
  111083. releaseCanvas(): void;
  111084. }
  111085. }
  111086. declare module BABYLON {
  111087. interface FreeCameraInputsManager {
  111088. /**
  111089. * Add virtual joystick input support to the input manager.
  111090. * @returns the current input manager
  111091. */
  111092. addVirtualJoystick(): FreeCameraInputsManager;
  111093. }
  111094. /**
  111095. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  111096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111097. */
  111098. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  111099. /**
  111100. * Defines the camera the input is attached to.
  111101. */
  111102. camera: FreeCamera;
  111103. private _leftjoystick;
  111104. private _rightjoystick;
  111105. /**
  111106. * Gets the left stick of the virtual joystick.
  111107. * @returns The virtual Joystick
  111108. */
  111109. getLeftJoystick(): VirtualJoystick;
  111110. /**
  111111. * Gets the right stick of the virtual joystick.
  111112. * @returns The virtual Joystick
  111113. */
  111114. getRightJoystick(): VirtualJoystick;
  111115. /**
  111116. * Update the current camera state depending on the inputs that have been used this frame.
  111117. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111118. */
  111119. checkInputs(): void;
  111120. /**
  111121. * Attach the input controls to a specific dom element to get the input from.
  111122. * @param element Defines the element the controls should be listened from
  111123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111124. */
  111125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111126. /**
  111127. * Detach the current controls from the specified dom element.
  111128. * @param element Defines the element to stop listening the inputs from
  111129. */
  111130. detachControl(element: Nullable<HTMLElement>): void;
  111131. /**
  111132. * Gets the class name of the current intput.
  111133. * @returns the class name
  111134. */
  111135. getClassName(): string;
  111136. /**
  111137. * Get the friendly name associated with the input class.
  111138. * @returns the input friendly name
  111139. */
  111140. getSimpleName(): string;
  111141. }
  111142. }
  111143. declare module BABYLON {
  111144. /**
  111145. * This represents a FPS type of camera controlled by touch.
  111146. * This is like a universal camera minus the Gamepad controls.
  111147. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111148. */
  111149. export class TouchCamera extends FreeCamera {
  111150. /**
  111151. * Defines the touch sensibility for rotation.
  111152. * The higher the faster.
  111153. */
  111154. get touchAngularSensibility(): number;
  111155. set touchAngularSensibility(value: number);
  111156. /**
  111157. * Defines the touch sensibility for move.
  111158. * The higher the faster.
  111159. */
  111160. get touchMoveSensibility(): number;
  111161. set touchMoveSensibility(value: number);
  111162. /**
  111163. * Instantiates a new touch camera.
  111164. * This represents a FPS type of camera controlled by touch.
  111165. * This is like a universal camera minus the Gamepad controls.
  111166. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111167. * @param name Define the name of the camera in the scene
  111168. * @param position Define the start position of the camera in the scene
  111169. * @param scene Define the scene the camera belongs to
  111170. */
  111171. constructor(name: string, position: Vector3, scene: Scene);
  111172. /**
  111173. * Gets the current object class name.
  111174. * @return the class name
  111175. */
  111176. getClassName(): string;
  111177. /** @hidden */
  111178. _setupInputs(): void;
  111179. }
  111180. }
  111181. declare module BABYLON {
  111182. /**
  111183. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  111184. * being tilted forward or back and left or right.
  111185. */
  111186. export class DeviceOrientationCamera extends FreeCamera {
  111187. private _initialQuaternion;
  111188. private _quaternionCache;
  111189. private _tmpDragQuaternion;
  111190. private _disablePointerInputWhenUsingDeviceOrientation;
  111191. /**
  111192. * Creates a new device orientation camera
  111193. * @param name The name of the camera
  111194. * @param position The start position camera
  111195. * @param scene The scene the camera belongs to
  111196. */
  111197. constructor(name: string, position: Vector3, scene: Scene);
  111198. /**
  111199. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  111200. */
  111201. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  111202. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  111203. private _dragFactor;
  111204. /**
  111205. * Enabled turning on the y axis when the orientation sensor is active
  111206. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  111207. */
  111208. enableHorizontalDragging(dragFactor?: number): void;
  111209. /**
  111210. * Gets the current instance class name ("DeviceOrientationCamera").
  111211. * This helps avoiding instanceof at run time.
  111212. * @returns the class name
  111213. */
  111214. getClassName(): string;
  111215. /**
  111216. * @hidden
  111217. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  111218. */
  111219. _checkInputs(): void;
  111220. /**
  111221. * Reset the camera to its default orientation on the specified axis only.
  111222. * @param axis The axis to reset
  111223. */
  111224. resetToCurrentRotation(axis?: Axis): void;
  111225. }
  111226. }
  111227. declare module BABYLON {
  111228. /**
  111229. * Defines supported buttons for XBox360 compatible gamepads
  111230. */
  111231. export enum Xbox360Button {
  111232. /** A */
  111233. A = 0,
  111234. /** B */
  111235. B = 1,
  111236. /** X */
  111237. X = 2,
  111238. /** Y */
  111239. Y = 3,
  111240. /** Start */
  111241. Start = 4,
  111242. /** Back */
  111243. Back = 5,
  111244. /** Left button */
  111245. LB = 6,
  111246. /** Right button */
  111247. RB = 7,
  111248. /** Left stick */
  111249. LeftStick = 8,
  111250. /** Right stick */
  111251. RightStick = 9
  111252. }
  111253. /** Defines values for XBox360 DPad */
  111254. export enum Xbox360Dpad {
  111255. /** Up */
  111256. Up = 0,
  111257. /** Down */
  111258. Down = 1,
  111259. /** Left */
  111260. Left = 2,
  111261. /** Right */
  111262. Right = 3
  111263. }
  111264. /**
  111265. * Defines a XBox360 gamepad
  111266. */
  111267. export class Xbox360Pad extends Gamepad {
  111268. private _leftTrigger;
  111269. private _rightTrigger;
  111270. private _onlefttriggerchanged;
  111271. private _onrighttriggerchanged;
  111272. private _onbuttondown;
  111273. private _onbuttonup;
  111274. private _ondpaddown;
  111275. private _ondpadup;
  111276. /** Observable raised when a button is pressed */
  111277. onButtonDownObservable: Observable<Xbox360Button>;
  111278. /** Observable raised when a button is released */
  111279. onButtonUpObservable: Observable<Xbox360Button>;
  111280. /** Observable raised when a pad is pressed */
  111281. onPadDownObservable: Observable<Xbox360Dpad>;
  111282. /** Observable raised when a pad is released */
  111283. onPadUpObservable: Observable<Xbox360Dpad>;
  111284. private _buttonA;
  111285. private _buttonB;
  111286. private _buttonX;
  111287. private _buttonY;
  111288. private _buttonBack;
  111289. private _buttonStart;
  111290. private _buttonLB;
  111291. private _buttonRB;
  111292. private _buttonLeftStick;
  111293. private _buttonRightStick;
  111294. private _dPadUp;
  111295. private _dPadDown;
  111296. private _dPadLeft;
  111297. private _dPadRight;
  111298. private _isXboxOnePad;
  111299. /**
  111300. * Creates a new XBox360 gamepad object
  111301. * @param id defines the id of this gamepad
  111302. * @param index defines its index
  111303. * @param gamepad defines the internal HTML gamepad object
  111304. * @param xboxOne defines if it is a XBox One gamepad
  111305. */
  111306. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  111307. /**
  111308. * Defines the callback to call when left trigger is pressed
  111309. * @param callback defines the callback to use
  111310. */
  111311. onlefttriggerchanged(callback: (value: number) => void): void;
  111312. /**
  111313. * Defines the callback to call when right trigger is pressed
  111314. * @param callback defines the callback to use
  111315. */
  111316. onrighttriggerchanged(callback: (value: number) => void): void;
  111317. /**
  111318. * Gets the left trigger value
  111319. */
  111320. get leftTrigger(): number;
  111321. /**
  111322. * Sets the left trigger value
  111323. */
  111324. set leftTrigger(newValue: number);
  111325. /**
  111326. * Gets the right trigger value
  111327. */
  111328. get rightTrigger(): number;
  111329. /**
  111330. * Sets the right trigger value
  111331. */
  111332. set rightTrigger(newValue: number);
  111333. /**
  111334. * Defines the callback to call when a button is pressed
  111335. * @param callback defines the callback to use
  111336. */
  111337. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  111338. /**
  111339. * Defines the callback to call when a button is released
  111340. * @param callback defines the callback to use
  111341. */
  111342. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  111343. /**
  111344. * Defines the callback to call when a pad is pressed
  111345. * @param callback defines the callback to use
  111346. */
  111347. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  111348. /**
  111349. * Defines the callback to call when a pad is released
  111350. * @param callback defines the callback to use
  111351. */
  111352. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  111353. private _setButtonValue;
  111354. private _setDPadValue;
  111355. /**
  111356. * Gets the value of the `A` button
  111357. */
  111358. get buttonA(): number;
  111359. /**
  111360. * Sets the value of the `A` button
  111361. */
  111362. set buttonA(value: number);
  111363. /**
  111364. * Gets the value of the `B` button
  111365. */
  111366. get buttonB(): number;
  111367. /**
  111368. * Sets the value of the `B` button
  111369. */
  111370. set buttonB(value: number);
  111371. /**
  111372. * Gets the value of the `X` button
  111373. */
  111374. get buttonX(): number;
  111375. /**
  111376. * Sets the value of the `X` button
  111377. */
  111378. set buttonX(value: number);
  111379. /**
  111380. * Gets the value of the `Y` button
  111381. */
  111382. get buttonY(): number;
  111383. /**
  111384. * Sets the value of the `Y` button
  111385. */
  111386. set buttonY(value: number);
  111387. /**
  111388. * Gets the value of the `Start` button
  111389. */
  111390. get buttonStart(): number;
  111391. /**
  111392. * Sets the value of the `Start` button
  111393. */
  111394. set buttonStart(value: number);
  111395. /**
  111396. * Gets the value of the `Back` button
  111397. */
  111398. get buttonBack(): number;
  111399. /**
  111400. * Sets the value of the `Back` button
  111401. */
  111402. set buttonBack(value: number);
  111403. /**
  111404. * Gets the value of the `Left` button
  111405. */
  111406. get buttonLB(): number;
  111407. /**
  111408. * Sets the value of the `Left` button
  111409. */
  111410. set buttonLB(value: number);
  111411. /**
  111412. * Gets the value of the `Right` button
  111413. */
  111414. get buttonRB(): number;
  111415. /**
  111416. * Sets the value of the `Right` button
  111417. */
  111418. set buttonRB(value: number);
  111419. /**
  111420. * Gets the value of the Left joystick
  111421. */
  111422. get buttonLeftStick(): number;
  111423. /**
  111424. * Sets the value of the Left joystick
  111425. */
  111426. set buttonLeftStick(value: number);
  111427. /**
  111428. * Gets the value of the Right joystick
  111429. */
  111430. get buttonRightStick(): number;
  111431. /**
  111432. * Sets the value of the Right joystick
  111433. */
  111434. set buttonRightStick(value: number);
  111435. /**
  111436. * Gets the value of D-pad up
  111437. */
  111438. get dPadUp(): number;
  111439. /**
  111440. * Sets the value of D-pad up
  111441. */
  111442. set dPadUp(value: number);
  111443. /**
  111444. * Gets the value of D-pad down
  111445. */
  111446. get dPadDown(): number;
  111447. /**
  111448. * Sets the value of D-pad down
  111449. */
  111450. set dPadDown(value: number);
  111451. /**
  111452. * Gets the value of D-pad left
  111453. */
  111454. get dPadLeft(): number;
  111455. /**
  111456. * Sets the value of D-pad left
  111457. */
  111458. set dPadLeft(value: number);
  111459. /**
  111460. * Gets the value of D-pad right
  111461. */
  111462. get dPadRight(): number;
  111463. /**
  111464. * Sets the value of D-pad right
  111465. */
  111466. set dPadRight(value: number);
  111467. /**
  111468. * Force the gamepad to synchronize with device values
  111469. */
  111470. update(): void;
  111471. /**
  111472. * Disposes the gamepad
  111473. */
  111474. dispose(): void;
  111475. }
  111476. }
  111477. declare module BABYLON {
  111478. /**
  111479. * Defines supported buttons for DualShock compatible gamepads
  111480. */
  111481. export enum DualShockButton {
  111482. /** Cross */
  111483. Cross = 0,
  111484. /** Circle */
  111485. Circle = 1,
  111486. /** Square */
  111487. Square = 2,
  111488. /** Triangle */
  111489. Triangle = 3,
  111490. /** Options */
  111491. Options = 4,
  111492. /** Share */
  111493. Share = 5,
  111494. /** L1 */
  111495. L1 = 6,
  111496. /** R1 */
  111497. R1 = 7,
  111498. /** Left stick */
  111499. LeftStick = 8,
  111500. /** Right stick */
  111501. RightStick = 9
  111502. }
  111503. /** Defines values for DualShock DPad */
  111504. export enum DualShockDpad {
  111505. /** Up */
  111506. Up = 0,
  111507. /** Down */
  111508. Down = 1,
  111509. /** Left */
  111510. Left = 2,
  111511. /** Right */
  111512. Right = 3
  111513. }
  111514. /**
  111515. * Defines a DualShock gamepad
  111516. */
  111517. export class DualShockPad extends Gamepad {
  111518. private _leftTrigger;
  111519. private _rightTrigger;
  111520. private _onlefttriggerchanged;
  111521. private _onrighttriggerchanged;
  111522. private _onbuttondown;
  111523. private _onbuttonup;
  111524. private _ondpaddown;
  111525. private _ondpadup;
  111526. /** Observable raised when a button is pressed */
  111527. onButtonDownObservable: Observable<DualShockButton>;
  111528. /** Observable raised when a button is released */
  111529. onButtonUpObservable: Observable<DualShockButton>;
  111530. /** Observable raised when a pad is pressed */
  111531. onPadDownObservable: Observable<DualShockDpad>;
  111532. /** Observable raised when a pad is released */
  111533. onPadUpObservable: Observable<DualShockDpad>;
  111534. private _buttonCross;
  111535. private _buttonCircle;
  111536. private _buttonSquare;
  111537. private _buttonTriangle;
  111538. private _buttonShare;
  111539. private _buttonOptions;
  111540. private _buttonL1;
  111541. private _buttonR1;
  111542. private _buttonLeftStick;
  111543. private _buttonRightStick;
  111544. private _dPadUp;
  111545. private _dPadDown;
  111546. private _dPadLeft;
  111547. private _dPadRight;
  111548. /**
  111549. * Creates a new DualShock gamepad object
  111550. * @param id defines the id of this gamepad
  111551. * @param index defines its index
  111552. * @param gamepad defines the internal HTML gamepad object
  111553. */
  111554. constructor(id: string, index: number, gamepad: any);
  111555. /**
  111556. * Defines the callback to call when left trigger is pressed
  111557. * @param callback defines the callback to use
  111558. */
  111559. onlefttriggerchanged(callback: (value: number) => void): void;
  111560. /**
  111561. * Defines the callback to call when right trigger is pressed
  111562. * @param callback defines the callback to use
  111563. */
  111564. onrighttriggerchanged(callback: (value: number) => void): void;
  111565. /**
  111566. * Gets the left trigger value
  111567. */
  111568. get leftTrigger(): number;
  111569. /**
  111570. * Sets the left trigger value
  111571. */
  111572. set leftTrigger(newValue: number);
  111573. /**
  111574. * Gets the right trigger value
  111575. */
  111576. get rightTrigger(): number;
  111577. /**
  111578. * Sets the right trigger value
  111579. */
  111580. set rightTrigger(newValue: number);
  111581. /**
  111582. * Defines the callback to call when a button is pressed
  111583. * @param callback defines the callback to use
  111584. */
  111585. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  111586. /**
  111587. * Defines the callback to call when a button is released
  111588. * @param callback defines the callback to use
  111589. */
  111590. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  111591. /**
  111592. * Defines the callback to call when a pad is pressed
  111593. * @param callback defines the callback to use
  111594. */
  111595. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  111596. /**
  111597. * Defines the callback to call when a pad is released
  111598. * @param callback defines the callback to use
  111599. */
  111600. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  111601. private _setButtonValue;
  111602. private _setDPadValue;
  111603. /**
  111604. * Gets the value of the `Cross` button
  111605. */
  111606. get buttonCross(): number;
  111607. /**
  111608. * Sets the value of the `Cross` button
  111609. */
  111610. set buttonCross(value: number);
  111611. /**
  111612. * Gets the value of the `Circle` button
  111613. */
  111614. get buttonCircle(): number;
  111615. /**
  111616. * Sets the value of the `Circle` button
  111617. */
  111618. set buttonCircle(value: number);
  111619. /**
  111620. * Gets the value of the `Square` button
  111621. */
  111622. get buttonSquare(): number;
  111623. /**
  111624. * Sets the value of the `Square` button
  111625. */
  111626. set buttonSquare(value: number);
  111627. /**
  111628. * Gets the value of the `Triangle` button
  111629. */
  111630. get buttonTriangle(): number;
  111631. /**
  111632. * Sets the value of the `Triangle` button
  111633. */
  111634. set buttonTriangle(value: number);
  111635. /**
  111636. * Gets the value of the `Options` button
  111637. */
  111638. get buttonOptions(): number;
  111639. /**
  111640. * Sets the value of the `Options` button
  111641. */
  111642. set buttonOptions(value: number);
  111643. /**
  111644. * Gets the value of the `Share` button
  111645. */
  111646. get buttonShare(): number;
  111647. /**
  111648. * Sets the value of the `Share` button
  111649. */
  111650. set buttonShare(value: number);
  111651. /**
  111652. * Gets the value of the `L1` button
  111653. */
  111654. get buttonL1(): number;
  111655. /**
  111656. * Sets the value of the `L1` button
  111657. */
  111658. set buttonL1(value: number);
  111659. /**
  111660. * Gets the value of the `R1` button
  111661. */
  111662. get buttonR1(): number;
  111663. /**
  111664. * Sets the value of the `R1` button
  111665. */
  111666. set buttonR1(value: number);
  111667. /**
  111668. * Gets the value of the Left joystick
  111669. */
  111670. get buttonLeftStick(): number;
  111671. /**
  111672. * Sets the value of the Left joystick
  111673. */
  111674. set buttonLeftStick(value: number);
  111675. /**
  111676. * Gets the value of the Right joystick
  111677. */
  111678. get buttonRightStick(): number;
  111679. /**
  111680. * Sets the value of the Right joystick
  111681. */
  111682. set buttonRightStick(value: number);
  111683. /**
  111684. * Gets the value of D-pad up
  111685. */
  111686. get dPadUp(): number;
  111687. /**
  111688. * Sets the value of D-pad up
  111689. */
  111690. set dPadUp(value: number);
  111691. /**
  111692. * Gets the value of D-pad down
  111693. */
  111694. get dPadDown(): number;
  111695. /**
  111696. * Sets the value of D-pad down
  111697. */
  111698. set dPadDown(value: number);
  111699. /**
  111700. * Gets the value of D-pad left
  111701. */
  111702. get dPadLeft(): number;
  111703. /**
  111704. * Sets the value of D-pad left
  111705. */
  111706. set dPadLeft(value: number);
  111707. /**
  111708. * Gets the value of D-pad right
  111709. */
  111710. get dPadRight(): number;
  111711. /**
  111712. * Sets the value of D-pad right
  111713. */
  111714. set dPadRight(value: number);
  111715. /**
  111716. * Force the gamepad to synchronize with device values
  111717. */
  111718. update(): void;
  111719. /**
  111720. * Disposes the gamepad
  111721. */
  111722. dispose(): void;
  111723. }
  111724. }
  111725. declare module BABYLON {
  111726. /**
  111727. * Manager for handling gamepads
  111728. */
  111729. export class GamepadManager {
  111730. private _scene?;
  111731. private _babylonGamepads;
  111732. private _oneGamepadConnected;
  111733. /** @hidden */
  111734. _isMonitoring: boolean;
  111735. private _gamepadEventSupported;
  111736. private _gamepadSupport?;
  111737. /**
  111738. * observable to be triggered when the gamepad controller has been connected
  111739. */
  111740. onGamepadConnectedObservable: Observable<Gamepad>;
  111741. /**
  111742. * observable to be triggered when the gamepad controller has been disconnected
  111743. */
  111744. onGamepadDisconnectedObservable: Observable<Gamepad>;
  111745. private _onGamepadConnectedEvent;
  111746. private _onGamepadDisconnectedEvent;
  111747. /**
  111748. * Initializes the gamepad manager
  111749. * @param _scene BabylonJS scene
  111750. */
  111751. constructor(_scene?: Scene | undefined);
  111752. /**
  111753. * The gamepads in the game pad manager
  111754. */
  111755. get gamepads(): Gamepad[];
  111756. /**
  111757. * Get the gamepad controllers based on type
  111758. * @param type The type of gamepad controller
  111759. * @returns Nullable gamepad
  111760. */
  111761. getGamepadByType(type?: number): Nullable<Gamepad>;
  111762. /**
  111763. * Disposes the gamepad manager
  111764. */
  111765. dispose(): void;
  111766. private _addNewGamepad;
  111767. private _startMonitoringGamepads;
  111768. private _stopMonitoringGamepads;
  111769. /** @hidden */
  111770. _checkGamepadsStatus(): void;
  111771. private _updateGamepadObjects;
  111772. }
  111773. }
  111774. declare module BABYLON {
  111775. interface Scene {
  111776. /** @hidden */
  111777. _gamepadManager: Nullable<GamepadManager>;
  111778. /**
  111779. * Gets the gamepad manager associated with the scene
  111780. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  111781. */
  111782. gamepadManager: GamepadManager;
  111783. }
  111784. /**
  111785. * Interface representing a free camera inputs manager
  111786. */
  111787. interface FreeCameraInputsManager {
  111788. /**
  111789. * Adds gamepad input support to the FreeCameraInputsManager.
  111790. * @returns the FreeCameraInputsManager
  111791. */
  111792. addGamepad(): FreeCameraInputsManager;
  111793. }
  111794. /**
  111795. * Interface representing an arc rotate camera inputs manager
  111796. */
  111797. interface ArcRotateCameraInputsManager {
  111798. /**
  111799. * Adds gamepad input support to the ArcRotateCamera InputManager.
  111800. * @returns the camera inputs manager
  111801. */
  111802. addGamepad(): ArcRotateCameraInputsManager;
  111803. }
  111804. /**
  111805. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  111806. */
  111807. export class GamepadSystemSceneComponent implements ISceneComponent {
  111808. /**
  111809. * The component name helpfull to identify the component in the list of scene components.
  111810. */
  111811. readonly name: string;
  111812. /**
  111813. * The scene the component belongs to.
  111814. */
  111815. scene: Scene;
  111816. /**
  111817. * Creates a new instance of the component for the given scene
  111818. * @param scene Defines the scene to register the component in
  111819. */
  111820. constructor(scene: Scene);
  111821. /**
  111822. * Registers the component in a given scene
  111823. */
  111824. register(): void;
  111825. /**
  111826. * Rebuilds the elements related to this component in case of
  111827. * context lost for instance.
  111828. */
  111829. rebuild(): void;
  111830. /**
  111831. * Disposes the component and the associated ressources
  111832. */
  111833. dispose(): void;
  111834. private _beforeCameraUpdate;
  111835. }
  111836. }
  111837. declare module BABYLON {
  111838. /**
  111839. * 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,
  111840. * which still works and will still be found in many Playgrounds.
  111841. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111842. */
  111843. export class UniversalCamera extends TouchCamera {
  111844. /**
  111845. * Defines the gamepad rotation sensiblity.
  111846. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111847. */
  111848. get gamepadAngularSensibility(): number;
  111849. set gamepadAngularSensibility(value: number);
  111850. /**
  111851. * Defines the gamepad move sensiblity.
  111852. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111853. */
  111854. get gamepadMoveSensibility(): number;
  111855. set gamepadMoveSensibility(value: number);
  111856. /**
  111857. * 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,
  111858. * which still works and will still be found in many Playgrounds.
  111859. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111860. * @param name Define the name of the camera in the scene
  111861. * @param position Define the start position of the camera in the scene
  111862. * @param scene Define the scene the camera belongs to
  111863. */
  111864. constructor(name: string, position: Vector3, scene: Scene);
  111865. /**
  111866. * Gets the current object class name.
  111867. * @return the class name
  111868. */
  111869. getClassName(): string;
  111870. }
  111871. }
  111872. declare module BABYLON {
  111873. /**
  111874. * This represents a FPS type of camera. This is only here for back compat purpose.
  111875. * Please use the UniversalCamera instead as both are identical.
  111876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111877. */
  111878. export class GamepadCamera extends UniversalCamera {
  111879. /**
  111880. * Instantiates a new Gamepad Camera
  111881. * This represents a FPS type of camera. This is only here for back compat purpose.
  111882. * Please use the UniversalCamera instead as both are identical.
  111883. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111884. * @param name Define the name of the camera in the scene
  111885. * @param position Define the start position of the camera in the scene
  111886. * @param scene Define the scene the camera belongs to
  111887. */
  111888. constructor(name: string, position: Vector3, scene: Scene);
  111889. /**
  111890. * Gets the current object class name.
  111891. * @return the class name
  111892. */
  111893. getClassName(): string;
  111894. }
  111895. }
  111896. declare module BABYLON {
  111897. /** @hidden */
  111898. export var passPixelShader: {
  111899. name: string;
  111900. shader: string;
  111901. };
  111902. }
  111903. declare module BABYLON {
  111904. /** @hidden */
  111905. export var passCubePixelShader: {
  111906. name: string;
  111907. shader: string;
  111908. };
  111909. }
  111910. declare module BABYLON {
  111911. /**
  111912. * PassPostProcess which produces an output the same as it's input
  111913. */
  111914. export class PassPostProcess extends PostProcess {
  111915. /**
  111916. * Creates the PassPostProcess
  111917. * @param name The name of the effect.
  111918. * @param options The required width/height ratio to downsize to before computing the render pass.
  111919. * @param camera The camera to apply the render pass to.
  111920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111921. * @param engine The engine which the post process will be applied. (default: current engine)
  111922. * @param reusable If the post process can be reused on the same frame. (default: false)
  111923. * @param textureType The type of texture to be used when performing the post processing.
  111924. * @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)
  111925. */
  111926. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111927. }
  111928. /**
  111929. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  111930. */
  111931. export class PassCubePostProcess extends PostProcess {
  111932. private _face;
  111933. /**
  111934. * Gets or sets the cube face to display.
  111935. * * 0 is +X
  111936. * * 1 is -X
  111937. * * 2 is +Y
  111938. * * 3 is -Y
  111939. * * 4 is +Z
  111940. * * 5 is -Z
  111941. */
  111942. get face(): number;
  111943. set face(value: number);
  111944. /**
  111945. * Creates the PassCubePostProcess
  111946. * @param name The name of the effect.
  111947. * @param options The required width/height ratio to downsize to before computing the render pass.
  111948. * @param camera The camera to apply the render pass to.
  111949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111950. * @param engine The engine which the post process will be applied. (default: current engine)
  111951. * @param reusable If the post process can be reused on the same frame. (default: false)
  111952. * @param textureType The type of texture to be used when performing the post processing.
  111953. * @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)
  111954. */
  111955. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111956. }
  111957. }
  111958. declare module BABYLON {
  111959. /** @hidden */
  111960. export var anaglyphPixelShader: {
  111961. name: string;
  111962. shader: string;
  111963. };
  111964. }
  111965. declare module BABYLON {
  111966. /**
  111967. * Postprocess used to generate anaglyphic rendering
  111968. */
  111969. export class AnaglyphPostProcess extends PostProcess {
  111970. private _passedProcess;
  111971. /**
  111972. * Creates a new AnaglyphPostProcess
  111973. * @param name defines postprocess name
  111974. * @param options defines creation options or target ratio scale
  111975. * @param rigCameras defines cameras using this postprocess
  111976. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  111977. * @param engine defines hosting engine
  111978. * @param reusable defines if the postprocess will be reused multiple times per frame
  111979. */
  111980. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  111981. }
  111982. }
  111983. declare module BABYLON {
  111984. /**
  111985. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  111986. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  111987. */
  111988. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  111989. /**
  111990. * Creates a new AnaglyphArcRotateCamera
  111991. * @param name defines camera name
  111992. * @param alpha defines alpha angle (in radians)
  111993. * @param beta defines beta angle (in radians)
  111994. * @param radius defines radius
  111995. * @param target defines camera target
  111996. * @param interaxialDistance defines distance between each color axis
  111997. * @param scene defines the hosting scene
  111998. */
  111999. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  112000. /**
  112001. * Gets camera class name
  112002. * @returns AnaglyphArcRotateCamera
  112003. */
  112004. getClassName(): string;
  112005. }
  112006. }
  112007. declare module BABYLON {
  112008. /**
  112009. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  112010. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112011. */
  112012. export class AnaglyphFreeCamera extends FreeCamera {
  112013. /**
  112014. * Creates a new AnaglyphFreeCamera
  112015. * @param name defines camera name
  112016. * @param position defines initial position
  112017. * @param interaxialDistance defines distance between each color axis
  112018. * @param scene defines the hosting scene
  112019. */
  112020. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112021. /**
  112022. * Gets camera class name
  112023. * @returns AnaglyphFreeCamera
  112024. */
  112025. getClassName(): string;
  112026. }
  112027. }
  112028. declare module BABYLON {
  112029. /**
  112030. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  112031. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112032. */
  112033. export class AnaglyphGamepadCamera extends GamepadCamera {
  112034. /**
  112035. * Creates a new AnaglyphGamepadCamera
  112036. * @param name defines camera name
  112037. * @param position defines initial position
  112038. * @param interaxialDistance defines distance between each color axis
  112039. * @param scene defines the hosting scene
  112040. */
  112041. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112042. /**
  112043. * Gets camera class name
  112044. * @returns AnaglyphGamepadCamera
  112045. */
  112046. getClassName(): string;
  112047. }
  112048. }
  112049. declare module BABYLON {
  112050. /**
  112051. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  112052. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112053. */
  112054. export class AnaglyphUniversalCamera extends UniversalCamera {
  112055. /**
  112056. * Creates a new AnaglyphUniversalCamera
  112057. * @param name defines camera name
  112058. * @param position defines initial position
  112059. * @param interaxialDistance defines distance between each color axis
  112060. * @param scene defines the hosting scene
  112061. */
  112062. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112063. /**
  112064. * Gets camera class name
  112065. * @returns AnaglyphUniversalCamera
  112066. */
  112067. getClassName(): string;
  112068. }
  112069. }
  112070. declare module BABYLON {
  112071. /** @hidden */
  112072. export var stereoscopicInterlacePixelShader: {
  112073. name: string;
  112074. shader: string;
  112075. };
  112076. }
  112077. declare module BABYLON {
  112078. /**
  112079. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  112080. */
  112081. export class StereoscopicInterlacePostProcess extends PostProcess {
  112082. private _stepSize;
  112083. private _passedProcess;
  112084. /**
  112085. * Initializes a StereoscopicInterlacePostProcess
  112086. * @param name The name of the effect.
  112087. * @param rigCameras The rig cameras to be appled to the post process
  112088. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  112089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112090. * @param engine The engine which the post process will be applied. (default: current engine)
  112091. * @param reusable If the post process can be reused on the same frame. (default: false)
  112092. */
  112093. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112094. }
  112095. }
  112096. declare module BABYLON {
  112097. /**
  112098. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  112099. * @see http://doc.babylonjs.com/features/cameras
  112100. */
  112101. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  112102. /**
  112103. * Creates a new StereoscopicArcRotateCamera
  112104. * @param name defines camera name
  112105. * @param alpha defines alpha angle (in radians)
  112106. * @param beta defines beta angle (in radians)
  112107. * @param radius defines radius
  112108. * @param target defines camera target
  112109. * @param interaxialDistance defines distance between each color axis
  112110. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112111. * @param scene defines the hosting scene
  112112. */
  112113. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112114. /**
  112115. * Gets camera class name
  112116. * @returns StereoscopicArcRotateCamera
  112117. */
  112118. getClassName(): string;
  112119. }
  112120. }
  112121. declare module BABYLON {
  112122. /**
  112123. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  112124. * @see http://doc.babylonjs.com/features/cameras
  112125. */
  112126. export class StereoscopicFreeCamera extends FreeCamera {
  112127. /**
  112128. * Creates a new StereoscopicFreeCamera
  112129. * @param name defines camera name
  112130. * @param position defines initial position
  112131. * @param interaxialDistance defines distance between each color axis
  112132. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112133. * @param scene defines the hosting scene
  112134. */
  112135. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112136. /**
  112137. * Gets camera class name
  112138. * @returns StereoscopicFreeCamera
  112139. */
  112140. getClassName(): string;
  112141. }
  112142. }
  112143. declare module BABYLON {
  112144. /**
  112145. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  112146. * @see http://doc.babylonjs.com/features/cameras
  112147. */
  112148. export class StereoscopicGamepadCamera extends GamepadCamera {
  112149. /**
  112150. * Creates a new StereoscopicGamepadCamera
  112151. * @param name defines camera name
  112152. * @param position defines initial position
  112153. * @param interaxialDistance defines distance between each color axis
  112154. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112155. * @param scene defines the hosting scene
  112156. */
  112157. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112158. /**
  112159. * Gets camera class name
  112160. * @returns StereoscopicGamepadCamera
  112161. */
  112162. getClassName(): string;
  112163. }
  112164. }
  112165. declare module BABYLON {
  112166. /**
  112167. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  112168. * @see http://doc.babylonjs.com/features/cameras
  112169. */
  112170. export class StereoscopicUniversalCamera extends UniversalCamera {
  112171. /**
  112172. * Creates a new StereoscopicUniversalCamera
  112173. * @param name defines camera name
  112174. * @param position defines initial position
  112175. * @param interaxialDistance defines distance between each color axis
  112176. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112177. * @param scene defines the hosting scene
  112178. */
  112179. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112180. /**
  112181. * Gets camera class name
  112182. * @returns StereoscopicUniversalCamera
  112183. */
  112184. getClassName(): string;
  112185. }
  112186. }
  112187. declare module BABYLON {
  112188. /**
  112189. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  112190. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112191. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112192. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112193. */
  112194. export class VirtualJoysticksCamera extends FreeCamera {
  112195. /**
  112196. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  112197. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112198. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112199. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112200. * @param name Define the name of the camera in the scene
  112201. * @param position Define the start position of the camera in the scene
  112202. * @param scene Define the scene the camera belongs to
  112203. */
  112204. constructor(name: string, position: Vector3, scene: Scene);
  112205. /**
  112206. * Gets the current object class name.
  112207. * @return the class name
  112208. */
  112209. getClassName(): string;
  112210. }
  112211. }
  112212. declare module BABYLON {
  112213. /**
  112214. * This represents all the required metrics to create a VR camera.
  112215. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  112216. */
  112217. export class VRCameraMetrics {
  112218. /**
  112219. * Define the horizontal resolution off the screen.
  112220. */
  112221. hResolution: number;
  112222. /**
  112223. * Define the vertical resolution off the screen.
  112224. */
  112225. vResolution: number;
  112226. /**
  112227. * Define the horizontal screen size.
  112228. */
  112229. hScreenSize: number;
  112230. /**
  112231. * Define the vertical screen size.
  112232. */
  112233. vScreenSize: number;
  112234. /**
  112235. * Define the vertical screen center position.
  112236. */
  112237. vScreenCenter: number;
  112238. /**
  112239. * Define the distance of the eyes to the screen.
  112240. */
  112241. eyeToScreenDistance: number;
  112242. /**
  112243. * Define the distance between both lenses
  112244. */
  112245. lensSeparationDistance: number;
  112246. /**
  112247. * Define the distance between both viewer's eyes.
  112248. */
  112249. interpupillaryDistance: number;
  112250. /**
  112251. * Define the distortion factor of the VR postprocess.
  112252. * Please, touch with care.
  112253. */
  112254. distortionK: number[];
  112255. /**
  112256. * Define the chromatic aberration correction factors for the VR post process.
  112257. */
  112258. chromaAbCorrection: number[];
  112259. /**
  112260. * Define the scale factor of the post process.
  112261. * The smaller the better but the slower.
  112262. */
  112263. postProcessScaleFactor: number;
  112264. /**
  112265. * Define an offset for the lens center.
  112266. */
  112267. lensCenterOffset: number;
  112268. /**
  112269. * Define if the current vr camera should compensate the distortion of the lense or not.
  112270. */
  112271. compensateDistortion: boolean;
  112272. /**
  112273. * Defines if multiview should be enabled when rendering (Default: false)
  112274. */
  112275. multiviewEnabled: boolean;
  112276. /**
  112277. * Gets the rendering aspect ratio based on the provided resolutions.
  112278. */
  112279. get aspectRatio(): number;
  112280. /**
  112281. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  112282. */
  112283. get aspectRatioFov(): number;
  112284. /**
  112285. * @hidden
  112286. */
  112287. get leftHMatrix(): Matrix;
  112288. /**
  112289. * @hidden
  112290. */
  112291. get rightHMatrix(): Matrix;
  112292. /**
  112293. * @hidden
  112294. */
  112295. get leftPreViewMatrix(): Matrix;
  112296. /**
  112297. * @hidden
  112298. */
  112299. get rightPreViewMatrix(): Matrix;
  112300. /**
  112301. * Get the default VRMetrics based on the most generic setup.
  112302. * @returns the default vr metrics
  112303. */
  112304. static GetDefault(): VRCameraMetrics;
  112305. }
  112306. }
  112307. declare module BABYLON {
  112308. /** @hidden */
  112309. export var vrDistortionCorrectionPixelShader: {
  112310. name: string;
  112311. shader: string;
  112312. };
  112313. }
  112314. declare module BABYLON {
  112315. /**
  112316. * VRDistortionCorrectionPostProcess used for mobile VR
  112317. */
  112318. export class VRDistortionCorrectionPostProcess extends PostProcess {
  112319. private _isRightEye;
  112320. private _distortionFactors;
  112321. private _postProcessScaleFactor;
  112322. private _lensCenterOffset;
  112323. private _scaleIn;
  112324. private _scaleFactor;
  112325. private _lensCenter;
  112326. /**
  112327. * Initializes the VRDistortionCorrectionPostProcess
  112328. * @param name The name of the effect.
  112329. * @param camera The camera to apply the render pass to.
  112330. * @param isRightEye If this is for the right eye distortion
  112331. * @param vrMetrics All the required metrics for the VR camera
  112332. */
  112333. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  112334. }
  112335. }
  112336. declare module BABYLON {
  112337. /**
  112338. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  112339. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112340. */
  112341. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  112342. /**
  112343. * Creates a new VRDeviceOrientationArcRotateCamera
  112344. * @param name defines camera name
  112345. * @param alpha defines the camera rotation along the logitudinal axis
  112346. * @param beta defines the camera rotation along the latitudinal axis
  112347. * @param radius defines the camera distance from its target
  112348. * @param target defines the camera target
  112349. * @param scene defines the scene the camera belongs to
  112350. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112351. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112352. */
  112353. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112354. /**
  112355. * Gets camera class name
  112356. * @returns VRDeviceOrientationArcRotateCamera
  112357. */
  112358. getClassName(): string;
  112359. }
  112360. }
  112361. declare module BABYLON {
  112362. /**
  112363. * Camera used to simulate VR rendering (based on FreeCamera)
  112364. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112365. */
  112366. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  112367. /**
  112368. * Creates a new VRDeviceOrientationFreeCamera
  112369. * @param name defines camera name
  112370. * @param position defines the start position of the camera
  112371. * @param scene defines the scene the camera belongs to
  112372. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112373. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112374. */
  112375. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112376. /**
  112377. * Gets camera class name
  112378. * @returns VRDeviceOrientationFreeCamera
  112379. */
  112380. getClassName(): string;
  112381. }
  112382. }
  112383. declare module BABYLON {
  112384. /**
  112385. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  112386. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112387. */
  112388. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  112389. /**
  112390. * Creates a new VRDeviceOrientationGamepadCamera
  112391. * @param name defines camera name
  112392. * @param position defines the start position of the camera
  112393. * @param scene defines the scene the camera belongs to
  112394. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112395. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112396. */
  112397. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112398. /**
  112399. * Gets camera class name
  112400. * @returns VRDeviceOrientationGamepadCamera
  112401. */
  112402. getClassName(): string;
  112403. }
  112404. }
  112405. declare module BABYLON {
  112406. /** @hidden */
  112407. export var imageProcessingPixelShader: {
  112408. name: string;
  112409. shader: string;
  112410. };
  112411. }
  112412. declare module BABYLON {
  112413. /**
  112414. * ImageProcessingPostProcess
  112415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  112416. */
  112417. export class ImageProcessingPostProcess extends PostProcess {
  112418. /**
  112419. * Default configuration related to image processing available in the PBR Material.
  112420. */
  112421. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112422. /**
  112423. * Gets the image processing configuration used either in this material.
  112424. */
  112425. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  112426. /**
  112427. * Sets the Default image processing configuration used either in the this material.
  112428. *
  112429. * If sets to null, the scene one is in use.
  112430. */
  112431. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  112432. /**
  112433. * Keep track of the image processing observer to allow dispose and replace.
  112434. */
  112435. private _imageProcessingObserver;
  112436. /**
  112437. * Attaches a new image processing configuration to the PBR Material.
  112438. * @param configuration
  112439. */
  112440. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  112441. /**
  112442. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112443. */
  112444. get colorCurves(): Nullable<ColorCurves>;
  112445. /**
  112446. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112447. */
  112448. set colorCurves(value: Nullable<ColorCurves>);
  112449. /**
  112450. * Gets wether the color curves effect is enabled.
  112451. */
  112452. get colorCurvesEnabled(): boolean;
  112453. /**
  112454. * Sets wether the color curves effect is enabled.
  112455. */
  112456. set colorCurvesEnabled(value: boolean);
  112457. /**
  112458. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112459. */
  112460. get colorGradingTexture(): Nullable<BaseTexture>;
  112461. /**
  112462. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112463. */
  112464. set colorGradingTexture(value: Nullable<BaseTexture>);
  112465. /**
  112466. * Gets wether the color grading effect is enabled.
  112467. */
  112468. get colorGradingEnabled(): boolean;
  112469. /**
  112470. * Gets wether the color grading effect is enabled.
  112471. */
  112472. set colorGradingEnabled(value: boolean);
  112473. /**
  112474. * Gets exposure used in the effect.
  112475. */
  112476. get exposure(): number;
  112477. /**
  112478. * Sets exposure used in the effect.
  112479. */
  112480. set exposure(value: number);
  112481. /**
  112482. * Gets wether tonemapping is enabled or not.
  112483. */
  112484. get toneMappingEnabled(): boolean;
  112485. /**
  112486. * Sets wether tonemapping is enabled or not
  112487. */
  112488. set toneMappingEnabled(value: boolean);
  112489. /**
  112490. * Gets the type of tone mapping effect.
  112491. */
  112492. get toneMappingType(): number;
  112493. /**
  112494. * Sets the type of tone mapping effect.
  112495. */
  112496. set toneMappingType(value: number);
  112497. /**
  112498. * Gets contrast used in the effect.
  112499. */
  112500. get contrast(): number;
  112501. /**
  112502. * Sets contrast used in the effect.
  112503. */
  112504. set contrast(value: number);
  112505. /**
  112506. * Gets Vignette stretch size.
  112507. */
  112508. get vignetteStretch(): number;
  112509. /**
  112510. * Sets Vignette stretch size.
  112511. */
  112512. set vignetteStretch(value: number);
  112513. /**
  112514. * Gets Vignette centre X Offset.
  112515. */
  112516. get vignetteCentreX(): number;
  112517. /**
  112518. * Sets Vignette centre X Offset.
  112519. */
  112520. set vignetteCentreX(value: number);
  112521. /**
  112522. * Gets Vignette centre Y Offset.
  112523. */
  112524. get vignetteCentreY(): number;
  112525. /**
  112526. * Sets Vignette centre Y Offset.
  112527. */
  112528. set vignetteCentreY(value: number);
  112529. /**
  112530. * Gets Vignette weight or intensity of the vignette effect.
  112531. */
  112532. get vignetteWeight(): number;
  112533. /**
  112534. * Sets Vignette weight or intensity of the vignette effect.
  112535. */
  112536. set vignetteWeight(value: number);
  112537. /**
  112538. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112539. * if vignetteEnabled is set to true.
  112540. */
  112541. get vignetteColor(): Color4;
  112542. /**
  112543. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112544. * if vignetteEnabled is set to true.
  112545. */
  112546. set vignetteColor(value: Color4);
  112547. /**
  112548. * Gets Camera field of view used by the Vignette effect.
  112549. */
  112550. get vignetteCameraFov(): number;
  112551. /**
  112552. * Sets Camera field of view used by the Vignette effect.
  112553. */
  112554. set vignetteCameraFov(value: number);
  112555. /**
  112556. * Gets the vignette blend mode allowing different kind of effect.
  112557. */
  112558. get vignetteBlendMode(): number;
  112559. /**
  112560. * Sets the vignette blend mode allowing different kind of effect.
  112561. */
  112562. set vignetteBlendMode(value: number);
  112563. /**
  112564. * Gets wether the vignette effect is enabled.
  112565. */
  112566. get vignetteEnabled(): boolean;
  112567. /**
  112568. * Sets wether the vignette effect is enabled.
  112569. */
  112570. set vignetteEnabled(value: boolean);
  112571. private _fromLinearSpace;
  112572. /**
  112573. * Gets wether the input of the processing is in Gamma or Linear Space.
  112574. */
  112575. get fromLinearSpace(): boolean;
  112576. /**
  112577. * Sets wether the input of the processing is in Gamma or Linear Space.
  112578. */
  112579. set fromLinearSpace(value: boolean);
  112580. /**
  112581. * Defines cache preventing GC.
  112582. */
  112583. private _defines;
  112584. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  112585. /**
  112586. * "ImageProcessingPostProcess"
  112587. * @returns "ImageProcessingPostProcess"
  112588. */
  112589. getClassName(): string;
  112590. protected _updateParameters(): void;
  112591. dispose(camera?: Camera): void;
  112592. }
  112593. }
  112594. declare module BABYLON {
  112595. /**
  112596. * Class containing static functions to help procedurally build meshes
  112597. */
  112598. export class GroundBuilder {
  112599. /**
  112600. * Creates a ground mesh
  112601. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  112602. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  112603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112604. * @param name defines the name of the mesh
  112605. * @param options defines the options used to create the mesh
  112606. * @param scene defines the hosting scene
  112607. * @returns the ground mesh
  112608. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  112609. */
  112610. static CreateGround(name: string, options: {
  112611. width?: number;
  112612. height?: number;
  112613. subdivisions?: number;
  112614. subdivisionsX?: number;
  112615. subdivisionsY?: number;
  112616. updatable?: boolean;
  112617. }, scene: any): Mesh;
  112618. /**
  112619. * Creates a tiled ground mesh
  112620. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  112621. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  112622. * * 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
  112623. * * 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
  112624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112625. * @param name defines the name of the mesh
  112626. * @param options defines the options used to create the mesh
  112627. * @param scene defines the hosting scene
  112628. * @returns the tiled ground mesh
  112629. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  112630. */
  112631. static CreateTiledGround(name: string, options: {
  112632. xmin: number;
  112633. zmin: number;
  112634. xmax: number;
  112635. zmax: number;
  112636. subdivisions?: {
  112637. w: number;
  112638. h: number;
  112639. };
  112640. precision?: {
  112641. w: number;
  112642. h: number;
  112643. };
  112644. updatable?: boolean;
  112645. }, scene?: Nullable<Scene>): Mesh;
  112646. /**
  112647. * Creates a ground mesh from a height map
  112648. * * The parameter `url` sets the URL of the height map image resource.
  112649. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  112650. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  112651. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  112652. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  112653. * * 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.
  112654. * * 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).
  112655. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  112656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112657. * @param name defines the name of the mesh
  112658. * @param url defines the url to the height map
  112659. * @param options defines the options used to create the mesh
  112660. * @param scene defines the hosting scene
  112661. * @returns the ground mesh
  112662. * @see https://doc.babylonjs.com/babylon101/height_map
  112663. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  112664. */
  112665. static CreateGroundFromHeightMap(name: string, url: string, options: {
  112666. width?: number;
  112667. height?: number;
  112668. subdivisions?: number;
  112669. minHeight?: number;
  112670. maxHeight?: number;
  112671. colorFilter?: Color3;
  112672. alphaFilter?: number;
  112673. updatable?: boolean;
  112674. onReady?: (mesh: GroundMesh) => void;
  112675. }, scene?: Nullable<Scene>): GroundMesh;
  112676. }
  112677. }
  112678. declare module BABYLON {
  112679. /**
  112680. * Class containing static functions to help procedurally build meshes
  112681. */
  112682. export class TorusBuilder {
  112683. /**
  112684. * Creates a torus mesh
  112685. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  112686. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  112687. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  112688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112691. * @param name defines the name of the mesh
  112692. * @param options defines the options used to create the mesh
  112693. * @param scene defines the hosting scene
  112694. * @returns the torus mesh
  112695. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  112696. */
  112697. static CreateTorus(name: string, options: {
  112698. diameter?: number;
  112699. thickness?: number;
  112700. tessellation?: number;
  112701. updatable?: boolean;
  112702. sideOrientation?: number;
  112703. frontUVs?: Vector4;
  112704. backUVs?: Vector4;
  112705. }, scene: any): Mesh;
  112706. }
  112707. }
  112708. declare module BABYLON {
  112709. /**
  112710. * Class containing static functions to help procedurally build meshes
  112711. */
  112712. export class CylinderBuilder {
  112713. /**
  112714. * Creates a cylinder or a cone mesh
  112715. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  112716. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  112717. * * 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.
  112718. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  112719. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  112720. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  112721. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  112722. * * 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).
  112723. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  112724. * * 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).
  112725. * * 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
  112726. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  112727. * * 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
  112728. * * 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.
  112729. * * If `enclose` is false, a ring surface is one element.
  112730. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  112731. * * 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
  112732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112735. * @param name defines the name of the mesh
  112736. * @param options defines the options used to create the mesh
  112737. * @param scene defines the hosting scene
  112738. * @returns the cylinder mesh
  112739. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  112740. */
  112741. static CreateCylinder(name: string, options: {
  112742. height?: number;
  112743. diameterTop?: number;
  112744. diameterBottom?: number;
  112745. diameter?: number;
  112746. tessellation?: number;
  112747. subdivisions?: number;
  112748. arc?: number;
  112749. faceColors?: Color4[];
  112750. faceUV?: Vector4[];
  112751. updatable?: boolean;
  112752. hasRings?: boolean;
  112753. enclose?: boolean;
  112754. cap?: number;
  112755. sideOrientation?: number;
  112756. frontUVs?: Vector4;
  112757. backUVs?: Vector4;
  112758. }, scene: any): Mesh;
  112759. }
  112760. }
  112761. declare module BABYLON {
  112762. /**
  112763. * States of the webXR experience
  112764. */
  112765. export enum WebXRState {
  112766. /**
  112767. * Transitioning to being in XR mode
  112768. */
  112769. ENTERING_XR = 0,
  112770. /**
  112771. * Transitioning to non XR mode
  112772. */
  112773. EXITING_XR = 1,
  112774. /**
  112775. * In XR mode and presenting
  112776. */
  112777. IN_XR = 2,
  112778. /**
  112779. * Not entered XR mode
  112780. */
  112781. NOT_IN_XR = 3
  112782. }
  112783. /**
  112784. * Abstraction of the XR render target
  112785. */
  112786. export interface WebXRRenderTarget extends IDisposable {
  112787. /**
  112788. * xrpresent context of the canvas which can be used to display/mirror xr content
  112789. */
  112790. canvasContext: WebGLRenderingContext;
  112791. /**
  112792. * xr layer for the canvas
  112793. */
  112794. xrLayer: Nullable<XRWebGLLayer>;
  112795. /**
  112796. * Initializes the xr layer for the session
  112797. * @param xrSession xr session
  112798. * @returns a promise that will resolve once the XR Layer has been created
  112799. */
  112800. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  112801. }
  112802. }
  112803. declare module BABYLON {
  112804. /**
  112805. * COnfiguration object for WebXR output canvas
  112806. */
  112807. export class WebXRManagedOutputCanvasOptions {
  112808. /**
  112809. * Options for this XR Layer output
  112810. */
  112811. canvasOptions: XRWebGLLayerOptions;
  112812. /**
  112813. * CSS styling for a newly created canvas (if not provided)
  112814. */
  112815. newCanvasCssStyle?: string;
  112816. /**
  112817. * Get the default values of the configuration object
  112818. * @returns default values of this configuration object
  112819. */
  112820. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  112821. }
  112822. /**
  112823. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  112824. */
  112825. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  112826. private configuration;
  112827. private _engine;
  112828. private _canvas;
  112829. /**
  112830. * xrpresent context of the canvas which can be used to display/mirror xr content
  112831. */
  112832. canvasContext: WebGLRenderingContext;
  112833. /**
  112834. * xr layer for the canvas
  112835. */
  112836. xrLayer: Nullable<XRWebGLLayer>;
  112837. /**
  112838. * Initializes the xr layer for the session
  112839. * @param xrSession xr session
  112840. * @returns a promise that will resolve once the XR Layer has been created
  112841. */
  112842. initializeXRLayerAsync(xrSession: any): any;
  112843. /**
  112844. * Initializes the canvas to be added/removed upon entering/exiting xr
  112845. * @param engine the Babylon engine
  112846. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  112847. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  112848. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  112849. */
  112850. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  112851. /**
  112852. * Disposes of the object
  112853. */
  112854. dispose(): void;
  112855. private _setManagedOutputCanvas;
  112856. private _addCanvas;
  112857. private _removeCanvas;
  112858. }
  112859. }
  112860. declare module BABYLON {
  112861. /**
  112862. * Manages an XRSession to work with Babylon's engine
  112863. * @see https://doc.babylonjs.com/how_to/webxr
  112864. */
  112865. export class WebXRSessionManager implements IDisposable {
  112866. /** The scene which the session should be created for */
  112867. scene: Scene;
  112868. /**
  112869. * Fires every time a new xrFrame arrives which can be used to update the camera
  112870. */
  112871. onXRFrameObservable: Observable<XRFrame>;
  112872. /**
  112873. * Fires when the xr session is ended either by the device or manually done
  112874. */
  112875. onXRSessionEnded: Observable<any>;
  112876. /**
  112877. * Fires when the xr session is ended either by the device or manually done
  112878. */
  112879. onXRSessionInit: Observable<XRSession>;
  112880. /**
  112881. * Underlying xr session
  112882. */
  112883. session: XRSession;
  112884. /**
  112885. * Type of reference space used when creating the session
  112886. */
  112887. referenceSpace: XRReferenceSpace;
  112888. /**
  112889. * Current XR frame
  112890. */
  112891. currentFrame: Nullable<XRFrame>;
  112892. /** WebXR timestamp updated every frame */
  112893. currentTimestamp: number;
  112894. private _xrNavigator;
  112895. private baseLayer;
  112896. private _rttProvider;
  112897. private _sessionEnded;
  112898. /**
  112899. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  112900. * @param scene The scene which the session should be created for
  112901. */
  112902. constructor(
  112903. /** The scene which the session should be created for */
  112904. scene: Scene);
  112905. /**
  112906. * Initializes the manager
  112907. * After initialization enterXR can be called to start an XR session
  112908. * @returns Promise which resolves after it is initialized
  112909. */
  112910. initializeAsync(): Promise<void>;
  112911. /**
  112912. * Initializes an xr session
  112913. * @param xrSessionMode mode to initialize
  112914. * @param optionalFeatures defines optional values to pass to the session builder
  112915. * @returns a promise which will resolve once the session has been initialized
  112916. */
  112917. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  112918. /**
  112919. * Sets the reference space on the xr session
  112920. * @param referenceSpace space to set
  112921. * @returns a promise that will resolve once the reference space has been set
  112922. */
  112923. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  112924. /**
  112925. * Updates the render state of the session
  112926. * @param state state to set
  112927. * @returns a promise that resolves once the render state has been updated
  112928. */
  112929. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  112930. /**
  112931. * Starts rendering to the xr layer
  112932. * @returns a promise that will resolve once rendering has started
  112933. */
  112934. startRenderingToXRAsync(): Promise<void>;
  112935. /**
  112936. * Gets the correct render target texture to be rendered this frame for this eye
  112937. * @param eye the eye for which to get the render target
  112938. * @returns the render target for the specified eye
  112939. */
  112940. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  112941. /**
  112942. * Stops the xrSession and restores the renderloop
  112943. * @returns Promise which resolves after it exits XR
  112944. */
  112945. exitXRAsync(): Promise<void>;
  112946. /**
  112947. * Checks if a session would be supported for the creation options specified
  112948. * @param sessionMode session mode to check if supported eg. immersive-vr
  112949. * @returns true if supported
  112950. */
  112951. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  112952. /**
  112953. * Creates a WebXRRenderTarget object for the XR session
  112954. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  112955. * @param options optional options to provide when creating a new render target
  112956. * @returns a WebXR render target to which the session can render
  112957. */
  112958. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  112959. /**
  112960. * @hidden
  112961. * Converts the render layer of xrSession to a render target
  112962. * @param session session to create render target for
  112963. * @param scene scene the new render target should be created for
  112964. * @param baseLayer the webgl layer to create the render target for
  112965. */
  112966. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  112967. /**
  112968. * Disposes of the session manager
  112969. */
  112970. dispose(): void;
  112971. /**
  112972. * Gets a promise returning true when fullfiled if the given session mode is supported
  112973. * @param sessionMode defines the session to test
  112974. * @returns a promise
  112975. */
  112976. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  112977. }
  112978. }
  112979. declare module BABYLON {
  112980. /**
  112981. * WebXR Camera which holds the views for the xrSession
  112982. * @see https://doc.babylonjs.com/how_to/webxr
  112983. */
  112984. export class WebXRCamera extends FreeCamera {
  112985. /**
  112986. * Is the camera in debug mode. Used when using an emulator
  112987. */
  112988. debugMode: boolean;
  112989. /**
  112990. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  112991. * @param name the name of the camera
  112992. * @param scene the scene to add the camera to
  112993. */
  112994. constructor(name: string, scene: Scene);
  112995. private _updateNumberOfRigCameras;
  112996. /** @hidden */
  112997. _updateForDualEyeDebugging(): void;
  112998. /**
  112999. * Updates the cameras position from the current pose information of the XR session
  113000. * @param xrSessionManager the session containing pose information
  113001. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  113002. */
  113003. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  113004. }
  113005. }
  113006. declare module BABYLON {
  113007. /**
  113008. * Defining the interface required for a (webxr) feature
  113009. */
  113010. export interface IWebXRFeature extends IDisposable {
  113011. /**
  113012. * Attach the feature to the session
  113013. * Will usually be called by the features manager
  113014. *
  113015. * @returns true if successful.
  113016. */
  113017. attach(): boolean;
  113018. /**
  113019. * Detach the feature from the session
  113020. * Will usually be called by the features manager
  113021. *
  113022. * @returns true if successful.
  113023. */
  113024. detach(): boolean;
  113025. }
  113026. /**
  113027. * Defining the constructor of a feature. Used to register the modules.
  113028. */
  113029. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  113030. /**
  113031. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  113032. * It is mainly used in AR sessions.
  113033. *
  113034. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  113035. */
  113036. export class WebXRFeaturesManager implements IDisposable {
  113037. private _xrSessionManager;
  113038. private static readonly _AvailableFeatures;
  113039. /**
  113040. * Used to register a module. After calling this function a developer can use this feature in the scene.
  113041. * Mainly used internally.
  113042. *
  113043. * @param featureName the name of the feature to register
  113044. * @param constructorFunction the function used to construct the module
  113045. * @param version the (babylon) version of the module
  113046. * @param stable is that a stable version of this module
  113047. */
  113048. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  113049. /**
  113050. * Returns a constructor of a specific feature.
  113051. *
  113052. * @param featureName the name of the feature to construct
  113053. * @param version the version of the feature to load
  113054. * @param xrSessionManager the xrSessionManager. Used to construct the module
  113055. * @param options optional options provided to the module.
  113056. * @returns a function that, when called, will return a new instance of this feature
  113057. */
  113058. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  113059. /**
  113060. * Return the latest unstable version of this feature
  113061. * @param featureName the name of the feature to search
  113062. * @returns the version number. if not found will return -1
  113063. */
  113064. static GetLatestVersionOfFeature(featureName: string): number;
  113065. /**
  113066. * Return the latest stable version of this feature
  113067. * @param featureName the name of the feature to search
  113068. * @returns the version number. if not found will return -1
  113069. */
  113070. static GetStableVersionOfFeature(featureName: string): number;
  113071. /**
  113072. * Can be used to return the list of features currently registered
  113073. *
  113074. * @returns an Array of available features
  113075. */
  113076. static GetAvailableFeatures(): string[];
  113077. /**
  113078. * Gets the versions available for a specific feature
  113079. * @param featureName the name of the feature
  113080. * @returns an array with the available versions
  113081. */
  113082. static GetAvailableVersions(featureName: string): string[];
  113083. private _features;
  113084. /**
  113085. * constructs a new features manages.
  113086. *
  113087. * @param _xrSessionManager an instance of WebXRSessionManager
  113088. */
  113089. constructor(_xrSessionManager: WebXRSessionManager);
  113090. /**
  113091. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  113092. *
  113093. * @param featureName the name of the feature to load or the class of the feature
  113094. * @param version optional version to load. if not provided the latest version will be enabled
  113095. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  113096. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  113097. * @returns a new constructed feature or throws an error if feature not found.
  113098. */
  113099. enableFeature(featureName: string | {
  113100. Name: string;
  113101. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  113102. /**
  113103. * Used to disable an already-enabled feature
  113104. * @param featureName the feature to disable
  113105. * @returns true if disable was successful
  113106. */
  113107. disableFeature(featureName: string | {
  113108. Name: string;
  113109. }): boolean;
  113110. /**
  113111. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  113112. * Can be used during a session to start a feature
  113113. * @param featureName the name of feature to attach
  113114. */
  113115. attachFeature(featureName: string): void;
  113116. /**
  113117. * Can be used inside a session or when the session ends to detach a specific feature
  113118. * @param featureName the name of the feature to detach
  113119. */
  113120. detachFeature(featureName: string): void;
  113121. /**
  113122. * Get the list of enabled features
  113123. * @returns an array of enabled features
  113124. */
  113125. getEnabledFeatures(): string[];
  113126. /**
  113127. * get the implementation of an enabled feature.
  113128. * @param featureName the name of the feature to load
  113129. * @returns the feature class, if found
  113130. */
  113131. getEnabledFeature(featureName: string): IWebXRFeature;
  113132. /**
  113133. * dispose this features manager
  113134. */
  113135. dispose(): void;
  113136. }
  113137. }
  113138. declare module BABYLON {
  113139. /**
  113140. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  113141. * @see https://doc.babylonjs.com/how_to/webxr
  113142. */
  113143. export class WebXRExperienceHelper implements IDisposable {
  113144. private scene;
  113145. /**
  113146. * 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
  113147. */
  113148. container: AbstractMesh;
  113149. /**
  113150. * Camera used to render xr content
  113151. */
  113152. camera: WebXRCamera;
  113153. /**
  113154. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  113155. */
  113156. state: WebXRState;
  113157. private _setState;
  113158. private static _TmpVector;
  113159. /**
  113160. * Fires when the state of the experience helper has changed
  113161. */
  113162. onStateChangedObservable: Observable<WebXRState>;
  113163. /** Session manager used to keep track of xr session */
  113164. sessionManager: WebXRSessionManager;
  113165. /** A features manager for this xr session */
  113166. featuresManager: WebXRFeaturesManager;
  113167. private _nonVRCamera;
  113168. private _originalSceneAutoClear;
  113169. private _supported;
  113170. /**
  113171. * Creates the experience helper
  113172. * @param scene the scene to attach the experience helper to
  113173. * @returns a promise for the experience helper
  113174. */
  113175. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  113176. /**
  113177. * Creates a WebXRExperienceHelper
  113178. * @param scene The scene the helper should be created in
  113179. */
  113180. private constructor();
  113181. /**
  113182. * Exits XR mode and returns the scene to its original state
  113183. * @returns promise that resolves after xr mode has exited
  113184. */
  113185. exitXRAsync(): Promise<void>;
  113186. /**
  113187. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  113188. * @param sessionMode options for the XR session
  113189. * @param referenceSpaceType frame of reference of the XR session
  113190. * @param renderTarget the output canvas that will be used to enter XR mode
  113191. * @returns promise that resolves after xr mode has entered
  113192. */
  113193. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  113194. /**
  113195. * Updates the global position of the camera by moving the camera's container
  113196. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  113197. * @param position The desired global position of the camera
  113198. */
  113199. setPositionOfCameraUsingContainer(position: Vector3): void;
  113200. /**
  113201. * Rotates the xr camera by rotating the camera's container around the camera's position
  113202. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  113203. * @param rotation the desired quaternion rotation to apply to the camera
  113204. */
  113205. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  113206. /**
  113207. * Disposes of the experience helper
  113208. */
  113209. dispose(): void;
  113210. }
  113211. }
  113212. declare module BABYLON {
  113213. /**
  113214. * Represents an XR input
  113215. */
  113216. export class WebXRController {
  113217. private scene;
  113218. /** The underlying input source for the controller */
  113219. inputSource: XRInputSource;
  113220. private parentContainer;
  113221. /**
  113222. * 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
  113223. */
  113224. grip?: AbstractMesh;
  113225. /**
  113226. * Pointer which can be used to select objects or attach a visible laser to
  113227. */
  113228. pointer: AbstractMesh;
  113229. private _gamepadMode;
  113230. /**
  113231. * If available, this is the gamepad object related to this controller.
  113232. * Using this object it is possible to get click events and trackpad changes of the
  113233. * webxr controller that is currently being used.
  113234. */
  113235. gamepadController?: WebVRController;
  113236. /**
  113237. * Event that fires when the controller is removed/disposed
  113238. */
  113239. onDisposeObservable: Observable<{}>;
  113240. private _tmpQuaternion;
  113241. private _tmpVector;
  113242. /**
  113243. * Creates the controller
  113244. * @see https://doc.babylonjs.com/how_to/webxr
  113245. * @param scene the scene which the controller should be associated to
  113246. * @param inputSource the underlying input source for the controller
  113247. * @param parentContainer parent that the controller meshes should be children of
  113248. */
  113249. constructor(scene: Scene,
  113250. /** The underlying input source for the controller */
  113251. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  113252. /**
  113253. * Updates the controller pose based on the given XRFrame
  113254. * @param xrFrame xr frame to update the pose with
  113255. * @param referenceSpace reference space to use
  113256. */
  113257. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  113258. /**
  113259. * Gets a world space ray coming from the controller
  113260. * @param result the resulting ray
  113261. */
  113262. getWorldPointerRayToRef(result: Ray): void;
  113263. /**
  113264. * Get the scene associated with this controller
  113265. * @returns the scene object
  113266. */
  113267. getScene(): Scene;
  113268. /**
  113269. * Disposes of the object
  113270. */
  113271. dispose(): void;
  113272. }
  113273. }
  113274. declare module BABYLON {
  113275. /**
  113276. * XR input used to track XR inputs such as controllers/rays
  113277. */
  113278. export class WebXRInput implements IDisposable {
  113279. /**
  113280. * Base experience the input listens to
  113281. */
  113282. baseExperience: WebXRExperienceHelper;
  113283. /**
  113284. * XR controllers being tracked
  113285. */
  113286. controllers: Array<WebXRController>;
  113287. private _frameObserver;
  113288. private _stateObserver;
  113289. /**
  113290. * Event when a controller has been connected/added
  113291. */
  113292. onControllerAddedObservable: Observable<WebXRController>;
  113293. /**
  113294. * Event when a controller has been removed/disconnected
  113295. */
  113296. onControllerRemovedObservable: Observable<WebXRController>;
  113297. /**
  113298. * Initializes the WebXRInput
  113299. * @param baseExperience experience helper which the input should be created for
  113300. */
  113301. constructor(
  113302. /**
  113303. * Base experience the input listens to
  113304. */
  113305. baseExperience: WebXRExperienceHelper);
  113306. private _onInputSourcesChange;
  113307. private _addAndRemoveControllers;
  113308. /**
  113309. * Disposes of the object
  113310. */
  113311. dispose(): void;
  113312. }
  113313. }
  113314. declare module BABYLON {
  113315. /**
  113316. * Class used to represent data loading progression
  113317. */
  113318. export class SceneLoaderProgressEvent {
  113319. /** defines if data length to load can be evaluated */
  113320. readonly lengthComputable: boolean;
  113321. /** defines the loaded data length */
  113322. readonly loaded: number;
  113323. /** defines the data length to load */
  113324. readonly total: number;
  113325. /**
  113326. * Create a new progress event
  113327. * @param lengthComputable defines if data length to load can be evaluated
  113328. * @param loaded defines the loaded data length
  113329. * @param total defines the data length to load
  113330. */
  113331. constructor(
  113332. /** defines if data length to load can be evaluated */
  113333. lengthComputable: boolean,
  113334. /** defines the loaded data length */
  113335. loaded: number,
  113336. /** defines the data length to load */
  113337. total: number);
  113338. /**
  113339. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  113340. * @param event defines the source event
  113341. * @returns a new SceneLoaderProgressEvent
  113342. */
  113343. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  113344. }
  113345. /**
  113346. * Interface used by SceneLoader plugins to define supported file extensions
  113347. */
  113348. export interface ISceneLoaderPluginExtensions {
  113349. /**
  113350. * Defines the list of supported extensions
  113351. */
  113352. [extension: string]: {
  113353. isBinary: boolean;
  113354. };
  113355. }
  113356. /**
  113357. * Interface used by SceneLoader plugin factory
  113358. */
  113359. export interface ISceneLoaderPluginFactory {
  113360. /**
  113361. * Defines the name of the factory
  113362. */
  113363. name: string;
  113364. /**
  113365. * Function called to create a new plugin
  113366. * @return the new plugin
  113367. */
  113368. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  113369. /**
  113370. * The callback that returns true if the data can be directly loaded.
  113371. * @param data string containing the file data
  113372. * @returns if the data can be loaded directly
  113373. */
  113374. canDirectLoad?(data: string): boolean;
  113375. }
  113376. /**
  113377. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  113378. */
  113379. export interface ISceneLoaderPluginBase {
  113380. /**
  113381. * The friendly name of this plugin.
  113382. */
  113383. name: string;
  113384. /**
  113385. * The file extensions supported by this plugin.
  113386. */
  113387. extensions: string | ISceneLoaderPluginExtensions;
  113388. /**
  113389. * The callback called when loading from a url.
  113390. * @param scene scene loading this url
  113391. * @param url url to load
  113392. * @param onSuccess callback called when the file successfully loads
  113393. * @param onProgress callback called while file is loading (if the server supports this mode)
  113394. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113395. * @param onError callback called when the file fails to load
  113396. * @returns a file request object
  113397. */
  113398. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113399. /**
  113400. * The callback called when loading from a file object.
  113401. * @param scene scene loading this file
  113402. * @param file defines the file to load
  113403. * @param onSuccess defines the callback to call when data is loaded
  113404. * @param onProgress defines the callback to call during loading process
  113405. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  113406. * @param onError defines the callback to call when an error occurs
  113407. * @returns a file request object
  113408. */
  113409. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113410. /**
  113411. * The callback that returns true if the data can be directly loaded.
  113412. * @param data string containing the file data
  113413. * @returns if the data can be loaded directly
  113414. */
  113415. canDirectLoad?(data: string): boolean;
  113416. /**
  113417. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  113418. * @param scene scene loading this data
  113419. * @param data string containing the data
  113420. * @returns data to pass to the plugin
  113421. */
  113422. directLoad?(scene: Scene, data: string): any;
  113423. /**
  113424. * The callback that allows custom handling of the root url based on the response url.
  113425. * @param rootUrl the original root url
  113426. * @param responseURL the response url if available
  113427. * @returns the new root url
  113428. */
  113429. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  113430. }
  113431. /**
  113432. * Interface used to define a SceneLoader plugin
  113433. */
  113434. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  113435. /**
  113436. * Import meshes into a scene.
  113437. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113438. * @param scene The scene to import into
  113439. * @param data The data to import
  113440. * @param rootUrl The root url for scene and resources
  113441. * @param meshes The meshes array to import into
  113442. * @param particleSystems The particle systems array to import into
  113443. * @param skeletons The skeletons array to import into
  113444. * @param onError The callback when import fails
  113445. * @returns True if successful or false otherwise
  113446. */
  113447. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  113448. /**
  113449. * Load into a scene.
  113450. * @param scene The scene to load into
  113451. * @param data The data to import
  113452. * @param rootUrl The root url for scene and resources
  113453. * @param onError The callback when import fails
  113454. * @returns True if successful or false otherwise
  113455. */
  113456. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  113457. /**
  113458. * Load into an asset container.
  113459. * @param scene The scene to load into
  113460. * @param data The data to import
  113461. * @param rootUrl The root url for scene and resources
  113462. * @param onError The callback when import fails
  113463. * @returns The loaded asset container
  113464. */
  113465. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  113466. }
  113467. /**
  113468. * Interface used to define an async SceneLoader plugin
  113469. */
  113470. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  113471. /**
  113472. * Import meshes into a scene.
  113473. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113474. * @param scene The scene to import into
  113475. * @param data The data to import
  113476. * @param rootUrl The root url for scene and resources
  113477. * @param onProgress The callback when the load progresses
  113478. * @param fileName Defines the name of the file to load
  113479. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  113480. */
  113481. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  113482. meshes: AbstractMesh[];
  113483. particleSystems: IParticleSystem[];
  113484. skeletons: Skeleton[];
  113485. animationGroups: AnimationGroup[];
  113486. }>;
  113487. /**
  113488. * Load into a scene.
  113489. * @param scene The scene to load into
  113490. * @param data The data to import
  113491. * @param rootUrl The root url for scene and resources
  113492. * @param onProgress The callback when the load progresses
  113493. * @param fileName Defines the name of the file to load
  113494. * @returns Nothing
  113495. */
  113496. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  113497. /**
  113498. * Load into an asset container.
  113499. * @param scene The scene to load into
  113500. * @param data The data to import
  113501. * @param rootUrl The root url for scene and resources
  113502. * @param onProgress The callback when the load progresses
  113503. * @param fileName Defines the name of the file to load
  113504. * @returns The loaded asset container
  113505. */
  113506. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  113507. }
  113508. /**
  113509. * Mode that determines how to handle old animation groups before loading new ones.
  113510. */
  113511. export enum SceneLoaderAnimationGroupLoadingMode {
  113512. /**
  113513. * Reset all old animations to initial state then dispose them.
  113514. */
  113515. Clean = 0,
  113516. /**
  113517. * Stop all old animations.
  113518. */
  113519. Stop = 1,
  113520. /**
  113521. * Restart old animations from first frame.
  113522. */
  113523. Sync = 2,
  113524. /**
  113525. * Old animations remains untouched.
  113526. */
  113527. NoSync = 3
  113528. }
  113529. /**
  113530. * Class used to load scene from various file formats using registered plugins
  113531. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  113532. */
  113533. export class SceneLoader {
  113534. /**
  113535. * No logging while loading
  113536. */
  113537. static readonly NO_LOGGING: number;
  113538. /**
  113539. * Minimal logging while loading
  113540. */
  113541. static readonly MINIMAL_LOGGING: number;
  113542. /**
  113543. * Summary logging while loading
  113544. */
  113545. static readonly SUMMARY_LOGGING: number;
  113546. /**
  113547. * Detailled logging while loading
  113548. */
  113549. static readonly DETAILED_LOGGING: number;
  113550. /**
  113551. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  113552. */
  113553. static get ForceFullSceneLoadingForIncremental(): boolean;
  113554. static set ForceFullSceneLoadingForIncremental(value: boolean);
  113555. /**
  113556. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  113557. */
  113558. static get ShowLoadingScreen(): boolean;
  113559. static set ShowLoadingScreen(value: boolean);
  113560. /**
  113561. * Defines the current logging level (while loading the scene)
  113562. * @ignorenaming
  113563. */
  113564. static get loggingLevel(): number;
  113565. static set loggingLevel(value: number);
  113566. /**
  113567. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  113568. */
  113569. static get CleanBoneMatrixWeights(): boolean;
  113570. static set CleanBoneMatrixWeights(value: boolean);
  113571. /**
  113572. * Event raised when a plugin is used to load a scene
  113573. */
  113574. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  113575. private static _registeredPlugins;
  113576. private static _getDefaultPlugin;
  113577. private static _getPluginForExtension;
  113578. private static _getPluginForDirectLoad;
  113579. private static _getPluginForFilename;
  113580. private static _getDirectLoad;
  113581. private static _loadData;
  113582. private static _getFileInfo;
  113583. /**
  113584. * Gets a plugin that can load the given extension
  113585. * @param extension defines the extension to load
  113586. * @returns a plugin or null if none works
  113587. */
  113588. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  113589. /**
  113590. * Gets a boolean indicating that the given extension can be loaded
  113591. * @param extension defines the extension to load
  113592. * @returns true if the extension is supported
  113593. */
  113594. static IsPluginForExtensionAvailable(extension: string): boolean;
  113595. /**
  113596. * Adds a new plugin to the list of registered plugins
  113597. * @param plugin defines the plugin to add
  113598. */
  113599. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  113600. /**
  113601. * Import meshes into a scene
  113602. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113603. * @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)
  113604. * @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)
  113605. * @param scene the instance of BABYLON.Scene to append to
  113606. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  113607. * @param onProgress a callback with a progress event for each file being loaded
  113608. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113609. * @param pluginExtension the extension used to determine the plugin
  113610. * @returns The loaded plugin
  113611. */
  113612. 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>;
  113613. /**
  113614. * Import meshes into a scene
  113615. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113616. * @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)
  113617. * @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)
  113618. * @param scene the instance of BABYLON.Scene to append to
  113619. * @param onProgress a callback with a progress event for each file being loaded
  113620. * @param pluginExtension the extension used to determine the plugin
  113621. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  113622. */
  113623. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  113624. meshes: AbstractMesh[];
  113625. particleSystems: IParticleSystem[];
  113626. skeletons: Skeleton[];
  113627. animationGroups: AnimationGroup[];
  113628. }>;
  113629. /**
  113630. * Load a scene
  113631. * @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)
  113632. * @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)
  113633. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113634. * @param onSuccess a callback with the scene when import succeeds
  113635. * @param onProgress a callback with a progress event for each file being loaded
  113636. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113637. * @param pluginExtension the extension used to determine the plugin
  113638. * @returns The loaded plugin
  113639. */
  113640. 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>;
  113641. /**
  113642. * Load a scene
  113643. * @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)
  113644. * @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)
  113645. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113646. * @param onProgress a callback with a progress event for each file being loaded
  113647. * @param pluginExtension the extension used to determine the plugin
  113648. * @returns The loaded scene
  113649. */
  113650. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113651. /**
  113652. * Append a scene
  113653. * @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)
  113654. * @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)
  113655. * @param scene is the instance of BABYLON.Scene to append to
  113656. * @param onSuccess a callback with the scene when import succeeds
  113657. * @param onProgress a callback with a progress event for each file being loaded
  113658. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113659. * @param pluginExtension the extension used to determine the plugin
  113660. * @returns The loaded plugin
  113661. */
  113662. 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>;
  113663. /**
  113664. * Append a scene
  113665. * @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)
  113666. * @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)
  113667. * @param scene is the instance of BABYLON.Scene to append to
  113668. * @param onProgress a callback with a progress event for each file being loaded
  113669. * @param pluginExtension the extension used to determine the plugin
  113670. * @returns The given scene
  113671. */
  113672. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113673. /**
  113674. * Load a scene into an asset container
  113675. * @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)
  113676. * @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)
  113677. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113678. * @param onSuccess a callback with the scene when import succeeds
  113679. * @param onProgress a callback with a progress event for each file being loaded
  113680. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113681. * @param pluginExtension the extension used to determine the plugin
  113682. * @returns The loaded plugin
  113683. */
  113684. 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>;
  113685. /**
  113686. * Load a scene into an asset container
  113687. * @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)
  113688. * @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)
  113689. * @param scene is the instance of Scene to append to
  113690. * @param onProgress a callback with a progress event for each file being loaded
  113691. * @param pluginExtension the extension used to determine the plugin
  113692. * @returns The loaded asset container
  113693. */
  113694. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  113695. /**
  113696. * Import animations from a file into a scene
  113697. * @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)
  113698. * @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)
  113699. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113700. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113701. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113702. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113703. * @param onSuccess a callback with the scene when import succeeds
  113704. * @param onProgress a callback with a progress event for each file being loaded
  113705. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113706. */
  113707. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  113708. /**
  113709. * Import animations from a file into a scene
  113710. * @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)
  113711. * @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)
  113712. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113713. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113714. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113715. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113716. * @param onSuccess a callback with the scene when import succeeds
  113717. * @param onProgress a callback with a progress event for each file being loaded
  113718. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113719. * @returns the updated scene with imported animations
  113720. */
  113721. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  113722. }
  113723. }
  113724. declare module BABYLON {
  113725. /**
  113726. * Generic Controller
  113727. */
  113728. export class GenericController extends WebVRController {
  113729. /**
  113730. * Base Url for the controller model.
  113731. */
  113732. static readonly MODEL_BASE_URL: string;
  113733. /**
  113734. * File name for the controller model.
  113735. */
  113736. static readonly MODEL_FILENAME: string;
  113737. /**
  113738. * Creates a new GenericController from a gamepad
  113739. * @param vrGamepad the gamepad that the controller should be created from
  113740. */
  113741. constructor(vrGamepad: any);
  113742. /**
  113743. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113744. * @param scene scene in which to add meshes
  113745. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113746. */
  113747. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113748. /**
  113749. * Called once for each button that changed state since the last frame
  113750. * @param buttonIdx Which button index changed
  113751. * @param state New state of the button
  113752. * @param changes Which properties on the state changed since last frame
  113753. */
  113754. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113755. }
  113756. }
  113757. declare module BABYLON {
  113758. /**
  113759. * Defines the WindowsMotionController object that the state of the windows motion controller
  113760. */
  113761. export class WindowsMotionController extends WebVRController {
  113762. /**
  113763. * The base url used to load the left and right controller models
  113764. */
  113765. static MODEL_BASE_URL: string;
  113766. /**
  113767. * The name of the left controller model file
  113768. */
  113769. static MODEL_LEFT_FILENAME: string;
  113770. /**
  113771. * The name of the right controller model file
  113772. */
  113773. static MODEL_RIGHT_FILENAME: string;
  113774. /**
  113775. * The controller name prefix for this controller type
  113776. */
  113777. static readonly GAMEPAD_ID_PREFIX: string;
  113778. /**
  113779. * The controller id pattern for this controller type
  113780. */
  113781. private static readonly GAMEPAD_ID_PATTERN;
  113782. private _loadedMeshInfo;
  113783. protected readonly _mapping: {
  113784. buttons: string[];
  113785. buttonMeshNames: {
  113786. 'trigger': string;
  113787. 'menu': string;
  113788. 'grip': string;
  113789. 'thumbstick': string;
  113790. 'trackpad': string;
  113791. };
  113792. buttonObservableNames: {
  113793. 'trigger': string;
  113794. 'menu': string;
  113795. 'grip': string;
  113796. 'thumbstick': string;
  113797. 'trackpad': string;
  113798. };
  113799. axisMeshNames: string[];
  113800. pointingPoseMeshName: string;
  113801. };
  113802. /**
  113803. * Fired when the trackpad on this controller is clicked
  113804. */
  113805. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113806. /**
  113807. * Fired when the trackpad on this controller is modified
  113808. */
  113809. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113810. /**
  113811. * The current x and y values of this controller's trackpad
  113812. */
  113813. trackpad: StickValues;
  113814. /**
  113815. * Creates a new WindowsMotionController from a gamepad
  113816. * @param vrGamepad the gamepad that the controller should be created from
  113817. */
  113818. constructor(vrGamepad: any);
  113819. /**
  113820. * Fired when the trigger on this controller is modified
  113821. */
  113822. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113823. /**
  113824. * Fired when the menu button on this controller is modified
  113825. */
  113826. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113827. /**
  113828. * Fired when the grip button on this controller is modified
  113829. */
  113830. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113831. /**
  113832. * Fired when the thumbstick button on this controller is modified
  113833. */
  113834. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113835. /**
  113836. * Fired when the touchpad button on this controller is modified
  113837. */
  113838. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113839. /**
  113840. * Fired when the touchpad values on this controller are modified
  113841. */
  113842. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  113843. protected _updateTrackpad(): void;
  113844. /**
  113845. * Called once per frame by the engine.
  113846. */
  113847. update(): void;
  113848. /**
  113849. * Called once for each button that changed state since the last frame
  113850. * @param buttonIdx Which button index changed
  113851. * @param state New state of the button
  113852. * @param changes Which properties on the state changed since last frame
  113853. */
  113854. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113855. /**
  113856. * Moves the buttons on the controller mesh based on their current state
  113857. * @param buttonName the name of the button to move
  113858. * @param buttonValue the value of the button which determines the buttons new position
  113859. */
  113860. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  113861. /**
  113862. * Moves the axis on the controller mesh based on its current state
  113863. * @param axis the index of the axis
  113864. * @param axisValue the value of the axis which determines the meshes new position
  113865. * @hidden
  113866. */
  113867. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  113868. /**
  113869. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113870. * @param scene scene in which to add meshes
  113871. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113872. */
  113873. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  113874. /**
  113875. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  113876. * can be transformed by button presses and axes values, based on this._mapping.
  113877. *
  113878. * @param scene scene in which the meshes exist
  113879. * @param meshes list of meshes that make up the controller model to process
  113880. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  113881. */
  113882. private processModel;
  113883. private createMeshInfo;
  113884. /**
  113885. * Gets the ray of the controller in the direction the controller is pointing
  113886. * @param length the length the resulting ray should be
  113887. * @returns a ray in the direction the controller is pointing
  113888. */
  113889. getForwardRay(length?: number): Ray;
  113890. /**
  113891. * Disposes of the controller
  113892. */
  113893. dispose(): void;
  113894. }
  113895. /**
  113896. * This class represents a new windows motion controller in XR.
  113897. */
  113898. export class XRWindowsMotionController extends WindowsMotionController {
  113899. /**
  113900. * Changing the original WIndowsMotionController mapping to fir the new mapping
  113901. */
  113902. protected readonly _mapping: {
  113903. buttons: string[];
  113904. buttonMeshNames: {
  113905. 'trigger': string;
  113906. 'menu': string;
  113907. 'grip': string;
  113908. 'thumbstick': string;
  113909. 'trackpad': string;
  113910. };
  113911. buttonObservableNames: {
  113912. 'trigger': string;
  113913. 'menu': string;
  113914. 'grip': string;
  113915. 'thumbstick': string;
  113916. 'trackpad': string;
  113917. };
  113918. axisMeshNames: string[];
  113919. pointingPoseMeshName: string;
  113920. };
  113921. /**
  113922. * Construct a new XR-Based windows motion controller
  113923. *
  113924. * @param gamepadInfo the gamepad object from the browser
  113925. */
  113926. constructor(gamepadInfo: any);
  113927. /**
  113928. * holds the thumbstick values (X,Y)
  113929. */
  113930. thumbstickValues: StickValues;
  113931. /**
  113932. * Fired when the thumbstick on this controller is clicked
  113933. */
  113934. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  113935. /**
  113936. * Fired when the thumbstick on this controller is modified
  113937. */
  113938. onThumbstickValuesChangedObservable: Observable<StickValues>;
  113939. /**
  113940. * Fired when the touchpad button on this controller is modified
  113941. */
  113942. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113943. /**
  113944. * Fired when the touchpad values on this controller are modified
  113945. */
  113946. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113947. /**
  113948. * Fired when the thumbstick button on this controller is modified
  113949. * here to prevent breaking changes
  113950. */
  113951. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113952. /**
  113953. * updating the thumbstick(!) and not the trackpad.
  113954. * This is named this way due to the difference between WebVR and XR and to avoid
  113955. * changing the parent class.
  113956. */
  113957. protected _updateTrackpad(): void;
  113958. /**
  113959. * Disposes the class with joy
  113960. */
  113961. dispose(): void;
  113962. }
  113963. }
  113964. declare module BABYLON {
  113965. /**
  113966. * Oculus Touch Controller
  113967. */
  113968. export class OculusTouchController extends WebVRController {
  113969. /**
  113970. * Base Url for the controller model.
  113971. */
  113972. static MODEL_BASE_URL: string;
  113973. /**
  113974. * File name for the left controller model.
  113975. */
  113976. static MODEL_LEFT_FILENAME: string;
  113977. /**
  113978. * File name for the right controller model.
  113979. */
  113980. static MODEL_RIGHT_FILENAME: string;
  113981. /**
  113982. * Base Url for the Quest controller model.
  113983. */
  113984. static QUEST_MODEL_BASE_URL: string;
  113985. /**
  113986. * @hidden
  113987. * If the controllers are running on a device that needs the updated Quest controller models
  113988. */
  113989. static _IsQuest: boolean;
  113990. /**
  113991. * Fired when the secondary trigger on this controller is modified
  113992. */
  113993. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  113994. /**
  113995. * Fired when the thumb rest on this controller is modified
  113996. */
  113997. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  113998. /**
  113999. * Creates a new OculusTouchController from a gamepad
  114000. * @param vrGamepad the gamepad that the controller should be created from
  114001. */
  114002. constructor(vrGamepad: any);
  114003. /**
  114004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114005. * @param scene scene in which to add meshes
  114006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114007. */
  114008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114009. /**
  114010. * Fired when the A button on this controller is modified
  114011. */
  114012. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114013. /**
  114014. * Fired when the B button on this controller is modified
  114015. */
  114016. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114017. /**
  114018. * Fired when the X button on this controller is modified
  114019. */
  114020. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114021. /**
  114022. * Fired when the Y button on this controller is modified
  114023. */
  114024. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114025. /**
  114026. * Called once for each button that changed state since the last frame
  114027. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  114028. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  114029. * 2) secondary trigger (same)
  114030. * 3) A (right) X (left), touch, pressed = value
  114031. * 4) B / Y
  114032. * 5) thumb rest
  114033. * @param buttonIdx Which button index changed
  114034. * @param state New state of the button
  114035. * @param changes Which properties on the state changed since last frame
  114036. */
  114037. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114038. }
  114039. }
  114040. declare module BABYLON {
  114041. /**
  114042. * Vive Controller
  114043. */
  114044. export class ViveController extends WebVRController {
  114045. /**
  114046. * Base Url for the controller model.
  114047. */
  114048. static MODEL_BASE_URL: string;
  114049. /**
  114050. * File name for the controller model.
  114051. */
  114052. static MODEL_FILENAME: string;
  114053. /**
  114054. * Creates a new ViveController from a gamepad
  114055. * @param vrGamepad the gamepad that the controller should be created from
  114056. */
  114057. constructor(vrGamepad: any);
  114058. /**
  114059. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114060. * @param scene scene in which to add meshes
  114061. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114062. */
  114063. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114064. /**
  114065. * Fired when the left button on this controller is modified
  114066. */
  114067. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114068. /**
  114069. * Fired when the right button on this controller is modified
  114070. */
  114071. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114072. /**
  114073. * Fired when the menu button on this controller is modified
  114074. */
  114075. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114076. /**
  114077. * Called once for each button that changed state since the last frame
  114078. * Vive mapping:
  114079. * 0: touchpad
  114080. * 1: trigger
  114081. * 2: left AND right buttons
  114082. * 3: menu button
  114083. * @param buttonIdx Which button index changed
  114084. * @param state New state of the button
  114085. * @param changes Which properties on the state changed since last frame
  114086. */
  114087. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114088. }
  114089. }
  114090. declare module BABYLON {
  114091. /**
  114092. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  114093. */
  114094. export class WebXRControllerModelLoader {
  114095. /**
  114096. * an observable that triggers when a new model (the mesh itself) was initialized.
  114097. * To know when the mesh was loaded use the controller's own modelLoaded() method
  114098. */
  114099. onControllerModelLoaded: Observable<WebXRController>;
  114100. /**
  114101. * Creates the WebXRControllerModelLoader
  114102. * @param input xr input that creates the controllers
  114103. */
  114104. constructor(input: WebXRInput);
  114105. }
  114106. }
  114107. declare module BABYLON {
  114108. /**
  114109. * Handles pointer input automatically for the pointer of XR controllers
  114110. */
  114111. export class WebXRControllerPointerSelection {
  114112. private static _idCounter;
  114113. private _tmpRay;
  114114. /**
  114115. * Creates a WebXRControllerPointerSelection
  114116. * @param input input manager to setup pointer selection
  114117. */
  114118. constructor(input: WebXRInput);
  114119. private _convertNormalToDirectionOfRay;
  114120. private _updatePointerDistance;
  114121. }
  114122. }
  114123. declare module BABYLON {
  114124. /**
  114125. * Enables teleportation
  114126. */
  114127. export class WebXRControllerTeleportation {
  114128. private _teleportationFillColor;
  114129. private _teleportationBorderColor;
  114130. private _tmpRay;
  114131. private _tmpVector;
  114132. /**
  114133. * when set to true (default) teleportation will wait for thumbstick changes.
  114134. * When set to false teleportation will be disabled.
  114135. *
  114136. * If set to false while teleporting results can be unexpected.
  114137. */
  114138. enabled: boolean;
  114139. /**
  114140. * Creates a WebXRControllerTeleportation
  114141. * @param input input manager to add teleportation to
  114142. * @param floorMeshes floormeshes which can be teleported to
  114143. */
  114144. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  114145. }
  114146. }
  114147. declare module BABYLON {
  114148. /**
  114149. * Button which can be used to enter a different mode of XR
  114150. */
  114151. export class WebXREnterExitUIButton {
  114152. /** button element */
  114153. element: HTMLElement;
  114154. /** XR initialization options for the button */
  114155. sessionMode: XRSessionMode;
  114156. /** Reference space type */
  114157. referenceSpaceType: XRReferenceSpaceType;
  114158. /**
  114159. * Creates a WebXREnterExitUIButton
  114160. * @param element button element
  114161. * @param sessionMode XR initialization session mode
  114162. * @param referenceSpaceType the type of reference space to be used
  114163. */
  114164. constructor(
  114165. /** button element */
  114166. element: HTMLElement,
  114167. /** XR initialization options for the button */
  114168. sessionMode: XRSessionMode,
  114169. /** Reference space type */
  114170. referenceSpaceType: XRReferenceSpaceType);
  114171. /**
  114172. * Overwritable function which can be used to update the button's visuals when the state changes
  114173. * @param activeButton the current active button in the UI
  114174. */
  114175. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  114176. }
  114177. /**
  114178. * Options to create the webXR UI
  114179. */
  114180. export class WebXREnterExitUIOptions {
  114181. /**
  114182. * Context to enter xr with
  114183. */
  114184. renderTarget?: Nullable<WebXRRenderTarget>;
  114185. /**
  114186. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  114187. */
  114188. customButtons?: Array<WebXREnterExitUIButton>;
  114189. /**
  114190. * A session mode to use when creating the default button.
  114191. * Default is immersive-vr
  114192. */
  114193. sessionMode?: XRSessionMode;
  114194. /**
  114195. * A reference space type to use when creating the default button.
  114196. * Default is local-floor
  114197. */
  114198. referenceSpaceType?: XRReferenceSpaceType;
  114199. }
  114200. /**
  114201. * UI to allow the user to enter/exit XR mode
  114202. */
  114203. export class WebXREnterExitUI implements IDisposable {
  114204. private scene;
  114205. /** version of the options passed to this UI */
  114206. options: WebXREnterExitUIOptions;
  114207. private _overlay;
  114208. private _buttons;
  114209. private _activeButton;
  114210. /**
  114211. * Fired every time the active button is changed.
  114212. *
  114213. * When xr is entered via a button that launches xr that button will be the callback parameter
  114214. *
  114215. * When exiting xr the callback parameter will be null)
  114216. */
  114217. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  114218. /**
  114219. * Creates UI to allow the user to enter/exit XR mode
  114220. * @param scene the scene to add the ui to
  114221. * @param helper the xr experience helper to enter/exit xr with
  114222. * @param options options to configure the UI
  114223. * @returns the created ui
  114224. */
  114225. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  114226. /**
  114227. *
  114228. * @param scene babylon scene object to use
  114229. * @param options (read-only) version of the options passed to this UI
  114230. */
  114231. private constructor();
  114232. private _updateButtons;
  114233. /**
  114234. * Disposes of the object
  114235. */
  114236. dispose(): void;
  114237. }
  114238. }
  114239. declare module BABYLON {
  114240. /**
  114241. * Options for the default xr helper
  114242. */
  114243. export class WebXRDefaultExperienceOptions {
  114244. /**
  114245. * Floor meshes that should be used for teleporting
  114246. */
  114247. floorMeshes: Array<AbstractMesh>;
  114248. /**
  114249. * Enable or disable default UI to enter XR
  114250. */
  114251. disableDefaultUI?: boolean;
  114252. /**
  114253. * optional configuration for the output canvas
  114254. */
  114255. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  114256. /**
  114257. * optional UI options. This can be used among other to change session mode and reference space type
  114258. */
  114259. uiOptions?: WebXREnterExitUIOptions;
  114260. }
  114261. /**
  114262. * Default experience which provides a similar setup to the previous webVRExperience
  114263. */
  114264. export class WebXRDefaultExperience {
  114265. /**
  114266. * Base experience
  114267. */
  114268. baseExperience: WebXRExperienceHelper;
  114269. /**
  114270. * Input experience extension
  114271. */
  114272. input: WebXRInput;
  114273. /**
  114274. * Loads the controller models
  114275. */
  114276. controllerModelLoader: WebXRControllerModelLoader;
  114277. /**
  114278. * Enables laser pointer and selection
  114279. */
  114280. pointerSelection: WebXRControllerPointerSelection;
  114281. /**
  114282. * Enables teleportation
  114283. */
  114284. teleportation: WebXRControllerTeleportation;
  114285. /**
  114286. * Enables ui for entering/exiting xr
  114287. */
  114288. enterExitUI: WebXREnterExitUI;
  114289. /**
  114290. * Default target xr should render to
  114291. */
  114292. renderTarget: WebXRRenderTarget;
  114293. /**
  114294. * Creates the default xr experience
  114295. * @param scene scene
  114296. * @param options options for basic configuration
  114297. * @returns resulting WebXRDefaultExperience
  114298. */
  114299. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114300. private constructor();
  114301. /**
  114302. * DIsposes of the experience helper
  114303. */
  114304. dispose(): void;
  114305. }
  114306. }
  114307. declare module BABYLON {
  114308. /**
  114309. * Options to modify the vr teleportation behavior.
  114310. */
  114311. export interface VRTeleportationOptions {
  114312. /**
  114313. * The name of the mesh which should be used as the teleportation floor. (default: null)
  114314. */
  114315. floorMeshName?: string;
  114316. /**
  114317. * A list of meshes to be used as the teleportation floor. (default: empty)
  114318. */
  114319. floorMeshes?: Mesh[];
  114320. /**
  114321. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  114322. */
  114323. teleportationMode?: number;
  114324. /**
  114325. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  114326. */
  114327. teleportationTime?: number;
  114328. /**
  114329. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  114330. */
  114331. teleportationSpeed?: number;
  114332. /**
  114333. * The easing function used in the animation or null for Linear. (default CircleEase)
  114334. */
  114335. easingFunction?: EasingFunction;
  114336. }
  114337. /**
  114338. * Options to modify the vr experience helper's behavior.
  114339. */
  114340. export interface VRExperienceHelperOptions extends WebVROptions {
  114341. /**
  114342. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  114343. */
  114344. createDeviceOrientationCamera?: boolean;
  114345. /**
  114346. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  114347. */
  114348. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  114349. /**
  114350. * Uses the main button on the controller to toggle the laser casted. (default: true)
  114351. */
  114352. laserToggle?: boolean;
  114353. /**
  114354. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  114355. */
  114356. floorMeshes?: Mesh[];
  114357. /**
  114358. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  114359. */
  114360. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  114361. /**
  114362. * Defines if WebXR should be used instead of WebVR (if available)
  114363. */
  114364. useXR?: boolean;
  114365. }
  114366. /**
  114367. * Event containing information after VR has been entered
  114368. */
  114369. export class OnAfterEnteringVRObservableEvent {
  114370. /**
  114371. * If entering vr was successful
  114372. */
  114373. success: boolean;
  114374. }
  114375. /**
  114376. * Helps to quickly add VR support to an existing scene.
  114377. * See http://doc.babylonjs.com/how_to/webvr_helper
  114378. */
  114379. export class VRExperienceHelper {
  114380. /** Options to modify the vr experience helper's behavior. */
  114381. webVROptions: VRExperienceHelperOptions;
  114382. private _scene;
  114383. private _position;
  114384. private _btnVR;
  114385. private _btnVRDisplayed;
  114386. private _webVRsupported;
  114387. private _webVRready;
  114388. private _webVRrequesting;
  114389. private _webVRpresenting;
  114390. private _hasEnteredVR;
  114391. private _fullscreenVRpresenting;
  114392. private _inputElement;
  114393. private _webVRCamera;
  114394. private _vrDeviceOrientationCamera;
  114395. private _deviceOrientationCamera;
  114396. private _existingCamera;
  114397. private _onKeyDown;
  114398. private _onVrDisplayPresentChange;
  114399. private _onVRDisplayChanged;
  114400. private _onVRRequestPresentStart;
  114401. private _onVRRequestPresentComplete;
  114402. /**
  114403. * 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)
  114404. */
  114405. enableGazeEvenWhenNoPointerLock: boolean;
  114406. /**
  114407. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  114408. */
  114409. exitVROnDoubleTap: boolean;
  114410. /**
  114411. * Observable raised right before entering VR.
  114412. */
  114413. onEnteringVRObservable: Observable<VRExperienceHelper>;
  114414. /**
  114415. * Observable raised when entering VR has completed.
  114416. */
  114417. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  114418. /**
  114419. * Observable raised when exiting VR.
  114420. */
  114421. onExitingVRObservable: Observable<VRExperienceHelper>;
  114422. /**
  114423. * Observable raised when controller mesh is loaded.
  114424. */
  114425. onControllerMeshLoadedObservable: Observable<WebVRController>;
  114426. /** Return this.onEnteringVRObservable
  114427. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  114428. */
  114429. get onEnteringVR(): Observable<VRExperienceHelper>;
  114430. /** Return this.onExitingVRObservable
  114431. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  114432. */
  114433. get onExitingVR(): Observable<VRExperienceHelper>;
  114434. /** Return this.onControllerMeshLoadedObservable
  114435. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  114436. */
  114437. get onControllerMeshLoaded(): Observable<WebVRController>;
  114438. private _rayLength;
  114439. private _useCustomVRButton;
  114440. private _teleportationRequested;
  114441. private _teleportActive;
  114442. private _floorMeshName;
  114443. private _floorMeshesCollection;
  114444. private _teleportationMode;
  114445. private _teleportationTime;
  114446. private _teleportationSpeed;
  114447. private _teleportationEasing;
  114448. private _rotationAllowed;
  114449. private _teleportBackwardsVector;
  114450. private _teleportationTarget;
  114451. private _isDefaultTeleportationTarget;
  114452. private _postProcessMove;
  114453. private _teleportationFillColor;
  114454. private _teleportationBorderColor;
  114455. private _rotationAngle;
  114456. private _haloCenter;
  114457. private _cameraGazer;
  114458. private _padSensibilityUp;
  114459. private _padSensibilityDown;
  114460. private _leftController;
  114461. private _rightController;
  114462. /**
  114463. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  114464. */
  114465. onNewMeshSelected: Observable<AbstractMesh>;
  114466. /**
  114467. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  114468. * This observable will provide the mesh and the controller used to select the mesh
  114469. */
  114470. onMeshSelectedWithController: Observable<{
  114471. mesh: AbstractMesh;
  114472. controller: WebVRController;
  114473. }>;
  114474. /**
  114475. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  114476. */
  114477. onNewMeshPicked: Observable<PickingInfo>;
  114478. private _circleEase;
  114479. /**
  114480. * Observable raised before camera teleportation
  114481. */
  114482. onBeforeCameraTeleport: Observable<Vector3>;
  114483. /**
  114484. * Observable raised after camera teleportation
  114485. */
  114486. onAfterCameraTeleport: Observable<Vector3>;
  114487. /**
  114488. * Observable raised when current selected mesh gets unselected
  114489. */
  114490. onSelectedMeshUnselected: Observable<AbstractMesh>;
  114491. private _raySelectionPredicate;
  114492. /**
  114493. * To be optionaly changed by user to define custom ray selection
  114494. */
  114495. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  114496. /**
  114497. * To be optionaly changed by user to define custom selection logic (after ray selection)
  114498. */
  114499. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114500. /**
  114501. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  114502. */
  114503. teleportationEnabled: boolean;
  114504. private _defaultHeight;
  114505. private _teleportationInitialized;
  114506. private _interactionsEnabled;
  114507. private _interactionsRequested;
  114508. private _displayGaze;
  114509. private _displayLaserPointer;
  114510. /**
  114511. * The mesh used to display where the user is going to teleport.
  114512. */
  114513. get teleportationTarget(): Mesh;
  114514. /**
  114515. * Sets the mesh to be used to display where the user is going to teleport.
  114516. */
  114517. set teleportationTarget(value: Mesh);
  114518. /**
  114519. * 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
  114520. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  114521. * See http://doc.babylonjs.com/resources/baking_transformations
  114522. */
  114523. get gazeTrackerMesh(): Mesh;
  114524. set gazeTrackerMesh(value: Mesh);
  114525. /**
  114526. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  114527. */
  114528. updateGazeTrackerScale: boolean;
  114529. /**
  114530. * If the gaze trackers color should be updated when selecting meshes
  114531. */
  114532. updateGazeTrackerColor: boolean;
  114533. /**
  114534. * If the controller laser color should be updated when selecting meshes
  114535. */
  114536. updateControllerLaserColor: boolean;
  114537. /**
  114538. * The gaze tracking mesh corresponding to the left controller
  114539. */
  114540. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  114541. /**
  114542. * The gaze tracking mesh corresponding to the right controller
  114543. */
  114544. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  114545. /**
  114546. * If the ray of the gaze should be displayed.
  114547. */
  114548. get displayGaze(): boolean;
  114549. /**
  114550. * Sets if the ray of the gaze should be displayed.
  114551. */
  114552. set displayGaze(value: boolean);
  114553. /**
  114554. * If the ray of the LaserPointer should be displayed.
  114555. */
  114556. get displayLaserPointer(): boolean;
  114557. /**
  114558. * Sets if the ray of the LaserPointer should be displayed.
  114559. */
  114560. set displayLaserPointer(value: boolean);
  114561. /**
  114562. * The deviceOrientationCamera used as the camera when not in VR.
  114563. */
  114564. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  114565. /**
  114566. * Based on the current WebVR support, returns the current VR camera used.
  114567. */
  114568. get currentVRCamera(): Nullable<Camera>;
  114569. /**
  114570. * The webVRCamera which is used when in VR.
  114571. */
  114572. get webVRCamera(): WebVRFreeCamera;
  114573. /**
  114574. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  114575. */
  114576. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  114577. /**
  114578. * The html button that is used to trigger entering into VR.
  114579. */
  114580. get vrButton(): Nullable<HTMLButtonElement>;
  114581. private get _teleportationRequestInitiated();
  114582. /**
  114583. * Defines wether or not Pointer lock should be requested when switching to
  114584. * full screen.
  114585. */
  114586. requestPointerLockOnFullScreen: boolean;
  114587. /**
  114588. * If asking to force XR, this will be populated with the default xr experience
  114589. */
  114590. xr: WebXRDefaultExperience;
  114591. /**
  114592. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  114593. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  114594. */
  114595. xrTestDone: boolean;
  114596. /**
  114597. * Instantiates a VRExperienceHelper.
  114598. * Helps to quickly add VR support to an existing scene.
  114599. * @param scene The scene the VRExperienceHelper belongs to.
  114600. * @param webVROptions Options to modify the vr experience helper's behavior.
  114601. */
  114602. constructor(scene: Scene,
  114603. /** Options to modify the vr experience helper's behavior. */
  114604. webVROptions?: VRExperienceHelperOptions);
  114605. private completeVRInit;
  114606. private _onDefaultMeshLoaded;
  114607. private _onResize;
  114608. private _onFullscreenChange;
  114609. /**
  114610. * Gets a value indicating if we are currently in VR mode.
  114611. */
  114612. get isInVRMode(): boolean;
  114613. private onVrDisplayPresentChange;
  114614. private onVRDisplayChanged;
  114615. private moveButtonToBottomRight;
  114616. private displayVRButton;
  114617. private updateButtonVisibility;
  114618. private _cachedAngularSensibility;
  114619. /**
  114620. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  114621. * Otherwise, will use the fullscreen API.
  114622. */
  114623. enterVR(): void;
  114624. /**
  114625. * Attempt to exit VR, or fullscreen.
  114626. */
  114627. exitVR(): void;
  114628. /**
  114629. * The position of the vr experience helper.
  114630. */
  114631. get position(): Vector3;
  114632. /**
  114633. * Sets the position of the vr experience helper.
  114634. */
  114635. set position(value: Vector3);
  114636. /**
  114637. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  114638. */
  114639. enableInteractions(): void;
  114640. private get _noControllerIsActive();
  114641. private beforeRender;
  114642. private _isTeleportationFloor;
  114643. /**
  114644. * Adds a floor mesh to be used for teleportation.
  114645. * @param floorMesh the mesh to be used for teleportation.
  114646. */
  114647. addFloorMesh(floorMesh: Mesh): void;
  114648. /**
  114649. * Removes a floor mesh from being used for teleportation.
  114650. * @param floorMesh the mesh to be removed.
  114651. */
  114652. removeFloorMesh(floorMesh: Mesh): void;
  114653. /**
  114654. * Enables interactions and teleportation using the VR controllers and gaze.
  114655. * @param vrTeleportationOptions options to modify teleportation behavior.
  114656. */
  114657. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  114658. private _onNewGamepadConnected;
  114659. private _tryEnableInteractionOnController;
  114660. private _onNewGamepadDisconnected;
  114661. private _enableInteractionOnController;
  114662. private _checkTeleportWithRay;
  114663. private _checkRotate;
  114664. private _checkTeleportBackwards;
  114665. private _enableTeleportationOnController;
  114666. private _createTeleportationCircles;
  114667. private _displayTeleportationTarget;
  114668. private _hideTeleportationTarget;
  114669. private _rotateCamera;
  114670. private _moveTeleportationSelectorTo;
  114671. private _workingVector;
  114672. private _workingQuaternion;
  114673. private _workingMatrix;
  114674. /**
  114675. * Time Constant Teleportation Mode
  114676. */
  114677. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  114678. /**
  114679. * Speed Constant Teleportation Mode
  114680. */
  114681. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  114682. /**
  114683. * Teleports the users feet to the desired location
  114684. * @param location The location where the user's feet should be placed
  114685. */
  114686. teleportCamera(location: Vector3): void;
  114687. private _convertNormalToDirectionOfRay;
  114688. private _castRayAndSelectObject;
  114689. private _notifySelectedMeshUnselected;
  114690. /**
  114691. * Sets the color of the laser ray from the vr controllers.
  114692. * @param color new color for the ray.
  114693. */
  114694. changeLaserColor(color: Color3): void;
  114695. /**
  114696. * Sets the color of the ray from the vr headsets gaze.
  114697. * @param color new color for the ray.
  114698. */
  114699. changeGazeColor(color: Color3): void;
  114700. /**
  114701. * Exits VR and disposes of the vr experience helper
  114702. */
  114703. dispose(): void;
  114704. /**
  114705. * Gets the name of the VRExperienceHelper class
  114706. * @returns "VRExperienceHelper"
  114707. */
  114708. getClassName(): string;
  114709. }
  114710. }
  114711. declare module BABYLON {
  114712. /**
  114713. * Options used for hit testing
  114714. */
  114715. export interface IWebXRHitTestOptions {
  114716. /**
  114717. * Only test when user interacted with the scene. Default - hit test every frame
  114718. */
  114719. testOnPointerDownOnly?: boolean;
  114720. /**
  114721. * The node to use to transform the local results to world coordinates
  114722. */
  114723. worldParentNode?: TransformNode;
  114724. }
  114725. /**
  114726. * Interface defining the babylon result of raycasting/hit-test
  114727. */
  114728. export interface IWebXRHitResult {
  114729. /**
  114730. * The native hit test result
  114731. */
  114732. xrHitResult: XRHitResult;
  114733. /**
  114734. * Transformation matrix that can be applied to a node that will put it in the hit point location
  114735. */
  114736. transformationMatrix: Matrix;
  114737. }
  114738. /**
  114739. * The currently-working hit-test module.
  114740. * Hit test (or raycasting) is used to interact with the real world.
  114741. * For further information read here - https://github.com/immersive-web/hit-test
  114742. */
  114743. export class WebXRHitTestLegacy implements IWebXRFeature {
  114744. private _xrSessionManager;
  114745. /**
  114746. * options to use when constructing this feature
  114747. */
  114748. readonly options: IWebXRHitTestOptions;
  114749. /**
  114750. * The module's name
  114751. */
  114752. static readonly Name: string;
  114753. /**
  114754. * The (Babylon) version of this module.
  114755. * This is an integer representing the implementation version.
  114756. * This number does not correspond to the webxr specs version
  114757. */
  114758. static readonly Version: number;
  114759. /**
  114760. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  114761. * @param event the (select) event to use to select with
  114762. * @param referenceSpace the reference space to use for this hit test
  114763. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114764. */
  114765. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  114766. /**
  114767. * execute a hit test with an XR Ray
  114768. *
  114769. * @param xrSession a native xrSession that will execute this hit test
  114770. * @param xrRay the ray (position and direction) to use for raycasting
  114771. * @param referenceSpace native XR reference space to use for the hit-test
  114772. * @param filter filter function that will filter the results
  114773. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114774. */
  114775. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  114776. /**
  114777. * Triggered when new babylon (transformed) hit test results are available
  114778. */
  114779. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  114780. /**
  114781. * Creates a new instance of the (legacy version) hit test feature
  114782. * @param _xrSessionManager an instance of WebXRSessionManager
  114783. * @param options options to use when constructing this feature
  114784. */
  114785. constructor(_xrSessionManager: WebXRSessionManager,
  114786. /**
  114787. * options to use when constructing this feature
  114788. */
  114789. options?: IWebXRHitTestOptions);
  114790. private _onSelectEnabled;
  114791. private _xrFrameObserver;
  114792. private _attached;
  114793. /**
  114794. * Populated with the last native XR Hit Results
  114795. */
  114796. lastNativeXRHitResults: XRHitResult[];
  114797. /**
  114798. * attach this feature
  114799. * Will usually be called by the features manager
  114800. *
  114801. * @returns true if successful.
  114802. */
  114803. attach(): boolean;
  114804. /**
  114805. * detach this feature.
  114806. * Will usually be called by the features manager
  114807. *
  114808. * @returns true if successful.
  114809. */
  114810. detach(): boolean;
  114811. private _onHitTestResults;
  114812. private _onSelect;
  114813. /**
  114814. * Dispose this feature and all of the resources attached
  114815. */
  114816. dispose(): void;
  114817. }
  114818. }
  114819. declare module BABYLON {
  114820. /**
  114821. * Options used in the plane detector module
  114822. */
  114823. export interface IWebXRPlaneDetectorOptions {
  114824. /**
  114825. * The node to use to transform the local results to world coordinates
  114826. */
  114827. worldParentNode?: TransformNode;
  114828. }
  114829. /**
  114830. * A babylon interface for a webxr plane.
  114831. * A Plane is actually a polygon, built from N points in space
  114832. */
  114833. export interface IWebXRPlane {
  114834. /**
  114835. * a babylon-assigned ID for this polygon
  114836. */
  114837. id: number;
  114838. /**
  114839. * the native xr-plane object
  114840. */
  114841. xrPlane: XRPlane;
  114842. /**
  114843. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  114844. */
  114845. polygonDefinition: Array<Vector3>;
  114846. /**
  114847. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  114848. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  114849. */
  114850. transformationMatrix: Matrix;
  114851. }
  114852. /**
  114853. * The plane detector is used to detect planes in the real world when in AR
  114854. * For more information see https://github.com/immersive-web/real-world-geometry/
  114855. */
  114856. export class WebXRPlaneDetector implements IWebXRFeature {
  114857. private _xrSessionManager;
  114858. private _options;
  114859. /**
  114860. * The module's name
  114861. */
  114862. static readonly Name: string;
  114863. /**
  114864. * The (Babylon) version of this module.
  114865. * This is an integer representing the implementation version.
  114866. * This number does not correspond to the webxr specs version
  114867. */
  114868. static readonly Version: number;
  114869. /**
  114870. * Observers registered here will be executed when a new plane was added to the session
  114871. */
  114872. onPlaneAddedObservable: Observable<IWebXRPlane>;
  114873. /**
  114874. * Observers registered here will be executed when a plane is no longer detected in the session
  114875. */
  114876. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  114877. /**
  114878. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  114879. * This can execute N times every frame
  114880. */
  114881. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  114882. private _enabled;
  114883. private _attached;
  114884. private _detectedPlanes;
  114885. private _lastFrameDetected;
  114886. private _observerTracked;
  114887. /**
  114888. * construct a new Plane Detector
  114889. * @param _xrSessionManager an instance of xr Session manager
  114890. * @param _options configuration to use when constructing this feature
  114891. */
  114892. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  114893. /**
  114894. * attach this feature
  114895. * Will usually be called by the features manager
  114896. *
  114897. * @returns true if successful.
  114898. */
  114899. attach(): boolean;
  114900. /**
  114901. * detach this feature.
  114902. * Will usually be called by the features manager
  114903. *
  114904. * @returns true if successful.
  114905. */
  114906. detach(): boolean;
  114907. /**
  114908. * Dispose this feature and all of the resources attached
  114909. */
  114910. dispose(): void;
  114911. private _updatePlaneWithXRPlane;
  114912. /**
  114913. * avoiding using Array.find for global support.
  114914. * @param xrPlane the plane to find in the array
  114915. */
  114916. private findIndexInPlaneArray;
  114917. }
  114918. }
  114919. declare module BABYLON {
  114920. /**
  114921. * Configuration options of the anchor system
  114922. */
  114923. export interface IWebXRAnchorSystemOptions {
  114924. /**
  114925. * a node that will be used to convert local to world coordinates
  114926. */
  114927. worldParentNode?: TransformNode;
  114928. /**
  114929. * should the anchor system use plane detection.
  114930. * If set to true, the plane-detection feature should be set using setPlaneDetector
  114931. */
  114932. usePlaneDetection?: boolean;
  114933. /**
  114934. * Should a new anchor be added every time a select event is triggered
  114935. */
  114936. addAnchorOnSelect?: boolean;
  114937. }
  114938. /**
  114939. * A babylon container for an XR Anchor
  114940. */
  114941. export interface IWebXRAnchor {
  114942. /**
  114943. * A babylon-assigned ID for this anchor
  114944. */
  114945. id: number;
  114946. /**
  114947. * The native anchor object
  114948. */
  114949. xrAnchor: XRAnchor;
  114950. /**
  114951. * Transformation matrix to apply to an object attached to this anchor
  114952. */
  114953. transformationMatrix: Matrix;
  114954. }
  114955. /**
  114956. * An implementation of the anchor system of WebXR.
  114957. * Note that the current documented implementation is not available in any browser. Future implementations
  114958. * will use the frame to create an anchor and not the session or a detected plane
  114959. * For further information see https://github.com/immersive-web/anchors/
  114960. */
  114961. export class WebXRAnchorSystem implements IWebXRFeature {
  114962. private _xrSessionManager;
  114963. private _options;
  114964. /**
  114965. * The module's name
  114966. */
  114967. static readonly Name: string;
  114968. /**
  114969. * The (Babylon) version of this module.
  114970. * This is an integer representing the implementation version.
  114971. * This number does not correspond to the webxr specs version
  114972. */
  114973. static readonly Version: number;
  114974. /**
  114975. * Observers registered here will be executed when a new anchor was added to the session
  114976. */
  114977. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  114978. /**
  114979. * Observers registered here will be executed when an existing anchor updates
  114980. * This can execute N times every frame
  114981. */
  114982. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  114983. /**
  114984. * Observers registered here will be executed when an anchor was removed from the session
  114985. */
  114986. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  114987. private _planeDetector;
  114988. private _hitTestModule;
  114989. private _enabled;
  114990. private _attached;
  114991. private _trackedAnchors;
  114992. private _lastFrameDetected;
  114993. private _observerTracked;
  114994. /**
  114995. * constructs a new anchor system
  114996. * @param _xrSessionManager an instance of WebXRSessionManager
  114997. * @param _options configuration object for this feature
  114998. */
  114999. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  115000. /**
  115001. * set the plane detector to use in order to create anchors from frames
  115002. * @param planeDetector the plane-detector module to use
  115003. * @param enable enable plane-anchors. default is true
  115004. */
  115005. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  115006. /**
  115007. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  115008. * @param hitTestModule the hit-test module to use.
  115009. */
  115010. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  115011. /**
  115012. * attach this feature
  115013. * Will usually be called by the features manager
  115014. *
  115015. * @returns true if successful.
  115016. */
  115017. attach(): boolean;
  115018. /**
  115019. * detach this feature.
  115020. * Will usually be called by the features manager
  115021. *
  115022. * @returns true if successful.
  115023. */
  115024. detach(): boolean;
  115025. /**
  115026. * Dispose this feature and all of the resources attached
  115027. */
  115028. dispose(): void;
  115029. private _onSelect;
  115030. /**
  115031. * Add anchor at a specific XR point.
  115032. *
  115033. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  115034. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  115035. * @returns a promise the fulfills when the anchor was created
  115036. */
  115037. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  115038. private _updateAnchorWithXRFrame;
  115039. /**
  115040. * avoiding using Array.find for global support.
  115041. * @param xrAnchor the plane to find in the array
  115042. */
  115043. private _findIndexInAnchorArray;
  115044. }
  115045. }
  115046. declare module BABYLON {
  115047. /**
  115048. * Options interface for the background remover plugin
  115049. */
  115050. export interface IWebXRBackgroundRemoverOptions {
  115051. /**
  115052. * don't disable the environment helper
  115053. */
  115054. ignoreEnvironmentHelper?: boolean;
  115055. /**
  115056. * flags to configure the removal of the environment helper.
  115057. * If not set, the entire background will be removed. If set, flags should be set as well.
  115058. */
  115059. environmentHelperRemovalFlags?: {
  115060. /**
  115061. * Should the skybox be removed (default false)
  115062. */
  115063. skyBox?: boolean;
  115064. /**
  115065. * Should the ground be removed (default false)
  115066. */
  115067. ground?: boolean;
  115068. };
  115069. /**
  115070. * Further background meshes to disable when entering AR
  115071. */
  115072. backgroundMeshes?: AbstractMesh[];
  115073. }
  115074. /**
  115075. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  115076. */
  115077. export class WebXRBackgroundRemover implements IWebXRFeature {
  115078. private _xrSessionManager;
  115079. /**
  115080. * read-only options to be used in this module
  115081. */
  115082. readonly options: IWebXRBackgroundRemoverOptions;
  115083. /**
  115084. * The module's name
  115085. */
  115086. static readonly Name: string;
  115087. /**
  115088. * The (Babylon) version of this module.
  115089. * This is an integer representing the implementation version.
  115090. * This number does not correspond to the webxr specs version
  115091. */
  115092. static readonly Version: number;
  115093. /**
  115094. * registered observers will be triggered when the background state changes
  115095. */
  115096. onBackgroundStateChangedObservable: Observable<boolean>;
  115097. /**
  115098. * constructs a new background remover module
  115099. * @param _xrSessionManager the session manager for this module
  115100. * @param options read-only options to be used in this module
  115101. */
  115102. constructor(_xrSessionManager: WebXRSessionManager,
  115103. /**
  115104. * read-only options to be used in this module
  115105. */
  115106. options?: IWebXRBackgroundRemoverOptions);
  115107. /**
  115108. * attach this feature
  115109. * Will usually be called by the features manager
  115110. *
  115111. * @returns true if successful.
  115112. */
  115113. attach(): boolean;
  115114. /**
  115115. * detach this feature.
  115116. * Will usually be called by the features manager
  115117. *
  115118. * @returns true if successful.
  115119. */
  115120. detach(): boolean;
  115121. private _setBackgroundState;
  115122. /**
  115123. * Dispose this feature and all of the resources attached
  115124. */
  115125. dispose(): void;
  115126. }
  115127. }
  115128. declare module BABYLON {
  115129. /**
  115130. * Contains an array of blocks representing the octree
  115131. */
  115132. export interface IOctreeContainer<T> {
  115133. /**
  115134. * Blocks within the octree
  115135. */
  115136. blocks: Array<OctreeBlock<T>>;
  115137. }
  115138. /**
  115139. * Class used to store a cell in an octree
  115140. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115141. */
  115142. export class OctreeBlock<T> {
  115143. /**
  115144. * Gets the content of the current block
  115145. */
  115146. entries: T[];
  115147. /**
  115148. * Gets the list of block children
  115149. */
  115150. blocks: Array<OctreeBlock<T>>;
  115151. private _depth;
  115152. private _maxDepth;
  115153. private _capacity;
  115154. private _minPoint;
  115155. private _maxPoint;
  115156. private _boundingVectors;
  115157. private _creationFunc;
  115158. /**
  115159. * Creates a new block
  115160. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  115161. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  115162. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115163. * @param depth defines the current depth of this block in the octree
  115164. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  115165. * @param creationFunc defines a callback to call when an element is added to the block
  115166. */
  115167. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  115168. /**
  115169. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115170. */
  115171. get capacity(): number;
  115172. /**
  115173. * Gets the minimum vector (in world space) of the block's bounding box
  115174. */
  115175. get minPoint(): Vector3;
  115176. /**
  115177. * Gets the maximum vector (in world space) of the block's bounding box
  115178. */
  115179. get maxPoint(): Vector3;
  115180. /**
  115181. * Add a new element to this block
  115182. * @param entry defines the element to add
  115183. */
  115184. addEntry(entry: T): void;
  115185. /**
  115186. * Remove an element from this block
  115187. * @param entry defines the element to remove
  115188. */
  115189. removeEntry(entry: T): void;
  115190. /**
  115191. * Add an array of elements to this block
  115192. * @param entries defines the array of elements to add
  115193. */
  115194. addEntries(entries: T[]): void;
  115195. /**
  115196. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  115197. * @param frustumPlanes defines the frustum planes to test
  115198. * @param selection defines the array to store current content if selection is positive
  115199. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115200. */
  115201. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115202. /**
  115203. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  115204. * @param sphereCenter defines the bounding sphere center
  115205. * @param sphereRadius defines the bounding sphere radius
  115206. * @param selection defines the array to store current content if selection is positive
  115207. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115208. */
  115209. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115210. /**
  115211. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  115212. * @param ray defines the ray to test with
  115213. * @param selection defines the array to store current content if selection is positive
  115214. */
  115215. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  115216. /**
  115217. * Subdivide the content into child blocks (this block will then be empty)
  115218. */
  115219. createInnerBlocks(): void;
  115220. /**
  115221. * @hidden
  115222. */
  115223. 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;
  115224. }
  115225. }
  115226. declare module BABYLON {
  115227. /**
  115228. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  115229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115230. */
  115231. export class Octree<T> {
  115232. /** 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.) */
  115233. maxDepth: number;
  115234. /**
  115235. * Blocks within the octree containing objects
  115236. */
  115237. blocks: Array<OctreeBlock<T>>;
  115238. /**
  115239. * Content stored in the octree
  115240. */
  115241. dynamicContent: T[];
  115242. private _maxBlockCapacity;
  115243. private _selectionContent;
  115244. private _creationFunc;
  115245. /**
  115246. * Creates a octree
  115247. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115248. * @param creationFunc function to be used to instatiate the octree
  115249. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  115250. * @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.)
  115251. */
  115252. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  115253. /** 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.) */
  115254. maxDepth?: number);
  115255. /**
  115256. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  115257. * @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);
  115258. * @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);
  115259. * @param entries meshes to be added to the octree blocks
  115260. */
  115261. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  115262. /**
  115263. * Adds a mesh to the octree
  115264. * @param entry Mesh to add to the octree
  115265. */
  115266. addMesh(entry: T): void;
  115267. /**
  115268. * Remove an element from the octree
  115269. * @param entry defines the element to remove
  115270. */
  115271. removeMesh(entry: T): void;
  115272. /**
  115273. * Selects an array of meshes within the frustum
  115274. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  115275. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  115276. * @returns array of meshes within the frustum
  115277. */
  115278. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  115279. /**
  115280. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  115281. * @param sphereCenter defines the bounding sphere center
  115282. * @param sphereRadius defines the bounding sphere radius
  115283. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115284. * @returns an array of objects that intersect the sphere
  115285. */
  115286. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  115287. /**
  115288. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  115289. * @param ray defines the ray to test with
  115290. * @returns array of intersected objects
  115291. */
  115292. intersectsRay(ray: Ray): SmartArray<T>;
  115293. /**
  115294. * Adds a mesh into the octree block if it intersects the block
  115295. */
  115296. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  115297. /**
  115298. * Adds a submesh into the octree block if it intersects the block
  115299. */
  115300. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  115301. }
  115302. }
  115303. declare module BABYLON {
  115304. interface Scene {
  115305. /**
  115306. * @hidden
  115307. * Backing Filed
  115308. */
  115309. _selectionOctree: Octree<AbstractMesh>;
  115310. /**
  115311. * Gets the octree used to boost mesh selection (picking)
  115312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115313. */
  115314. selectionOctree: Octree<AbstractMesh>;
  115315. /**
  115316. * Creates or updates the octree used to boost selection (picking)
  115317. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115318. * @param maxCapacity defines the maximum capacity per leaf
  115319. * @param maxDepth defines the maximum depth of the octree
  115320. * @returns an octree of AbstractMesh
  115321. */
  115322. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  115323. }
  115324. interface AbstractMesh {
  115325. /**
  115326. * @hidden
  115327. * Backing Field
  115328. */
  115329. _submeshesOctree: Octree<SubMesh>;
  115330. /**
  115331. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  115332. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  115333. * @param maxCapacity defines the maximum size of each block (64 by default)
  115334. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  115335. * @returns the new octree
  115336. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  115337. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115338. */
  115339. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  115340. }
  115341. /**
  115342. * Defines the octree scene component responsible to manage any octrees
  115343. * in a given scene.
  115344. */
  115345. export class OctreeSceneComponent {
  115346. /**
  115347. * The component name help to identify the component in the list of scene components.
  115348. */
  115349. readonly name: string;
  115350. /**
  115351. * The scene the component belongs to.
  115352. */
  115353. scene: Scene;
  115354. /**
  115355. * Indicates if the meshes have been checked to make sure they are isEnabled()
  115356. */
  115357. readonly checksIsEnabled: boolean;
  115358. /**
  115359. * Creates a new instance of the component for the given scene
  115360. * @param scene Defines the scene to register the component in
  115361. */
  115362. constructor(scene: Scene);
  115363. /**
  115364. * Registers the component in a given scene
  115365. */
  115366. register(): void;
  115367. /**
  115368. * Return the list of active meshes
  115369. * @returns the list of active meshes
  115370. */
  115371. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  115372. /**
  115373. * Return the list of active sub meshes
  115374. * @param mesh The mesh to get the candidates sub meshes from
  115375. * @returns the list of active sub meshes
  115376. */
  115377. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  115378. private _tempRay;
  115379. /**
  115380. * Return the list of sub meshes intersecting with a given local ray
  115381. * @param mesh defines the mesh to find the submesh for
  115382. * @param localRay defines the ray in local space
  115383. * @returns the list of intersecting sub meshes
  115384. */
  115385. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  115386. /**
  115387. * Return the list of sub meshes colliding with a collider
  115388. * @param mesh defines the mesh to find the submesh for
  115389. * @param collider defines the collider to evaluate the collision against
  115390. * @returns the list of colliding sub meshes
  115391. */
  115392. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  115393. /**
  115394. * Rebuilds the elements related to this component in case of
  115395. * context lost for instance.
  115396. */
  115397. rebuild(): void;
  115398. /**
  115399. * Disposes the component and the associated ressources.
  115400. */
  115401. dispose(): void;
  115402. }
  115403. }
  115404. declare module BABYLON {
  115405. /**
  115406. * Renders a layer on top of an existing scene
  115407. */
  115408. export class UtilityLayerRenderer implements IDisposable {
  115409. /** the original scene that will be rendered on top of */
  115410. originalScene: Scene;
  115411. private _pointerCaptures;
  115412. private _lastPointerEvents;
  115413. private static _DefaultUtilityLayer;
  115414. private static _DefaultKeepDepthUtilityLayer;
  115415. private _sharedGizmoLight;
  115416. private _renderCamera;
  115417. /**
  115418. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  115419. * @returns the camera that is used when rendering the utility layer
  115420. */
  115421. getRenderCamera(): Nullable<Camera>;
  115422. /**
  115423. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  115424. * @param cam the camera that should be used when rendering the utility layer
  115425. */
  115426. setRenderCamera(cam: Nullable<Camera>): void;
  115427. /**
  115428. * @hidden
  115429. * Light which used by gizmos to get light shading
  115430. */
  115431. _getSharedGizmoLight(): HemisphericLight;
  115432. /**
  115433. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  115434. */
  115435. pickUtilitySceneFirst: boolean;
  115436. /**
  115437. * 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)
  115438. */
  115439. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  115440. /**
  115441. * 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)
  115442. */
  115443. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  115444. /**
  115445. * The scene that is rendered on top of the original scene
  115446. */
  115447. utilityLayerScene: Scene;
  115448. /**
  115449. * If the utility layer should automatically be rendered on top of existing scene
  115450. */
  115451. shouldRender: boolean;
  115452. /**
  115453. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  115454. */
  115455. onlyCheckPointerDownEvents: boolean;
  115456. /**
  115457. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  115458. */
  115459. processAllEvents: boolean;
  115460. /**
  115461. * Observable raised when the pointer move from the utility layer scene to the main scene
  115462. */
  115463. onPointerOutObservable: Observable<number>;
  115464. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  115465. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  115466. private _afterRenderObserver;
  115467. private _sceneDisposeObserver;
  115468. private _originalPointerObserver;
  115469. /**
  115470. * Instantiates a UtilityLayerRenderer
  115471. * @param originalScene the original scene that will be rendered on top of
  115472. * @param handleEvents boolean indicating if the utility layer should handle events
  115473. */
  115474. constructor(
  115475. /** the original scene that will be rendered on top of */
  115476. originalScene: Scene, handleEvents?: boolean);
  115477. private _notifyObservers;
  115478. /**
  115479. * Renders the utility layers scene on top of the original scene
  115480. */
  115481. render(): void;
  115482. /**
  115483. * Disposes of the renderer
  115484. */
  115485. dispose(): void;
  115486. private _updateCamera;
  115487. }
  115488. }
  115489. declare module BABYLON {
  115490. /**
  115491. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  115492. */
  115493. export class Gizmo implements IDisposable {
  115494. /** The utility layer the gizmo will be added to */
  115495. gizmoLayer: UtilityLayerRenderer;
  115496. /**
  115497. * The root mesh of the gizmo
  115498. */
  115499. _rootMesh: Mesh;
  115500. private _attachedMesh;
  115501. /**
  115502. * Ratio for the scale of the gizmo (Default: 1)
  115503. */
  115504. scaleRatio: number;
  115505. /**
  115506. * If a custom mesh has been set (Default: false)
  115507. */
  115508. protected _customMeshSet: boolean;
  115509. /**
  115510. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  115511. * * When set, interactions will be enabled
  115512. */
  115513. get attachedMesh(): Nullable<AbstractMesh>;
  115514. set attachedMesh(value: Nullable<AbstractMesh>);
  115515. /**
  115516. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115517. * @param mesh The mesh to replace the default mesh of the gizmo
  115518. */
  115519. setCustomMesh(mesh: Mesh): void;
  115520. /**
  115521. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  115522. */
  115523. updateGizmoRotationToMatchAttachedMesh: boolean;
  115524. /**
  115525. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  115526. */
  115527. updateGizmoPositionToMatchAttachedMesh: boolean;
  115528. /**
  115529. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  115530. */
  115531. updateScale: boolean;
  115532. protected _interactionsEnabled: boolean;
  115533. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115534. private _beforeRenderObserver;
  115535. private _tempVector;
  115536. /**
  115537. * Creates a gizmo
  115538. * @param gizmoLayer The utility layer the gizmo will be added to
  115539. */
  115540. constructor(
  115541. /** The utility layer the gizmo will be added to */
  115542. gizmoLayer?: UtilityLayerRenderer);
  115543. /**
  115544. * Updates the gizmo to match the attached mesh's position/rotation
  115545. */
  115546. protected _update(): void;
  115547. /**
  115548. * Disposes of the gizmo
  115549. */
  115550. dispose(): void;
  115551. }
  115552. }
  115553. declare module BABYLON {
  115554. /**
  115555. * Single plane drag gizmo
  115556. */
  115557. export class PlaneDragGizmo extends Gizmo {
  115558. /**
  115559. * Drag behavior responsible for the gizmos dragging interactions
  115560. */
  115561. dragBehavior: PointerDragBehavior;
  115562. private _pointerObserver;
  115563. /**
  115564. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115565. */
  115566. snapDistance: number;
  115567. /**
  115568. * Event that fires each time the gizmo snaps to a new location.
  115569. * * snapDistance is the the change in distance
  115570. */
  115571. onSnapObservable: Observable<{
  115572. snapDistance: number;
  115573. }>;
  115574. private _plane;
  115575. private _coloredMaterial;
  115576. private _hoverMaterial;
  115577. private _isEnabled;
  115578. private _parent;
  115579. /** @hidden */
  115580. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  115581. /** @hidden */
  115582. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115583. /**
  115584. * Creates a PlaneDragGizmo
  115585. * @param gizmoLayer The utility layer the gizmo will be added to
  115586. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  115587. * @param color The color of the gizmo
  115588. */
  115589. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115590. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115591. /**
  115592. * If the gizmo is enabled
  115593. */
  115594. set isEnabled(value: boolean);
  115595. get isEnabled(): boolean;
  115596. /**
  115597. * Disposes of the gizmo
  115598. */
  115599. dispose(): void;
  115600. }
  115601. }
  115602. declare module BABYLON {
  115603. /**
  115604. * Gizmo that enables dragging a mesh along 3 axis
  115605. */
  115606. export class PositionGizmo extends Gizmo {
  115607. /**
  115608. * Internal gizmo used for interactions on the x axis
  115609. */
  115610. xGizmo: AxisDragGizmo;
  115611. /**
  115612. * Internal gizmo used for interactions on the y axis
  115613. */
  115614. yGizmo: AxisDragGizmo;
  115615. /**
  115616. * Internal gizmo used for interactions on the z axis
  115617. */
  115618. zGizmo: AxisDragGizmo;
  115619. /**
  115620. * Internal gizmo used for interactions on the yz plane
  115621. */
  115622. xPlaneGizmo: PlaneDragGizmo;
  115623. /**
  115624. * Internal gizmo used for interactions on the xz plane
  115625. */
  115626. yPlaneGizmo: PlaneDragGizmo;
  115627. /**
  115628. * Internal gizmo used for interactions on the xy plane
  115629. */
  115630. zPlaneGizmo: PlaneDragGizmo;
  115631. /**
  115632. * private variables
  115633. */
  115634. private _meshAttached;
  115635. private _updateGizmoRotationToMatchAttachedMesh;
  115636. private _snapDistance;
  115637. private _scaleRatio;
  115638. /** Fires an event when any of it's sub gizmos are dragged */
  115639. onDragStartObservable: Observable<unknown>;
  115640. /** Fires an event when any of it's sub gizmos are released from dragging */
  115641. onDragEndObservable: Observable<unknown>;
  115642. /**
  115643. * If set to true, planar drag is enabled
  115644. */
  115645. private _planarGizmoEnabled;
  115646. get attachedMesh(): Nullable<AbstractMesh>;
  115647. set attachedMesh(mesh: Nullable<AbstractMesh>);
  115648. /**
  115649. * Creates a PositionGizmo
  115650. * @param gizmoLayer The utility layer the gizmo will be added to
  115651. */
  115652. constructor(gizmoLayer?: UtilityLayerRenderer);
  115653. /**
  115654. * If the planar drag gizmo is enabled
  115655. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  115656. */
  115657. set planarGizmoEnabled(value: boolean);
  115658. get planarGizmoEnabled(): boolean;
  115659. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  115660. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  115661. /**
  115662. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115663. */
  115664. set snapDistance(value: number);
  115665. get snapDistance(): number;
  115666. /**
  115667. * Ratio for the scale of the gizmo (Default: 1)
  115668. */
  115669. set scaleRatio(value: number);
  115670. get scaleRatio(): number;
  115671. /**
  115672. * Disposes of the gizmo
  115673. */
  115674. dispose(): void;
  115675. /**
  115676. * CustomMeshes are not supported by this gizmo
  115677. * @param mesh The mesh to replace the default mesh of the gizmo
  115678. */
  115679. setCustomMesh(mesh: Mesh): void;
  115680. }
  115681. }
  115682. declare module BABYLON {
  115683. /**
  115684. * Single axis drag gizmo
  115685. */
  115686. export class AxisDragGizmo extends Gizmo {
  115687. /**
  115688. * Drag behavior responsible for the gizmos dragging interactions
  115689. */
  115690. dragBehavior: PointerDragBehavior;
  115691. private _pointerObserver;
  115692. /**
  115693. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115694. */
  115695. snapDistance: number;
  115696. /**
  115697. * Event that fires each time the gizmo snaps to a new location.
  115698. * * snapDistance is the the change in distance
  115699. */
  115700. onSnapObservable: Observable<{
  115701. snapDistance: number;
  115702. }>;
  115703. private _isEnabled;
  115704. private _parent;
  115705. private _arrow;
  115706. private _coloredMaterial;
  115707. private _hoverMaterial;
  115708. /** @hidden */
  115709. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  115710. /** @hidden */
  115711. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115712. /**
  115713. * Creates an AxisDragGizmo
  115714. * @param gizmoLayer The utility layer the gizmo will be added to
  115715. * @param dragAxis The axis which the gizmo will be able to drag on
  115716. * @param color The color of the gizmo
  115717. */
  115718. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115719. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115720. /**
  115721. * If the gizmo is enabled
  115722. */
  115723. set isEnabled(value: boolean);
  115724. get isEnabled(): boolean;
  115725. /**
  115726. * Disposes of the gizmo
  115727. */
  115728. dispose(): void;
  115729. }
  115730. }
  115731. declare module BABYLON.Debug {
  115732. /**
  115733. * The Axes viewer will show 3 axes in a specific point in space
  115734. */
  115735. export class AxesViewer {
  115736. private _xAxis;
  115737. private _yAxis;
  115738. private _zAxis;
  115739. private _scaleLinesFactor;
  115740. private _instanced;
  115741. /**
  115742. * Gets the hosting scene
  115743. */
  115744. scene: Scene;
  115745. /**
  115746. * Gets or sets a number used to scale line length
  115747. */
  115748. scaleLines: number;
  115749. /** Gets the node hierarchy used to render x-axis */
  115750. get xAxis(): TransformNode;
  115751. /** Gets the node hierarchy used to render y-axis */
  115752. get yAxis(): TransformNode;
  115753. /** Gets the node hierarchy used to render z-axis */
  115754. get zAxis(): TransformNode;
  115755. /**
  115756. * Creates a new AxesViewer
  115757. * @param scene defines the hosting scene
  115758. * @param scaleLines defines a number used to scale line length (1 by default)
  115759. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  115760. * @param xAxis defines the node hierarchy used to render the x-axis
  115761. * @param yAxis defines the node hierarchy used to render the y-axis
  115762. * @param zAxis defines the node hierarchy used to render the z-axis
  115763. */
  115764. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  115765. /**
  115766. * Force the viewer to update
  115767. * @param position defines the position of the viewer
  115768. * @param xaxis defines the x axis of the viewer
  115769. * @param yaxis defines the y axis of the viewer
  115770. * @param zaxis defines the z axis of the viewer
  115771. */
  115772. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  115773. /**
  115774. * Creates an instance of this axes viewer.
  115775. * @returns a new axes viewer with instanced meshes
  115776. */
  115777. createInstance(): AxesViewer;
  115778. /** Releases resources */
  115779. dispose(): void;
  115780. private static _SetRenderingGroupId;
  115781. }
  115782. }
  115783. declare module BABYLON.Debug {
  115784. /**
  115785. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  115786. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  115787. */
  115788. export class BoneAxesViewer extends AxesViewer {
  115789. /**
  115790. * Gets or sets the target mesh where to display the axes viewer
  115791. */
  115792. mesh: Nullable<Mesh>;
  115793. /**
  115794. * Gets or sets the target bone where to display the axes viewer
  115795. */
  115796. bone: Nullable<Bone>;
  115797. /** Gets current position */
  115798. pos: Vector3;
  115799. /** Gets direction of X axis */
  115800. xaxis: Vector3;
  115801. /** Gets direction of Y axis */
  115802. yaxis: Vector3;
  115803. /** Gets direction of Z axis */
  115804. zaxis: Vector3;
  115805. /**
  115806. * Creates a new BoneAxesViewer
  115807. * @param scene defines the hosting scene
  115808. * @param bone defines the target bone
  115809. * @param mesh defines the target mesh
  115810. * @param scaleLines defines a scaling factor for line length (1 by default)
  115811. */
  115812. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  115813. /**
  115814. * Force the viewer to update
  115815. */
  115816. update(): void;
  115817. /** Releases resources */
  115818. dispose(): void;
  115819. }
  115820. }
  115821. declare module BABYLON {
  115822. /**
  115823. * Interface used to define scene explorer extensibility option
  115824. */
  115825. export interface IExplorerExtensibilityOption {
  115826. /**
  115827. * Define the option label
  115828. */
  115829. label: string;
  115830. /**
  115831. * Defines the action to execute on click
  115832. */
  115833. action: (entity: any) => void;
  115834. }
  115835. /**
  115836. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  115837. */
  115838. export interface IExplorerExtensibilityGroup {
  115839. /**
  115840. * Defines a predicate to test if a given type mut be extended
  115841. */
  115842. predicate: (entity: any) => boolean;
  115843. /**
  115844. * Gets the list of options added to a type
  115845. */
  115846. entries: IExplorerExtensibilityOption[];
  115847. }
  115848. /**
  115849. * Interface used to define the options to use to create the Inspector
  115850. */
  115851. export interface IInspectorOptions {
  115852. /**
  115853. * Display in overlay mode (default: false)
  115854. */
  115855. overlay?: boolean;
  115856. /**
  115857. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  115858. */
  115859. globalRoot?: HTMLElement;
  115860. /**
  115861. * Display the Scene explorer
  115862. */
  115863. showExplorer?: boolean;
  115864. /**
  115865. * Display the property inspector
  115866. */
  115867. showInspector?: boolean;
  115868. /**
  115869. * Display in embed mode (both panes on the right)
  115870. */
  115871. embedMode?: boolean;
  115872. /**
  115873. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  115874. */
  115875. handleResize?: boolean;
  115876. /**
  115877. * Allow the panes to popup (default: true)
  115878. */
  115879. enablePopup?: boolean;
  115880. /**
  115881. * Allow the panes to be closed by users (default: true)
  115882. */
  115883. enableClose?: boolean;
  115884. /**
  115885. * Optional list of extensibility entries
  115886. */
  115887. explorerExtensibility?: IExplorerExtensibilityGroup[];
  115888. /**
  115889. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  115890. */
  115891. inspectorURL?: string;
  115892. /**
  115893. * Optional initial tab (default to DebugLayerTab.Properties)
  115894. */
  115895. initialTab?: DebugLayerTab;
  115896. }
  115897. interface Scene {
  115898. /**
  115899. * @hidden
  115900. * Backing field
  115901. */
  115902. _debugLayer: DebugLayer;
  115903. /**
  115904. * Gets the debug layer (aka Inspector) associated with the scene
  115905. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115906. */
  115907. debugLayer: DebugLayer;
  115908. }
  115909. /**
  115910. * Enum of inspector action tab
  115911. */
  115912. export enum DebugLayerTab {
  115913. /**
  115914. * Properties tag (default)
  115915. */
  115916. Properties = 0,
  115917. /**
  115918. * Debug tab
  115919. */
  115920. Debug = 1,
  115921. /**
  115922. * Statistics tab
  115923. */
  115924. Statistics = 2,
  115925. /**
  115926. * Tools tab
  115927. */
  115928. Tools = 3,
  115929. /**
  115930. * Settings tab
  115931. */
  115932. Settings = 4
  115933. }
  115934. /**
  115935. * The debug layer (aka Inspector) is the go to tool in order to better understand
  115936. * what is happening in your scene
  115937. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115938. */
  115939. export class DebugLayer {
  115940. /**
  115941. * Define the url to get the inspector script from.
  115942. * By default it uses the babylonjs CDN.
  115943. * @ignoreNaming
  115944. */
  115945. static InspectorURL: string;
  115946. private _scene;
  115947. private BJSINSPECTOR;
  115948. private _onPropertyChangedObservable?;
  115949. /**
  115950. * Observable triggered when a property is changed through the inspector.
  115951. */
  115952. get onPropertyChangedObservable(): any;
  115953. /**
  115954. * Instantiates a new debug layer.
  115955. * The debug layer (aka Inspector) is the go to tool in order to better understand
  115956. * what is happening in your scene
  115957. * @see http://doc.babylonjs.com/features/playground_debuglayer
  115958. * @param scene Defines the scene to inspect
  115959. */
  115960. constructor(scene: Scene);
  115961. /** Creates the inspector window. */
  115962. private _createInspector;
  115963. /**
  115964. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  115965. * @param entity defines the entity to select
  115966. * @param lineContainerTitle defines the specific block to highlight
  115967. */
  115968. select(entity: any, lineContainerTitle?: string): void;
  115969. /** Get the inspector from bundle or global */
  115970. private _getGlobalInspector;
  115971. /**
  115972. * Get if the inspector is visible or not.
  115973. * @returns true if visible otherwise, false
  115974. */
  115975. isVisible(): boolean;
  115976. /**
  115977. * Hide the inspector and close its window.
  115978. */
  115979. hide(): void;
  115980. /**
  115981. * Launch the debugLayer.
  115982. * @param config Define the configuration of the inspector
  115983. * @return a promise fulfilled when the debug layer is visible
  115984. */
  115985. show(config?: IInspectorOptions): Promise<DebugLayer>;
  115986. }
  115987. }
  115988. declare module BABYLON {
  115989. /**
  115990. * Class containing static functions to help procedurally build meshes
  115991. */
  115992. export class BoxBuilder {
  115993. /**
  115994. * Creates a box mesh
  115995. * * The parameter `size` sets the size (float) of each box side (default 1)
  115996. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115997. * * 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)
  115998. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116002. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  116003. * @param name defines the name of the mesh
  116004. * @param options defines the options used to create the mesh
  116005. * @param scene defines the hosting scene
  116006. * @returns the box mesh
  116007. */
  116008. static CreateBox(name: string, options: {
  116009. size?: number;
  116010. width?: number;
  116011. height?: number;
  116012. depth?: number;
  116013. faceUV?: Vector4[];
  116014. faceColors?: Color4[];
  116015. sideOrientation?: number;
  116016. frontUVs?: Vector4;
  116017. backUVs?: Vector4;
  116018. wrap?: boolean;
  116019. topBaseAt?: number;
  116020. bottomBaseAt?: number;
  116021. updatable?: boolean;
  116022. }, scene?: Nullable<Scene>): Mesh;
  116023. }
  116024. }
  116025. declare module BABYLON {
  116026. /**
  116027. * Class containing static functions to help procedurally build meshes
  116028. */
  116029. export class SphereBuilder {
  116030. /**
  116031. * Creates a sphere mesh
  116032. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116033. * * 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`)
  116034. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116035. * * 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
  116036. * * 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)
  116037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116040. * @param name defines the name of the mesh
  116041. * @param options defines the options used to create the mesh
  116042. * @param scene defines the hosting scene
  116043. * @returns the sphere mesh
  116044. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116045. */
  116046. static CreateSphere(name: string, options: {
  116047. segments?: number;
  116048. diameter?: number;
  116049. diameterX?: number;
  116050. diameterY?: number;
  116051. diameterZ?: number;
  116052. arc?: number;
  116053. slice?: number;
  116054. sideOrientation?: number;
  116055. frontUVs?: Vector4;
  116056. backUVs?: Vector4;
  116057. updatable?: boolean;
  116058. }, scene?: Nullable<Scene>): Mesh;
  116059. }
  116060. }
  116061. declare module BABYLON.Debug {
  116062. /**
  116063. * Used to show the physics impostor around the specific mesh
  116064. */
  116065. export class PhysicsViewer {
  116066. /** @hidden */
  116067. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  116068. /** @hidden */
  116069. protected _meshes: Array<Nullable<AbstractMesh>>;
  116070. /** @hidden */
  116071. protected _scene: Nullable<Scene>;
  116072. /** @hidden */
  116073. protected _numMeshes: number;
  116074. /** @hidden */
  116075. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  116076. private _renderFunction;
  116077. private _utilityLayer;
  116078. private _debugBoxMesh;
  116079. private _debugSphereMesh;
  116080. private _debugCylinderMesh;
  116081. private _debugMaterial;
  116082. private _debugMeshMeshes;
  116083. /**
  116084. * Creates a new PhysicsViewer
  116085. * @param scene defines the hosting scene
  116086. */
  116087. constructor(scene: Scene);
  116088. /** @hidden */
  116089. protected _updateDebugMeshes(): void;
  116090. /**
  116091. * Renders a specified physic impostor
  116092. * @param impostor defines the impostor to render
  116093. * @param targetMesh defines the mesh represented by the impostor
  116094. * @returns the new debug mesh used to render the impostor
  116095. */
  116096. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  116097. /**
  116098. * Hides a specified physic impostor
  116099. * @param impostor defines the impostor to hide
  116100. */
  116101. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  116102. private _getDebugMaterial;
  116103. private _getDebugBoxMesh;
  116104. private _getDebugSphereMesh;
  116105. private _getDebugCylinderMesh;
  116106. private _getDebugMeshMesh;
  116107. private _getDebugMesh;
  116108. /** Releases all resources */
  116109. dispose(): void;
  116110. }
  116111. }
  116112. declare module BABYLON {
  116113. /**
  116114. * Class containing static functions to help procedurally build meshes
  116115. */
  116116. export class LinesBuilder {
  116117. /**
  116118. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116119. * * 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
  116120. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116121. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116122. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116123. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116124. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116125. * * 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
  116126. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116129. * @param name defines the name of the new line system
  116130. * @param options defines the options used to create the line system
  116131. * @param scene defines the hosting scene
  116132. * @returns a new line system mesh
  116133. */
  116134. static CreateLineSystem(name: string, options: {
  116135. lines: Vector3[][];
  116136. updatable?: boolean;
  116137. instance?: Nullable<LinesMesh>;
  116138. colors?: Nullable<Color4[][]>;
  116139. useVertexAlpha?: boolean;
  116140. }, scene: Nullable<Scene>): LinesMesh;
  116141. /**
  116142. * Creates a line mesh
  116143. * 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
  116144. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116145. * * The parameter `points` is an array successive Vector3
  116146. * * 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
  116147. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116148. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116149. * * When updating an instance, remember that only point positions can change, not the number of points
  116150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116152. * @param name defines the name of the new line system
  116153. * @param options defines the options used to create the line system
  116154. * @param scene defines the hosting scene
  116155. * @returns a new line mesh
  116156. */
  116157. static CreateLines(name: string, options: {
  116158. points: Vector3[];
  116159. updatable?: boolean;
  116160. instance?: Nullable<LinesMesh>;
  116161. colors?: Color4[];
  116162. useVertexAlpha?: boolean;
  116163. }, scene?: Nullable<Scene>): LinesMesh;
  116164. /**
  116165. * Creates a dashed line mesh
  116166. * * 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
  116167. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116168. * * The parameter `points` is an array successive Vector3
  116169. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116170. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116171. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116172. * * 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
  116173. * * When updating an instance, remember that only point positions can change, not the number of points
  116174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116175. * @param name defines the name of the mesh
  116176. * @param options defines the options used to create the mesh
  116177. * @param scene defines the hosting scene
  116178. * @returns the dashed line mesh
  116179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116180. */
  116181. static CreateDashedLines(name: string, options: {
  116182. points: Vector3[];
  116183. dashSize?: number;
  116184. gapSize?: number;
  116185. dashNb?: number;
  116186. updatable?: boolean;
  116187. instance?: LinesMesh;
  116188. }, scene?: Nullable<Scene>): LinesMesh;
  116189. }
  116190. }
  116191. declare module BABYLON {
  116192. /**
  116193. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116194. * in order to better appreciate the issue one might have.
  116195. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116196. */
  116197. export class RayHelper {
  116198. /**
  116199. * Defines the ray we are currently tryin to visualize.
  116200. */
  116201. ray: Nullable<Ray>;
  116202. private _renderPoints;
  116203. private _renderLine;
  116204. private _renderFunction;
  116205. private _scene;
  116206. private _updateToMeshFunction;
  116207. private _attachedToMesh;
  116208. private _meshSpaceDirection;
  116209. private _meshSpaceOrigin;
  116210. /**
  116211. * Helper function to create a colored helper in a scene in one line.
  116212. * @param ray Defines the ray we are currently tryin to visualize
  116213. * @param scene Defines the scene the ray is used in
  116214. * @param color Defines the color we want to see the ray in
  116215. * @returns The newly created ray helper.
  116216. */
  116217. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  116218. /**
  116219. * Instantiate a new ray helper.
  116220. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116221. * in order to better appreciate the issue one might have.
  116222. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116223. * @param ray Defines the ray we are currently tryin to visualize
  116224. */
  116225. constructor(ray: Ray);
  116226. /**
  116227. * Shows the ray we are willing to debug.
  116228. * @param scene Defines the scene the ray needs to be rendered in
  116229. * @param color Defines the color the ray needs to be rendered in
  116230. */
  116231. show(scene: Scene, color?: Color3): void;
  116232. /**
  116233. * Hides the ray we are debugging.
  116234. */
  116235. hide(): void;
  116236. private _render;
  116237. /**
  116238. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  116239. * @param mesh Defines the mesh we want the helper attached to
  116240. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  116241. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  116242. * @param length Defines the length of the ray
  116243. */
  116244. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  116245. /**
  116246. * Detach the ray helper from the mesh it has previously been attached to.
  116247. */
  116248. detachFromMesh(): void;
  116249. private _updateToMesh;
  116250. /**
  116251. * Dispose the helper and release its associated resources.
  116252. */
  116253. dispose(): void;
  116254. }
  116255. }
  116256. declare module BABYLON.Debug {
  116257. /**
  116258. * Class used to render a debug view of a given skeleton
  116259. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  116260. */
  116261. export class SkeletonViewer {
  116262. /** defines the skeleton to render */
  116263. skeleton: Skeleton;
  116264. /** defines the mesh attached to the skeleton */
  116265. mesh: AbstractMesh;
  116266. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116267. autoUpdateBonesMatrices: boolean;
  116268. /** defines the rendering group id to use with the viewer */
  116269. renderingGroupId: number;
  116270. /** Gets or sets the color used to render the skeleton */
  116271. color: Color3;
  116272. private _scene;
  116273. private _debugLines;
  116274. private _debugMesh;
  116275. private _isEnabled;
  116276. private _renderFunction;
  116277. private _utilityLayer;
  116278. /**
  116279. * Returns the mesh used to render the bones
  116280. */
  116281. get debugMesh(): Nullable<LinesMesh>;
  116282. /**
  116283. * Creates a new SkeletonViewer
  116284. * @param skeleton defines the skeleton to render
  116285. * @param mesh defines the mesh attached to the skeleton
  116286. * @param scene defines the hosting scene
  116287. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  116288. * @param renderingGroupId defines the rendering group id to use with the viewer
  116289. */
  116290. constructor(
  116291. /** defines the skeleton to render */
  116292. skeleton: Skeleton,
  116293. /** defines the mesh attached to the skeleton */
  116294. mesh: AbstractMesh, scene: Scene,
  116295. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116296. autoUpdateBonesMatrices?: boolean,
  116297. /** defines the rendering group id to use with the viewer */
  116298. renderingGroupId?: number);
  116299. /** Gets or sets a boolean indicating if the viewer is enabled */
  116300. set isEnabled(value: boolean);
  116301. get isEnabled(): boolean;
  116302. private _getBonePosition;
  116303. private _getLinesForBonesWithLength;
  116304. private _getLinesForBonesNoLength;
  116305. /** Update the viewer to sync with current skeleton state */
  116306. update(): void;
  116307. /** Release associated resources */
  116308. dispose(): void;
  116309. }
  116310. }
  116311. declare module BABYLON {
  116312. /**
  116313. * Options to create the null engine
  116314. */
  116315. export class NullEngineOptions {
  116316. /**
  116317. * Render width (Default: 512)
  116318. */
  116319. renderWidth: number;
  116320. /**
  116321. * Render height (Default: 256)
  116322. */
  116323. renderHeight: number;
  116324. /**
  116325. * Texture size (Default: 512)
  116326. */
  116327. textureSize: number;
  116328. /**
  116329. * If delta time between frames should be constant
  116330. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116331. */
  116332. deterministicLockstep: boolean;
  116333. /**
  116334. * Maximum about of steps between frames (Default: 4)
  116335. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116336. */
  116337. lockstepMaxSteps: number;
  116338. }
  116339. /**
  116340. * The null engine class provides support for headless version of babylon.js.
  116341. * This can be used in server side scenario or for testing purposes
  116342. */
  116343. export class NullEngine extends Engine {
  116344. private _options;
  116345. /**
  116346. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116347. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116348. * @returns true if engine is in deterministic lock step mode
  116349. */
  116350. isDeterministicLockStep(): boolean;
  116351. /**
  116352. * Gets the max steps when engine is running in deterministic lock step
  116353. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116354. * @returns the max steps
  116355. */
  116356. getLockstepMaxSteps(): number;
  116357. /**
  116358. * Gets the current hardware scaling level.
  116359. * By default the hardware scaling level is computed from the window device ratio.
  116360. * 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.
  116361. * @returns a number indicating the current hardware scaling level
  116362. */
  116363. getHardwareScalingLevel(): number;
  116364. constructor(options?: NullEngineOptions);
  116365. /**
  116366. * Creates a vertex buffer
  116367. * @param vertices the data for the vertex buffer
  116368. * @returns the new WebGL static buffer
  116369. */
  116370. createVertexBuffer(vertices: FloatArray): DataBuffer;
  116371. /**
  116372. * Creates a new index buffer
  116373. * @param indices defines the content of the index buffer
  116374. * @param updatable defines if the index buffer must be updatable
  116375. * @returns a new webGL buffer
  116376. */
  116377. createIndexBuffer(indices: IndicesArray): DataBuffer;
  116378. /**
  116379. * Clear the current render buffer or the current render target (if any is set up)
  116380. * @param color defines the color to use
  116381. * @param backBuffer defines if the back buffer must be cleared
  116382. * @param depth defines if the depth buffer must be cleared
  116383. * @param stencil defines if the stencil buffer must be cleared
  116384. */
  116385. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116386. /**
  116387. * Gets the current render width
  116388. * @param useScreen defines if screen size must be used (or the current render target if any)
  116389. * @returns a number defining the current render width
  116390. */
  116391. getRenderWidth(useScreen?: boolean): number;
  116392. /**
  116393. * Gets the current render height
  116394. * @param useScreen defines if screen size must be used (or the current render target if any)
  116395. * @returns a number defining the current render height
  116396. */
  116397. getRenderHeight(useScreen?: boolean): number;
  116398. /**
  116399. * Set the WebGL's viewport
  116400. * @param viewport defines the viewport element to be used
  116401. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116402. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116403. */
  116404. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116405. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  116406. /**
  116407. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116408. * @param pipelineContext defines the pipeline context to use
  116409. * @param uniformsNames defines the list of uniform names
  116410. * @returns an array of webGL uniform locations
  116411. */
  116412. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116413. /**
  116414. * Gets the lsit of active attributes for a given webGL program
  116415. * @param pipelineContext defines the pipeline context to use
  116416. * @param attributesNames defines the list of attribute names to get
  116417. * @returns an array of indices indicating the offset of each attribute
  116418. */
  116419. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116420. /**
  116421. * Binds an effect to the webGL context
  116422. * @param effect defines the effect to bind
  116423. */
  116424. bindSamplers(effect: Effect): void;
  116425. /**
  116426. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116427. * @param effect defines the effect to activate
  116428. */
  116429. enableEffect(effect: Effect): void;
  116430. /**
  116431. * Set various states to the webGL context
  116432. * @param culling defines backface culling state
  116433. * @param zOffset defines the value to apply to zOffset (0 by default)
  116434. * @param force defines if states must be applied even if cache is up to date
  116435. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116436. */
  116437. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116438. /**
  116439. * Set the value of an uniform to an array of int32
  116440. * @param uniform defines the webGL uniform location where to store the value
  116441. * @param array defines the array of int32 to store
  116442. */
  116443. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  116444. /**
  116445. * Set the value of an uniform to an array of int32 (stored as vec2)
  116446. * @param uniform defines the webGL uniform location where to store the value
  116447. * @param array defines the array of int32 to store
  116448. */
  116449. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  116450. /**
  116451. * Set the value of an uniform to an array of int32 (stored as vec3)
  116452. * @param uniform defines the webGL uniform location where to store the value
  116453. * @param array defines the array of int32 to store
  116454. */
  116455. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  116456. /**
  116457. * Set the value of an uniform to an array of int32 (stored as vec4)
  116458. * @param uniform defines the webGL uniform location where to store the value
  116459. * @param array defines the array of int32 to store
  116460. */
  116461. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  116462. /**
  116463. * Set the value of an uniform to an array of float32
  116464. * @param uniform defines the webGL uniform location where to store the value
  116465. * @param array defines the array of float32 to store
  116466. */
  116467. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  116468. /**
  116469. * Set the value of an uniform to an array of float32 (stored as vec2)
  116470. * @param uniform defines the webGL uniform location where to store the value
  116471. * @param array defines the array of float32 to store
  116472. */
  116473. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  116474. /**
  116475. * Set the value of an uniform to an array of float32 (stored as vec3)
  116476. * @param uniform defines the webGL uniform location where to store the value
  116477. * @param array defines the array of float32 to store
  116478. */
  116479. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  116480. /**
  116481. * Set the value of an uniform to an array of float32 (stored as vec4)
  116482. * @param uniform defines the webGL uniform location where to store the value
  116483. * @param array defines the array of float32 to store
  116484. */
  116485. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  116486. /**
  116487. * Set the value of an uniform to an array of number
  116488. * @param uniform defines the webGL uniform location where to store the value
  116489. * @param array defines the array of number to store
  116490. */
  116491. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  116492. /**
  116493. * Set the value of an uniform to an array of number (stored as vec2)
  116494. * @param uniform defines the webGL uniform location where to store the value
  116495. * @param array defines the array of number to store
  116496. */
  116497. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  116498. /**
  116499. * Set the value of an uniform to an array of number (stored as vec3)
  116500. * @param uniform defines the webGL uniform location where to store the value
  116501. * @param array defines the array of number to store
  116502. */
  116503. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  116504. /**
  116505. * Set the value of an uniform to an array of number (stored as vec4)
  116506. * @param uniform defines the webGL uniform location where to store the value
  116507. * @param array defines the array of number to store
  116508. */
  116509. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  116510. /**
  116511. * Set the value of an uniform to an array of float32 (stored as matrices)
  116512. * @param uniform defines the webGL uniform location where to store the value
  116513. * @param matrices defines the array of float32 to store
  116514. */
  116515. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  116516. /**
  116517. * Set the value of an uniform to a matrix (3x3)
  116518. * @param uniform defines the webGL uniform location where to store the value
  116519. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116520. */
  116521. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116522. /**
  116523. * Set the value of an uniform to a matrix (2x2)
  116524. * @param uniform defines the webGL uniform location where to store the value
  116525. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116526. */
  116527. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116528. /**
  116529. * Set the value of an uniform to a number (float)
  116530. * @param uniform defines the webGL uniform location where to store the value
  116531. * @param value defines the float number to store
  116532. */
  116533. setFloat(uniform: WebGLUniformLocation, value: number): void;
  116534. /**
  116535. * Set the value of an uniform to a vec2
  116536. * @param uniform defines the webGL uniform location where to store the value
  116537. * @param x defines the 1st component of the value
  116538. * @param y defines the 2nd component of the value
  116539. */
  116540. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  116541. /**
  116542. * Set the value of an uniform to a vec3
  116543. * @param uniform defines the webGL uniform location where to store the value
  116544. * @param x defines the 1st component of the value
  116545. * @param y defines the 2nd component of the value
  116546. * @param z defines the 3rd component of the value
  116547. */
  116548. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  116549. /**
  116550. * Set the value of an uniform to a boolean
  116551. * @param uniform defines the webGL uniform location where to store the value
  116552. * @param bool defines the boolean to store
  116553. */
  116554. setBool(uniform: WebGLUniformLocation, bool: number): void;
  116555. /**
  116556. * Set the value of an uniform to a vec4
  116557. * @param uniform defines the webGL uniform location where to store the value
  116558. * @param x defines the 1st component of the value
  116559. * @param y defines the 2nd component of the value
  116560. * @param z defines the 3rd component of the value
  116561. * @param w defines the 4th component of the value
  116562. */
  116563. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  116564. /**
  116565. * Sets the current alpha mode
  116566. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  116567. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116568. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116569. */
  116570. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116571. /**
  116572. * Bind webGl buffers directly to the webGL context
  116573. * @param vertexBuffers defines the vertex buffer to bind
  116574. * @param indexBuffer defines the index buffer to bind
  116575. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116576. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116577. * @param effect defines the effect associated with the vertex buffer
  116578. */
  116579. bindBuffers(vertexBuffers: {
  116580. [key: string]: VertexBuffer;
  116581. }, indexBuffer: DataBuffer, effect: Effect): void;
  116582. /**
  116583. * Force the entire cache to be cleared
  116584. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116585. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116586. */
  116587. wipeCaches(bruteForce?: boolean): void;
  116588. /**
  116589. * Send a draw order
  116590. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116591. * @param indexStart defines the starting index
  116592. * @param indexCount defines the number of index to draw
  116593. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116594. */
  116595. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116596. /**
  116597. * Draw a list of indexed primitives
  116598. * @param fillMode defines the primitive to use
  116599. * @param indexStart defines the starting index
  116600. * @param indexCount defines the number of index to draw
  116601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116602. */
  116603. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116604. /**
  116605. * Draw a list of unindexed primitives
  116606. * @param fillMode defines the primitive to use
  116607. * @param verticesStart defines the index of first vertex to draw
  116608. * @param verticesCount defines the count of vertices to draw
  116609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116610. */
  116611. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116612. /** @hidden */
  116613. _createTexture(): WebGLTexture;
  116614. /** @hidden */
  116615. _releaseTexture(texture: InternalTexture): void;
  116616. /**
  116617. * Usually called from Texture.ts.
  116618. * Passed information to create a WebGLTexture
  116619. * @param urlArg defines a value which contains one of the following:
  116620. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116621. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116622. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116623. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116624. * @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)
  116625. * @param scene needed for loading to the correct scene
  116626. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116627. * @param onLoad optional callback to be called upon successful completion
  116628. * @param onError optional callback to be called upon failure
  116629. * @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
  116630. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116631. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116632. * @param forcedExtension defines the extension to use to pick the right loader
  116633. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  116634. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116635. */
  116636. 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;
  116637. /**
  116638. * Creates a new render target texture
  116639. * @param size defines the size of the texture
  116640. * @param options defines the options used to create the texture
  116641. * @returns a new render target texture stored in an InternalTexture
  116642. */
  116643. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  116644. /**
  116645. * Update the sampling mode of a given texture
  116646. * @param samplingMode defines the required sampling mode
  116647. * @param texture defines the texture to update
  116648. */
  116649. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  116650. /**
  116651. * Binds the frame buffer to the specified texture.
  116652. * @param texture The texture to render to or null for the default canvas
  116653. * @param faceIndex The face of the texture to render to in case of cube texture
  116654. * @param requiredWidth The width of the target to render to
  116655. * @param requiredHeight The height of the target to render to
  116656. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116657. * @param depthStencilTexture The depth stencil texture to use to render
  116658. * @param lodLevel defines le lod level to bind to the frame buffer
  116659. */
  116660. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  116661. /**
  116662. * Unbind the current render target texture from the webGL context
  116663. * @param texture defines the render target texture to unbind
  116664. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116665. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116666. */
  116667. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116668. /**
  116669. * Creates a dynamic vertex buffer
  116670. * @param vertices the data for the dynamic vertex buffer
  116671. * @returns the new WebGL dynamic buffer
  116672. */
  116673. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  116674. /**
  116675. * Update the content of a dynamic texture
  116676. * @param texture defines the texture to update
  116677. * @param canvas defines the canvas containing the source
  116678. * @param invertY defines if data must be stored with Y axis inverted
  116679. * @param premulAlpha defines if alpha is stored as premultiplied
  116680. * @param format defines the format of the data
  116681. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  116682. */
  116683. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  116684. /**
  116685. * Gets a boolean indicating if all created effects are ready
  116686. * @returns true if all effects are ready
  116687. */
  116688. areAllEffectsReady(): boolean;
  116689. /**
  116690. * @hidden
  116691. * Get the current error code of the webGL context
  116692. * @returns the error code
  116693. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116694. */
  116695. getError(): number;
  116696. /** @hidden */
  116697. _getUnpackAlignement(): number;
  116698. /** @hidden */
  116699. _unpackFlipY(value: boolean): void;
  116700. /**
  116701. * Update a dynamic index buffer
  116702. * @param indexBuffer defines the target index buffer
  116703. * @param indices defines the data to update
  116704. * @param offset defines the offset in the target index buffer where update should start
  116705. */
  116706. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  116707. /**
  116708. * Updates a dynamic vertex buffer.
  116709. * @param vertexBuffer the vertex buffer to update
  116710. * @param vertices the data used to update the vertex buffer
  116711. * @param byteOffset the byte offset of the data (optional)
  116712. * @param byteLength the byte length of the data (optional)
  116713. */
  116714. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  116715. /** @hidden */
  116716. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  116717. /** @hidden */
  116718. _bindTexture(channel: number, texture: InternalTexture): void;
  116719. protected _deleteBuffer(buffer: WebGLBuffer): void;
  116720. /**
  116721. * 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
  116722. */
  116723. releaseEffects(): void;
  116724. displayLoadingUI(): void;
  116725. hideLoadingUI(): void;
  116726. /** @hidden */
  116727. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116728. /** @hidden */
  116729. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116730. /** @hidden */
  116731. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116732. /** @hidden */
  116733. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  116734. }
  116735. }
  116736. declare module BABYLON {
  116737. /** @hidden */
  116738. export class _OcclusionDataStorage {
  116739. /** @hidden */
  116740. occlusionInternalRetryCounter: number;
  116741. /** @hidden */
  116742. isOcclusionQueryInProgress: boolean;
  116743. /** @hidden */
  116744. isOccluded: boolean;
  116745. /** @hidden */
  116746. occlusionRetryCount: number;
  116747. /** @hidden */
  116748. occlusionType: number;
  116749. /** @hidden */
  116750. occlusionQueryAlgorithmType: number;
  116751. }
  116752. interface Engine {
  116753. /**
  116754. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  116755. * @return the new query
  116756. */
  116757. createQuery(): WebGLQuery;
  116758. /**
  116759. * Delete and release a webGL query
  116760. * @param query defines the query to delete
  116761. * @return the current engine
  116762. */
  116763. deleteQuery(query: WebGLQuery): Engine;
  116764. /**
  116765. * Check if a given query has resolved and got its value
  116766. * @param query defines the query to check
  116767. * @returns true if the query got its value
  116768. */
  116769. isQueryResultAvailable(query: WebGLQuery): boolean;
  116770. /**
  116771. * Gets the value of a given query
  116772. * @param query defines the query to check
  116773. * @returns the value of the query
  116774. */
  116775. getQueryResult(query: WebGLQuery): number;
  116776. /**
  116777. * Initiates an occlusion query
  116778. * @param algorithmType defines the algorithm to use
  116779. * @param query defines the query to use
  116780. * @returns the current engine
  116781. * @see http://doc.babylonjs.com/features/occlusionquery
  116782. */
  116783. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  116784. /**
  116785. * Ends an occlusion query
  116786. * @see http://doc.babylonjs.com/features/occlusionquery
  116787. * @param algorithmType defines the algorithm to use
  116788. * @returns the current engine
  116789. */
  116790. endOcclusionQuery(algorithmType: number): Engine;
  116791. /**
  116792. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  116793. * Please note that only one query can be issued at a time
  116794. * @returns a time token used to track the time span
  116795. */
  116796. startTimeQuery(): Nullable<_TimeToken>;
  116797. /**
  116798. * Ends a time query
  116799. * @param token defines the token used to measure the time span
  116800. * @returns the time spent (in ns)
  116801. */
  116802. endTimeQuery(token: _TimeToken): int;
  116803. /** @hidden */
  116804. _currentNonTimestampToken: Nullable<_TimeToken>;
  116805. /** @hidden */
  116806. _createTimeQuery(): WebGLQuery;
  116807. /** @hidden */
  116808. _deleteTimeQuery(query: WebGLQuery): void;
  116809. /** @hidden */
  116810. _getGlAlgorithmType(algorithmType: number): number;
  116811. /** @hidden */
  116812. _getTimeQueryResult(query: WebGLQuery): any;
  116813. /** @hidden */
  116814. _getTimeQueryAvailability(query: WebGLQuery): any;
  116815. }
  116816. interface AbstractMesh {
  116817. /**
  116818. * Backing filed
  116819. * @hidden
  116820. */
  116821. __occlusionDataStorage: _OcclusionDataStorage;
  116822. /**
  116823. * Access property
  116824. * @hidden
  116825. */
  116826. _occlusionDataStorage: _OcclusionDataStorage;
  116827. /**
  116828. * 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.
  116829. * The default value is -1 which means don't break the query and wait till the result
  116830. * @see http://doc.babylonjs.com/features/occlusionquery
  116831. */
  116832. occlusionRetryCount: number;
  116833. /**
  116834. * 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:
  116835. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  116836. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  116837. * * 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.
  116838. * @see http://doc.babylonjs.com/features/occlusionquery
  116839. */
  116840. occlusionType: number;
  116841. /**
  116842. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  116843. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  116844. * * 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.
  116845. * @see http://doc.babylonjs.com/features/occlusionquery
  116846. */
  116847. occlusionQueryAlgorithmType: number;
  116848. /**
  116849. * 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
  116850. * @see http://doc.babylonjs.com/features/occlusionquery
  116851. */
  116852. isOccluded: boolean;
  116853. /**
  116854. * Flag to check the progress status of the query
  116855. * @see http://doc.babylonjs.com/features/occlusionquery
  116856. */
  116857. isOcclusionQueryInProgress: boolean;
  116858. }
  116859. }
  116860. declare module BABYLON {
  116861. /** @hidden */
  116862. export var _forceTransformFeedbackToBundle: boolean;
  116863. interface Engine {
  116864. /**
  116865. * Creates a webGL transform feedback object
  116866. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  116867. * @returns the webGL transform feedback object
  116868. */
  116869. createTransformFeedback(): WebGLTransformFeedback;
  116870. /**
  116871. * Delete a webGL transform feedback object
  116872. * @param value defines the webGL transform feedback object to delete
  116873. */
  116874. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  116875. /**
  116876. * Bind a webGL transform feedback object to the webgl context
  116877. * @param value defines the webGL transform feedback object to bind
  116878. */
  116879. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  116880. /**
  116881. * Begins a transform feedback operation
  116882. * @param usePoints defines if points or triangles must be used
  116883. */
  116884. beginTransformFeedback(usePoints: boolean): void;
  116885. /**
  116886. * Ends a transform feedback operation
  116887. */
  116888. endTransformFeedback(): void;
  116889. /**
  116890. * Specify the varyings to use with transform feedback
  116891. * @param program defines the associated webGL program
  116892. * @param value defines the list of strings representing the varying names
  116893. */
  116894. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  116895. /**
  116896. * Bind a webGL buffer for a transform feedback operation
  116897. * @param value defines the webGL buffer to bind
  116898. */
  116899. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  116900. }
  116901. }
  116902. declare module BABYLON {
  116903. /**
  116904. * Creation options of the multi render target texture.
  116905. */
  116906. export interface IMultiRenderTargetOptions {
  116907. /**
  116908. * Define if the texture needs to create mip maps after render.
  116909. */
  116910. generateMipMaps?: boolean;
  116911. /**
  116912. * Define the types of all the draw buffers we want to create
  116913. */
  116914. types?: number[];
  116915. /**
  116916. * Define the sampling modes of all the draw buffers we want to create
  116917. */
  116918. samplingModes?: number[];
  116919. /**
  116920. * Define if a depth buffer is required
  116921. */
  116922. generateDepthBuffer?: boolean;
  116923. /**
  116924. * Define if a stencil buffer is required
  116925. */
  116926. generateStencilBuffer?: boolean;
  116927. /**
  116928. * Define if a depth texture is required instead of a depth buffer
  116929. */
  116930. generateDepthTexture?: boolean;
  116931. /**
  116932. * Define the number of desired draw buffers
  116933. */
  116934. textureCount?: number;
  116935. /**
  116936. * Define if aspect ratio should be adapted to the texture or stay the scene one
  116937. */
  116938. doNotChangeAspectRatio?: boolean;
  116939. /**
  116940. * Define the default type of the buffers we are creating
  116941. */
  116942. defaultType?: number;
  116943. }
  116944. /**
  116945. * A multi render target, like a render target provides the ability to render to a texture.
  116946. * Unlike the render target, it can render to several draw buffers in one draw.
  116947. * This is specially interesting in deferred rendering or for any effects requiring more than
  116948. * just one color from a single pass.
  116949. */
  116950. export class MultiRenderTarget extends RenderTargetTexture {
  116951. private _internalTextures;
  116952. private _textures;
  116953. private _multiRenderTargetOptions;
  116954. /**
  116955. * Get if draw buffers are currently supported by the used hardware and browser.
  116956. */
  116957. get isSupported(): boolean;
  116958. /**
  116959. * Get the list of textures generated by the multi render target.
  116960. */
  116961. get textures(): Texture[];
  116962. /**
  116963. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  116964. */
  116965. get depthTexture(): Texture;
  116966. /**
  116967. * Set the wrapping mode on U of all the textures we are rendering to.
  116968. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  116969. */
  116970. set wrapU(wrap: number);
  116971. /**
  116972. * Set the wrapping mode on V of all the textures we are rendering to.
  116973. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  116974. */
  116975. set wrapV(wrap: number);
  116976. /**
  116977. * Instantiate a new multi render target texture.
  116978. * A multi render target, like a render target provides the ability to render to a texture.
  116979. * Unlike the render target, it can render to several draw buffers in one draw.
  116980. * This is specially interesting in deferred rendering or for any effects requiring more than
  116981. * just one color from a single pass.
  116982. * @param name Define the name of the texture
  116983. * @param size Define the size of the buffers to render to
  116984. * @param count Define the number of target we are rendering into
  116985. * @param scene Define the scene the texture belongs to
  116986. * @param options Define the options used to create the multi render target
  116987. */
  116988. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  116989. /** @hidden */
  116990. _rebuild(): void;
  116991. private _createInternalTextures;
  116992. private _createTextures;
  116993. /**
  116994. * Define the number of samples used if MSAA is enabled.
  116995. */
  116996. get samples(): number;
  116997. set samples(value: number);
  116998. /**
  116999. * Resize all the textures in the multi render target.
  117000. * Be carrefull as it will recreate all the data in the new texture.
  117001. * @param size Define the new size
  117002. */
  117003. resize(size: any): void;
  117004. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  117005. /**
  117006. * Dispose the render targets and their associated resources
  117007. */
  117008. dispose(): void;
  117009. /**
  117010. * Release all the underlying texture used as draw buffers.
  117011. */
  117012. releaseInternalTextures(): void;
  117013. }
  117014. }
  117015. declare module BABYLON {
  117016. interface ThinEngine {
  117017. /**
  117018. * Unbind a list of render target textures from the webGL context
  117019. * This is used only when drawBuffer extension or webGL2 are active
  117020. * @param textures defines the render target textures to unbind
  117021. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  117022. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  117023. */
  117024. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  117025. /**
  117026. * Create a multi render target texture
  117027. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  117028. * @param size defines the size of the texture
  117029. * @param options defines the creation options
  117030. * @returns the cube texture as an InternalTexture
  117031. */
  117032. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  117033. /**
  117034. * Update the sample count for a given multiple render target texture
  117035. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117036. * @param textures defines the textures to update
  117037. * @param samples defines the sample count to set
  117038. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117039. */
  117040. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  117041. }
  117042. }
  117043. declare module BABYLON {
  117044. /**
  117045. * Class used to define an additional view for the engine
  117046. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117047. */
  117048. export class EngineView {
  117049. /** Defines the canvas where to render the view */
  117050. target: HTMLCanvasElement;
  117051. /** Defines an optional camera used to render the view (will use active camera else) */
  117052. camera?: Camera;
  117053. }
  117054. interface Engine {
  117055. /**
  117056. * Gets or sets the HTML element to use for attaching events
  117057. */
  117058. inputElement: Nullable<HTMLElement>;
  117059. /**
  117060. * Gets the current engine view
  117061. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117062. */
  117063. activeView: Nullable<EngineView>;
  117064. /** Gets or sets the list of views */
  117065. views: EngineView[];
  117066. /**
  117067. * Register a new child canvas
  117068. * @param canvas defines the canvas to register
  117069. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  117070. * @returns the associated view
  117071. */
  117072. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  117073. /**
  117074. * Remove a registered child canvas
  117075. * @param canvas defines the canvas to remove
  117076. * @returns the current engine
  117077. */
  117078. unRegisterView(canvas: HTMLCanvasElement): Engine;
  117079. }
  117080. }
  117081. declare module BABYLON {
  117082. /**
  117083. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  117084. */
  117085. export interface CubeMapInfo {
  117086. /**
  117087. * The pixel array for the front face.
  117088. * This is stored in format, left to right, up to down format.
  117089. */
  117090. front: Nullable<ArrayBufferView>;
  117091. /**
  117092. * The pixel array for the back face.
  117093. * This is stored in format, left to right, up to down format.
  117094. */
  117095. back: Nullable<ArrayBufferView>;
  117096. /**
  117097. * The pixel array for the left face.
  117098. * This is stored in format, left to right, up to down format.
  117099. */
  117100. left: Nullable<ArrayBufferView>;
  117101. /**
  117102. * The pixel array for the right face.
  117103. * This is stored in format, left to right, up to down format.
  117104. */
  117105. right: Nullable<ArrayBufferView>;
  117106. /**
  117107. * The pixel array for the up face.
  117108. * This is stored in format, left to right, up to down format.
  117109. */
  117110. up: Nullable<ArrayBufferView>;
  117111. /**
  117112. * The pixel array for the down face.
  117113. * This is stored in format, left to right, up to down format.
  117114. */
  117115. down: Nullable<ArrayBufferView>;
  117116. /**
  117117. * The size of the cubemap stored.
  117118. *
  117119. * Each faces will be size * size pixels.
  117120. */
  117121. size: number;
  117122. /**
  117123. * The format of the texture.
  117124. *
  117125. * RGBA, RGB.
  117126. */
  117127. format: number;
  117128. /**
  117129. * The type of the texture data.
  117130. *
  117131. * UNSIGNED_INT, FLOAT.
  117132. */
  117133. type: number;
  117134. /**
  117135. * Specifies whether the texture is in gamma space.
  117136. */
  117137. gammaSpace: boolean;
  117138. }
  117139. /**
  117140. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  117141. */
  117142. export class PanoramaToCubeMapTools {
  117143. private static FACE_FRONT;
  117144. private static FACE_BACK;
  117145. private static FACE_RIGHT;
  117146. private static FACE_LEFT;
  117147. private static FACE_DOWN;
  117148. private static FACE_UP;
  117149. /**
  117150. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  117151. *
  117152. * @param float32Array The source data.
  117153. * @param inputWidth The width of the input panorama.
  117154. * @param inputHeight The height of the input panorama.
  117155. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  117156. * @return The cubemap data
  117157. */
  117158. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  117159. private static CreateCubemapTexture;
  117160. private static CalcProjectionSpherical;
  117161. }
  117162. }
  117163. declare module BABYLON {
  117164. /**
  117165. * Helper class dealing with the extraction of spherical polynomial dataArray
  117166. * from a cube map.
  117167. */
  117168. export class CubeMapToSphericalPolynomialTools {
  117169. private static FileFaces;
  117170. /**
  117171. * Converts a texture to the according Spherical Polynomial data.
  117172. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117173. *
  117174. * @param texture The texture to extract the information from.
  117175. * @return The Spherical Polynomial data.
  117176. */
  117177. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  117178. /**
  117179. * Converts a cubemap to the according Spherical Polynomial data.
  117180. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117181. *
  117182. * @param cubeInfo The Cube map to extract the information from.
  117183. * @return The Spherical Polynomial data.
  117184. */
  117185. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  117186. }
  117187. }
  117188. declare module BABYLON {
  117189. interface BaseTexture {
  117190. /**
  117191. * Get the polynomial representation of the texture data.
  117192. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  117193. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  117194. */
  117195. sphericalPolynomial: Nullable<SphericalPolynomial>;
  117196. }
  117197. }
  117198. declare module BABYLON {
  117199. /** @hidden */
  117200. export var rgbdEncodePixelShader: {
  117201. name: string;
  117202. shader: string;
  117203. };
  117204. }
  117205. declare module BABYLON {
  117206. /** @hidden */
  117207. export var rgbdDecodePixelShader: {
  117208. name: string;
  117209. shader: string;
  117210. };
  117211. }
  117212. declare module BABYLON {
  117213. /**
  117214. * Raw texture data and descriptor sufficient for WebGL texture upload
  117215. */
  117216. export interface EnvironmentTextureInfo {
  117217. /**
  117218. * Version of the environment map
  117219. */
  117220. version: number;
  117221. /**
  117222. * Width of image
  117223. */
  117224. width: number;
  117225. /**
  117226. * Irradiance information stored in the file.
  117227. */
  117228. irradiance: any;
  117229. /**
  117230. * Specular information stored in the file.
  117231. */
  117232. specular: any;
  117233. }
  117234. /**
  117235. * Defines One Image in the file. It requires only the position in the file
  117236. * as well as the length.
  117237. */
  117238. interface BufferImageData {
  117239. /**
  117240. * Length of the image data.
  117241. */
  117242. length: number;
  117243. /**
  117244. * Position of the data from the null terminator delimiting the end of the JSON.
  117245. */
  117246. position: number;
  117247. }
  117248. /**
  117249. * Defines the specular data enclosed in the file.
  117250. * This corresponds to the version 1 of the data.
  117251. */
  117252. export interface EnvironmentTextureSpecularInfoV1 {
  117253. /**
  117254. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  117255. */
  117256. specularDataPosition?: number;
  117257. /**
  117258. * This contains all the images data needed to reconstruct the cubemap.
  117259. */
  117260. mipmaps: Array<BufferImageData>;
  117261. /**
  117262. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  117263. */
  117264. lodGenerationScale: number;
  117265. }
  117266. /**
  117267. * Sets of helpers addressing the serialization and deserialization of environment texture
  117268. * stored in a BabylonJS env file.
  117269. * Those files are usually stored as .env files.
  117270. */
  117271. export class EnvironmentTextureTools {
  117272. /**
  117273. * Magic number identifying the env file.
  117274. */
  117275. private static _MagicBytes;
  117276. /**
  117277. * Gets the environment info from an env file.
  117278. * @param data The array buffer containing the .env bytes.
  117279. * @returns the environment file info (the json header) if successfully parsed.
  117280. */
  117281. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  117282. /**
  117283. * Creates an environment texture from a loaded cube texture.
  117284. * @param texture defines the cube texture to convert in env file
  117285. * @return a promise containing the environment data if succesfull.
  117286. */
  117287. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  117288. /**
  117289. * Creates a JSON representation of the spherical data.
  117290. * @param texture defines the texture containing the polynomials
  117291. * @return the JSON representation of the spherical info
  117292. */
  117293. private static _CreateEnvTextureIrradiance;
  117294. /**
  117295. * Creates the ArrayBufferViews used for initializing environment texture image data.
  117296. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  117297. * @param info parameters that determine what views will be created for accessing the underlying buffer
  117298. * @return the views described by info providing access to the underlying buffer
  117299. */
  117300. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  117301. /**
  117302. * Uploads the texture info contained in the env file to the GPU.
  117303. * @param texture defines the internal texture to upload to
  117304. * @param arrayBuffer defines the buffer cotaining the data to load
  117305. * @param info defines the texture info retrieved through the GetEnvInfo method
  117306. * @returns a promise
  117307. */
  117308. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  117309. private static _OnImageReadyAsync;
  117310. /**
  117311. * Uploads the levels of image data to the GPU.
  117312. * @param texture defines the internal texture to upload to
  117313. * @param imageData defines the array buffer views of image data [mipmap][face]
  117314. * @returns a promise
  117315. */
  117316. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  117317. /**
  117318. * Uploads spherical polynomials information to the texture.
  117319. * @param texture defines the texture we are trying to upload the information to
  117320. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  117321. */
  117322. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  117323. /** @hidden */
  117324. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117325. }
  117326. }
  117327. declare module BABYLON {
  117328. /**
  117329. * Contains position and normal vectors for a vertex
  117330. */
  117331. export class PositionNormalVertex {
  117332. /** the position of the vertex (defaut: 0,0,0) */
  117333. position: Vector3;
  117334. /** the normal of the vertex (defaut: 0,1,0) */
  117335. normal: Vector3;
  117336. /**
  117337. * Creates a PositionNormalVertex
  117338. * @param position the position of the vertex (defaut: 0,0,0)
  117339. * @param normal the normal of the vertex (defaut: 0,1,0)
  117340. */
  117341. constructor(
  117342. /** the position of the vertex (defaut: 0,0,0) */
  117343. position?: Vector3,
  117344. /** the normal of the vertex (defaut: 0,1,0) */
  117345. normal?: Vector3);
  117346. /**
  117347. * Clones the PositionNormalVertex
  117348. * @returns the cloned PositionNormalVertex
  117349. */
  117350. clone(): PositionNormalVertex;
  117351. }
  117352. /**
  117353. * Contains position, normal and uv vectors for a vertex
  117354. */
  117355. export class PositionNormalTextureVertex {
  117356. /** the position of the vertex (defaut: 0,0,0) */
  117357. position: Vector3;
  117358. /** the normal of the vertex (defaut: 0,1,0) */
  117359. normal: Vector3;
  117360. /** the uv of the vertex (default: 0,0) */
  117361. uv: Vector2;
  117362. /**
  117363. * Creates a PositionNormalTextureVertex
  117364. * @param position the position of the vertex (defaut: 0,0,0)
  117365. * @param normal the normal of the vertex (defaut: 0,1,0)
  117366. * @param uv the uv of the vertex (default: 0,0)
  117367. */
  117368. constructor(
  117369. /** the position of the vertex (defaut: 0,0,0) */
  117370. position?: Vector3,
  117371. /** the normal of the vertex (defaut: 0,1,0) */
  117372. normal?: Vector3,
  117373. /** the uv of the vertex (default: 0,0) */
  117374. uv?: Vector2);
  117375. /**
  117376. * Clones the PositionNormalTextureVertex
  117377. * @returns the cloned PositionNormalTextureVertex
  117378. */
  117379. clone(): PositionNormalTextureVertex;
  117380. }
  117381. }
  117382. declare module BABYLON {
  117383. /** @hidden */
  117384. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  117385. private _genericAttributeLocation;
  117386. private _varyingLocationCount;
  117387. private _varyingLocationMap;
  117388. private _replacements;
  117389. private _textureCount;
  117390. private _uniforms;
  117391. lineProcessor(line: string): string;
  117392. attributeProcessor(attribute: string): string;
  117393. varyingProcessor(varying: string, isFragment: boolean): string;
  117394. uniformProcessor(uniform: string): string;
  117395. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  117396. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  117397. }
  117398. }
  117399. declare module BABYLON {
  117400. /**
  117401. * Container for accessors for natively-stored mesh data buffers.
  117402. */
  117403. class NativeDataBuffer extends DataBuffer {
  117404. /**
  117405. * Accessor value used to identify/retrieve a natively-stored index buffer.
  117406. */
  117407. nativeIndexBuffer?: any;
  117408. /**
  117409. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  117410. */
  117411. nativeVertexBuffer?: any;
  117412. }
  117413. /** @hidden */
  117414. class NativeTexture extends InternalTexture {
  117415. getInternalTexture(): InternalTexture;
  117416. getViewCount(): number;
  117417. }
  117418. /** @hidden */
  117419. export class NativeEngine extends Engine {
  117420. private readonly _native;
  117421. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  117422. private readonly INVALID_HANDLE;
  117423. getHardwareScalingLevel(): number;
  117424. constructor();
  117425. /**
  117426. * Can be used to override the current requestAnimationFrame requester.
  117427. * @hidden
  117428. */
  117429. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  117430. /**
  117431. * Override default engine behavior.
  117432. * @param color
  117433. * @param backBuffer
  117434. * @param depth
  117435. * @param stencil
  117436. */
  117437. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  117438. /**
  117439. * Gets host document
  117440. * @returns the host document object
  117441. */
  117442. getHostDocument(): Nullable<Document>;
  117443. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  117444. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  117445. createVertexBuffer(data: DataArray): NativeDataBuffer;
  117446. recordVertexArrayObject(vertexBuffers: {
  117447. [key: string]: VertexBuffer;
  117448. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  117449. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117450. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117451. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  117452. /**
  117453. * Draw a list of indexed primitives
  117454. * @param fillMode defines the primitive to use
  117455. * @param indexStart defines the starting index
  117456. * @param indexCount defines the number of index to draw
  117457. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117458. */
  117459. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  117460. /**
  117461. * Draw a list of unindexed primitives
  117462. * @param fillMode defines the primitive to use
  117463. * @param verticesStart defines the index of first vertex to draw
  117464. * @param verticesCount defines the count of vertices to draw
  117465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117466. */
  117467. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  117468. createPipelineContext(): IPipelineContext;
  117469. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  117470. /** @hidden */
  117471. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  117472. /** @hidden */
  117473. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  117474. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117475. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117476. protected _setProgram(program: WebGLProgram): void;
  117477. _releaseEffect(effect: Effect): void;
  117478. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117479. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  117480. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  117481. bindSamplers(effect: Effect): void;
  117482. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  117483. getRenderWidth(useScreen?: boolean): number;
  117484. getRenderHeight(useScreen?: boolean): number;
  117485. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  117486. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117487. /**
  117488. * Set the z offset to apply to current rendering
  117489. * @param value defines the offset to apply
  117490. */
  117491. setZOffset(value: number): void;
  117492. /**
  117493. * Gets the current value of the zOffset
  117494. * @returns the current zOffset state
  117495. */
  117496. getZOffset(): number;
  117497. /**
  117498. * Enable or disable depth buffering
  117499. * @param enable defines the state to set
  117500. */
  117501. setDepthBuffer(enable: boolean): void;
  117502. /**
  117503. * Gets a boolean indicating if depth writing is enabled
  117504. * @returns the current depth writing state
  117505. */
  117506. getDepthWrite(): boolean;
  117507. /**
  117508. * Enable or disable depth writing
  117509. * @param enable defines the state to set
  117510. */
  117511. setDepthWrite(enable: boolean): void;
  117512. /**
  117513. * Enable or disable color writing
  117514. * @param enable defines the state to set
  117515. */
  117516. setColorWrite(enable: boolean): void;
  117517. /**
  117518. * Gets a boolean indicating if color writing is enabled
  117519. * @returns the current color writing state
  117520. */
  117521. getColorWrite(): boolean;
  117522. /**
  117523. * Sets alpha constants used by some alpha blending modes
  117524. * @param r defines the red component
  117525. * @param g defines the green component
  117526. * @param b defines the blue component
  117527. * @param a defines the alpha component
  117528. */
  117529. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  117530. /**
  117531. * Sets the current alpha mode
  117532. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  117533. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  117534. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117535. */
  117536. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  117537. /**
  117538. * Gets the current alpha mode
  117539. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117540. * @returns the current alpha mode
  117541. */
  117542. getAlphaMode(): number;
  117543. setInt(uniform: WebGLUniformLocation, int: number): void;
  117544. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  117545. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  117546. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  117547. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  117548. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  117549. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  117550. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  117551. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  117552. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  117553. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  117554. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  117555. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  117556. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  117557. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117558. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117559. setFloat(uniform: WebGLUniformLocation, value: number): void;
  117560. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  117561. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  117562. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  117563. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  117564. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  117565. wipeCaches(bruteForce?: boolean): void;
  117566. _createTexture(): WebGLTexture;
  117567. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  117568. /**
  117569. * Usually called from BABYLON.Texture.ts.
  117570. * Passed information to create a WebGLTexture
  117571. * @param urlArg defines a value which contains one of the following:
  117572. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  117573. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  117574. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  117575. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  117576. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  117577. * @param scene needed for loading to the correct scene
  117578. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  117579. * @param onLoad optional callback to be called upon successful completion
  117580. * @param onError optional callback to be called upon failure
  117581. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  117582. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  117583. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  117584. * @param forcedExtension defines the extension to use to pick the right loader
  117585. * @returns a InternalTexture for assignment back into BABYLON.Texture
  117586. */
  117587. 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;
  117588. /**
  117589. * Creates a cube texture
  117590. * @param rootUrl defines the url where the files to load is located
  117591. * @param scene defines the current scene
  117592. * @param files defines the list of files to load (1 per face)
  117593. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  117594. * @param onLoad defines an optional callback raised when the texture is loaded
  117595. * @param onError defines an optional callback raised if there is an issue to load the texture
  117596. * @param format defines the format of the data
  117597. * @param forcedExtension defines the extension to use to pick the right loader
  117598. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  117599. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117600. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117601. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  117602. * @returns the cube texture as an InternalTexture
  117603. */
  117604. 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;
  117605. private _getSamplingFilter;
  117606. private static _GetNativeTextureFormat;
  117607. createRenderTargetTexture(size: number | {
  117608. width: number;
  117609. height: number;
  117610. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  117611. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  117612. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  117613. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  117614. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  117615. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  117616. /**
  117617. * Updates a dynamic vertex buffer.
  117618. * @param vertexBuffer the vertex buffer to update
  117619. * @param data the data used to update the vertex buffer
  117620. * @param byteOffset the byte offset of the data (optional)
  117621. * @param byteLength the byte length of the data (optional)
  117622. */
  117623. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  117624. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  117625. private _updateAnisotropicLevel;
  117626. private _getAddressMode;
  117627. /** @hidden */
  117628. _bindTexture(channel: number, texture: InternalTexture): void;
  117629. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  117630. releaseEffects(): void;
  117631. /** @hidden */
  117632. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117633. /** @hidden */
  117634. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117635. /** @hidden */
  117636. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117637. /** @hidden */
  117638. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  117639. }
  117640. }
  117641. declare module BABYLON {
  117642. /**
  117643. * Gather the list of clipboard event types as constants.
  117644. */
  117645. export class ClipboardEventTypes {
  117646. /**
  117647. * The clipboard event is fired when a copy command is active (pressed).
  117648. */
  117649. static readonly COPY: number;
  117650. /**
  117651. * The clipboard event is fired when a cut command is active (pressed).
  117652. */
  117653. static readonly CUT: number;
  117654. /**
  117655. * The clipboard event is fired when a paste command is active (pressed).
  117656. */
  117657. static readonly PASTE: number;
  117658. }
  117659. /**
  117660. * This class is used to store clipboard related info for the onClipboardObservable event.
  117661. */
  117662. export class ClipboardInfo {
  117663. /**
  117664. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117665. */
  117666. type: number;
  117667. /**
  117668. * Defines the related dom event
  117669. */
  117670. event: ClipboardEvent;
  117671. /**
  117672. *Creates an instance of ClipboardInfo.
  117673. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  117674. * @param event Defines the related dom event
  117675. */
  117676. constructor(
  117677. /**
  117678. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117679. */
  117680. type: number,
  117681. /**
  117682. * Defines the related dom event
  117683. */
  117684. event: ClipboardEvent);
  117685. /**
  117686. * Get the clipboard event's type from the keycode.
  117687. * @param keyCode Defines the keyCode for the current keyboard event.
  117688. * @return {number}
  117689. */
  117690. static GetTypeFromCharacter(keyCode: number): number;
  117691. }
  117692. }
  117693. declare module BABYLON {
  117694. /**
  117695. * Google Daydream controller
  117696. */
  117697. export class DaydreamController extends WebVRController {
  117698. /**
  117699. * Base Url for the controller model.
  117700. */
  117701. static MODEL_BASE_URL: string;
  117702. /**
  117703. * File name for the controller model.
  117704. */
  117705. static MODEL_FILENAME: string;
  117706. /**
  117707. * Gamepad Id prefix used to identify Daydream Controller.
  117708. */
  117709. static readonly GAMEPAD_ID_PREFIX: string;
  117710. /**
  117711. * Creates a new DaydreamController from a gamepad
  117712. * @param vrGamepad the gamepad that the controller should be created from
  117713. */
  117714. constructor(vrGamepad: any);
  117715. /**
  117716. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117717. * @param scene scene in which to add meshes
  117718. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117719. */
  117720. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117721. /**
  117722. * Called once for each button that changed state since the last frame
  117723. * @param buttonIdx Which button index changed
  117724. * @param state New state of the button
  117725. * @param changes Which properties on the state changed since last frame
  117726. */
  117727. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117728. }
  117729. }
  117730. declare module BABYLON {
  117731. /**
  117732. * Gear VR Controller
  117733. */
  117734. export class GearVRController extends WebVRController {
  117735. /**
  117736. * Base Url for the controller model.
  117737. */
  117738. static MODEL_BASE_URL: string;
  117739. /**
  117740. * File name for the controller model.
  117741. */
  117742. static MODEL_FILENAME: string;
  117743. /**
  117744. * Gamepad Id prefix used to identify this controller.
  117745. */
  117746. static readonly GAMEPAD_ID_PREFIX: string;
  117747. private readonly _buttonIndexToObservableNameMap;
  117748. /**
  117749. * Creates a new GearVRController from a gamepad
  117750. * @param vrGamepad the gamepad that the controller should be created from
  117751. */
  117752. constructor(vrGamepad: any);
  117753. /**
  117754. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117755. * @param scene scene in which to add meshes
  117756. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117757. */
  117758. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117759. /**
  117760. * Called once for each button that changed state since the last frame
  117761. * @param buttonIdx Which button index changed
  117762. * @param state New state of the button
  117763. * @param changes Which properties on the state changed since last frame
  117764. */
  117765. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117766. }
  117767. }
  117768. declare module BABYLON {
  117769. /**
  117770. * Class containing static functions to help procedurally build meshes
  117771. */
  117772. export class PolyhedronBuilder {
  117773. /**
  117774. * Creates a polyhedron mesh
  117775. * * 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
  117776. * * The parameter `size` (positive float, default 1) sets the polygon size
  117777. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  117778. * * 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`
  117779. * * 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
  117780. * * 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)`)
  117781. * * 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
  117782. * * 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
  117783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117786. * @param name defines the name of the mesh
  117787. * @param options defines the options used to create the mesh
  117788. * @param scene defines the hosting scene
  117789. * @returns the polyhedron mesh
  117790. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  117791. */
  117792. static CreatePolyhedron(name: string, options: {
  117793. type?: number;
  117794. size?: number;
  117795. sizeX?: number;
  117796. sizeY?: number;
  117797. sizeZ?: number;
  117798. custom?: any;
  117799. faceUV?: Vector4[];
  117800. faceColors?: Color4[];
  117801. flat?: boolean;
  117802. updatable?: boolean;
  117803. sideOrientation?: number;
  117804. frontUVs?: Vector4;
  117805. backUVs?: Vector4;
  117806. }, scene?: Nullable<Scene>): Mesh;
  117807. }
  117808. }
  117809. declare module BABYLON {
  117810. /**
  117811. * Gizmo that enables scaling a mesh along 3 axis
  117812. */
  117813. export class ScaleGizmo extends Gizmo {
  117814. /**
  117815. * Internal gizmo used for interactions on the x axis
  117816. */
  117817. xGizmo: AxisScaleGizmo;
  117818. /**
  117819. * Internal gizmo used for interactions on the y axis
  117820. */
  117821. yGizmo: AxisScaleGizmo;
  117822. /**
  117823. * Internal gizmo used for interactions on the z axis
  117824. */
  117825. zGizmo: AxisScaleGizmo;
  117826. /**
  117827. * Internal gizmo used to scale all axis equally
  117828. */
  117829. uniformScaleGizmo: AxisScaleGizmo;
  117830. private _meshAttached;
  117831. private _updateGizmoRotationToMatchAttachedMesh;
  117832. private _snapDistance;
  117833. private _scaleRatio;
  117834. private _uniformScalingMesh;
  117835. private _octahedron;
  117836. private _sensitivity;
  117837. /** Fires an event when any of it's sub gizmos are dragged */
  117838. onDragStartObservable: Observable<unknown>;
  117839. /** Fires an event when any of it's sub gizmos are released from dragging */
  117840. onDragEndObservable: Observable<unknown>;
  117841. get attachedMesh(): Nullable<AbstractMesh>;
  117842. set attachedMesh(mesh: Nullable<AbstractMesh>);
  117843. /**
  117844. * Creates a ScaleGizmo
  117845. * @param gizmoLayer The utility layer the gizmo will be added to
  117846. */
  117847. constructor(gizmoLayer?: UtilityLayerRenderer);
  117848. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  117849. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  117850. /**
  117851. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  117852. */
  117853. set snapDistance(value: number);
  117854. get snapDistance(): number;
  117855. /**
  117856. * Ratio for the scale of the gizmo (Default: 1)
  117857. */
  117858. set scaleRatio(value: number);
  117859. get scaleRatio(): number;
  117860. /**
  117861. * Sensitivity factor for dragging (Default: 1)
  117862. */
  117863. set sensitivity(value: number);
  117864. get sensitivity(): number;
  117865. /**
  117866. * Disposes of the gizmo
  117867. */
  117868. dispose(): void;
  117869. }
  117870. }
  117871. declare module BABYLON {
  117872. /**
  117873. * Single axis scale gizmo
  117874. */
  117875. export class AxisScaleGizmo extends Gizmo {
  117876. /**
  117877. * Drag behavior responsible for the gizmos dragging interactions
  117878. */
  117879. dragBehavior: PointerDragBehavior;
  117880. private _pointerObserver;
  117881. /**
  117882. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  117883. */
  117884. snapDistance: number;
  117885. /**
  117886. * Event that fires each time the gizmo snaps to a new location.
  117887. * * snapDistance is the the change in distance
  117888. */
  117889. onSnapObservable: Observable<{
  117890. snapDistance: number;
  117891. }>;
  117892. /**
  117893. * If the scaling operation should be done on all axis (default: false)
  117894. */
  117895. uniformScaling: boolean;
  117896. /**
  117897. * Custom sensitivity value for the drag strength
  117898. */
  117899. sensitivity: number;
  117900. private _isEnabled;
  117901. private _parent;
  117902. private _arrow;
  117903. private _coloredMaterial;
  117904. private _hoverMaterial;
  117905. /**
  117906. * Creates an AxisScaleGizmo
  117907. * @param gizmoLayer The utility layer the gizmo will be added to
  117908. * @param dragAxis The axis which the gizmo will be able to scale on
  117909. * @param color The color of the gizmo
  117910. */
  117911. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  117912. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  117913. /**
  117914. * If the gizmo is enabled
  117915. */
  117916. set isEnabled(value: boolean);
  117917. get isEnabled(): boolean;
  117918. /**
  117919. * Disposes of the gizmo
  117920. */
  117921. dispose(): void;
  117922. /**
  117923. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  117924. * @param mesh The mesh to replace the default mesh of the gizmo
  117925. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  117926. */
  117927. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  117928. }
  117929. }
  117930. declare module BABYLON {
  117931. /**
  117932. * Bounding box gizmo
  117933. */
  117934. export class BoundingBoxGizmo extends Gizmo {
  117935. private _lineBoundingBox;
  117936. private _rotateSpheresParent;
  117937. private _scaleBoxesParent;
  117938. private _boundingDimensions;
  117939. private _renderObserver;
  117940. private _pointerObserver;
  117941. private _scaleDragSpeed;
  117942. private _tmpQuaternion;
  117943. private _tmpVector;
  117944. private _tmpRotationMatrix;
  117945. /**
  117946. * 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)
  117947. */
  117948. ignoreChildren: boolean;
  117949. /**
  117950. * 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)
  117951. */
  117952. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  117953. /**
  117954. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  117955. */
  117956. rotationSphereSize: number;
  117957. /**
  117958. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  117959. */
  117960. scaleBoxSize: number;
  117961. /**
  117962. * 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)
  117963. */
  117964. fixedDragMeshScreenSize: boolean;
  117965. /**
  117966. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  117967. */
  117968. fixedDragMeshScreenSizeDistanceFactor: number;
  117969. /**
  117970. * Fired when a rotation sphere or scale box is dragged
  117971. */
  117972. onDragStartObservable: Observable<{}>;
  117973. /**
  117974. * Fired when a scale box is dragged
  117975. */
  117976. onScaleBoxDragObservable: Observable<{}>;
  117977. /**
  117978. * Fired when a scale box drag is ended
  117979. */
  117980. onScaleBoxDragEndObservable: Observable<{}>;
  117981. /**
  117982. * Fired when a rotation sphere is dragged
  117983. */
  117984. onRotationSphereDragObservable: Observable<{}>;
  117985. /**
  117986. * Fired when a rotation sphere drag is ended
  117987. */
  117988. onRotationSphereDragEndObservable: Observable<{}>;
  117989. /**
  117990. * 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)
  117991. */
  117992. scalePivot: Nullable<Vector3>;
  117993. /**
  117994. * Mesh used as a pivot to rotate the attached mesh
  117995. */
  117996. private _anchorMesh;
  117997. private _existingMeshScale;
  117998. private _dragMesh;
  117999. private pointerDragBehavior;
  118000. private coloredMaterial;
  118001. private hoverColoredMaterial;
  118002. /**
  118003. * Sets the color of the bounding box gizmo
  118004. * @param color the color to set
  118005. */
  118006. setColor(color: Color3): void;
  118007. /**
  118008. * Creates an BoundingBoxGizmo
  118009. * @param gizmoLayer The utility layer the gizmo will be added to
  118010. * @param color The color of the gizmo
  118011. */
  118012. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  118013. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118014. private _selectNode;
  118015. /**
  118016. * Updates the bounding box information for the Gizmo
  118017. */
  118018. updateBoundingBox(): void;
  118019. private _updateRotationSpheres;
  118020. private _updateScaleBoxes;
  118021. /**
  118022. * Enables rotation on the specified axis and disables rotation on the others
  118023. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  118024. */
  118025. setEnabledRotationAxis(axis: string): void;
  118026. /**
  118027. * Enables/disables scaling
  118028. * @param enable if scaling should be enabled
  118029. */
  118030. setEnabledScaling(enable: boolean): void;
  118031. private _updateDummy;
  118032. /**
  118033. * Enables a pointer drag behavior on the bounding box of the gizmo
  118034. */
  118035. enableDragBehavior(): void;
  118036. /**
  118037. * Disposes of the gizmo
  118038. */
  118039. dispose(): void;
  118040. /**
  118041. * 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)
  118042. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  118043. * @returns the bounding box mesh with the passed in mesh as a child
  118044. */
  118045. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  118046. /**
  118047. * CustomMeshes are not supported by this gizmo
  118048. * @param mesh The mesh to replace the default mesh of the gizmo
  118049. */
  118050. setCustomMesh(mesh: Mesh): void;
  118051. }
  118052. }
  118053. declare module BABYLON {
  118054. /**
  118055. * Single plane rotation gizmo
  118056. */
  118057. export class PlaneRotationGizmo extends Gizmo {
  118058. /**
  118059. * Drag behavior responsible for the gizmos dragging interactions
  118060. */
  118061. dragBehavior: PointerDragBehavior;
  118062. private _pointerObserver;
  118063. /**
  118064. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  118065. */
  118066. snapDistance: number;
  118067. /**
  118068. * Event that fires each time the gizmo snaps to a new location.
  118069. * * snapDistance is the the change in distance
  118070. */
  118071. onSnapObservable: Observable<{
  118072. snapDistance: number;
  118073. }>;
  118074. private _isEnabled;
  118075. private _parent;
  118076. /**
  118077. * Creates a PlaneRotationGizmo
  118078. * @param gizmoLayer The utility layer the gizmo will be added to
  118079. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  118080. * @param color The color of the gizmo
  118081. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118082. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118083. */
  118084. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  118085. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118086. /**
  118087. * If the gizmo is enabled
  118088. */
  118089. set isEnabled(value: boolean);
  118090. get isEnabled(): boolean;
  118091. /**
  118092. * Disposes of the gizmo
  118093. */
  118094. dispose(): void;
  118095. }
  118096. }
  118097. declare module BABYLON {
  118098. /**
  118099. * Gizmo that enables rotating a mesh along 3 axis
  118100. */
  118101. export class RotationGizmo extends Gizmo {
  118102. /**
  118103. * Internal gizmo used for interactions on the x axis
  118104. */
  118105. xGizmo: PlaneRotationGizmo;
  118106. /**
  118107. * Internal gizmo used for interactions on the y axis
  118108. */
  118109. yGizmo: PlaneRotationGizmo;
  118110. /**
  118111. * Internal gizmo used for interactions on the z axis
  118112. */
  118113. zGizmo: PlaneRotationGizmo;
  118114. /** Fires an event when any of it's sub gizmos are dragged */
  118115. onDragStartObservable: Observable<unknown>;
  118116. /** Fires an event when any of it's sub gizmos are released from dragging */
  118117. onDragEndObservable: Observable<unknown>;
  118118. private _meshAttached;
  118119. get attachedMesh(): Nullable<AbstractMesh>;
  118120. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118121. /**
  118122. * Creates a RotationGizmo
  118123. * @param gizmoLayer The utility layer the gizmo will be added to
  118124. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118125. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118126. */
  118127. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  118128. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118129. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118130. /**
  118131. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118132. */
  118133. set snapDistance(value: number);
  118134. get snapDistance(): number;
  118135. /**
  118136. * Ratio for the scale of the gizmo (Default: 1)
  118137. */
  118138. set scaleRatio(value: number);
  118139. get scaleRatio(): number;
  118140. /**
  118141. * Disposes of the gizmo
  118142. */
  118143. dispose(): void;
  118144. /**
  118145. * CustomMeshes are not supported by this gizmo
  118146. * @param mesh The mesh to replace the default mesh of the gizmo
  118147. */
  118148. setCustomMesh(mesh: Mesh): void;
  118149. }
  118150. }
  118151. declare module BABYLON {
  118152. /**
  118153. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  118154. */
  118155. export class GizmoManager implements IDisposable {
  118156. private scene;
  118157. /**
  118158. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  118159. */
  118160. gizmos: {
  118161. positionGizmo: Nullable<PositionGizmo>;
  118162. rotationGizmo: Nullable<RotationGizmo>;
  118163. scaleGizmo: Nullable<ScaleGizmo>;
  118164. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  118165. };
  118166. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  118167. clearGizmoOnEmptyPointerEvent: boolean;
  118168. /** Fires an event when the manager is attached to a mesh */
  118169. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  118170. private _gizmosEnabled;
  118171. private _pointerObserver;
  118172. private _attachedMesh;
  118173. private _boundingBoxColor;
  118174. private _defaultUtilityLayer;
  118175. private _defaultKeepDepthUtilityLayer;
  118176. /**
  118177. * When bounding box gizmo is enabled, this can be used to track drag/end events
  118178. */
  118179. boundingBoxDragBehavior: SixDofDragBehavior;
  118180. /**
  118181. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  118182. */
  118183. attachableMeshes: Nullable<Array<AbstractMesh>>;
  118184. /**
  118185. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  118186. */
  118187. usePointerToAttachGizmos: boolean;
  118188. /**
  118189. * Utility layer that the bounding box gizmo belongs to
  118190. */
  118191. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  118192. /**
  118193. * Utility layer that all gizmos besides bounding box belong to
  118194. */
  118195. get utilityLayer(): UtilityLayerRenderer;
  118196. /**
  118197. * Instatiates a gizmo manager
  118198. * @param scene the scene to overlay the gizmos on top of
  118199. */
  118200. constructor(scene: Scene);
  118201. /**
  118202. * Attaches a set of gizmos to the specified mesh
  118203. * @param mesh The mesh the gizmo's should be attached to
  118204. */
  118205. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118206. /**
  118207. * If the position gizmo is enabled
  118208. */
  118209. set positionGizmoEnabled(value: boolean);
  118210. get positionGizmoEnabled(): boolean;
  118211. /**
  118212. * If the rotation gizmo is enabled
  118213. */
  118214. set rotationGizmoEnabled(value: boolean);
  118215. get rotationGizmoEnabled(): boolean;
  118216. /**
  118217. * If the scale gizmo is enabled
  118218. */
  118219. set scaleGizmoEnabled(value: boolean);
  118220. get scaleGizmoEnabled(): boolean;
  118221. /**
  118222. * If the boundingBox gizmo is enabled
  118223. */
  118224. set boundingBoxGizmoEnabled(value: boolean);
  118225. get boundingBoxGizmoEnabled(): boolean;
  118226. /**
  118227. * Disposes of the gizmo manager
  118228. */
  118229. dispose(): void;
  118230. }
  118231. }
  118232. declare module BABYLON {
  118233. /**
  118234. * A directional light is defined by a direction (what a surprise!).
  118235. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  118236. * 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.
  118237. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118238. */
  118239. export class DirectionalLight extends ShadowLight {
  118240. private _shadowFrustumSize;
  118241. /**
  118242. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  118243. */
  118244. get shadowFrustumSize(): number;
  118245. /**
  118246. * Specifies a fix frustum size for the shadow generation.
  118247. */
  118248. set shadowFrustumSize(value: number);
  118249. private _shadowOrthoScale;
  118250. /**
  118251. * Gets the shadow projection scale against the optimal computed one.
  118252. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118253. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118254. */
  118255. get shadowOrthoScale(): number;
  118256. /**
  118257. * Sets the shadow projection scale against the optimal computed one.
  118258. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118259. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118260. */
  118261. set shadowOrthoScale(value: number);
  118262. /**
  118263. * Automatically compute the projection matrix to best fit (including all the casters)
  118264. * on each frame.
  118265. */
  118266. autoUpdateExtends: boolean;
  118267. private _orthoLeft;
  118268. private _orthoRight;
  118269. private _orthoTop;
  118270. private _orthoBottom;
  118271. /**
  118272. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  118273. * The directional light is emitted from everywhere in the given direction.
  118274. * It can cast shadows.
  118275. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118276. * @param name The friendly name of the light
  118277. * @param direction The direction of the light
  118278. * @param scene The scene the light belongs to
  118279. */
  118280. constructor(name: string, direction: Vector3, scene: Scene);
  118281. /**
  118282. * Returns the string "DirectionalLight".
  118283. * @return The class name
  118284. */
  118285. getClassName(): string;
  118286. /**
  118287. * Returns the integer 1.
  118288. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118289. */
  118290. getTypeID(): number;
  118291. /**
  118292. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  118293. * Returns the DirectionalLight Shadow projection matrix.
  118294. */
  118295. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118296. /**
  118297. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  118298. * Returns the DirectionalLight Shadow projection matrix.
  118299. */
  118300. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  118301. /**
  118302. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  118303. * Returns the DirectionalLight Shadow projection matrix.
  118304. */
  118305. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118306. protected _buildUniformLayout(): void;
  118307. /**
  118308. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  118309. * @param effect The effect to update
  118310. * @param lightIndex The index of the light in the effect to update
  118311. * @returns The directional light
  118312. */
  118313. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  118314. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  118315. /**
  118316. * Gets the minZ used for shadow according to both the scene and the light.
  118317. *
  118318. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118319. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118320. * @param activeCamera The camera we are returning the min for
  118321. * @returns the depth min z
  118322. */
  118323. getDepthMinZ(activeCamera: Camera): number;
  118324. /**
  118325. * Gets the maxZ used for shadow according to both the scene and the light.
  118326. *
  118327. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118328. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118329. * @param activeCamera The camera we are returning the max for
  118330. * @returns the depth max z
  118331. */
  118332. getDepthMaxZ(activeCamera: Camera): number;
  118333. /**
  118334. * Prepares the list of defines specific to the light type.
  118335. * @param defines the list of defines
  118336. * @param lightIndex defines the index of the light for the effect
  118337. */
  118338. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118339. }
  118340. }
  118341. declare module BABYLON {
  118342. /**
  118343. * Class containing static functions to help procedurally build meshes
  118344. */
  118345. export class HemisphereBuilder {
  118346. /**
  118347. * Creates a hemisphere mesh
  118348. * @param name defines the name of the mesh
  118349. * @param options defines the options used to create the mesh
  118350. * @param scene defines the hosting scene
  118351. * @returns the hemisphere mesh
  118352. */
  118353. static CreateHemisphere(name: string, options: {
  118354. segments?: number;
  118355. diameter?: number;
  118356. sideOrientation?: number;
  118357. }, scene: any): Mesh;
  118358. }
  118359. }
  118360. declare module BABYLON {
  118361. /**
  118362. * A spot light is defined by a position, a direction, an angle, and an exponent.
  118363. * These values define a cone of light starting from the position, emitting toward the direction.
  118364. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  118365. * and the exponent defines the speed of the decay of the light with distance (reach).
  118366. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118367. */
  118368. export class SpotLight extends ShadowLight {
  118369. private _angle;
  118370. private _innerAngle;
  118371. private _cosHalfAngle;
  118372. private _lightAngleScale;
  118373. private _lightAngleOffset;
  118374. /**
  118375. * Gets the cone angle of the spot light in Radians.
  118376. */
  118377. get angle(): number;
  118378. /**
  118379. * Sets the cone angle of the spot light in Radians.
  118380. */
  118381. set angle(value: number);
  118382. /**
  118383. * Only used in gltf falloff mode, this defines the angle where
  118384. * the directional falloff will start before cutting at angle which could be seen
  118385. * as outer angle.
  118386. */
  118387. get innerAngle(): number;
  118388. /**
  118389. * Only used in gltf falloff mode, this defines the angle where
  118390. * the directional falloff will start before cutting at angle which could be seen
  118391. * as outer angle.
  118392. */
  118393. set innerAngle(value: number);
  118394. private _shadowAngleScale;
  118395. /**
  118396. * Allows scaling the angle of the light for shadow generation only.
  118397. */
  118398. get shadowAngleScale(): number;
  118399. /**
  118400. * Allows scaling the angle of the light for shadow generation only.
  118401. */
  118402. set shadowAngleScale(value: number);
  118403. /**
  118404. * The light decay speed with the distance from the emission spot.
  118405. */
  118406. exponent: number;
  118407. private _projectionTextureMatrix;
  118408. /**
  118409. * Allows reading the projecton texture
  118410. */
  118411. get projectionTextureMatrix(): Matrix;
  118412. protected _projectionTextureLightNear: number;
  118413. /**
  118414. * Gets the near clip of the Spotlight for texture projection.
  118415. */
  118416. get projectionTextureLightNear(): number;
  118417. /**
  118418. * Sets the near clip of the Spotlight for texture projection.
  118419. */
  118420. set projectionTextureLightNear(value: number);
  118421. protected _projectionTextureLightFar: number;
  118422. /**
  118423. * Gets the far clip of the Spotlight for texture projection.
  118424. */
  118425. get projectionTextureLightFar(): number;
  118426. /**
  118427. * Sets the far clip of the Spotlight for texture projection.
  118428. */
  118429. set projectionTextureLightFar(value: number);
  118430. protected _projectionTextureUpDirection: Vector3;
  118431. /**
  118432. * Gets the Up vector of the Spotlight for texture projection.
  118433. */
  118434. get projectionTextureUpDirection(): Vector3;
  118435. /**
  118436. * Sets the Up vector of the Spotlight for texture projection.
  118437. */
  118438. set projectionTextureUpDirection(value: Vector3);
  118439. private _projectionTexture;
  118440. /**
  118441. * Gets the projection texture of the light.
  118442. */
  118443. get projectionTexture(): Nullable<BaseTexture>;
  118444. /**
  118445. * Sets the projection texture of the light.
  118446. */
  118447. set projectionTexture(value: Nullable<BaseTexture>);
  118448. private _projectionTextureViewLightDirty;
  118449. private _projectionTextureProjectionLightDirty;
  118450. private _projectionTextureDirty;
  118451. private _projectionTextureViewTargetVector;
  118452. private _projectionTextureViewLightMatrix;
  118453. private _projectionTextureProjectionLightMatrix;
  118454. private _projectionTextureScalingMatrix;
  118455. /**
  118456. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  118457. * It can cast shadows.
  118458. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118459. * @param name The light friendly name
  118460. * @param position The position of the spot light in the scene
  118461. * @param direction The direction of the light in the scene
  118462. * @param angle The cone angle of the light in Radians
  118463. * @param exponent The light decay speed with the distance from the emission spot
  118464. * @param scene The scene the lights belongs to
  118465. */
  118466. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  118467. /**
  118468. * Returns the string "SpotLight".
  118469. * @returns the class name
  118470. */
  118471. getClassName(): string;
  118472. /**
  118473. * Returns the integer 2.
  118474. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118475. */
  118476. getTypeID(): number;
  118477. /**
  118478. * Overrides the direction setter to recompute the projection texture view light Matrix.
  118479. */
  118480. protected _setDirection(value: Vector3): void;
  118481. /**
  118482. * Overrides the position setter to recompute the projection texture view light Matrix.
  118483. */
  118484. protected _setPosition(value: Vector3): void;
  118485. /**
  118486. * 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.
  118487. * Returns the SpotLight.
  118488. */
  118489. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118490. protected _computeProjectionTextureViewLightMatrix(): void;
  118491. protected _computeProjectionTextureProjectionLightMatrix(): void;
  118492. /**
  118493. * Main function for light texture projection matrix computing.
  118494. */
  118495. protected _computeProjectionTextureMatrix(): void;
  118496. protected _buildUniformLayout(): void;
  118497. private _computeAngleValues;
  118498. /**
  118499. * Sets the passed Effect "effect" with the Light textures.
  118500. * @param effect The effect to update
  118501. * @param lightIndex The index of the light in the effect to update
  118502. * @returns The light
  118503. */
  118504. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  118505. /**
  118506. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  118507. * @param effect The effect to update
  118508. * @param lightIndex The index of the light in the effect to update
  118509. * @returns The spot light
  118510. */
  118511. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  118512. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118513. /**
  118514. * Disposes the light and the associated resources.
  118515. */
  118516. dispose(): void;
  118517. /**
  118518. * Prepares the list of defines specific to the light type.
  118519. * @param defines the list of defines
  118520. * @param lightIndex defines the index of the light for the effect
  118521. */
  118522. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118523. }
  118524. }
  118525. declare module BABYLON {
  118526. /**
  118527. * Gizmo that enables viewing a light
  118528. */
  118529. export class LightGizmo extends Gizmo {
  118530. private _lightMesh;
  118531. private _material;
  118532. private _cachedPosition;
  118533. private _cachedForward;
  118534. private _attachedMeshParent;
  118535. /**
  118536. * Creates a LightGizmo
  118537. * @param gizmoLayer The utility layer the gizmo will be added to
  118538. */
  118539. constructor(gizmoLayer?: UtilityLayerRenderer);
  118540. private _light;
  118541. /**
  118542. * The light that the gizmo is attached to
  118543. */
  118544. set light(light: Nullable<Light>);
  118545. get light(): Nullable<Light>;
  118546. /**
  118547. * Gets the material used to render the light gizmo
  118548. */
  118549. get material(): StandardMaterial;
  118550. /**
  118551. * @hidden
  118552. * Updates the gizmo to match the attached mesh's position/rotation
  118553. */
  118554. protected _update(): void;
  118555. private static _Scale;
  118556. /**
  118557. * Creates the lines for a light mesh
  118558. */
  118559. private static _CreateLightLines;
  118560. /**
  118561. * Disposes of the light gizmo
  118562. */
  118563. dispose(): void;
  118564. private static _CreateHemisphericLightMesh;
  118565. private static _CreatePointLightMesh;
  118566. private static _CreateSpotLightMesh;
  118567. private static _CreateDirectionalLightMesh;
  118568. }
  118569. }
  118570. declare module BABYLON {
  118571. /** @hidden */
  118572. export var backgroundFragmentDeclaration: {
  118573. name: string;
  118574. shader: string;
  118575. };
  118576. }
  118577. declare module BABYLON {
  118578. /** @hidden */
  118579. export var backgroundUboDeclaration: {
  118580. name: string;
  118581. shader: string;
  118582. };
  118583. }
  118584. declare module BABYLON {
  118585. /** @hidden */
  118586. export var backgroundPixelShader: {
  118587. name: string;
  118588. shader: string;
  118589. };
  118590. }
  118591. declare module BABYLON {
  118592. /** @hidden */
  118593. export var backgroundVertexDeclaration: {
  118594. name: string;
  118595. shader: string;
  118596. };
  118597. }
  118598. declare module BABYLON {
  118599. /** @hidden */
  118600. export var backgroundVertexShader: {
  118601. name: string;
  118602. shader: string;
  118603. };
  118604. }
  118605. declare module BABYLON {
  118606. /**
  118607. * Background material used to create an efficient environement around your scene.
  118608. */
  118609. export class BackgroundMaterial extends PushMaterial {
  118610. /**
  118611. * Standard reflectance value at parallel view angle.
  118612. */
  118613. static StandardReflectance0: number;
  118614. /**
  118615. * Standard reflectance value at grazing angle.
  118616. */
  118617. static StandardReflectance90: number;
  118618. protected _primaryColor: Color3;
  118619. /**
  118620. * Key light Color (multiply against the environement texture)
  118621. */
  118622. primaryColor: Color3;
  118623. protected __perceptualColor: Nullable<Color3>;
  118624. /**
  118625. * Experimental Internal Use Only.
  118626. *
  118627. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  118628. * This acts as a helper to set the primary color to a more "human friendly" value.
  118629. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  118630. * output color as close as possible from the chosen value.
  118631. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  118632. * part of lighting setup.)
  118633. */
  118634. get _perceptualColor(): Nullable<Color3>;
  118635. set _perceptualColor(value: Nullable<Color3>);
  118636. protected _primaryColorShadowLevel: float;
  118637. /**
  118638. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  118639. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  118640. */
  118641. get primaryColorShadowLevel(): float;
  118642. set primaryColorShadowLevel(value: float);
  118643. protected _primaryColorHighlightLevel: float;
  118644. /**
  118645. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  118646. * The primary color is used at the level chosen to define what the white area would look.
  118647. */
  118648. get primaryColorHighlightLevel(): float;
  118649. set primaryColorHighlightLevel(value: float);
  118650. protected _reflectionTexture: Nullable<BaseTexture>;
  118651. /**
  118652. * Reflection Texture used in the material.
  118653. * Should be author in a specific way for the best result (refer to the documentation).
  118654. */
  118655. reflectionTexture: Nullable<BaseTexture>;
  118656. protected _reflectionBlur: float;
  118657. /**
  118658. * Reflection Texture level of blur.
  118659. *
  118660. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  118661. * texture twice.
  118662. */
  118663. reflectionBlur: float;
  118664. protected _diffuseTexture: Nullable<BaseTexture>;
  118665. /**
  118666. * Diffuse Texture used in the material.
  118667. * Should be author in a specific way for the best result (refer to the documentation).
  118668. */
  118669. diffuseTexture: Nullable<BaseTexture>;
  118670. protected _shadowLights: Nullable<IShadowLight[]>;
  118671. /**
  118672. * Specify the list of lights casting shadow on the material.
  118673. * All scene shadow lights will be included if null.
  118674. */
  118675. shadowLights: Nullable<IShadowLight[]>;
  118676. protected _shadowLevel: float;
  118677. /**
  118678. * Helps adjusting the shadow to a softer level if required.
  118679. * 0 means black shadows and 1 means no shadows.
  118680. */
  118681. shadowLevel: float;
  118682. protected _sceneCenter: Vector3;
  118683. /**
  118684. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  118685. * It is usually zero but might be interesting to modify according to your setup.
  118686. */
  118687. sceneCenter: Vector3;
  118688. protected _opacityFresnel: boolean;
  118689. /**
  118690. * This helps specifying that the material is falling off to the sky box at grazing angle.
  118691. * This helps ensuring a nice transition when the camera goes under the ground.
  118692. */
  118693. opacityFresnel: boolean;
  118694. protected _reflectionFresnel: boolean;
  118695. /**
  118696. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  118697. * This helps adding a mirror texture on the ground.
  118698. */
  118699. reflectionFresnel: boolean;
  118700. protected _reflectionFalloffDistance: number;
  118701. /**
  118702. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  118703. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  118704. */
  118705. reflectionFalloffDistance: number;
  118706. protected _reflectionAmount: number;
  118707. /**
  118708. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  118709. */
  118710. reflectionAmount: number;
  118711. protected _reflectionReflectance0: number;
  118712. /**
  118713. * This specifies the weight of the reflection at grazing angle.
  118714. */
  118715. reflectionReflectance0: number;
  118716. protected _reflectionReflectance90: number;
  118717. /**
  118718. * This specifies the weight of the reflection at a perpendicular point of view.
  118719. */
  118720. reflectionReflectance90: number;
  118721. /**
  118722. * Sets the reflection reflectance fresnel values according to the default standard
  118723. * empirically know to work well :-)
  118724. */
  118725. set reflectionStandardFresnelWeight(value: number);
  118726. protected _useRGBColor: boolean;
  118727. /**
  118728. * Helps to directly use the maps channels instead of their level.
  118729. */
  118730. useRGBColor: boolean;
  118731. protected _enableNoise: boolean;
  118732. /**
  118733. * This helps reducing the banding effect that could occur on the background.
  118734. */
  118735. enableNoise: boolean;
  118736. /**
  118737. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118738. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  118739. * Recommended to be keep at 1.0 except for special cases.
  118740. */
  118741. get fovMultiplier(): number;
  118742. set fovMultiplier(value: number);
  118743. private _fovMultiplier;
  118744. /**
  118745. * Enable the FOV adjustment feature controlled by fovMultiplier.
  118746. */
  118747. useEquirectangularFOV: boolean;
  118748. private _maxSimultaneousLights;
  118749. /**
  118750. * Number of Simultaneous lights allowed on the material.
  118751. */
  118752. maxSimultaneousLights: int;
  118753. /**
  118754. * Default configuration related to image processing available in the Background Material.
  118755. */
  118756. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118757. /**
  118758. * Keep track of the image processing observer to allow dispose and replace.
  118759. */
  118760. private _imageProcessingObserver;
  118761. /**
  118762. * Attaches a new image processing configuration to the PBR Material.
  118763. * @param configuration (if null the scene configuration will be use)
  118764. */
  118765. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118766. /**
  118767. * Gets the image processing configuration used either in this material.
  118768. */
  118769. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  118770. /**
  118771. * Sets the Default image processing configuration used either in the this material.
  118772. *
  118773. * If sets to null, the scene one is in use.
  118774. */
  118775. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  118776. /**
  118777. * Gets wether the color curves effect is enabled.
  118778. */
  118779. get cameraColorCurvesEnabled(): boolean;
  118780. /**
  118781. * Sets wether the color curves effect is enabled.
  118782. */
  118783. set cameraColorCurvesEnabled(value: boolean);
  118784. /**
  118785. * Gets wether the color grading effect is enabled.
  118786. */
  118787. get cameraColorGradingEnabled(): boolean;
  118788. /**
  118789. * Gets wether the color grading effect is enabled.
  118790. */
  118791. set cameraColorGradingEnabled(value: boolean);
  118792. /**
  118793. * Gets wether tonemapping is enabled or not.
  118794. */
  118795. get cameraToneMappingEnabled(): boolean;
  118796. /**
  118797. * Sets wether tonemapping is enabled or not
  118798. */
  118799. set cameraToneMappingEnabled(value: boolean);
  118800. /**
  118801. * The camera exposure used on this material.
  118802. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118803. * This corresponds to a photographic exposure.
  118804. */
  118805. get cameraExposure(): float;
  118806. /**
  118807. * The camera exposure used on this material.
  118808. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118809. * This corresponds to a photographic exposure.
  118810. */
  118811. set cameraExposure(value: float);
  118812. /**
  118813. * Gets The camera contrast used on this material.
  118814. */
  118815. get cameraContrast(): float;
  118816. /**
  118817. * Sets The camera contrast used on this material.
  118818. */
  118819. set cameraContrast(value: float);
  118820. /**
  118821. * Gets the Color Grading 2D Lookup Texture.
  118822. */
  118823. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  118824. /**
  118825. * Sets the Color Grading 2D Lookup Texture.
  118826. */
  118827. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  118828. /**
  118829. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118830. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118831. * 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;
  118832. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118833. */
  118834. get cameraColorCurves(): Nullable<ColorCurves>;
  118835. /**
  118836. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118837. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118838. * 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;
  118839. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118840. */
  118841. set cameraColorCurves(value: Nullable<ColorCurves>);
  118842. /**
  118843. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  118844. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  118845. */
  118846. switchToBGR: boolean;
  118847. private _renderTargets;
  118848. private _reflectionControls;
  118849. private _white;
  118850. private _primaryShadowColor;
  118851. private _primaryHighlightColor;
  118852. /**
  118853. * Instantiates a Background Material in the given scene
  118854. * @param name The friendly name of the material
  118855. * @param scene The scene to add the material to
  118856. */
  118857. constructor(name: string, scene: Scene);
  118858. /**
  118859. * Gets a boolean indicating that current material needs to register RTT
  118860. */
  118861. get hasRenderTargetTextures(): boolean;
  118862. /**
  118863. * The entire material has been created in order to prevent overdraw.
  118864. * @returns false
  118865. */
  118866. needAlphaTesting(): boolean;
  118867. /**
  118868. * The entire material has been created in order to prevent overdraw.
  118869. * @returns true if blending is enable
  118870. */
  118871. needAlphaBlending(): boolean;
  118872. /**
  118873. * Checks wether the material is ready to be rendered for a given mesh.
  118874. * @param mesh The mesh to render
  118875. * @param subMesh The submesh to check against
  118876. * @param useInstances Specify wether or not the material is used with instances
  118877. * @returns true if all the dependencies are ready (Textures, Effects...)
  118878. */
  118879. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118880. /**
  118881. * Compute the primary color according to the chosen perceptual color.
  118882. */
  118883. private _computePrimaryColorFromPerceptualColor;
  118884. /**
  118885. * Compute the highlights and shadow colors according to their chosen levels.
  118886. */
  118887. private _computePrimaryColors;
  118888. /**
  118889. * Build the uniform buffer used in the material.
  118890. */
  118891. buildUniformLayout(): void;
  118892. /**
  118893. * Unbind the material.
  118894. */
  118895. unbind(): void;
  118896. /**
  118897. * Bind only the world matrix to the material.
  118898. * @param world The world matrix to bind.
  118899. */
  118900. bindOnlyWorldMatrix(world: Matrix): void;
  118901. /**
  118902. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  118903. * @param world The world matrix to bind.
  118904. * @param subMesh The submesh to bind for.
  118905. */
  118906. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118907. /**
  118908. * Checks to see if a texture is used in the material.
  118909. * @param texture - Base texture to use.
  118910. * @returns - Boolean specifying if a texture is used in the material.
  118911. */
  118912. hasTexture(texture: BaseTexture): boolean;
  118913. /**
  118914. * Dispose the material.
  118915. * @param forceDisposeEffect Force disposal of the associated effect.
  118916. * @param forceDisposeTextures Force disposal of the associated textures.
  118917. */
  118918. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  118919. /**
  118920. * Clones the material.
  118921. * @param name The cloned name.
  118922. * @returns The cloned material.
  118923. */
  118924. clone(name: string): BackgroundMaterial;
  118925. /**
  118926. * Serializes the current material to its JSON representation.
  118927. * @returns The JSON representation.
  118928. */
  118929. serialize(): any;
  118930. /**
  118931. * Gets the class name of the material
  118932. * @returns "BackgroundMaterial"
  118933. */
  118934. getClassName(): string;
  118935. /**
  118936. * Parse a JSON input to create back a background material.
  118937. * @param source The JSON data to parse
  118938. * @param scene The scene to create the parsed material in
  118939. * @param rootUrl The root url of the assets the material depends upon
  118940. * @returns the instantiated BackgroundMaterial.
  118941. */
  118942. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  118943. }
  118944. }
  118945. declare module BABYLON {
  118946. /**
  118947. * Represents the different options available during the creation of
  118948. * a Environment helper.
  118949. *
  118950. * This can control the default ground, skybox and image processing setup of your scene.
  118951. */
  118952. export interface IEnvironmentHelperOptions {
  118953. /**
  118954. * Specifies wether or not to create a ground.
  118955. * True by default.
  118956. */
  118957. createGround: boolean;
  118958. /**
  118959. * Specifies the ground size.
  118960. * 15 by default.
  118961. */
  118962. groundSize: number;
  118963. /**
  118964. * The texture used on the ground for the main color.
  118965. * Comes from the BabylonJS CDN by default.
  118966. *
  118967. * Remarks: Can be either a texture or a url.
  118968. */
  118969. groundTexture: string | BaseTexture;
  118970. /**
  118971. * The color mixed in the ground texture by default.
  118972. * BabylonJS clearColor by default.
  118973. */
  118974. groundColor: Color3;
  118975. /**
  118976. * Specifies the ground opacity.
  118977. * 1 by default.
  118978. */
  118979. groundOpacity: number;
  118980. /**
  118981. * Enables the ground to receive shadows.
  118982. * True by default.
  118983. */
  118984. enableGroundShadow: boolean;
  118985. /**
  118986. * Helps preventing the shadow to be fully black on the ground.
  118987. * 0.5 by default.
  118988. */
  118989. groundShadowLevel: number;
  118990. /**
  118991. * Creates a mirror texture attach to the ground.
  118992. * false by default.
  118993. */
  118994. enableGroundMirror: boolean;
  118995. /**
  118996. * Specifies the ground mirror size ratio.
  118997. * 0.3 by default as the default kernel is 64.
  118998. */
  118999. groundMirrorSizeRatio: number;
  119000. /**
  119001. * Specifies the ground mirror blur kernel size.
  119002. * 64 by default.
  119003. */
  119004. groundMirrorBlurKernel: number;
  119005. /**
  119006. * Specifies the ground mirror visibility amount.
  119007. * 1 by default
  119008. */
  119009. groundMirrorAmount: number;
  119010. /**
  119011. * Specifies the ground mirror reflectance weight.
  119012. * This uses the standard weight of the background material to setup the fresnel effect
  119013. * of the mirror.
  119014. * 1 by default.
  119015. */
  119016. groundMirrorFresnelWeight: number;
  119017. /**
  119018. * Specifies the ground mirror Falloff distance.
  119019. * This can helps reducing the size of the reflection.
  119020. * 0 by Default.
  119021. */
  119022. groundMirrorFallOffDistance: number;
  119023. /**
  119024. * Specifies the ground mirror texture type.
  119025. * Unsigned Int by Default.
  119026. */
  119027. groundMirrorTextureType: number;
  119028. /**
  119029. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  119030. * the shown objects.
  119031. */
  119032. groundYBias: number;
  119033. /**
  119034. * Specifies wether or not to create a skybox.
  119035. * True by default.
  119036. */
  119037. createSkybox: boolean;
  119038. /**
  119039. * Specifies the skybox size.
  119040. * 20 by default.
  119041. */
  119042. skyboxSize: number;
  119043. /**
  119044. * The texture used on the skybox for the main color.
  119045. * Comes from the BabylonJS CDN by default.
  119046. *
  119047. * Remarks: Can be either a texture or a url.
  119048. */
  119049. skyboxTexture: string | BaseTexture;
  119050. /**
  119051. * The color mixed in the skybox texture by default.
  119052. * BabylonJS clearColor by default.
  119053. */
  119054. skyboxColor: Color3;
  119055. /**
  119056. * The background rotation around the Y axis of the scene.
  119057. * This helps aligning the key lights of your scene with the background.
  119058. * 0 by default.
  119059. */
  119060. backgroundYRotation: number;
  119061. /**
  119062. * Compute automatically the size of the elements to best fit with the scene.
  119063. */
  119064. sizeAuto: boolean;
  119065. /**
  119066. * Default position of the rootMesh if autoSize is not true.
  119067. */
  119068. rootPosition: Vector3;
  119069. /**
  119070. * Sets up the image processing in the scene.
  119071. * true by default.
  119072. */
  119073. setupImageProcessing: boolean;
  119074. /**
  119075. * The texture used as your environment texture in the scene.
  119076. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  119077. *
  119078. * Remarks: Can be either a texture or a url.
  119079. */
  119080. environmentTexture: string | BaseTexture;
  119081. /**
  119082. * The value of the exposure to apply to the scene.
  119083. * 0.6 by default if setupImageProcessing is true.
  119084. */
  119085. cameraExposure: number;
  119086. /**
  119087. * The value of the contrast to apply to the scene.
  119088. * 1.6 by default if setupImageProcessing is true.
  119089. */
  119090. cameraContrast: number;
  119091. /**
  119092. * Specifies wether or not tonemapping should be enabled in the scene.
  119093. * true by default if setupImageProcessing is true.
  119094. */
  119095. toneMappingEnabled: boolean;
  119096. }
  119097. /**
  119098. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  119099. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  119100. * It also helps with the default setup of your imageProcessing configuration.
  119101. */
  119102. export class EnvironmentHelper {
  119103. /**
  119104. * Default ground texture URL.
  119105. */
  119106. private static _groundTextureCDNUrl;
  119107. /**
  119108. * Default skybox texture URL.
  119109. */
  119110. private static _skyboxTextureCDNUrl;
  119111. /**
  119112. * Default environment texture URL.
  119113. */
  119114. private static _environmentTextureCDNUrl;
  119115. /**
  119116. * Creates the default options for the helper.
  119117. */
  119118. private static _getDefaultOptions;
  119119. private _rootMesh;
  119120. /**
  119121. * Gets the root mesh created by the helper.
  119122. */
  119123. get rootMesh(): Mesh;
  119124. private _skybox;
  119125. /**
  119126. * Gets the skybox created by the helper.
  119127. */
  119128. get skybox(): Nullable<Mesh>;
  119129. private _skyboxTexture;
  119130. /**
  119131. * Gets the skybox texture created by the helper.
  119132. */
  119133. get skyboxTexture(): Nullable<BaseTexture>;
  119134. private _skyboxMaterial;
  119135. /**
  119136. * Gets the skybox material created by the helper.
  119137. */
  119138. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  119139. private _ground;
  119140. /**
  119141. * Gets the ground mesh created by the helper.
  119142. */
  119143. get ground(): Nullable<Mesh>;
  119144. private _groundTexture;
  119145. /**
  119146. * Gets the ground texture created by the helper.
  119147. */
  119148. get groundTexture(): Nullable<BaseTexture>;
  119149. private _groundMirror;
  119150. /**
  119151. * Gets the ground mirror created by the helper.
  119152. */
  119153. get groundMirror(): Nullable<MirrorTexture>;
  119154. /**
  119155. * Gets the ground mirror render list to helps pushing the meshes
  119156. * you wish in the ground reflection.
  119157. */
  119158. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  119159. private _groundMaterial;
  119160. /**
  119161. * Gets the ground material created by the helper.
  119162. */
  119163. get groundMaterial(): Nullable<BackgroundMaterial>;
  119164. /**
  119165. * Stores the creation options.
  119166. */
  119167. private readonly _scene;
  119168. private _options;
  119169. /**
  119170. * This observable will be notified with any error during the creation of the environment,
  119171. * mainly texture creation errors.
  119172. */
  119173. onErrorObservable: Observable<{
  119174. message?: string;
  119175. exception?: any;
  119176. }>;
  119177. /**
  119178. * constructor
  119179. * @param options Defines the options we want to customize the helper
  119180. * @param scene The scene to add the material to
  119181. */
  119182. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  119183. /**
  119184. * Updates the background according to the new options
  119185. * @param options
  119186. */
  119187. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  119188. /**
  119189. * Sets the primary color of all the available elements.
  119190. * @param color the main color to affect to the ground and the background
  119191. */
  119192. setMainColor(color: Color3): void;
  119193. /**
  119194. * Setup the image processing according to the specified options.
  119195. */
  119196. private _setupImageProcessing;
  119197. /**
  119198. * Setup the environment texture according to the specified options.
  119199. */
  119200. private _setupEnvironmentTexture;
  119201. /**
  119202. * Setup the background according to the specified options.
  119203. */
  119204. private _setupBackground;
  119205. /**
  119206. * Get the scene sizes according to the setup.
  119207. */
  119208. private _getSceneSize;
  119209. /**
  119210. * Setup the ground according to the specified options.
  119211. */
  119212. private _setupGround;
  119213. /**
  119214. * Setup the ground material according to the specified options.
  119215. */
  119216. private _setupGroundMaterial;
  119217. /**
  119218. * Setup the ground diffuse texture according to the specified options.
  119219. */
  119220. private _setupGroundDiffuseTexture;
  119221. /**
  119222. * Setup the ground mirror texture according to the specified options.
  119223. */
  119224. private _setupGroundMirrorTexture;
  119225. /**
  119226. * Setup the ground to receive the mirror texture.
  119227. */
  119228. private _setupMirrorInGroundMaterial;
  119229. /**
  119230. * Setup the skybox according to the specified options.
  119231. */
  119232. private _setupSkybox;
  119233. /**
  119234. * Setup the skybox material according to the specified options.
  119235. */
  119236. private _setupSkyboxMaterial;
  119237. /**
  119238. * Setup the skybox reflection texture according to the specified options.
  119239. */
  119240. private _setupSkyboxReflectionTexture;
  119241. private _errorHandler;
  119242. /**
  119243. * Dispose all the elements created by the Helper.
  119244. */
  119245. dispose(): void;
  119246. }
  119247. }
  119248. declare module BABYLON {
  119249. /**
  119250. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  119251. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  119252. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  119253. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  119254. */
  119255. export class PhotoDome extends TransformNode {
  119256. /**
  119257. * Define the image as a Monoscopic panoramic 360 image.
  119258. */
  119259. static readonly MODE_MONOSCOPIC: number;
  119260. /**
  119261. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119262. */
  119263. static readonly MODE_TOPBOTTOM: number;
  119264. /**
  119265. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119266. */
  119267. static readonly MODE_SIDEBYSIDE: number;
  119268. private _useDirectMapping;
  119269. /**
  119270. * The texture being displayed on the sphere
  119271. */
  119272. protected _photoTexture: Texture;
  119273. /**
  119274. * Gets or sets the texture being displayed on the sphere
  119275. */
  119276. get photoTexture(): Texture;
  119277. set photoTexture(value: Texture);
  119278. /**
  119279. * Observable raised when an error occured while loading the 360 image
  119280. */
  119281. onLoadErrorObservable: Observable<string>;
  119282. /**
  119283. * The skybox material
  119284. */
  119285. protected _material: BackgroundMaterial;
  119286. /**
  119287. * The surface used for the skybox
  119288. */
  119289. protected _mesh: Mesh;
  119290. /**
  119291. * Gets the mesh used for the skybox.
  119292. */
  119293. get mesh(): Mesh;
  119294. /**
  119295. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119296. * Also see the options.resolution property.
  119297. */
  119298. get fovMultiplier(): number;
  119299. set fovMultiplier(value: number);
  119300. private _imageMode;
  119301. /**
  119302. * Gets or set the current video mode for the video. It can be:
  119303. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  119304. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119305. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119306. */
  119307. get imageMode(): number;
  119308. set imageMode(value: number);
  119309. /**
  119310. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  119311. * @param name Element's name, child elements will append suffixes for their own names.
  119312. * @param urlsOfPhoto defines the url of the photo to display
  119313. * @param options defines an object containing optional or exposed sub element properties
  119314. * @param onError defines a callback called when an error occured while loading the texture
  119315. */
  119316. constructor(name: string, urlOfPhoto: string, options: {
  119317. resolution?: number;
  119318. size?: number;
  119319. useDirectMapping?: boolean;
  119320. faceForward?: boolean;
  119321. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  119322. private _onBeforeCameraRenderObserver;
  119323. private _changeImageMode;
  119324. /**
  119325. * Releases resources associated with this node.
  119326. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119327. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119328. */
  119329. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119330. }
  119331. }
  119332. declare module BABYLON {
  119333. /**
  119334. * Class used to host RGBD texture specific utilities
  119335. */
  119336. export class RGBDTextureTools {
  119337. /**
  119338. * Expand the RGBD Texture from RGBD to Half Float if possible.
  119339. * @param texture the texture to expand.
  119340. */
  119341. static ExpandRGBDTexture(texture: Texture): void;
  119342. }
  119343. }
  119344. declare module BABYLON {
  119345. /**
  119346. * Class used to host texture specific utilities
  119347. */
  119348. export class BRDFTextureTools {
  119349. /**
  119350. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  119351. * @param scene defines the hosting scene
  119352. * @returns the environment BRDF texture
  119353. */
  119354. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  119355. private static _environmentBRDFBase64Texture;
  119356. }
  119357. }
  119358. declare module BABYLON {
  119359. /**
  119360. * @hidden
  119361. */
  119362. export interface IMaterialClearCoatDefines {
  119363. CLEARCOAT: boolean;
  119364. CLEARCOAT_DEFAULTIOR: boolean;
  119365. CLEARCOAT_TEXTURE: boolean;
  119366. CLEARCOAT_TEXTUREDIRECTUV: number;
  119367. CLEARCOAT_BUMP: boolean;
  119368. CLEARCOAT_BUMPDIRECTUV: number;
  119369. CLEARCOAT_TINT: boolean;
  119370. CLEARCOAT_TINT_TEXTURE: boolean;
  119371. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  119372. /** @hidden */
  119373. _areTexturesDirty: boolean;
  119374. }
  119375. /**
  119376. * Define the code related to the clear coat parameters of the pbr material.
  119377. */
  119378. export class PBRClearCoatConfiguration {
  119379. /**
  119380. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119381. * The default fits with a polyurethane material.
  119382. */
  119383. private static readonly _DefaultIndexOfRefraction;
  119384. private _isEnabled;
  119385. /**
  119386. * Defines if the clear coat is enabled in the material.
  119387. */
  119388. isEnabled: boolean;
  119389. /**
  119390. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  119391. */
  119392. intensity: number;
  119393. /**
  119394. * Defines the clear coat layer roughness.
  119395. */
  119396. roughness: number;
  119397. private _indexOfRefraction;
  119398. /**
  119399. * Defines the index of refraction of the clear coat.
  119400. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119401. * The default fits with a polyurethane material.
  119402. * Changing the default value is more performance intensive.
  119403. */
  119404. indexOfRefraction: number;
  119405. private _texture;
  119406. /**
  119407. * Stores the clear coat values in a texture.
  119408. */
  119409. texture: Nullable<BaseTexture>;
  119410. private _bumpTexture;
  119411. /**
  119412. * Define the clear coat specific bump texture.
  119413. */
  119414. bumpTexture: Nullable<BaseTexture>;
  119415. private _isTintEnabled;
  119416. /**
  119417. * Defines if the clear coat tint is enabled in the material.
  119418. */
  119419. isTintEnabled: boolean;
  119420. /**
  119421. * Defines the clear coat tint of the material.
  119422. * This is only use if tint is enabled
  119423. */
  119424. tintColor: Color3;
  119425. /**
  119426. * Defines the distance at which the tint color should be found in the
  119427. * clear coat media.
  119428. * This is only use if tint is enabled
  119429. */
  119430. tintColorAtDistance: number;
  119431. /**
  119432. * Defines the clear coat layer thickness.
  119433. * This is only use if tint is enabled
  119434. */
  119435. tintThickness: number;
  119436. private _tintTexture;
  119437. /**
  119438. * Stores the clear tint values in a texture.
  119439. * rgb is tint
  119440. * a is a thickness factor
  119441. */
  119442. tintTexture: Nullable<BaseTexture>;
  119443. /** @hidden */
  119444. private _internalMarkAllSubMeshesAsTexturesDirty;
  119445. /** @hidden */
  119446. _markAllSubMeshesAsTexturesDirty(): void;
  119447. /**
  119448. * Instantiate a new istance of clear coat configuration.
  119449. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119450. */
  119451. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119452. /**
  119453. * Gets wehter the submesh is ready to be used or not.
  119454. * @param defines the list of "defines" to update.
  119455. * @param scene defines the scene the material belongs to.
  119456. * @param engine defines the engine the material belongs to.
  119457. * @param disableBumpMap defines wether the material disables bump or not.
  119458. * @returns - boolean indicating that the submesh is ready or not.
  119459. */
  119460. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  119461. /**
  119462. * Checks to see if a texture is used in the material.
  119463. * @param defines the list of "defines" to update.
  119464. * @param scene defines the scene to the material belongs to.
  119465. */
  119466. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  119467. /**
  119468. * Binds the material data.
  119469. * @param uniformBuffer defines the Uniform buffer to fill in.
  119470. * @param scene defines the scene the material belongs to.
  119471. * @param engine defines the engine the material belongs to.
  119472. * @param disableBumpMap defines wether the material disables bump or not.
  119473. * @param isFrozen defines wether the material is frozen or not.
  119474. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  119475. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  119476. */
  119477. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  119478. /**
  119479. * Checks to see if a texture is used in the material.
  119480. * @param texture - Base texture to use.
  119481. * @returns - Boolean specifying if a texture is used in the material.
  119482. */
  119483. hasTexture(texture: BaseTexture): boolean;
  119484. /**
  119485. * Returns an array of the actively used textures.
  119486. * @param activeTextures Array of BaseTextures
  119487. */
  119488. getActiveTextures(activeTextures: BaseTexture[]): void;
  119489. /**
  119490. * Returns the animatable textures.
  119491. * @param animatables Array of animatable textures.
  119492. */
  119493. getAnimatables(animatables: IAnimatable[]): void;
  119494. /**
  119495. * Disposes the resources of the material.
  119496. * @param forceDisposeTextures - Forces the disposal of all textures.
  119497. */
  119498. dispose(forceDisposeTextures?: boolean): void;
  119499. /**
  119500. * Get the current class name of the texture useful for serialization or dynamic coding.
  119501. * @returns "PBRClearCoatConfiguration"
  119502. */
  119503. getClassName(): string;
  119504. /**
  119505. * Add fallbacks to the effect fallbacks list.
  119506. * @param defines defines the Base texture to use.
  119507. * @param fallbacks defines the current fallback list.
  119508. * @param currentRank defines the current fallback rank.
  119509. * @returns the new fallback rank.
  119510. */
  119511. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119512. /**
  119513. * Add the required uniforms to the current list.
  119514. * @param uniforms defines the current uniform list.
  119515. */
  119516. static AddUniforms(uniforms: string[]): void;
  119517. /**
  119518. * Add the required samplers to the current list.
  119519. * @param samplers defines the current sampler list.
  119520. */
  119521. static AddSamplers(samplers: string[]): void;
  119522. /**
  119523. * Add the required uniforms to the current buffer.
  119524. * @param uniformBuffer defines the current uniform buffer.
  119525. */
  119526. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119527. /**
  119528. * Makes a duplicate of the current configuration into another one.
  119529. * @param clearCoatConfiguration define the config where to copy the info
  119530. */
  119531. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  119532. /**
  119533. * Serializes this clear coat configuration.
  119534. * @returns - An object with the serialized config.
  119535. */
  119536. serialize(): any;
  119537. /**
  119538. * Parses a anisotropy Configuration from a serialized object.
  119539. * @param source - Serialized object.
  119540. * @param scene Defines the scene we are parsing for
  119541. * @param rootUrl Defines the rootUrl to load from
  119542. */
  119543. parse(source: any, scene: Scene, rootUrl: string): void;
  119544. }
  119545. }
  119546. declare module BABYLON {
  119547. /**
  119548. * @hidden
  119549. */
  119550. export interface IMaterialAnisotropicDefines {
  119551. ANISOTROPIC: boolean;
  119552. ANISOTROPIC_TEXTURE: boolean;
  119553. ANISOTROPIC_TEXTUREDIRECTUV: number;
  119554. MAINUV1: boolean;
  119555. _areTexturesDirty: boolean;
  119556. _needUVs: boolean;
  119557. }
  119558. /**
  119559. * Define the code related to the anisotropic parameters of the pbr material.
  119560. */
  119561. export class PBRAnisotropicConfiguration {
  119562. private _isEnabled;
  119563. /**
  119564. * Defines if the anisotropy is enabled in the material.
  119565. */
  119566. isEnabled: boolean;
  119567. /**
  119568. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  119569. */
  119570. intensity: number;
  119571. /**
  119572. * Defines if the effect is along the tangents, bitangents or in between.
  119573. * By default, the effect is "strectching" the highlights along the tangents.
  119574. */
  119575. direction: Vector2;
  119576. private _texture;
  119577. /**
  119578. * Stores the anisotropy values in a texture.
  119579. * rg is direction (like normal from -1 to 1)
  119580. * b is a intensity
  119581. */
  119582. texture: Nullable<BaseTexture>;
  119583. /** @hidden */
  119584. private _internalMarkAllSubMeshesAsTexturesDirty;
  119585. /** @hidden */
  119586. _markAllSubMeshesAsTexturesDirty(): void;
  119587. /**
  119588. * Instantiate a new istance of anisotropy configuration.
  119589. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119590. */
  119591. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119592. /**
  119593. * Specifies that the submesh is ready to be used.
  119594. * @param defines the list of "defines" to update.
  119595. * @param scene defines the scene the material belongs to.
  119596. * @returns - boolean indicating that the submesh is ready or not.
  119597. */
  119598. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  119599. /**
  119600. * Checks to see if a texture is used in the material.
  119601. * @param defines the list of "defines" to update.
  119602. * @param mesh the mesh we are preparing the defines for.
  119603. * @param scene defines the scene the material belongs to.
  119604. */
  119605. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  119606. /**
  119607. * Binds the material data.
  119608. * @param uniformBuffer defines the Uniform buffer to fill in.
  119609. * @param scene defines the scene the material belongs to.
  119610. * @param isFrozen defines wether the material is frozen or not.
  119611. */
  119612. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119613. /**
  119614. * Checks to see if a texture is used in the material.
  119615. * @param texture - Base texture to use.
  119616. * @returns - Boolean specifying if a texture is used in the material.
  119617. */
  119618. hasTexture(texture: BaseTexture): boolean;
  119619. /**
  119620. * Returns an array of the actively used textures.
  119621. * @param activeTextures Array of BaseTextures
  119622. */
  119623. getActiveTextures(activeTextures: BaseTexture[]): void;
  119624. /**
  119625. * Returns the animatable textures.
  119626. * @param animatables Array of animatable textures.
  119627. */
  119628. getAnimatables(animatables: IAnimatable[]): void;
  119629. /**
  119630. * Disposes the resources of the material.
  119631. * @param forceDisposeTextures - Forces the disposal of all textures.
  119632. */
  119633. dispose(forceDisposeTextures?: boolean): void;
  119634. /**
  119635. * Get the current class name of the texture useful for serialization or dynamic coding.
  119636. * @returns "PBRAnisotropicConfiguration"
  119637. */
  119638. getClassName(): string;
  119639. /**
  119640. * Add fallbacks to the effect fallbacks list.
  119641. * @param defines defines the Base texture to use.
  119642. * @param fallbacks defines the current fallback list.
  119643. * @param currentRank defines the current fallback rank.
  119644. * @returns the new fallback rank.
  119645. */
  119646. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119647. /**
  119648. * Add the required uniforms to the current list.
  119649. * @param uniforms defines the current uniform list.
  119650. */
  119651. static AddUniforms(uniforms: string[]): void;
  119652. /**
  119653. * Add the required uniforms to the current buffer.
  119654. * @param uniformBuffer defines the current uniform buffer.
  119655. */
  119656. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119657. /**
  119658. * Add the required samplers to the current list.
  119659. * @param samplers defines the current sampler list.
  119660. */
  119661. static AddSamplers(samplers: string[]): void;
  119662. /**
  119663. * Makes a duplicate of the current configuration into another one.
  119664. * @param anisotropicConfiguration define the config where to copy the info
  119665. */
  119666. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  119667. /**
  119668. * Serializes this anisotropy configuration.
  119669. * @returns - An object with the serialized config.
  119670. */
  119671. serialize(): any;
  119672. /**
  119673. * Parses a anisotropy Configuration from a serialized object.
  119674. * @param source - Serialized object.
  119675. * @param scene Defines the scene we are parsing for
  119676. * @param rootUrl Defines the rootUrl to load from
  119677. */
  119678. parse(source: any, scene: Scene, rootUrl: string): void;
  119679. }
  119680. }
  119681. declare module BABYLON {
  119682. /**
  119683. * @hidden
  119684. */
  119685. export interface IMaterialBRDFDefines {
  119686. BRDF_V_HEIGHT_CORRELATED: boolean;
  119687. MS_BRDF_ENERGY_CONSERVATION: boolean;
  119688. SPHERICAL_HARMONICS: boolean;
  119689. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  119690. /** @hidden */
  119691. _areMiscDirty: boolean;
  119692. }
  119693. /**
  119694. * Define the code related to the BRDF parameters of the pbr material.
  119695. */
  119696. export class PBRBRDFConfiguration {
  119697. /**
  119698. * Default value used for the energy conservation.
  119699. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119700. */
  119701. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  119702. /**
  119703. * Default value used for the Smith Visibility Height Correlated mode.
  119704. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119705. */
  119706. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  119707. /**
  119708. * Default value used for the IBL diffuse part.
  119709. * This can help switching back to the polynomials mode globally which is a tiny bit
  119710. * less GPU intensive at the drawback of a lower quality.
  119711. */
  119712. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  119713. /**
  119714. * Default value used for activating energy conservation for the specular workflow.
  119715. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119716. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119717. */
  119718. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  119719. private _useEnergyConservation;
  119720. /**
  119721. * Defines if the material uses energy conservation.
  119722. */
  119723. useEnergyConservation: boolean;
  119724. private _useSmithVisibilityHeightCorrelated;
  119725. /**
  119726. * LEGACY Mode set to false
  119727. * Defines if the material uses height smith correlated visibility term.
  119728. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  119729. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  119730. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  119731. * Not relying on height correlated will also disable energy conservation.
  119732. */
  119733. useSmithVisibilityHeightCorrelated: boolean;
  119734. private _useSphericalHarmonics;
  119735. /**
  119736. * LEGACY Mode set to false
  119737. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  119738. * diffuse part of the IBL.
  119739. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  119740. * to the ground truth.
  119741. */
  119742. useSphericalHarmonics: boolean;
  119743. private _useSpecularGlossinessInputEnergyConservation;
  119744. /**
  119745. * Defines if the material uses energy conservation, when the specular workflow is active.
  119746. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119747. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119748. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  119749. */
  119750. useSpecularGlossinessInputEnergyConservation: boolean;
  119751. /** @hidden */
  119752. private _internalMarkAllSubMeshesAsMiscDirty;
  119753. /** @hidden */
  119754. _markAllSubMeshesAsMiscDirty(): void;
  119755. /**
  119756. * Instantiate a new istance of clear coat configuration.
  119757. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  119758. */
  119759. constructor(markAllSubMeshesAsMiscDirty: () => void);
  119760. /**
  119761. * Checks to see if a texture is used in the material.
  119762. * @param defines the list of "defines" to update.
  119763. */
  119764. prepareDefines(defines: IMaterialBRDFDefines): void;
  119765. /**
  119766. * Get the current class name of the texture useful for serialization or dynamic coding.
  119767. * @returns "PBRClearCoatConfiguration"
  119768. */
  119769. getClassName(): string;
  119770. /**
  119771. * Makes a duplicate of the current configuration into another one.
  119772. * @param brdfConfiguration define the config where to copy the info
  119773. */
  119774. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  119775. /**
  119776. * Serializes this BRDF configuration.
  119777. * @returns - An object with the serialized config.
  119778. */
  119779. serialize(): any;
  119780. /**
  119781. * Parses a anisotropy Configuration from a serialized object.
  119782. * @param source - Serialized object.
  119783. * @param scene Defines the scene we are parsing for
  119784. * @param rootUrl Defines the rootUrl to load from
  119785. */
  119786. parse(source: any, scene: Scene, rootUrl: string): void;
  119787. }
  119788. }
  119789. declare module BABYLON {
  119790. /**
  119791. * @hidden
  119792. */
  119793. export interface IMaterialSheenDefines {
  119794. SHEEN: boolean;
  119795. SHEEN_TEXTURE: boolean;
  119796. SHEEN_TEXTUREDIRECTUV: number;
  119797. SHEEN_LINKWITHALBEDO: boolean;
  119798. /** @hidden */
  119799. _areTexturesDirty: boolean;
  119800. }
  119801. /**
  119802. * Define the code related to the Sheen parameters of the pbr material.
  119803. */
  119804. export class PBRSheenConfiguration {
  119805. private _isEnabled;
  119806. /**
  119807. * Defines if the material uses sheen.
  119808. */
  119809. isEnabled: boolean;
  119810. private _linkSheenWithAlbedo;
  119811. /**
  119812. * Defines if the sheen is linked to the sheen color.
  119813. */
  119814. linkSheenWithAlbedo: boolean;
  119815. /**
  119816. * Defines the sheen intensity.
  119817. */
  119818. intensity: number;
  119819. /**
  119820. * Defines the sheen color.
  119821. */
  119822. color: Color3;
  119823. private _texture;
  119824. /**
  119825. * Stores the sheen tint values in a texture.
  119826. * rgb is tint
  119827. * a is a intensity
  119828. */
  119829. texture: Nullable<BaseTexture>;
  119830. /** @hidden */
  119831. private _internalMarkAllSubMeshesAsTexturesDirty;
  119832. /** @hidden */
  119833. _markAllSubMeshesAsTexturesDirty(): void;
  119834. /**
  119835. * Instantiate a new istance of clear coat configuration.
  119836. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119837. */
  119838. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119839. /**
  119840. * Specifies that the submesh is ready to be used.
  119841. * @param defines the list of "defines" to update.
  119842. * @param scene defines the scene the material belongs to.
  119843. * @returns - boolean indicating that the submesh is ready or not.
  119844. */
  119845. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  119846. /**
  119847. * Checks to see if a texture is used in the material.
  119848. * @param defines the list of "defines" to update.
  119849. * @param scene defines the scene the material belongs to.
  119850. */
  119851. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  119852. /**
  119853. * Binds the material data.
  119854. * @param uniformBuffer defines the Uniform buffer to fill in.
  119855. * @param scene defines the scene the material belongs to.
  119856. * @param isFrozen defines wether the material is frozen or not.
  119857. */
  119858. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119859. /**
  119860. * Checks to see if a texture is used in the material.
  119861. * @param texture - Base texture to use.
  119862. * @returns - Boolean specifying if a texture is used in the material.
  119863. */
  119864. hasTexture(texture: BaseTexture): boolean;
  119865. /**
  119866. * Returns an array of the actively used textures.
  119867. * @param activeTextures Array of BaseTextures
  119868. */
  119869. getActiveTextures(activeTextures: BaseTexture[]): void;
  119870. /**
  119871. * Returns the animatable textures.
  119872. * @param animatables Array of animatable textures.
  119873. */
  119874. getAnimatables(animatables: IAnimatable[]): void;
  119875. /**
  119876. * Disposes the resources of the material.
  119877. * @param forceDisposeTextures - Forces the disposal of all textures.
  119878. */
  119879. dispose(forceDisposeTextures?: boolean): void;
  119880. /**
  119881. * Get the current class name of the texture useful for serialization or dynamic coding.
  119882. * @returns "PBRSheenConfiguration"
  119883. */
  119884. getClassName(): string;
  119885. /**
  119886. * Add fallbacks to the effect fallbacks list.
  119887. * @param defines defines the Base texture to use.
  119888. * @param fallbacks defines the current fallback list.
  119889. * @param currentRank defines the current fallback rank.
  119890. * @returns the new fallback rank.
  119891. */
  119892. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119893. /**
  119894. * Add the required uniforms to the current list.
  119895. * @param uniforms defines the current uniform list.
  119896. */
  119897. static AddUniforms(uniforms: string[]): void;
  119898. /**
  119899. * Add the required uniforms to the current buffer.
  119900. * @param uniformBuffer defines the current uniform buffer.
  119901. */
  119902. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119903. /**
  119904. * Add the required samplers to the current list.
  119905. * @param samplers defines the current sampler list.
  119906. */
  119907. static AddSamplers(samplers: string[]): void;
  119908. /**
  119909. * Makes a duplicate of the current configuration into another one.
  119910. * @param sheenConfiguration define the config where to copy the info
  119911. */
  119912. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  119913. /**
  119914. * Serializes this BRDF configuration.
  119915. * @returns - An object with the serialized config.
  119916. */
  119917. serialize(): any;
  119918. /**
  119919. * Parses a anisotropy Configuration from a serialized object.
  119920. * @param source - Serialized object.
  119921. * @param scene Defines the scene we are parsing for
  119922. * @param rootUrl Defines the rootUrl to load from
  119923. */
  119924. parse(source: any, scene: Scene, rootUrl: string): void;
  119925. }
  119926. }
  119927. declare module BABYLON {
  119928. /**
  119929. * @hidden
  119930. */
  119931. export interface IMaterialSubSurfaceDefines {
  119932. SUBSURFACE: boolean;
  119933. SS_REFRACTION: boolean;
  119934. SS_TRANSLUCENCY: boolean;
  119935. SS_SCATERRING: boolean;
  119936. SS_THICKNESSANDMASK_TEXTURE: boolean;
  119937. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  119938. SS_REFRACTIONMAP_3D: boolean;
  119939. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  119940. SS_LODINREFRACTIONALPHA: boolean;
  119941. SS_GAMMAREFRACTION: boolean;
  119942. SS_RGBDREFRACTION: boolean;
  119943. SS_LINEARSPECULARREFRACTION: boolean;
  119944. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  119945. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  119946. /** @hidden */
  119947. _areTexturesDirty: boolean;
  119948. }
  119949. /**
  119950. * Define the code related to the sub surface parameters of the pbr material.
  119951. */
  119952. export class PBRSubSurfaceConfiguration {
  119953. private _isRefractionEnabled;
  119954. /**
  119955. * Defines if the refraction is enabled in the material.
  119956. */
  119957. isRefractionEnabled: boolean;
  119958. private _isTranslucencyEnabled;
  119959. /**
  119960. * Defines if the translucency is enabled in the material.
  119961. */
  119962. isTranslucencyEnabled: boolean;
  119963. private _isScatteringEnabled;
  119964. /**
  119965. * Defines the refraction intensity of the material.
  119966. * The refraction when enabled replaces the Diffuse part of the material.
  119967. * The intensity helps transitionning between diffuse and refraction.
  119968. */
  119969. refractionIntensity: number;
  119970. /**
  119971. * Defines the translucency intensity of the material.
  119972. * When translucency has been enabled, this defines how much of the "translucency"
  119973. * is addded to the diffuse part of the material.
  119974. */
  119975. translucencyIntensity: number;
  119976. /**
  119977. * Defines the scattering intensity of the material.
  119978. * When scattering has been enabled, this defines how much of the "scattered light"
  119979. * is addded to the diffuse part of the material.
  119980. */
  119981. scatteringIntensity: number;
  119982. private _thicknessTexture;
  119983. /**
  119984. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  119985. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  119986. * 0 would mean minimumThickness
  119987. * 1 would mean maximumThickness
  119988. * The other channels might be use as a mask to vary the different effects intensity.
  119989. */
  119990. thicknessTexture: Nullable<BaseTexture>;
  119991. private _refractionTexture;
  119992. /**
  119993. * Defines the texture to use for refraction.
  119994. */
  119995. refractionTexture: Nullable<BaseTexture>;
  119996. private _indexOfRefraction;
  119997. /**
  119998. * Defines the index of refraction used in the material.
  119999. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  120000. */
  120001. indexOfRefraction: number;
  120002. private _invertRefractionY;
  120003. /**
  120004. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  120005. */
  120006. invertRefractionY: boolean;
  120007. private _linkRefractionWithTransparency;
  120008. /**
  120009. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  120010. * Materials half opaque for instance using refraction could benefit from this control.
  120011. */
  120012. linkRefractionWithTransparency: boolean;
  120013. /**
  120014. * Defines the minimum thickness stored in the thickness map.
  120015. * If no thickness map is defined, this value will be used to simulate thickness.
  120016. */
  120017. minimumThickness: number;
  120018. /**
  120019. * Defines the maximum thickness stored in the thickness map.
  120020. */
  120021. maximumThickness: number;
  120022. /**
  120023. * Defines the volume tint of the material.
  120024. * This is used for both translucency and scattering.
  120025. */
  120026. tintColor: Color3;
  120027. /**
  120028. * Defines the distance at which the tint color should be found in the media.
  120029. * This is used for refraction only.
  120030. */
  120031. tintColorAtDistance: number;
  120032. /**
  120033. * Defines how far each channel transmit through the media.
  120034. * It is defined as a color to simplify it selection.
  120035. */
  120036. diffusionDistance: Color3;
  120037. private _useMaskFromThicknessTexture;
  120038. /**
  120039. * Stores the intensity of the different subsurface effects in the thickness texture.
  120040. * * the green channel is the translucency intensity.
  120041. * * the blue channel is the scattering intensity.
  120042. * * the alpha channel is the refraction intensity.
  120043. */
  120044. useMaskFromThicknessTexture: boolean;
  120045. /** @hidden */
  120046. private _internalMarkAllSubMeshesAsTexturesDirty;
  120047. /** @hidden */
  120048. _markAllSubMeshesAsTexturesDirty(): void;
  120049. /**
  120050. * Instantiate a new istance of sub surface configuration.
  120051. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  120052. */
  120053. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  120054. /**
  120055. * Gets wehter the submesh is ready to be used or not.
  120056. * @param defines the list of "defines" to update.
  120057. * @param scene defines the scene the material belongs to.
  120058. * @returns - boolean indicating that the submesh is ready or not.
  120059. */
  120060. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  120061. /**
  120062. * Checks to see if a texture is used in the material.
  120063. * @param defines the list of "defines" to update.
  120064. * @param scene defines the scene to the material belongs to.
  120065. */
  120066. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  120067. /**
  120068. * Binds the material data.
  120069. * @param uniformBuffer defines the Uniform buffer to fill in.
  120070. * @param scene defines the scene the material belongs to.
  120071. * @param engine defines the engine the material belongs to.
  120072. * @param isFrozen defines wether the material is frozen or not.
  120073. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  120074. */
  120075. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  120076. /**
  120077. * Unbinds the material from the mesh.
  120078. * @param activeEffect defines the effect that should be unbound from.
  120079. * @returns true if unbound, otherwise false
  120080. */
  120081. unbind(activeEffect: Effect): boolean;
  120082. /**
  120083. * Returns the texture used for refraction or null if none is used.
  120084. * @param scene defines the scene the material belongs to.
  120085. * @returns - Refraction texture if present. If no refraction texture and refraction
  120086. * is linked with transparency, returns environment texture. Otherwise, returns null.
  120087. */
  120088. private _getRefractionTexture;
  120089. /**
  120090. * Returns true if alpha blending should be disabled.
  120091. */
  120092. get disableAlphaBlending(): boolean;
  120093. /**
  120094. * Fills the list of render target textures.
  120095. * @param renderTargets the list of render targets to update
  120096. */
  120097. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  120098. /**
  120099. * Checks to see if a texture is used in the material.
  120100. * @param texture - Base texture to use.
  120101. * @returns - Boolean specifying if a texture is used in the material.
  120102. */
  120103. hasTexture(texture: BaseTexture): boolean;
  120104. /**
  120105. * Gets a boolean indicating that current material needs to register RTT
  120106. * @returns true if this uses a render target otherwise false.
  120107. */
  120108. hasRenderTargetTextures(): boolean;
  120109. /**
  120110. * Returns an array of the actively used textures.
  120111. * @param activeTextures Array of BaseTextures
  120112. */
  120113. getActiveTextures(activeTextures: BaseTexture[]): void;
  120114. /**
  120115. * Returns the animatable textures.
  120116. * @param animatables Array of animatable textures.
  120117. */
  120118. getAnimatables(animatables: IAnimatable[]): void;
  120119. /**
  120120. * Disposes the resources of the material.
  120121. * @param forceDisposeTextures - Forces the disposal of all textures.
  120122. */
  120123. dispose(forceDisposeTextures?: boolean): void;
  120124. /**
  120125. * Get the current class name of the texture useful for serialization or dynamic coding.
  120126. * @returns "PBRSubSurfaceConfiguration"
  120127. */
  120128. getClassName(): string;
  120129. /**
  120130. * Add fallbacks to the effect fallbacks list.
  120131. * @param defines defines the Base texture to use.
  120132. * @param fallbacks defines the current fallback list.
  120133. * @param currentRank defines the current fallback rank.
  120134. * @returns the new fallback rank.
  120135. */
  120136. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120137. /**
  120138. * Add the required uniforms to the current list.
  120139. * @param uniforms defines the current uniform list.
  120140. */
  120141. static AddUniforms(uniforms: string[]): void;
  120142. /**
  120143. * Add the required samplers to the current list.
  120144. * @param samplers defines the current sampler list.
  120145. */
  120146. static AddSamplers(samplers: string[]): void;
  120147. /**
  120148. * Add the required uniforms to the current buffer.
  120149. * @param uniformBuffer defines the current uniform buffer.
  120150. */
  120151. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120152. /**
  120153. * Makes a duplicate of the current configuration into another one.
  120154. * @param configuration define the config where to copy the info
  120155. */
  120156. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  120157. /**
  120158. * Serializes this Sub Surface configuration.
  120159. * @returns - An object with the serialized config.
  120160. */
  120161. serialize(): any;
  120162. /**
  120163. * Parses a anisotropy Configuration from a serialized object.
  120164. * @param source - Serialized object.
  120165. * @param scene Defines the scene we are parsing for
  120166. * @param rootUrl Defines the rootUrl to load from
  120167. */
  120168. parse(source: any, scene: Scene, rootUrl: string): void;
  120169. }
  120170. }
  120171. declare module BABYLON {
  120172. /** @hidden */
  120173. export var pbrFragmentDeclaration: {
  120174. name: string;
  120175. shader: string;
  120176. };
  120177. }
  120178. declare module BABYLON {
  120179. /** @hidden */
  120180. export var pbrUboDeclaration: {
  120181. name: string;
  120182. shader: string;
  120183. };
  120184. }
  120185. declare module BABYLON {
  120186. /** @hidden */
  120187. export var pbrFragmentExtraDeclaration: {
  120188. name: string;
  120189. shader: string;
  120190. };
  120191. }
  120192. declare module BABYLON {
  120193. /** @hidden */
  120194. export var pbrFragmentSamplersDeclaration: {
  120195. name: string;
  120196. shader: string;
  120197. };
  120198. }
  120199. declare module BABYLON {
  120200. /** @hidden */
  120201. export var pbrHelperFunctions: {
  120202. name: string;
  120203. shader: string;
  120204. };
  120205. }
  120206. declare module BABYLON {
  120207. /** @hidden */
  120208. export var harmonicsFunctions: {
  120209. name: string;
  120210. shader: string;
  120211. };
  120212. }
  120213. declare module BABYLON {
  120214. /** @hidden */
  120215. export var pbrDirectLightingSetupFunctions: {
  120216. name: string;
  120217. shader: string;
  120218. };
  120219. }
  120220. declare module BABYLON {
  120221. /** @hidden */
  120222. export var pbrDirectLightingFalloffFunctions: {
  120223. name: string;
  120224. shader: string;
  120225. };
  120226. }
  120227. declare module BABYLON {
  120228. /** @hidden */
  120229. export var pbrBRDFFunctions: {
  120230. name: string;
  120231. shader: string;
  120232. };
  120233. }
  120234. declare module BABYLON {
  120235. /** @hidden */
  120236. export var pbrDirectLightingFunctions: {
  120237. name: string;
  120238. shader: string;
  120239. };
  120240. }
  120241. declare module BABYLON {
  120242. /** @hidden */
  120243. export var pbrIBLFunctions: {
  120244. name: string;
  120245. shader: string;
  120246. };
  120247. }
  120248. declare module BABYLON {
  120249. /** @hidden */
  120250. export var pbrDebug: {
  120251. name: string;
  120252. shader: string;
  120253. };
  120254. }
  120255. declare module BABYLON {
  120256. /** @hidden */
  120257. export var pbrPixelShader: {
  120258. name: string;
  120259. shader: string;
  120260. };
  120261. }
  120262. declare module BABYLON {
  120263. /** @hidden */
  120264. export var pbrVertexDeclaration: {
  120265. name: string;
  120266. shader: string;
  120267. };
  120268. }
  120269. declare module BABYLON {
  120270. /** @hidden */
  120271. export var pbrVertexShader: {
  120272. name: string;
  120273. shader: string;
  120274. };
  120275. }
  120276. declare module BABYLON {
  120277. /**
  120278. * Manages the defines for the PBR Material.
  120279. * @hidden
  120280. */
  120281. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  120282. PBR: boolean;
  120283. MAINUV1: boolean;
  120284. MAINUV2: boolean;
  120285. UV1: boolean;
  120286. UV2: boolean;
  120287. ALBEDO: boolean;
  120288. ALBEDODIRECTUV: number;
  120289. VERTEXCOLOR: boolean;
  120290. AMBIENT: boolean;
  120291. AMBIENTDIRECTUV: number;
  120292. AMBIENTINGRAYSCALE: boolean;
  120293. OPACITY: boolean;
  120294. VERTEXALPHA: boolean;
  120295. OPACITYDIRECTUV: number;
  120296. OPACITYRGB: boolean;
  120297. ALPHATEST: boolean;
  120298. DEPTHPREPASS: boolean;
  120299. ALPHABLEND: boolean;
  120300. ALPHAFROMALBEDO: boolean;
  120301. ALPHATESTVALUE: string;
  120302. SPECULAROVERALPHA: boolean;
  120303. RADIANCEOVERALPHA: boolean;
  120304. ALPHAFRESNEL: boolean;
  120305. LINEARALPHAFRESNEL: boolean;
  120306. PREMULTIPLYALPHA: boolean;
  120307. EMISSIVE: boolean;
  120308. EMISSIVEDIRECTUV: number;
  120309. REFLECTIVITY: boolean;
  120310. REFLECTIVITYDIRECTUV: number;
  120311. SPECULARTERM: boolean;
  120312. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  120313. MICROSURFACEAUTOMATIC: boolean;
  120314. LODBASEDMICROSFURACE: boolean;
  120315. MICROSURFACEMAP: boolean;
  120316. MICROSURFACEMAPDIRECTUV: number;
  120317. METALLICWORKFLOW: boolean;
  120318. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  120319. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  120320. METALLNESSSTOREINMETALMAPBLUE: boolean;
  120321. AOSTOREINMETALMAPRED: boolean;
  120322. METALLICF0FACTORFROMMETALLICMAP: boolean;
  120323. ENVIRONMENTBRDF: boolean;
  120324. ENVIRONMENTBRDF_RGBD: boolean;
  120325. NORMAL: boolean;
  120326. TANGENT: boolean;
  120327. BUMP: boolean;
  120328. BUMPDIRECTUV: number;
  120329. OBJECTSPACE_NORMALMAP: boolean;
  120330. PARALLAX: boolean;
  120331. PARALLAXOCCLUSION: boolean;
  120332. NORMALXYSCALE: boolean;
  120333. LIGHTMAP: boolean;
  120334. LIGHTMAPDIRECTUV: number;
  120335. USELIGHTMAPASSHADOWMAP: boolean;
  120336. GAMMALIGHTMAP: boolean;
  120337. RGBDLIGHTMAP: boolean;
  120338. REFLECTION: boolean;
  120339. REFLECTIONMAP_3D: boolean;
  120340. REFLECTIONMAP_SPHERICAL: boolean;
  120341. REFLECTIONMAP_PLANAR: boolean;
  120342. REFLECTIONMAP_CUBIC: boolean;
  120343. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  120344. REFLECTIONMAP_PROJECTION: boolean;
  120345. REFLECTIONMAP_SKYBOX: boolean;
  120346. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  120347. REFLECTIONMAP_EXPLICIT: boolean;
  120348. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  120349. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  120350. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  120351. INVERTCUBICMAP: boolean;
  120352. USESPHERICALFROMREFLECTIONMAP: boolean;
  120353. USEIRRADIANCEMAP: boolean;
  120354. SPHERICAL_HARMONICS: boolean;
  120355. USESPHERICALINVERTEX: boolean;
  120356. REFLECTIONMAP_OPPOSITEZ: boolean;
  120357. LODINREFLECTIONALPHA: boolean;
  120358. GAMMAREFLECTION: boolean;
  120359. RGBDREFLECTION: boolean;
  120360. LINEARSPECULARREFLECTION: boolean;
  120361. RADIANCEOCCLUSION: boolean;
  120362. HORIZONOCCLUSION: boolean;
  120363. INSTANCES: boolean;
  120364. NUM_BONE_INFLUENCERS: number;
  120365. BonesPerMesh: number;
  120366. BONETEXTURE: boolean;
  120367. NONUNIFORMSCALING: boolean;
  120368. MORPHTARGETS: boolean;
  120369. MORPHTARGETS_NORMAL: boolean;
  120370. MORPHTARGETS_TANGENT: boolean;
  120371. MORPHTARGETS_UV: boolean;
  120372. NUM_MORPH_INFLUENCERS: number;
  120373. IMAGEPROCESSING: boolean;
  120374. VIGNETTE: boolean;
  120375. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120376. VIGNETTEBLENDMODEOPAQUE: boolean;
  120377. TONEMAPPING: boolean;
  120378. TONEMAPPING_ACES: boolean;
  120379. CONTRAST: boolean;
  120380. COLORCURVES: boolean;
  120381. COLORGRADING: boolean;
  120382. COLORGRADING3D: boolean;
  120383. SAMPLER3DGREENDEPTH: boolean;
  120384. SAMPLER3DBGRMAP: boolean;
  120385. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120386. EXPOSURE: boolean;
  120387. MULTIVIEW: boolean;
  120388. USEPHYSICALLIGHTFALLOFF: boolean;
  120389. USEGLTFLIGHTFALLOFF: boolean;
  120390. TWOSIDEDLIGHTING: boolean;
  120391. SHADOWFLOAT: boolean;
  120392. CLIPPLANE: boolean;
  120393. CLIPPLANE2: boolean;
  120394. CLIPPLANE3: boolean;
  120395. CLIPPLANE4: boolean;
  120396. CLIPPLANE5: boolean;
  120397. CLIPPLANE6: boolean;
  120398. POINTSIZE: boolean;
  120399. FOG: boolean;
  120400. LOGARITHMICDEPTH: boolean;
  120401. FORCENORMALFORWARD: boolean;
  120402. SPECULARAA: boolean;
  120403. CLEARCOAT: boolean;
  120404. CLEARCOAT_DEFAULTIOR: boolean;
  120405. CLEARCOAT_TEXTURE: boolean;
  120406. CLEARCOAT_TEXTUREDIRECTUV: number;
  120407. CLEARCOAT_BUMP: boolean;
  120408. CLEARCOAT_BUMPDIRECTUV: number;
  120409. CLEARCOAT_TINT: boolean;
  120410. CLEARCOAT_TINT_TEXTURE: boolean;
  120411. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  120412. ANISOTROPIC: boolean;
  120413. ANISOTROPIC_TEXTURE: boolean;
  120414. ANISOTROPIC_TEXTUREDIRECTUV: number;
  120415. BRDF_V_HEIGHT_CORRELATED: boolean;
  120416. MS_BRDF_ENERGY_CONSERVATION: boolean;
  120417. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  120418. SHEEN: boolean;
  120419. SHEEN_TEXTURE: boolean;
  120420. SHEEN_TEXTUREDIRECTUV: number;
  120421. SHEEN_LINKWITHALBEDO: boolean;
  120422. SUBSURFACE: boolean;
  120423. SS_REFRACTION: boolean;
  120424. SS_TRANSLUCENCY: boolean;
  120425. SS_SCATERRING: boolean;
  120426. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120427. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120428. SS_REFRACTIONMAP_3D: boolean;
  120429. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120430. SS_LODINREFRACTIONALPHA: boolean;
  120431. SS_GAMMAREFRACTION: boolean;
  120432. SS_RGBDREFRACTION: boolean;
  120433. SS_LINEARSPECULARREFRACTION: boolean;
  120434. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120435. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120436. UNLIT: boolean;
  120437. DEBUGMODE: number;
  120438. /**
  120439. * Initializes the PBR Material defines.
  120440. */
  120441. constructor();
  120442. /**
  120443. * Resets the PBR Material defines.
  120444. */
  120445. reset(): void;
  120446. }
  120447. /**
  120448. * The Physically based material base class of BJS.
  120449. *
  120450. * This offers the main features of a standard PBR material.
  120451. * For more information, please refer to the documentation :
  120452. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120453. */
  120454. export abstract class PBRBaseMaterial extends PushMaterial {
  120455. /**
  120456. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120457. */
  120458. static readonly PBRMATERIAL_OPAQUE: number;
  120459. /**
  120460. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120461. */
  120462. static readonly PBRMATERIAL_ALPHATEST: number;
  120463. /**
  120464. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120465. */
  120466. static readonly PBRMATERIAL_ALPHABLEND: number;
  120467. /**
  120468. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120469. * They are also discarded below the alpha cutoff threshold to improve performances.
  120470. */
  120471. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  120472. /**
  120473. * Defines the default value of how much AO map is occluding the analytical lights
  120474. * (point spot...).
  120475. */
  120476. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  120477. /**
  120478. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  120479. */
  120480. static readonly LIGHTFALLOFF_PHYSICAL: number;
  120481. /**
  120482. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  120483. * to enhance interoperability with other engines.
  120484. */
  120485. static readonly LIGHTFALLOFF_GLTF: number;
  120486. /**
  120487. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  120488. * to enhance interoperability with other materials.
  120489. */
  120490. static readonly LIGHTFALLOFF_STANDARD: number;
  120491. /**
  120492. * Intensity of the direct lights e.g. the four lights available in your scene.
  120493. * This impacts both the direct diffuse and specular highlights.
  120494. */
  120495. protected _directIntensity: number;
  120496. /**
  120497. * Intensity of the emissive part of the material.
  120498. * This helps controlling the emissive effect without modifying the emissive color.
  120499. */
  120500. protected _emissiveIntensity: number;
  120501. /**
  120502. * Intensity of the environment e.g. how much the environment will light the object
  120503. * either through harmonics for rough material or through the refelction for shiny ones.
  120504. */
  120505. protected _environmentIntensity: number;
  120506. /**
  120507. * This is a special control allowing the reduction of the specular highlights coming from the
  120508. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  120509. */
  120510. protected _specularIntensity: number;
  120511. /**
  120512. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  120513. */
  120514. private _lightingInfos;
  120515. /**
  120516. * Debug Control allowing disabling the bump map on this material.
  120517. */
  120518. protected _disableBumpMap: boolean;
  120519. /**
  120520. * AKA Diffuse Texture in standard nomenclature.
  120521. */
  120522. protected _albedoTexture: Nullable<BaseTexture>;
  120523. /**
  120524. * AKA Occlusion Texture in other nomenclature.
  120525. */
  120526. protected _ambientTexture: Nullable<BaseTexture>;
  120527. /**
  120528. * AKA Occlusion Texture Intensity in other nomenclature.
  120529. */
  120530. protected _ambientTextureStrength: number;
  120531. /**
  120532. * Defines how much the AO map is occluding the analytical lights (point spot...).
  120533. * 1 means it completely occludes it
  120534. * 0 mean it has no impact
  120535. */
  120536. protected _ambientTextureImpactOnAnalyticalLights: number;
  120537. /**
  120538. * Stores the alpha values in a texture.
  120539. */
  120540. protected _opacityTexture: Nullable<BaseTexture>;
  120541. /**
  120542. * Stores the reflection values in a texture.
  120543. */
  120544. protected _reflectionTexture: Nullable<BaseTexture>;
  120545. /**
  120546. * Stores the emissive values in a texture.
  120547. */
  120548. protected _emissiveTexture: Nullable<BaseTexture>;
  120549. /**
  120550. * AKA Specular texture in other nomenclature.
  120551. */
  120552. protected _reflectivityTexture: Nullable<BaseTexture>;
  120553. /**
  120554. * Used to switch from specular/glossiness to metallic/roughness workflow.
  120555. */
  120556. protected _metallicTexture: Nullable<BaseTexture>;
  120557. /**
  120558. * Specifies the metallic scalar of the metallic/roughness workflow.
  120559. * Can also be used to scale the metalness values of the metallic texture.
  120560. */
  120561. protected _metallic: Nullable<number>;
  120562. /**
  120563. * Specifies the roughness scalar of the metallic/roughness workflow.
  120564. * Can also be used to scale the roughness values of the metallic texture.
  120565. */
  120566. protected _roughness: Nullable<number>;
  120567. /**
  120568. * Specifies the an F0 factor to help configuring the material F0.
  120569. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  120570. * to 0.5 the previously hard coded value stays the same.
  120571. * Can also be used to scale the F0 values of the metallic texture.
  120572. */
  120573. protected _metallicF0Factor: number;
  120574. /**
  120575. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  120576. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  120577. * your expectation as it multiplies with the texture data.
  120578. */
  120579. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  120580. /**
  120581. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  120582. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  120583. */
  120584. protected _microSurfaceTexture: Nullable<BaseTexture>;
  120585. /**
  120586. * Stores surface normal data used to displace a mesh in a texture.
  120587. */
  120588. protected _bumpTexture: Nullable<BaseTexture>;
  120589. /**
  120590. * Stores the pre-calculated light information of a mesh in a texture.
  120591. */
  120592. protected _lightmapTexture: Nullable<BaseTexture>;
  120593. /**
  120594. * The color of a material in ambient lighting.
  120595. */
  120596. protected _ambientColor: Color3;
  120597. /**
  120598. * AKA Diffuse Color in other nomenclature.
  120599. */
  120600. protected _albedoColor: Color3;
  120601. /**
  120602. * AKA Specular Color in other nomenclature.
  120603. */
  120604. protected _reflectivityColor: Color3;
  120605. /**
  120606. * The color applied when light is reflected from a material.
  120607. */
  120608. protected _reflectionColor: Color3;
  120609. /**
  120610. * The color applied when light is emitted from a material.
  120611. */
  120612. protected _emissiveColor: Color3;
  120613. /**
  120614. * AKA Glossiness in other nomenclature.
  120615. */
  120616. protected _microSurface: number;
  120617. /**
  120618. * Specifies that the material will use the light map as a show map.
  120619. */
  120620. protected _useLightmapAsShadowmap: boolean;
  120621. /**
  120622. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  120623. * makes the reflect vector face the model (under horizon).
  120624. */
  120625. protected _useHorizonOcclusion: boolean;
  120626. /**
  120627. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  120628. * too much the area relying on ambient texture to define their ambient occlusion.
  120629. */
  120630. protected _useRadianceOcclusion: boolean;
  120631. /**
  120632. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  120633. */
  120634. protected _useAlphaFromAlbedoTexture: boolean;
  120635. /**
  120636. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  120637. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  120638. */
  120639. protected _useSpecularOverAlpha: boolean;
  120640. /**
  120641. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  120642. */
  120643. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  120644. /**
  120645. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  120646. */
  120647. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  120648. /**
  120649. * Specifies if the metallic texture contains the roughness information in its green channel.
  120650. */
  120651. protected _useRoughnessFromMetallicTextureGreen: boolean;
  120652. /**
  120653. * Specifies if the metallic texture contains the metallness information in its blue channel.
  120654. */
  120655. protected _useMetallnessFromMetallicTextureBlue: boolean;
  120656. /**
  120657. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  120658. */
  120659. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  120660. /**
  120661. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  120662. */
  120663. protected _useAmbientInGrayScale: boolean;
  120664. /**
  120665. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  120666. * The material will try to infer what glossiness each pixel should be.
  120667. */
  120668. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  120669. /**
  120670. * Defines the falloff type used in this material.
  120671. * It by default is Physical.
  120672. */
  120673. protected _lightFalloff: number;
  120674. /**
  120675. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  120676. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  120677. */
  120678. protected _useRadianceOverAlpha: boolean;
  120679. /**
  120680. * Allows using an object space normal map (instead of tangent space).
  120681. */
  120682. protected _useObjectSpaceNormalMap: boolean;
  120683. /**
  120684. * Allows using the bump map in parallax mode.
  120685. */
  120686. protected _useParallax: boolean;
  120687. /**
  120688. * Allows using the bump map in parallax occlusion mode.
  120689. */
  120690. protected _useParallaxOcclusion: boolean;
  120691. /**
  120692. * Controls the scale bias of the parallax mode.
  120693. */
  120694. protected _parallaxScaleBias: number;
  120695. /**
  120696. * If sets to true, disables all the lights affecting the material.
  120697. */
  120698. protected _disableLighting: boolean;
  120699. /**
  120700. * Number of Simultaneous lights allowed on the material.
  120701. */
  120702. protected _maxSimultaneousLights: number;
  120703. /**
  120704. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  120705. */
  120706. protected _invertNormalMapX: boolean;
  120707. /**
  120708. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  120709. */
  120710. protected _invertNormalMapY: boolean;
  120711. /**
  120712. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120713. */
  120714. protected _twoSidedLighting: boolean;
  120715. /**
  120716. * Defines the alpha limits in alpha test mode.
  120717. */
  120718. protected _alphaCutOff: number;
  120719. /**
  120720. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  120721. */
  120722. protected _forceAlphaTest: boolean;
  120723. /**
  120724. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120725. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  120726. */
  120727. protected _useAlphaFresnel: boolean;
  120728. /**
  120729. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120730. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  120731. */
  120732. protected _useLinearAlphaFresnel: boolean;
  120733. /**
  120734. * The transparency mode of the material.
  120735. */
  120736. protected _transparencyMode: Nullable<number>;
  120737. /**
  120738. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  120739. * from cos thetav and roughness:
  120740. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  120741. */
  120742. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  120743. /**
  120744. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  120745. */
  120746. protected _forceIrradianceInFragment: boolean;
  120747. /**
  120748. * Force normal to face away from face.
  120749. */
  120750. protected _forceNormalForward: boolean;
  120751. /**
  120752. * Enables specular anti aliasing in the PBR shader.
  120753. * It will both interacts on the Geometry for analytical and IBL lighting.
  120754. * It also prefilter the roughness map based on the bump values.
  120755. */
  120756. protected _enableSpecularAntiAliasing: boolean;
  120757. /**
  120758. * Default configuration related to image processing available in the PBR Material.
  120759. */
  120760. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120761. /**
  120762. * Keep track of the image processing observer to allow dispose and replace.
  120763. */
  120764. private _imageProcessingObserver;
  120765. /**
  120766. * Attaches a new image processing configuration to the PBR Material.
  120767. * @param configuration
  120768. */
  120769. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120770. /**
  120771. * Stores the available render targets.
  120772. */
  120773. private _renderTargets;
  120774. /**
  120775. * Sets the global ambient color for the material used in lighting calculations.
  120776. */
  120777. private _globalAmbientColor;
  120778. /**
  120779. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  120780. */
  120781. private _useLogarithmicDepth;
  120782. /**
  120783. * If set to true, no lighting calculations will be applied.
  120784. */
  120785. private _unlit;
  120786. private _debugMode;
  120787. /**
  120788. * @hidden
  120789. * This is reserved for the inspector.
  120790. * Defines the material debug mode.
  120791. * It helps seeing only some components of the material while troubleshooting.
  120792. */
  120793. debugMode: number;
  120794. /**
  120795. * @hidden
  120796. * This is reserved for the inspector.
  120797. * Specify from where on screen the debug mode should start.
  120798. * The value goes from -1 (full screen) to 1 (not visible)
  120799. * It helps with side by side comparison against the final render
  120800. * This defaults to -1
  120801. */
  120802. private debugLimit;
  120803. /**
  120804. * @hidden
  120805. * This is reserved for the inspector.
  120806. * As the default viewing range might not be enough (if the ambient is really small for instance)
  120807. * You can use the factor to better multiply the final value.
  120808. */
  120809. private debugFactor;
  120810. /**
  120811. * Defines the clear coat layer parameters for the material.
  120812. */
  120813. readonly clearCoat: PBRClearCoatConfiguration;
  120814. /**
  120815. * Defines the anisotropic parameters for the material.
  120816. */
  120817. readonly anisotropy: PBRAnisotropicConfiguration;
  120818. /**
  120819. * Defines the BRDF parameters for the material.
  120820. */
  120821. readonly brdf: PBRBRDFConfiguration;
  120822. /**
  120823. * Defines the Sheen parameters for the material.
  120824. */
  120825. readonly sheen: PBRSheenConfiguration;
  120826. /**
  120827. * Defines the SubSurface parameters for the material.
  120828. */
  120829. readonly subSurface: PBRSubSurfaceConfiguration;
  120830. /**
  120831. * Custom callback helping to override the default shader used in the material.
  120832. */
  120833. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  120834. protected _rebuildInParallel: boolean;
  120835. /**
  120836. * Instantiates a new PBRMaterial instance.
  120837. *
  120838. * @param name The material name
  120839. * @param scene The scene the material will be use in.
  120840. */
  120841. constructor(name: string, scene: Scene);
  120842. /**
  120843. * Gets a boolean indicating that current material needs to register RTT
  120844. */
  120845. get hasRenderTargetTextures(): boolean;
  120846. /**
  120847. * Gets the name of the material class.
  120848. */
  120849. getClassName(): string;
  120850. /**
  120851. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120852. */
  120853. get useLogarithmicDepth(): boolean;
  120854. /**
  120855. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120856. */
  120857. set useLogarithmicDepth(value: boolean);
  120858. /**
  120859. * Gets the current transparency mode.
  120860. */
  120861. get transparencyMode(): Nullable<number>;
  120862. /**
  120863. * Sets the transparency mode of the material.
  120864. *
  120865. * | Value | Type | Description |
  120866. * | ----- | ----------------------------------- | ----------- |
  120867. * | 0 | OPAQUE | |
  120868. * | 1 | ALPHATEST | |
  120869. * | 2 | ALPHABLEND | |
  120870. * | 3 | ALPHATESTANDBLEND | |
  120871. *
  120872. */
  120873. set transparencyMode(value: Nullable<number>);
  120874. /**
  120875. * Returns true if alpha blending should be disabled.
  120876. */
  120877. private get _disableAlphaBlending();
  120878. /**
  120879. * Specifies whether or not this material should be rendered in alpha blend mode.
  120880. */
  120881. needAlphaBlending(): boolean;
  120882. /**
  120883. * Specifies if the mesh will require alpha blending.
  120884. * @param mesh - BJS mesh.
  120885. */
  120886. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  120887. /**
  120888. * Specifies whether or not this material should be rendered in alpha test mode.
  120889. */
  120890. needAlphaTesting(): boolean;
  120891. /**
  120892. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  120893. */
  120894. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  120895. /**
  120896. * Gets the texture used for the alpha test.
  120897. */
  120898. getAlphaTestTexture(): Nullable<BaseTexture>;
  120899. /**
  120900. * Specifies that the submesh is ready to be used.
  120901. * @param mesh - BJS mesh.
  120902. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  120903. * @param useInstances - Specifies that instances should be used.
  120904. * @returns - boolean indicating that the submesh is ready or not.
  120905. */
  120906. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120907. /**
  120908. * Specifies if the material uses metallic roughness workflow.
  120909. * @returns boolean specifiying if the material uses metallic roughness workflow.
  120910. */
  120911. isMetallicWorkflow(): boolean;
  120912. private _prepareEffect;
  120913. private _prepareDefines;
  120914. /**
  120915. * Force shader compilation
  120916. */
  120917. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  120918. /**
  120919. * Initializes the uniform buffer layout for the shader.
  120920. */
  120921. buildUniformLayout(): void;
  120922. /**
  120923. * Unbinds the material from the mesh
  120924. */
  120925. unbind(): void;
  120926. /**
  120927. * Binds the submesh data.
  120928. * @param world - The world matrix.
  120929. * @param mesh - The BJS mesh.
  120930. * @param subMesh - A submesh of the BJS mesh.
  120931. */
  120932. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120933. /**
  120934. * Returns the animatable textures.
  120935. * @returns - Array of animatable textures.
  120936. */
  120937. getAnimatables(): IAnimatable[];
  120938. /**
  120939. * Returns the texture used for reflections.
  120940. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  120941. */
  120942. private _getReflectionTexture;
  120943. /**
  120944. * Returns an array of the actively used textures.
  120945. * @returns - Array of BaseTextures
  120946. */
  120947. getActiveTextures(): BaseTexture[];
  120948. /**
  120949. * Checks to see if a texture is used in the material.
  120950. * @param texture - Base texture to use.
  120951. * @returns - Boolean specifying if a texture is used in the material.
  120952. */
  120953. hasTexture(texture: BaseTexture): boolean;
  120954. /**
  120955. * Disposes the resources of the material.
  120956. * @param forceDisposeEffect - Forces the disposal of effects.
  120957. * @param forceDisposeTextures - Forces the disposal of all textures.
  120958. */
  120959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  120960. }
  120961. }
  120962. declare module BABYLON {
  120963. /**
  120964. * The Physically based material of BJS.
  120965. *
  120966. * This offers the main features of a standard PBR material.
  120967. * For more information, please refer to the documentation :
  120968. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120969. */
  120970. export class PBRMaterial extends PBRBaseMaterial {
  120971. /**
  120972. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120973. */
  120974. static readonly PBRMATERIAL_OPAQUE: number;
  120975. /**
  120976. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120977. */
  120978. static readonly PBRMATERIAL_ALPHATEST: number;
  120979. /**
  120980. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120981. */
  120982. static readonly PBRMATERIAL_ALPHABLEND: number;
  120983. /**
  120984. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120985. * They are also discarded below the alpha cutoff threshold to improve performances.
  120986. */
  120987. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  120988. /**
  120989. * Defines the default value of how much AO map is occluding the analytical lights
  120990. * (point spot...).
  120991. */
  120992. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  120993. /**
  120994. * Intensity of the direct lights e.g. the four lights available in your scene.
  120995. * This impacts both the direct diffuse and specular highlights.
  120996. */
  120997. directIntensity: number;
  120998. /**
  120999. * Intensity of the emissive part of the material.
  121000. * This helps controlling the emissive effect without modifying the emissive color.
  121001. */
  121002. emissiveIntensity: number;
  121003. /**
  121004. * Intensity of the environment e.g. how much the environment will light the object
  121005. * either through harmonics for rough material or through the refelction for shiny ones.
  121006. */
  121007. environmentIntensity: number;
  121008. /**
  121009. * This is a special control allowing the reduction of the specular highlights coming from the
  121010. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  121011. */
  121012. specularIntensity: number;
  121013. /**
  121014. * Debug Control allowing disabling the bump map on this material.
  121015. */
  121016. disableBumpMap: boolean;
  121017. /**
  121018. * AKA Diffuse Texture in standard nomenclature.
  121019. */
  121020. albedoTexture: BaseTexture;
  121021. /**
  121022. * AKA Occlusion Texture in other nomenclature.
  121023. */
  121024. ambientTexture: BaseTexture;
  121025. /**
  121026. * AKA Occlusion Texture Intensity in other nomenclature.
  121027. */
  121028. ambientTextureStrength: number;
  121029. /**
  121030. * Defines how much the AO map is occluding the analytical lights (point spot...).
  121031. * 1 means it completely occludes it
  121032. * 0 mean it has no impact
  121033. */
  121034. ambientTextureImpactOnAnalyticalLights: number;
  121035. /**
  121036. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  121037. */
  121038. opacityTexture: BaseTexture;
  121039. /**
  121040. * Stores the reflection values in a texture.
  121041. */
  121042. reflectionTexture: Nullable<BaseTexture>;
  121043. /**
  121044. * Stores the emissive values in a texture.
  121045. */
  121046. emissiveTexture: BaseTexture;
  121047. /**
  121048. * AKA Specular texture in other nomenclature.
  121049. */
  121050. reflectivityTexture: BaseTexture;
  121051. /**
  121052. * Used to switch from specular/glossiness to metallic/roughness workflow.
  121053. */
  121054. metallicTexture: BaseTexture;
  121055. /**
  121056. * Specifies the metallic scalar of the metallic/roughness workflow.
  121057. * Can also be used to scale the metalness values of the metallic texture.
  121058. */
  121059. metallic: Nullable<number>;
  121060. /**
  121061. * Specifies the roughness scalar of the metallic/roughness workflow.
  121062. * Can also be used to scale the roughness values of the metallic texture.
  121063. */
  121064. roughness: Nullable<number>;
  121065. /**
  121066. * Specifies the an F0 factor to help configuring the material F0.
  121067. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  121068. * to 0.5 the previously hard coded value stays the same.
  121069. * Can also be used to scale the F0 values of the metallic texture.
  121070. */
  121071. metallicF0Factor: number;
  121072. /**
  121073. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  121074. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  121075. * your expectation as it multiplies with the texture data.
  121076. */
  121077. useMetallicF0FactorFromMetallicTexture: boolean;
  121078. /**
  121079. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  121080. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  121081. */
  121082. microSurfaceTexture: BaseTexture;
  121083. /**
  121084. * Stores surface normal data used to displace a mesh in a texture.
  121085. */
  121086. bumpTexture: BaseTexture;
  121087. /**
  121088. * Stores the pre-calculated light information of a mesh in a texture.
  121089. */
  121090. lightmapTexture: BaseTexture;
  121091. /**
  121092. * Stores the refracted light information in a texture.
  121093. */
  121094. get refractionTexture(): Nullable<BaseTexture>;
  121095. set refractionTexture(value: Nullable<BaseTexture>);
  121096. /**
  121097. * The color of a material in ambient lighting.
  121098. */
  121099. ambientColor: Color3;
  121100. /**
  121101. * AKA Diffuse Color in other nomenclature.
  121102. */
  121103. albedoColor: Color3;
  121104. /**
  121105. * AKA Specular Color in other nomenclature.
  121106. */
  121107. reflectivityColor: Color3;
  121108. /**
  121109. * The color reflected from the material.
  121110. */
  121111. reflectionColor: Color3;
  121112. /**
  121113. * The color emitted from the material.
  121114. */
  121115. emissiveColor: Color3;
  121116. /**
  121117. * AKA Glossiness in other nomenclature.
  121118. */
  121119. microSurface: number;
  121120. /**
  121121. * source material index of refraction (IOR)' / 'destination material IOR.
  121122. */
  121123. get indexOfRefraction(): number;
  121124. set indexOfRefraction(value: number);
  121125. /**
  121126. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  121127. */
  121128. get invertRefractionY(): boolean;
  121129. set invertRefractionY(value: boolean);
  121130. /**
  121131. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  121132. * Materials half opaque for instance using refraction could benefit from this control.
  121133. */
  121134. get linkRefractionWithTransparency(): boolean;
  121135. set linkRefractionWithTransparency(value: boolean);
  121136. /**
  121137. * If true, the light map contains occlusion information instead of lighting info.
  121138. */
  121139. useLightmapAsShadowmap: boolean;
  121140. /**
  121141. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  121142. */
  121143. useAlphaFromAlbedoTexture: boolean;
  121144. /**
  121145. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  121146. */
  121147. forceAlphaTest: boolean;
  121148. /**
  121149. * Defines the alpha limits in alpha test mode.
  121150. */
  121151. alphaCutOff: number;
  121152. /**
  121153. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  121154. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  121155. */
  121156. useSpecularOverAlpha: boolean;
  121157. /**
  121158. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  121159. */
  121160. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  121161. /**
  121162. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  121163. */
  121164. useRoughnessFromMetallicTextureAlpha: boolean;
  121165. /**
  121166. * Specifies if the metallic texture contains the roughness information in its green channel.
  121167. */
  121168. useRoughnessFromMetallicTextureGreen: boolean;
  121169. /**
  121170. * Specifies if the metallic texture contains the metallness information in its blue channel.
  121171. */
  121172. useMetallnessFromMetallicTextureBlue: boolean;
  121173. /**
  121174. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  121175. */
  121176. useAmbientOcclusionFromMetallicTextureRed: boolean;
  121177. /**
  121178. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  121179. */
  121180. useAmbientInGrayScale: boolean;
  121181. /**
  121182. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  121183. * The material will try to infer what glossiness each pixel should be.
  121184. */
  121185. useAutoMicroSurfaceFromReflectivityMap: boolean;
  121186. /**
  121187. * BJS is using an harcoded light falloff based on a manually sets up range.
  121188. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121189. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121190. */
  121191. get usePhysicalLightFalloff(): boolean;
  121192. /**
  121193. * BJS is using an harcoded light falloff based on a manually sets up range.
  121194. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121195. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121196. */
  121197. set usePhysicalLightFalloff(value: boolean);
  121198. /**
  121199. * In order to support the falloff compatibility with gltf, a special mode has been added
  121200. * to reproduce the gltf light falloff.
  121201. */
  121202. get useGLTFLightFalloff(): boolean;
  121203. /**
  121204. * In order to support the falloff compatibility with gltf, a special mode has been added
  121205. * to reproduce the gltf light falloff.
  121206. */
  121207. set useGLTFLightFalloff(value: boolean);
  121208. /**
  121209. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  121210. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  121211. */
  121212. useRadianceOverAlpha: boolean;
  121213. /**
  121214. * Allows using an object space normal map (instead of tangent space).
  121215. */
  121216. useObjectSpaceNormalMap: boolean;
  121217. /**
  121218. * Allows using the bump map in parallax mode.
  121219. */
  121220. useParallax: boolean;
  121221. /**
  121222. * Allows using the bump map in parallax occlusion mode.
  121223. */
  121224. useParallaxOcclusion: boolean;
  121225. /**
  121226. * Controls the scale bias of the parallax mode.
  121227. */
  121228. parallaxScaleBias: number;
  121229. /**
  121230. * If sets to true, disables all the lights affecting the material.
  121231. */
  121232. disableLighting: boolean;
  121233. /**
  121234. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  121235. */
  121236. forceIrradianceInFragment: boolean;
  121237. /**
  121238. * Number of Simultaneous lights allowed on the material.
  121239. */
  121240. maxSimultaneousLights: number;
  121241. /**
  121242. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121243. */
  121244. invertNormalMapX: boolean;
  121245. /**
  121246. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121247. */
  121248. invertNormalMapY: boolean;
  121249. /**
  121250. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121251. */
  121252. twoSidedLighting: boolean;
  121253. /**
  121254. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121255. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  121256. */
  121257. useAlphaFresnel: boolean;
  121258. /**
  121259. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121260. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  121261. */
  121262. useLinearAlphaFresnel: boolean;
  121263. /**
  121264. * Let user defines the brdf lookup texture used for IBL.
  121265. * A default 8bit version is embedded but you could point at :
  121266. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  121267. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  121268. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  121269. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  121270. */
  121271. environmentBRDFTexture: Nullable<BaseTexture>;
  121272. /**
  121273. * Force normal to face away from face.
  121274. */
  121275. forceNormalForward: boolean;
  121276. /**
  121277. * Enables specular anti aliasing in the PBR shader.
  121278. * It will both interacts on the Geometry for analytical and IBL lighting.
  121279. * It also prefilter the roughness map based on the bump values.
  121280. */
  121281. enableSpecularAntiAliasing: boolean;
  121282. /**
  121283. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  121284. * makes the reflect vector face the model (under horizon).
  121285. */
  121286. useHorizonOcclusion: boolean;
  121287. /**
  121288. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  121289. * too much the area relying on ambient texture to define their ambient occlusion.
  121290. */
  121291. useRadianceOcclusion: boolean;
  121292. /**
  121293. * If set to true, no lighting calculations will be applied.
  121294. */
  121295. unlit: boolean;
  121296. /**
  121297. * Gets the image processing configuration used either in this material.
  121298. */
  121299. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  121300. /**
  121301. * Sets the Default image processing configuration used either in the this material.
  121302. *
  121303. * If sets to null, the scene one is in use.
  121304. */
  121305. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  121306. /**
  121307. * Gets wether the color curves effect is enabled.
  121308. */
  121309. get cameraColorCurvesEnabled(): boolean;
  121310. /**
  121311. * Sets wether the color curves effect is enabled.
  121312. */
  121313. set cameraColorCurvesEnabled(value: boolean);
  121314. /**
  121315. * Gets wether the color grading effect is enabled.
  121316. */
  121317. get cameraColorGradingEnabled(): boolean;
  121318. /**
  121319. * Gets wether the color grading effect is enabled.
  121320. */
  121321. set cameraColorGradingEnabled(value: boolean);
  121322. /**
  121323. * Gets wether tonemapping is enabled or not.
  121324. */
  121325. get cameraToneMappingEnabled(): boolean;
  121326. /**
  121327. * Sets wether tonemapping is enabled or not
  121328. */
  121329. set cameraToneMappingEnabled(value: boolean);
  121330. /**
  121331. * The camera exposure used on this material.
  121332. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121333. * This corresponds to a photographic exposure.
  121334. */
  121335. get cameraExposure(): number;
  121336. /**
  121337. * The camera exposure used on this material.
  121338. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121339. * This corresponds to a photographic exposure.
  121340. */
  121341. set cameraExposure(value: number);
  121342. /**
  121343. * Gets The camera contrast used on this material.
  121344. */
  121345. get cameraContrast(): number;
  121346. /**
  121347. * Sets The camera contrast used on this material.
  121348. */
  121349. set cameraContrast(value: number);
  121350. /**
  121351. * Gets the Color Grading 2D Lookup Texture.
  121352. */
  121353. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  121354. /**
  121355. * Sets the Color Grading 2D Lookup Texture.
  121356. */
  121357. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  121358. /**
  121359. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121360. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121361. * 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;
  121362. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121363. */
  121364. get cameraColorCurves(): Nullable<ColorCurves>;
  121365. /**
  121366. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121367. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121368. * 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;
  121369. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121370. */
  121371. set cameraColorCurves(value: Nullable<ColorCurves>);
  121372. /**
  121373. * Instantiates a new PBRMaterial instance.
  121374. *
  121375. * @param name The material name
  121376. * @param scene The scene the material will be use in.
  121377. */
  121378. constructor(name: string, scene: Scene);
  121379. /**
  121380. * Returns the name of this material class.
  121381. */
  121382. getClassName(): string;
  121383. /**
  121384. * Makes a duplicate of the current material.
  121385. * @param name - name to use for the new material.
  121386. */
  121387. clone(name: string): PBRMaterial;
  121388. /**
  121389. * Serializes this PBR Material.
  121390. * @returns - An object with the serialized material.
  121391. */
  121392. serialize(): any;
  121393. /**
  121394. * Parses a PBR Material from a serialized object.
  121395. * @param source - Serialized object.
  121396. * @param scene - BJS scene instance.
  121397. * @param rootUrl - url for the scene object
  121398. * @returns - PBRMaterial
  121399. */
  121400. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  121401. }
  121402. }
  121403. declare module BABYLON {
  121404. /**
  121405. * Direct draw surface info
  121406. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  121407. */
  121408. export interface DDSInfo {
  121409. /**
  121410. * Width of the texture
  121411. */
  121412. width: number;
  121413. /**
  121414. * Width of the texture
  121415. */
  121416. height: number;
  121417. /**
  121418. * Number of Mipmaps for the texture
  121419. * @see https://en.wikipedia.org/wiki/Mipmap
  121420. */
  121421. mipmapCount: number;
  121422. /**
  121423. * If the textures format is a known fourCC format
  121424. * @see https://www.fourcc.org/
  121425. */
  121426. isFourCC: boolean;
  121427. /**
  121428. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  121429. */
  121430. isRGB: boolean;
  121431. /**
  121432. * If the texture is a lumincance format
  121433. */
  121434. isLuminance: boolean;
  121435. /**
  121436. * If this is a cube texture
  121437. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  121438. */
  121439. isCube: boolean;
  121440. /**
  121441. * If the texture is a compressed format eg. FOURCC_DXT1
  121442. */
  121443. isCompressed: boolean;
  121444. /**
  121445. * The dxgiFormat of the texture
  121446. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  121447. */
  121448. dxgiFormat: number;
  121449. /**
  121450. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  121451. */
  121452. textureType: number;
  121453. /**
  121454. * Sphericle polynomial created for the dds texture
  121455. */
  121456. sphericalPolynomial?: SphericalPolynomial;
  121457. }
  121458. /**
  121459. * Class used to provide DDS decompression tools
  121460. */
  121461. export class DDSTools {
  121462. /**
  121463. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  121464. */
  121465. static StoreLODInAlphaChannel: boolean;
  121466. /**
  121467. * Gets DDS information from an array buffer
  121468. * @param arrayBuffer defines the array buffer to read data from
  121469. * @returns the DDS information
  121470. */
  121471. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  121472. private static _FloatView;
  121473. private static _Int32View;
  121474. private static _ToHalfFloat;
  121475. private static _FromHalfFloat;
  121476. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  121477. private static _GetHalfFloatRGBAArrayBuffer;
  121478. private static _GetFloatRGBAArrayBuffer;
  121479. private static _GetFloatAsUIntRGBAArrayBuffer;
  121480. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  121481. private static _GetRGBAArrayBuffer;
  121482. private static _ExtractLongWordOrder;
  121483. private static _GetRGBArrayBuffer;
  121484. private static _GetLuminanceArrayBuffer;
  121485. /**
  121486. * Uploads DDS Levels to a Babylon Texture
  121487. * @hidden
  121488. */
  121489. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  121490. }
  121491. interface ThinEngine {
  121492. /**
  121493. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  121494. * @param rootUrl defines the url where the file to load is located
  121495. * @param scene defines the current scene
  121496. * @param lodScale defines scale to apply to the mip map selection
  121497. * @param lodOffset defines offset to apply to the mip map selection
  121498. * @param onLoad defines an optional callback raised when the texture is loaded
  121499. * @param onError defines an optional callback raised if there is an issue to load the texture
  121500. * @param format defines the format of the data
  121501. * @param forcedExtension defines the extension to use to pick the right loader
  121502. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  121503. * @returns the cube texture as an InternalTexture
  121504. */
  121505. 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;
  121506. }
  121507. }
  121508. declare module BABYLON {
  121509. /**
  121510. * Implementation of the DDS Texture Loader.
  121511. * @hidden
  121512. */
  121513. export class _DDSTextureLoader implements IInternalTextureLoader {
  121514. /**
  121515. * Defines wether the loader supports cascade loading the different faces.
  121516. */
  121517. readonly supportCascades: boolean;
  121518. /**
  121519. * This returns if the loader support the current file information.
  121520. * @param extension defines the file extension of the file being loaded
  121521. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121522. * @param fallback defines the fallback internal texture if any
  121523. * @param isBase64 defines whether the texture is encoded as a base64
  121524. * @param isBuffer defines whether the texture data are stored as a buffer
  121525. * @returns true if the loader can load the specified file
  121526. */
  121527. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121528. /**
  121529. * Transform the url before loading if required.
  121530. * @param rootUrl the url of the texture
  121531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121532. * @returns the transformed texture
  121533. */
  121534. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121535. /**
  121536. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121537. * @param rootUrl the url of the texture
  121538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121539. * @returns the fallback texture
  121540. */
  121541. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121542. /**
  121543. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121544. * @param data contains the texture data
  121545. * @param texture defines the BabylonJS internal texture
  121546. * @param createPolynomials will be true if polynomials have been requested
  121547. * @param onLoad defines the callback to trigger once the texture is ready
  121548. * @param onError defines the callback to trigger in case of error
  121549. */
  121550. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121551. /**
  121552. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121553. * @param data contains the texture data
  121554. * @param texture defines the BabylonJS internal texture
  121555. * @param callback defines the method to call once ready to upload
  121556. */
  121557. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121558. }
  121559. }
  121560. declare module BABYLON {
  121561. /**
  121562. * Implementation of the ENV Texture Loader.
  121563. * @hidden
  121564. */
  121565. export class _ENVTextureLoader implements IInternalTextureLoader {
  121566. /**
  121567. * Defines wether the loader supports cascade loading the different faces.
  121568. */
  121569. readonly supportCascades: boolean;
  121570. /**
  121571. * This returns if the loader support the current file information.
  121572. * @param extension defines the file extension of the file being loaded
  121573. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121574. * @param fallback defines the fallback internal texture if any
  121575. * @param isBase64 defines whether the texture is encoded as a base64
  121576. * @param isBuffer defines whether the texture data are stored as a buffer
  121577. * @returns true if the loader can load the specified file
  121578. */
  121579. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121580. /**
  121581. * Transform the url before loading if required.
  121582. * @param rootUrl the url of the texture
  121583. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121584. * @returns the transformed texture
  121585. */
  121586. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121587. /**
  121588. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121589. * @param rootUrl the url of the texture
  121590. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121591. * @returns the fallback texture
  121592. */
  121593. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121594. /**
  121595. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121596. * @param data contains the texture data
  121597. * @param texture defines the BabylonJS internal texture
  121598. * @param createPolynomials will be true if polynomials have been requested
  121599. * @param onLoad defines the callback to trigger once the texture is ready
  121600. * @param onError defines the callback to trigger in case of error
  121601. */
  121602. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121603. /**
  121604. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121605. * @param data contains the texture data
  121606. * @param texture defines the BabylonJS internal texture
  121607. * @param callback defines the method to call once ready to upload
  121608. */
  121609. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121610. }
  121611. }
  121612. declare module BABYLON {
  121613. /**
  121614. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121615. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121616. */
  121617. export class KhronosTextureContainer {
  121618. /** contents of the KTX container file */
  121619. arrayBuffer: any;
  121620. private static HEADER_LEN;
  121621. private static COMPRESSED_2D;
  121622. private static COMPRESSED_3D;
  121623. private static TEX_2D;
  121624. private static TEX_3D;
  121625. /**
  121626. * Gets the openGL type
  121627. */
  121628. glType: number;
  121629. /**
  121630. * Gets the openGL type size
  121631. */
  121632. glTypeSize: number;
  121633. /**
  121634. * Gets the openGL format
  121635. */
  121636. glFormat: number;
  121637. /**
  121638. * Gets the openGL internal format
  121639. */
  121640. glInternalFormat: number;
  121641. /**
  121642. * Gets the base internal format
  121643. */
  121644. glBaseInternalFormat: number;
  121645. /**
  121646. * Gets image width in pixel
  121647. */
  121648. pixelWidth: number;
  121649. /**
  121650. * Gets image height in pixel
  121651. */
  121652. pixelHeight: number;
  121653. /**
  121654. * Gets image depth in pixels
  121655. */
  121656. pixelDepth: number;
  121657. /**
  121658. * Gets the number of array elements
  121659. */
  121660. numberOfArrayElements: number;
  121661. /**
  121662. * Gets the number of faces
  121663. */
  121664. numberOfFaces: number;
  121665. /**
  121666. * Gets the number of mipmap levels
  121667. */
  121668. numberOfMipmapLevels: number;
  121669. /**
  121670. * Gets the bytes of key value data
  121671. */
  121672. bytesOfKeyValueData: number;
  121673. /**
  121674. * Gets the load type
  121675. */
  121676. loadType: number;
  121677. /**
  121678. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  121679. */
  121680. isInvalid: boolean;
  121681. /**
  121682. * Creates a new KhronosTextureContainer
  121683. * @param arrayBuffer contents of the KTX container file
  121684. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  121685. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  121686. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  121687. */
  121688. constructor(
  121689. /** contents of the KTX container file */
  121690. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  121691. /**
  121692. * Uploads KTX content to a Babylon Texture.
  121693. * It is assumed that the texture has already been created & is currently bound
  121694. * @hidden
  121695. */
  121696. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  121697. private _upload2DCompressedLevels;
  121698. }
  121699. }
  121700. declare module BABYLON {
  121701. /**
  121702. * Implementation of the KTX Texture Loader.
  121703. * @hidden
  121704. */
  121705. export class _KTXTextureLoader implements IInternalTextureLoader {
  121706. /**
  121707. * Defines wether the loader supports cascade loading the different faces.
  121708. */
  121709. readonly supportCascades: boolean;
  121710. /**
  121711. * This returns if the loader support the current file information.
  121712. * @param extension defines the file extension of the file being loaded
  121713. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121714. * @param fallback defines the fallback internal texture if any
  121715. * @param isBase64 defines whether the texture is encoded as a base64
  121716. * @param isBuffer defines whether the texture data are stored as a buffer
  121717. * @returns true if the loader can load the specified file
  121718. */
  121719. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121720. /**
  121721. * Transform the url before loading if required.
  121722. * @param rootUrl the url of the texture
  121723. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121724. * @returns the transformed texture
  121725. */
  121726. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121727. /**
  121728. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121729. * @param rootUrl the url of the texture
  121730. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121731. * @returns the fallback texture
  121732. */
  121733. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121734. /**
  121735. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121736. * @param data contains the texture data
  121737. * @param texture defines the BabylonJS internal texture
  121738. * @param createPolynomials will be true if polynomials have been requested
  121739. * @param onLoad defines the callback to trigger once the texture is ready
  121740. * @param onError defines the callback to trigger in case of error
  121741. */
  121742. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121743. /**
  121744. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121745. * @param data contains the texture data
  121746. * @param texture defines the BabylonJS internal texture
  121747. * @param callback defines the method to call once ready to upload
  121748. */
  121749. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  121750. }
  121751. }
  121752. declare module BABYLON {
  121753. /** @hidden */
  121754. export var _forceSceneHelpersToBundle: boolean;
  121755. interface Scene {
  121756. /**
  121757. * Creates a default light for the scene.
  121758. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  121759. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  121760. */
  121761. createDefaultLight(replace?: boolean): void;
  121762. /**
  121763. * Creates a default camera for the scene.
  121764. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  121765. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121766. * @param replace has default false, when true replaces the active camera in the scene
  121767. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  121768. */
  121769. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121770. /**
  121771. * Creates a default camera and a default light.
  121772. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  121773. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121774. * @param replace has the default false, when true replaces the active camera/light in the scene
  121775. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  121776. */
  121777. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121778. /**
  121779. * Creates a new sky box
  121780. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  121781. * @param environmentTexture defines the texture to use as environment texture
  121782. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  121783. * @param scale defines the overall scale of the skybox
  121784. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  121785. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  121786. * @returns a new mesh holding the sky box
  121787. */
  121788. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  121789. /**
  121790. * Creates a new environment
  121791. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  121792. * @param options defines the options you can use to configure the environment
  121793. * @returns the new EnvironmentHelper
  121794. */
  121795. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  121796. /**
  121797. * Creates a new VREXperienceHelper
  121798. * @see http://doc.babylonjs.com/how_to/webvr_helper
  121799. * @param webVROptions defines the options used to create the new VREXperienceHelper
  121800. * @returns a new VREXperienceHelper
  121801. */
  121802. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  121803. /**
  121804. * Creates a new WebXRDefaultExperience
  121805. * @see http://doc.babylonjs.com/how_to/webxr
  121806. * @param options experience options
  121807. * @returns a promise for a new WebXRDefaultExperience
  121808. */
  121809. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121810. }
  121811. }
  121812. declare module BABYLON {
  121813. /**
  121814. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  121815. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  121816. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  121817. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  121818. */
  121819. export class VideoDome extends TransformNode {
  121820. /**
  121821. * Define the video source as a Monoscopic panoramic 360 video.
  121822. */
  121823. static readonly MODE_MONOSCOPIC: number;
  121824. /**
  121825. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121826. */
  121827. static readonly MODE_TOPBOTTOM: number;
  121828. /**
  121829. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121830. */
  121831. static readonly MODE_SIDEBYSIDE: number;
  121832. private _halfDome;
  121833. private _useDirectMapping;
  121834. /**
  121835. * The video texture being displayed on the sphere
  121836. */
  121837. protected _videoTexture: VideoTexture;
  121838. /**
  121839. * Gets the video texture being displayed on the sphere
  121840. */
  121841. get videoTexture(): VideoTexture;
  121842. /**
  121843. * The skybox material
  121844. */
  121845. protected _material: BackgroundMaterial;
  121846. /**
  121847. * The surface used for the skybox
  121848. */
  121849. protected _mesh: Mesh;
  121850. /**
  121851. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  121852. */
  121853. private _halfDomeMask;
  121854. /**
  121855. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  121856. * Also see the options.resolution property.
  121857. */
  121858. get fovMultiplier(): number;
  121859. set fovMultiplier(value: number);
  121860. private _videoMode;
  121861. /**
  121862. * Gets or set the current video mode for the video. It can be:
  121863. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  121864. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121865. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121866. */
  121867. get videoMode(): number;
  121868. set videoMode(value: number);
  121869. /**
  121870. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  121871. *
  121872. */
  121873. get halfDome(): boolean;
  121874. /**
  121875. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  121876. */
  121877. set halfDome(enabled: boolean);
  121878. /**
  121879. * Oberserver used in Stereoscopic VR Mode.
  121880. */
  121881. private _onBeforeCameraRenderObserver;
  121882. /**
  121883. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  121884. * @param name Element's name, child elements will append suffixes for their own names.
  121885. * @param urlsOrVideo defines the url(s) or the video element to use
  121886. * @param options An object containing optional or exposed sub element properties
  121887. */
  121888. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  121889. resolution?: number;
  121890. clickToPlay?: boolean;
  121891. autoPlay?: boolean;
  121892. loop?: boolean;
  121893. size?: number;
  121894. poster?: string;
  121895. faceForward?: boolean;
  121896. useDirectMapping?: boolean;
  121897. halfDomeMode?: boolean;
  121898. }, scene: Scene);
  121899. private _changeVideoMode;
  121900. /**
  121901. * Releases resources associated with this node.
  121902. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  121903. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  121904. */
  121905. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  121906. }
  121907. }
  121908. declare module BABYLON {
  121909. /**
  121910. * This class can be used to get instrumentation data from a Babylon engine
  121911. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121912. */
  121913. export class EngineInstrumentation implements IDisposable {
  121914. /**
  121915. * Define the instrumented engine.
  121916. */
  121917. engine: Engine;
  121918. private _captureGPUFrameTime;
  121919. private _gpuFrameTimeToken;
  121920. private _gpuFrameTime;
  121921. private _captureShaderCompilationTime;
  121922. private _shaderCompilationTime;
  121923. private _onBeginFrameObserver;
  121924. private _onEndFrameObserver;
  121925. private _onBeforeShaderCompilationObserver;
  121926. private _onAfterShaderCompilationObserver;
  121927. /**
  121928. * Gets the perf counter used for GPU frame time
  121929. */
  121930. get gpuFrameTimeCounter(): PerfCounter;
  121931. /**
  121932. * Gets the GPU frame time capture status
  121933. */
  121934. get captureGPUFrameTime(): boolean;
  121935. /**
  121936. * Enable or disable the GPU frame time capture
  121937. */
  121938. set captureGPUFrameTime(value: boolean);
  121939. /**
  121940. * Gets the perf counter used for shader compilation time
  121941. */
  121942. get shaderCompilationTimeCounter(): PerfCounter;
  121943. /**
  121944. * Gets the shader compilation time capture status
  121945. */
  121946. get captureShaderCompilationTime(): boolean;
  121947. /**
  121948. * Enable or disable the shader compilation time capture
  121949. */
  121950. set captureShaderCompilationTime(value: boolean);
  121951. /**
  121952. * Instantiates a new engine instrumentation.
  121953. * This class can be used to get instrumentation data from a Babylon engine
  121954. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121955. * @param engine Defines the engine to instrument
  121956. */
  121957. constructor(
  121958. /**
  121959. * Define the instrumented engine.
  121960. */
  121961. engine: Engine);
  121962. /**
  121963. * Dispose and release associated resources.
  121964. */
  121965. dispose(): void;
  121966. }
  121967. }
  121968. declare module BABYLON {
  121969. /**
  121970. * This class can be used to get instrumentation data from a Babylon engine
  121971. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  121972. */
  121973. export class SceneInstrumentation implements IDisposable {
  121974. /**
  121975. * Defines the scene to instrument
  121976. */
  121977. scene: Scene;
  121978. private _captureActiveMeshesEvaluationTime;
  121979. private _activeMeshesEvaluationTime;
  121980. private _captureRenderTargetsRenderTime;
  121981. private _renderTargetsRenderTime;
  121982. private _captureFrameTime;
  121983. private _frameTime;
  121984. private _captureRenderTime;
  121985. private _renderTime;
  121986. private _captureInterFrameTime;
  121987. private _interFrameTime;
  121988. private _captureParticlesRenderTime;
  121989. private _particlesRenderTime;
  121990. private _captureSpritesRenderTime;
  121991. private _spritesRenderTime;
  121992. private _capturePhysicsTime;
  121993. private _physicsTime;
  121994. private _captureAnimationsTime;
  121995. private _animationsTime;
  121996. private _captureCameraRenderTime;
  121997. private _cameraRenderTime;
  121998. private _onBeforeActiveMeshesEvaluationObserver;
  121999. private _onAfterActiveMeshesEvaluationObserver;
  122000. private _onBeforeRenderTargetsRenderObserver;
  122001. private _onAfterRenderTargetsRenderObserver;
  122002. private _onAfterRenderObserver;
  122003. private _onBeforeDrawPhaseObserver;
  122004. private _onAfterDrawPhaseObserver;
  122005. private _onBeforeAnimationsObserver;
  122006. private _onBeforeParticlesRenderingObserver;
  122007. private _onAfterParticlesRenderingObserver;
  122008. private _onBeforeSpritesRenderingObserver;
  122009. private _onAfterSpritesRenderingObserver;
  122010. private _onBeforePhysicsObserver;
  122011. private _onAfterPhysicsObserver;
  122012. private _onAfterAnimationsObserver;
  122013. private _onBeforeCameraRenderObserver;
  122014. private _onAfterCameraRenderObserver;
  122015. /**
  122016. * Gets the perf counter used for active meshes evaluation time
  122017. */
  122018. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  122019. /**
  122020. * Gets the active meshes evaluation time capture status
  122021. */
  122022. get captureActiveMeshesEvaluationTime(): boolean;
  122023. /**
  122024. * Enable or disable the active meshes evaluation time capture
  122025. */
  122026. set captureActiveMeshesEvaluationTime(value: boolean);
  122027. /**
  122028. * Gets the perf counter used for render targets render time
  122029. */
  122030. get renderTargetsRenderTimeCounter(): PerfCounter;
  122031. /**
  122032. * Gets the render targets render time capture status
  122033. */
  122034. get captureRenderTargetsRenderTime(): boolean;
  122035. /**
  122036. * Enable or disable the render targets render time capture
  122037. */
  122038. set captureRenderTargetsRenderTime(value: boolean);
  122039. /**
  122040. * Gets the perf counter used for particles render time
  122041. */
  122042. get particlesRenderTimeCounter(): PerfCounter;
  122043. /**
  122044. * Gets the particles render time capture status
  122045. */
  122046. get captureParticlesRenderTime(): boolean;
  122047. /**
  122048. * Enable or disable the particles render time capture
  122049. */
  122050. set captureParticlesRenderTime(value: boolean);
  122051. /**
  122052. * Gets the perf counter used for sprites render time
  122053. */
  122054. get spritesRenderTimeCounter(): PerfCounter;
  122055. /**
  122056. * Gets the sprites render time capture status
  122057. */
  122058. get captureSpritesRenderTime(): boolean;
  122059. /**
  122060. * Enable or disable the sprites render time capture
  122061. */
  122062. set captureSpritesRenderTime(value: boolean);
  122063. /**
  122064. * Gets the perf counter used for physics time
  122065. */
  122066. get physicsTimeCounter(): PerfCounter;
  122067. /**
  122068. * Gets the physics time capture status
  122069. */
  122070. get capturePhysicsTime(): boolean;
  122071. /**
  122072. * Enable or disable the physics time capture
  122073. */
  122074. set capturePhysicsTime(value: boolean);
  122075. /**
  122076. * Gets the perf counter used for animations time
  122077. */
  122078. get animationsTimeCounter(): PerfCounter;
  122079. /**
  122080. * Gets the animations time capture status
  122081. */
  122082. get captureAnimationsTime(): boolean;
  122083. /**
  122084. * Enable or disable the animations time capture
  122085. */
  122086. set captureAnimationsTime(value: boolean);
  122087. /**
  122088. * Gets the perf counter used for frame time capture
  122089. */
  122090. get frameTimeCounter(): PerfCounter;
  122091. /**
  122092. * Gets the frame time capture status
  122093. */
  122094. get captureFrameTime(): boolean;
  122095. /**
  122096. * Enable or disable the frame time capture
  122097. */
  122098. set captureFrameTime(value: boolean);
  122099. /**
  122100. * Gets the perf counter used for inter-frames time capture
  122101. */
  122102. get interFrameTimeCounter(): PerfCounter;
  122103. /**
  122104. * Gets the inter-frames time capture status
  122105. */
  122106. get captureInterFrameTime(): boolean;
  122107. /**
  122108. * Enable or disable the inter-frames time capture
  122109. */
  122110. set captureInterFrameTime(value: boolean);
  122111. /**
  122112. * Gets the perf counter used for render time capture
  122113. */
  122114. get renderTimeCounter(): PerfCounter;
  122115. /**
  122116. * Gets the render time capture status
  122117. */
  122118. get captureRenderTime(): boolean;
  122119. /**
  122120. * Enable or disable the render time capture
  122121. */
  122122. set captureRenderTime(value: boolean);
  122123. /**
  122124. * Gets the perf counter used for camera render time capture
  122125. */
  122126. get cameraRenderTimeCounter(): PerfCounter;
  122127. /**
  122128. * Gets the camera render time capture status
  122129. */
  122130. get captureCameraRenderTime(): boolean;
  122131. /**
  122132. * Enable or disable the camera render time capture
  122133. */
  122134. set captureCameraRenderTime(value: boolean);
  122135. /**
  122136. * Gets the perf counter used for draw calls
  122137. */
  122138. get drawCallsCounter(): PerfCounter;
  122139. /**
  122140. * Instantiates a new scene instrumentation.
  122141. * This class can be used to get instrumentation data from a Babylon engine
  122142. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122143. * @param scene Defines the scene to instrument
  122144. */
  122145. constructor(
  122146. /**
  122147. * Defines the scene to instrument
  122148. */
  122149. scene: Scene);
  122150. /**
  122151. * Dispose and release associated resources.
  122152. */
  122153. dispose(): void;
  122154. }
  122155. }
  122156. declare module BABYLON {
  122157. /** @hidden */
  122158. export var glowMapGenerationPixelShader: {
  122159. name: string;
  122160. shader: string;
  122161. };
  122162. }
  122163. declare module BABYLON {
  122164. /** @hidden */
  122165. export var glowMapGenerationVertexShader: {
  122166. name: string;
  122167. shader: string;
  122168. };
  122169. }
  122170. declare module BABYLON {
  122171. /**
  122172. * Effect layer options. This helps customizing the behaviour
  122173. * of the effect layer.
  122174. */
  122175. export interface IEffectLayerOptions {
  122176. /**
  122177. * Multiplication factor apply to the canvas size to compute the render target size
  122178. * used to generated the objects (the smaller the faster).
  122179. */
  122180. mainTextureRatio: number;
  122181. /**
  122182. * Enforces a fixed size texture to ensure effect stability across devices.
  122183. */
  122184. mainTextureFixedSize?: number;
  122185. /**
  122186. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  122187. */
  122188. alphaBlendingMode: number;
  122189. /**
  122190. * The camera attached to the layer.
  122191. */
  122192. camera: Nullable<Camera>;
  122193. /**
  122194. * The rendering group to draw the layer in.
  122195. */
  122196. renderingGroupId: number;
  122197. }
  122198. /**
  122199. * The effect layer Helps adding post process effect blended with the main pass.
  122200. *
  122201. * This can be for instance use to generate glow or higlight effects on the scene.
  122202. *
  122203. * The effect layer class can not be used directly and is intented to inherited from to be
  122204. * customized per effects.
  122205. */
  122206. export abstract class EffectLayer {
  122207. private _vertexBuffers;
  122208. private _indexBuffer;
  122209. private _cachedDefines;
  122210. private _effectLayerMapGenerationEffect;
  122211. private _effectLayerOptions;
  122212. private _mergeEffect;
  122213. protected _scene: Scene;
  122214. protected _engine: Engine;
  122215. protected _maxSize: number;
  122216. protected _mainTextureDesiredSize: ISize;
  122217. protected _mainTexture: RenderTargetTexture;
  122218. protected _shouldRender: boolean;
  122219. protected _postProcesses: PostProcess[];
  122220. protected _textures: BaseTexture[];
  122221. protected _emissiveTextureAndColor: {
  122222. texture: Nullable<BaseTexture>;
  122223. color: Color4;
  122224. };
  122225. /**
  122226. * The name of the layer
  122227. */
  122228. name: string;
  122229. /**
  122230. * The clear color of the texture used to generate the glow map.
  122231. */
  122232. neutralColor: Color4;
  122233. /**
  122234. * Specifies wether the highlight layer is enabled or not.
  122235. */
  122236. isEnabled: boolean;
  122237. /**
  122238. * Gets the camera attached to the layer.
  122239. */
  122240. get camera(): Nullable<Camera>;
  122241. /**
  122242. * Gets the rendering group id the layer should render in.
  122243. */
  122244. get renderingGroupId(): number;
  122245. set renderingGroupId(renderingGroupId: number);
  122246. /**
  122247. * An event triggered when the effect layer has been disposed.
  122248. */
  122249. onDisposeObservable: Observable<EffectLayer>;
  122250. /**
  122251. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  122252. */
  122253. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  122254. /**
  122255. * An event triggered when the generated texture is being merged in the scene.
  122256. */
  122257. onBeforeComposeObservable: Observable<EffectLayer>;
  122258. /**
  122259. * An event triggered when the mesh is rendered into the effect render target.
  122260. */
  122261. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  122262. /**
  122263. * An event triggered after the mesh has been rendered into the effect render target.
  122264. */
  122265. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  122266. /**
  122267. * An event triggered when the generated texture has been merged in the scene.
  122268. */
  122269. onAfterComposeObservable: Observable<EffectLayer>;
  122270. /**
  122271. * An event triggered when the efffect layer changes its size.
  122272. */
  122273. onSizeChangedObservable: Observable<EffectLayer>;
  122274. /** @hidden */
  122275. static _SceneComponentInitialization: (scene: Scene) => void;
  122276. /**
  122277. * Instantiates a new effect Layer and references it in the scene.
  122278. * @param name The name of the layer
  122279. * @param scene The scene to use the layer in
  122280. */
  122281. constructor(
  122282. /** The Friendly of the effect in the scene */
  122283. name: string, scene: Scene);
  122284. /**
  122285. * Get the effect name of the layer.
  122286. * @return The effect name
  122287. */
  122288. abstract getEffectName(): string;
  122289. /**
  122290. * Checks for the readiness of the element composing the layer.
  122291. * @param subMesh the mesh to check for
  122292. * @param useInstances specify wether or not to use instances to render the mesh
  122293. * @return true if ready otherwise, false
  122294. */
  122295. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122296. /**
  122297. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122298. * @returns true if the effect requires stencil during the main canvas render pass.
  122299. */
  122300. abstract needStencil(): boolean;
  122301. /**
  122302. * Create the merge effect. This is the shader use to blit the information back
  122303. * to the main canvas at the end of the scene rendering.
  122304. * @returns The effect containing the shader used to merge the effect on the main canvas
  122305. */
  122306. protected abstract _createMergeEffect(): Effect;
  122307. /**
  122308. * Creates the render target textures and post processes used in the effect layer.
  122309. */
  122310. protected abstract _createTextureAndPostProcesses(): void;
  122311. /**
  122312. * Implementation specific of rendering the generating effect on the main canvas.
  122313. * @param effect The effect used to render through
  122314. */
  122315. protected abstract _internalRender(effect: Effect): void;
  122316. /**
  122317. * Sets the required values for both the emissive texture and and the main color.
  122318. */
  122319. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122320. /**
  122321. * Free any resources and references associated to a mesh.
  122322. * Internal use
  122323. * @param mesh The mesh to free.
  122324. */
  122325. abstract _disposeMesh(mesh: Mesh): void;
  122326. /**
  122327. * Serializes this layer (Glow or Highlight for example)
  122328. * @returns a serialized layer object
  122329. */
  122330. abstract serialize?(): any;
  122331. /**
  122332. * Initializes the effect layer with the required options.
  122333. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  122334. */
  122335. protected _init(options: Partial<IEffectLayerOptions>): void;
  122336. /**
  122337. * Generates the index buffer of the full screen quad blending to the main canvas.
  122338. */
  122339. private _generateIndexBuffer;
  122340. /**
  122341. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  122342. */
  122343. private _generateVertexBuffer;
  122344. /**
  122345. * Sets the main texture desired size which is the closest power of two
  122346. * of the engine canvas size.
  122347. */
  122348. private _setMainTextureSize;
  122349. /**
  122350. * Creates the main texture for the effect layer.
  122351. */
  122352. protected _createMainTexture(): void;
  122353. /**
  122354. * Adds specific effects defines.
  122355. * @param defines The defines to add specifics to.
  122356. */
  122357. protected _addCustomEffectDefines(defines: string[]): void;
  122358. /**
  122359. * Checks for the readiness of the element composing the layer.
  122360. * @param subMesh the mesh to check for
  122361. * @param useInstances specify wether or not to use instances to render the mesh
  122362. * @param emissiveTexture the associated emissive texture used to generate the glow
  122363. * @return true if ready otherwise, false
  122364. */
  122365. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  122366. /**
  122367. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  122368. */
  122369. render(): void;
  122370. /**
  122371. * Determine if a given mesh will be used in the current effect.
  122372. * @param mesh mesh to test
  122373. * @returns true if the mesh will be used
  122374. */
  122375. hasMesh(mesh: AbstractMesh): boolean;
  122376. /**
  122377. * Returns true if the layer contains information to display, otherwise false.
  122378. * @returns true if the glow layer should be rendered
  122379. */
  122380. shouldRender(): boolean;
  122381. /**
  122382. * Returns true if the mesh should render, otherwise false.
  122383. * @param mesh The mesh to render
  122384. * @returns true if it should render otherwise false
  122385. */
  122386. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  122387. /**
  122388. * Returns true if the mesh can be rendered, otherwise false.
  122389. * @param mesh The mesh to render
  122390. * @param material The material used on the mesh
  122391. * @returns true if it can be rendered otherwise false
  122392. */
  122393. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122394. /**
  122395. * Returns true if the mesh should render, otherwise false.
  122396. * @param mesh The mesh to render
  122397. * @returns true if it should render otherwise false
  122398. */
  122399. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  122400. /**
  122401. * Renders the submesh passed in parameter to the generation map.
  122402. */
  122403. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  122404. /**
  122405. * Defines wether the current material of the mesh should be use to render the effect.
  122406. * @param mesh defines the current mesh to render
  122407. */
  122408. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122409. /**
  122410. * Rebuild the required buffers.
  122411. * @hidden Internal use only.
  122412. */
  122413. _rebuild(): void;
  122414. /**
  122415. * Dispose only the render target textures and post process.
  122416. */
  122417. private _disposeTextureAndPostProcesses;
  122418. /**
  122419. * Dispose the highlight layer and free resources.
  122420. */
  122421. dispose(): void;
  122422. /**
  122423. * Gets the class name of the effect layer
  122424. * @returns the string with the class name of the effect layer
  122425. */
  122426. getClassName(): string;
  122427. /**
  122428. * Creates an effect layer from parsed effect layer data
  122429. * @param parsedEffectLayer defines effect layer data
  122430. * @param scene defines the current scene
  122431. * @param rootUrl defines the root URL containing the effect layer information
  122432. * @returns a parsed effect Layer
  122433. */
  122434. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  122435. }
  122436. }
  122437. declare module BABYLON {
  122438. interface AbstractScene {
  122439. /**
  122440. * The list of effect layers (highlights/glow) added to the scene
  122441. * @see http://doc.babylonjs.com/how_to/highlight_layer
  122442. * @see http://doc.babylonjs.com/how_to/glow_layer
  122443. */
  122444. effectLayers: Array<EffectLayer>;
  122445. /**
  122446. * Removes the given effect layer from this scene.
  122447. * @param toRemove defines the effect layer to remove
  122448. * @returns the index of the removed effect layer
  122449. */
  122450. removeEffectLayer(toRemove: EffectLayer): number;
  122451. /**
  122452. * Adds the given effect layer to this scene
  122453. * @param newEffectLayer defines the effect layer to add
  122454. */
  122455. addEffectLayer(newEffectLayer: EffectLayer): void;
  122456. }
  122457. /**
  122458. * Defines the layer scene component responsible to manage any effect layers
  122459. * in a given scene.
  122460. */
  122461. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  122462. /**
  122463. * The component name helpfull to identify the component in the list of scene components.
  122464. */
  122465. readonly name: string;
  122466. /**
  122467. * The scene the component belongs to.
  122468. */
  122469. scene: Scene;
  122470. private _engine;
  122471. private _renderEffects;
  122472. private _needStencil;
  122473. private _previousStencilState;
  122474. /**
  122475. * Creates a new instance of the component for the given scene
  122476. * @param scene Defines the scene to register the component in
  122477. */
  122478. constructor(scene: Scene);
  122479. /**
  122480. * Registers the component in a given scene
  122481. */
  122482. register(): void;
  122483. /**
  122484. * Rebuilds the elements related to this component in case of
  122485. * context lost for instance.
  122486. */
  122487. rebuild(): void;
  122488. /**
  122489. * Serializes the component data to the specified json object
  122490. * @param serializationObject The object to serialize to
  122491. */
  122492. serialize(serializationObject: any): void;
  122493. /**
  122494. * Adds all the elements from the container to the scene
  122495. * @param container the container holding the elements
  122496. */
  122497. addFromContainer(container: AbstractScene): void;
  122498. /**
  122499. * Removes all the elements in the container from the scene
  122500. * @param container contains the elements to remove
  122501. * @param dispose if the removed element should be disposed (default: false)
  122502. */
  122503. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122504. /**
  122505. * Disposes the component and the associated ressources.
  122506. */
  122507. dispose(): void;
  122508. private _isReadyForMesh;
  122509. private _renderMainTexture;
  122510. private _setStencil;
  122511. private _setStencilBack;
  122512. private _draw;
  122513. private _drawCamera;
  122514. private _drawRenderingGroup;
  122515. }
  122516. }
  122517. declare module BABYLON {
  122518. /** @hidden */
  122519. export var glowMapMergePixelShader: {
  122520. name: string;
  122521. shader: string;
  122522. };
  122523. }
  122524. declare module BABYLON {
  122525. /** @hidden */
  122526. export var glowMapMergeVertexShader: {
  122527. name: string;
  122528. shader: string;
  122529. };
  122530. }
  122531. declare module BABYLON {
  122532. interface AbstractScene {
  122533. /**
  122534. * Return a the first highlight layer of the scene with a given name.
  122535. * @param name The name of the highlight layer to look for.
  122536. * @return The highlight layer if found otherwise null.
  122537. */
  122538. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  122539. }
  122540. /**
  122541. * Glow layer options. This helps customizing the behaviour
  122542. * of the glow layer.
  122543. */
  122544. export interface IGlowLayerOptions {
  122545. /**
  122546. * Multiplication factor apply to the canvas size to compute the render target size
  122547. * used to generated the glowing objects (the smaller the faster).
  122548. */
  122549. mainTextureRatio: number;
  122550. /**
  122551. * Enforces a fixed size texture to ensure resize independant blur.
  122552. */
  122553. mainTextureFixedSize?: number;
  122554. /**
  122555. * How big is the kernel of the blur texture.
  122556. */
  122557. blurKernelSize: number;
  122558. /**
  122559. * The camera attached to the layer.
  122560. */
  122561. camera: Nullable<Camera>;
  122562. /**
  122563. * Enable MSAA by chosing the number of samples.
  122564. */
  122565. mainTextureSamples?: number;
  122566. /**
  122567. * The rendering group to draw the layer in.
  122568. */
  122569. renderingGroupId: number;
  122570. }
  122571. /**
  122572. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  122573. *
  122574. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  122575. *
  122576. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  122577. */
  122578. export class GlowLayer extends EffectLayer {
  122579. /**
  122580. * Effect Name of the layer.
  122581. */
  122582. static readonly EffectName: string;
  122583. /**
  122584. * The default blur kernel size used for the glow.
  122585. */
  122586. static DefaultBlurKernelSize: number;
  122587. /**
  122588. * The default texture size ratio used for the glow.
  122589. */
  122590. static DefaultTextureRatio: number;
  122591. /**
  122592. * Sets the kernel size of the blur.
  122593. */
  122594. set blurKernelSize(value: number);
  122595. /**
  122596. * Gets the kernel size of the blur.
  122597. */
  122598. get blurKernelSize(): number;
  122599. /**
  122600. * Sets the glow intensity.
  122601. */
  122602. set intensity(value: number);
  122603. /**
  122604. * Gets the glow intensity.
  122605. */
  122606. get intensity(): number;
  122607. private _options;
  122608. private _intensity;
  122609. private _horizontalBlurPostprocess1;
  122610. private _verticalBlurPostprocess1;
  122611. private _horizontalBlurPostprocess2;
  122612. private _verticalBlurPostprocess2;
  122613. private _blurTexture1;
  122614. private _blurTexture2;
  122615. private _postProcesses1;
  122616. private _postProcesses2;
  122617. private _includedOnlyMeshes;
  122618. private _excludedMeshes;
  122619. private _meshesUsingTheirOwnMaterials;
  122620. /**
  122621. * Callback used to let the user override the color selection on a per mesh basis
  122622. */
  122623. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  122624. /**
  122625. * Callback used to let the user override the texture selection on a per mesh basis
  122626. */
  122627. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  122628. /**
  122629. * Instantiates a new glow Layer and references it to the scene.
  122630. * @param name The name of the layer
  122631. * @param scene The scene to use the layer in
  122632. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  122633. */
  122634. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  122635. /**
  122636. * Get the effect name of the layer.
  122637. * @return The effect name
  122638. */
  122639. getEffectName(): string;
  122640. /**
  122641. * Create the merge effect. This is the shader use to blit the information back
  122642. * to the main canvas at the end of the scene rendering.
  122643. */
  122644. protected _createMergeEffect(): Effect;
  122645. /**
  122646. * Creates the render target textures and post processes used in the glow layer.
  122647. */
  122648. protected _createTextureAndPostProcesses(): void;
  122649. /**
  122650. * Checks for the readiness of the element composing the layer.
  122651. * @param subMesh the mesh to check for
  122652. * @param useInstances specify wether or not to use instances to render the mesh
  122653. * @param emissiveTexture the associated emissive texture used to generate the glow
  122654. * @return true if ready otherwise, false
  122655. */
  122656. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122657. /**
  122658. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122659. */
  122660. needStencil(): boolean;
  122661. /**
  122662. * Returns true if the mesh can be rendered, otherwise false.
  122663. * @param mesh The mesh to render
  122664. * @param material The material used on the mesh
  122665. * @returns true if it can be rendered otherwise false
  122666. */
  122667. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122668. /**
  122669. * Implementation specific of rendering the generating effect on the main canvas.
  122670. * @param effect The effect used to render through
  122671. */
  122672. protected _internalRender(effect: Effect): void;
  122673. /**
  122674. * Sets the required values for both the emissive texture and and the main color.
  122675. */
  122676. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122677. /**
  122678. * Returns true if the mesh should render, otherwise false.
  122679. * @param mesh The mesh to render
  122680. * @returns true if it should render otherwise false
  122681. */
  122682. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122683. /**
  122684. * Adds specific effects defines.
  122685. * @param defines The defines to add specifics to.
  122686. */
  122687. protected _addCustomEffectDefines(defines: string[]): void;
  122688. /**
  122689. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  122690. * @param mesh The mesh to exclude from the glow layer
  122691. */
  122692. addExcludedMesh(mesh: Mesh): void;
  122693. /**
  122694. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  122695. * @param mesh The mesh to remove
  122696. */
  122697. removeExcludedMesh(mesh: Mesh): void;
  122698. /**
  122699. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  122700. * @param mesh The mesh to include in the glow layer
  122701. */
  122702. addIncludedOnlyMesh(mesh: Mesh): void;
  122703. /**
  122704. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  122705. * @param mesh The mesh to remove
  122706. */
  122707. removeIncludedOnlyMesh(mesh: Mesh): void;
  122708. /**
  122709. * Determine if a given mesh will be used in the glow layer
  122710. * @param mesh The mesh to test
  122711. * @returns true if the mesh will be highlighted by the current glow layer
  122712. */
  122713. hasMesh(mesh: AbstractMesh): boolean;
  122714. /**
  122715. * Defines wether the current material of the mesh should be use to render the effect.
  122716. * @param mesh defines the current mesh to render
  122717. */
  122718. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122719. /**
  122720. * Add a mesh to be rendered through its own material and not with emissive only.
  122721. * @param mesh The mesh for which we need to use its material
  122722. */
  122723. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  122724. /**
  122725. * Remove a mesh from being rendered through its own material and not with emissive only.
  122726. * @param mesh The mesh for which we need to not use its material
  122727. */
  122728. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  122729. /**
  122730. * Free any resources and references associated to a mesh.
  122731. * Internal use
  122732. * @param mesh The mesh to free.
  122733. * @hidden
  122734. */
  122735. _disposeMesh(mesh: Mesh): void;
  122736. /**
  122737. * Gets the class name of the effect layer
  122738. * @returns the string with the class name of the effect layer
  122739. */
  122740. getClassName(): string;
  122741. /**
  122742. * Serializes this glow layer
  122743. * @returns a serialized glow layer object
  122744. */
  122745. serialize(): any;
  122746. /**
  122747. * Creates a Glow Layer from parsed glow layer data
  122748. * @param parsedGlowLayer defines glow layer data
  122749. * @param scene defines the current scene
  122750. * @param rootUrl defines the root URL containing the glow layer information
  122751. * @returns a parsed Glow Layer
  122752. */
  122753. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  122754. }
  122755. }
  122756. declare module BABYLON {
  122757. /** @hidden */
  122758. export var glowBlurPostProcessPixelShader: {
  122759. name: string;
  122760. shader: string;
  122761. };
  122762. }
  122763. declare module BABYLON {
  122764. interface AbstractScene {
  122765. /**
  122766. * Return a the first highlight layer of the scene with a given name.
  122767. * @param name The name of the highlight layer to look for.
  122768. * @return The highlight layer if found otherwise null.
  122769. */
  122770. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  122771. }
  122772. /**
  122773. * Highlight layer options. This helps customizing the behaviour
  122774. * of the highlight layer.
  122775. */
  122776. export interface IHighlightLayerOptions {
  122777. /**
  122778. * Multiplication factor apply to the canvas size to compute the render target size
  122779. * used to generated the glowing objects (the smaller the faster).
  122780. */
  122781. mainTextureRatio: number;
  122782. /**
  122783. * Enforces a fixed size texture to ensure resize independant blur.
  122784. */
  122785. mainTextureFixedSize?: number;
  122786. /**
  122787. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  122788. * of the picture to blur (the smaller the faster).
  122789. */
  122790. blurTextureSizeRatio: number;
  122791. /**
  122792. * How big in texel of the blur texture is the vertical blur.
  122793. */
  122794. blurVerticalSize: number;
  122795. /**
  122796. * How big in texel of the blur texture is the horizontal blur.
  122797. */
  122798. blurHorizontalSize: number;
  122799. /**
  122800. * Alpha blending mode used to apply the blur. Default is combine.
  122801. */
  122802. alphaBlendingMode: number;
  122803. /**
  122804. * The camera attached to the layer.
  122805. */
  122806. camera: Nullable<Camera>;
  122807. /**
  122808. * Should we display highlight as a solid stroke?
  122809. */
  122810. isStroke?: boolean;
  122811. /**
  122812. * The rendering group to draw the layer in.
  122813. */
  122814. renderingGroupId: number;
  122815. }
  122816. /**
  122817. * The highlight layer Helps adding a glow effect around a mesh.
  122818. *
  122819. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  122820. * glowy meshes to your scene.
  122821. *
  122822. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  122823. */
  122824. export class HighlightLayer extends EffectLayer {
  122825. name: string;
  122826. /**
  122827. * Effect Name of the highlight layer.
  122828. */
  122829. static readonly EffectName: string;
  122830. /**
  122831. * The neutral color used during the preparation of the glow effect.
  122832. * This is black by default as the blend operation is a blend operation.
  122833. */
  122834. static NeutralColor: Color4;
  122835. /**
  122836. * Stencil value used for glowing meshes.
  122837. */
  122838. static GlowingMeshStencilReference: number;
  122839. /**
  122840. * Stencil value used for the other meshes in the scene.
  122841. */
  122842. static NormalMeshStencilReference: number;
  122843. /**
  122844. * Specifies whether or not the inner glow is ACTIVE in the layer.
  122845. */
  122846. innerGlow: boolean;
  122847. /**
  122848. * Specifies whether or not the outer glow is ACTIVE in the layer.
  122849. */
  122850. outerGlow: boolean;
  122851. /**
  122852. * Specifies the horizontal size of the blur.
  122853. */
  122854. set blurHorizontalSize(value: number);
  122855. /**
  122856. * Specifies the vertical size of the blur.
  122857. */
  122858. set blurVerticalSize(value: number);
  122859. /**
  122860. * Gets the horizontal size of the blur.
  122861. */
  122862. get blurHorizontalSize(): number;
  122863. /**
  122864. * Gets the vertical size of the blur.
  122865. */
  122866. get blurVerticalSize(): number;
  122867. /**
  122868. * An event triggered when the highlight layer is being blurred.
  122869. */
  122870. onBeforeBlurObservable: Observable<HighlightLayer>;
  122871. /**
  122872. * An event triggered when the highlight layer has been blurred.
  122873. */
  122874. onAfterBlurObservable: Observable<HighlightLayer>;
  122875. private _instanceGlowingMeshStencilReference;
  122876. private _options;
  122877. private _downSamplePostprocess;
  122878. private _horizontalBlurPostprocess;
  122879. private _verticalBlurPostprocess;
  122880. private _blurTexture;
  122881. private _meshes;
  122882. private _excludedMeshes;
  122883. /**
  122884. * Instantiates a new highlight Layer and references it to the scene..
  122885. * @param name The name of the layer
  122886. * @param scene The scene to use the layer in
  122887. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  122888. */
  122889. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  122890. /**
  122891. * Get the effect name of the layer.
  122892. * @return The effect name
  122893. */
  122894. getEffectName(): string;
  122895. /**
  122896. * Create the merge effect. This is the shader use to blit the information back
  122897. * to the main canvas at the end of the scene rendering.
  122898. */
  122899. protected _createMergeEffect(): Effect;
  122900. /**
  122901. * Creates the render target textures and post processes used in the highlight layer.
  122902. */
  122903. protected _createTextureAndPostProcesses(): void;
  122904. /**
  122905. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122906. */
  122907. needStencil(): boolean;
  122908. /**
  122909. * Checks for the readiness of the element composing the layer.
  122910. * @param subMesh the mesh to check for
  122911. * @param useInstances specify wether or not to use instances to render the mesh
  122912. * @param emissiveTexture the associated emissive texture used to generate the glow
  122913. * @return true if ready otherwise, false
  122914. */
  122915. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122916. /**
  122917. * Implementation specific of rendering the generating effect on the main canvas.
  122918. * @param effect The effect used to render through
  122919. */
  122920. protected _internalRender(effect: Effect): void;
  122921. /**
  122922. * Returns true if the layer contains information to display, otherwise false.
  122923. */
  122924. shouldRender(): boolean;
  122925. /**
  122926. * Returns true if the mesh should render, otherwise false.
  122927. * @param mesh The mesh to render
  122928. * @returns true if it should render otherwise false
  122929. */
  122930. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122931. /**
  122932. * Sets the required values for both the emissive texture and and the main color.
  122933. */
  122934. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122935. /**
  122936. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  122937. * @param mesh The mesh to exclude from the highlight layer
  122938. */
  122939. addExcludedMesh(mesh: Mesh): void;
  122940. /**
  122941. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  122942. * @param mesh The mesh to highlight
  122943. */
  122944. removeExcludedMesh(mesh: Mesh): void;
  122945. /**
  122946. * Determine if a given mesh will be highlighted by the current HighlightLayer
  122947. * @param mesh mesh to test
  122948. * @returns true if the mesh will be highlighted by the current HighlightLayer
  122949. */
  122950. hasMesh(mesh: AbstractMesh): boolean;
  122951. /**
  122952. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  122953. * @param mesh The mesh to highlight
  122954. * @param color The color of the highlight
  122955. * @param glowEmissiveOnly Extract the glow from the emissive texture
  122956. */
  122957. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  122958. /**
  122959. * Remove a mesh from the highlight layer in order to make it stop glowing.
  122960. * @param mesh The mesh to highlight
  122961. */
  122962. removeMesh(mesh: Mesh): void;
  122963. /**
  122964. * Force the stencil to the normal expected value for none glowing parts
  122965. */
  122966. private _defaultStencilReference;
  122967. /**
  122968. * Free any resources and references associated to a mesh.
  122969. * Internal use
  122970. * @param mesh The mesh to free.
  122971. * @hidden
  122972. */
  122973. _disposeMesh(mesh: Mesh): void;
  122974. /**
  122975. * Dispose the highlight layer and free resources.
  122976. */
  122977. dispose(): void;
  122978. /**
  122979. * Gets the class name of the effect layer
  122980. * @returns the string with the class name of the effect layer
  122981. */
  122982. getClassName(): string;
  122983. /**
  122984. * Serializes this Highlight layer
  122985. * @returns a serialized Highlight layer object
  122986. */
  122987. serialize(): any;
  122988. /**
  122989. * Creates a Highlight layer from parsed Highlight layer data
  122990. * @param parsedHightlightLayer defines the Highlight layer data
  122991. * @param scene defines the current scene
  122992. * @param rootUrl defines the root URL containing the Highlight layer information
  122993. * @returns a parsed Highlight layer
  122994. */
  122995. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  122996. }
  122997. }
  122998. declare module BABYLON {
  122999. interface AbstractScene {
  123000. /**
  123001. * The list of layers (background and foreground) of the scene
  123002. */
  123003. layers: Array<Layer>;
  123004. }
  123005. /**
  123006. * Defines the layer scene component responsible to manage any layers
  123007. * in a given scene.
  123008. */
  123009. export class LayerSceneComponent implements ISceneComponent {
  123010. /**
  123011. * The component name helpfull to identify the component in the list of scene components.
  123012. */
  123013. readonly name: string;
  123014. /**
  123015. * The scene the component belongs to.
  123016. */
  123017. scene: Scene;
  123018. private _engine;
  123019. /**
  123020. * Creates a new instance of the component for the given scene
  123021. * @param scene Defines the scene to register the component in
  123022. */
  123023. constructor(scene: Scene);
  123024. /**
  123025. * Registers the component in a given scene
  123026. */
  123027. register(): void;
  123028. /**
  123029. * Rebuilds the elements related to this component in case of
  123030. * context lost for instance.
  123031. */
  123032. rebuild(): void;
  123033. /**
  123034. * Disposes the component and the associated ressources.
  123035. */
  123036. dispose(): void;
  123037. private _draw;
  123038. private _drawCameraPredicate;
  123039. private _drawCameraBackground;
  123040. private _drawCameraForeground;
  123041. private _drawRenderTargetPredicate;
  123042. private _drawRenderTargetBackground;
  123043. private _drawRenderTargetForeground;
  123044. /**
  123045. * Adds all the elements from the container to the scene
  123046. * @param container the container holding the elements
  123047. */
  123048. addFromContainer(container: AbstractScene): void;
  123049. /**
  123050. * Removes all the elements in the container from the scene
  123051. * @param container contains the elements to remove
  123052. * @param dispose if the removed element should be disposed (default: false)
  123053. */
  123054. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123055. }
  123056. }
  123057. declare module BABYLON {
  123058. /** @hidden */
  123059. export var layerPixelShader: {
  123060. name: string;
  123061. shader: string;
  123062. };
  123063. }
  123064. declare module BABYLON {
  123065. /** @hidden */
  123066. export var layerVertexShader: {
  123067. name: string;
  123068. shader: string;
  123069. };
  123070. }
  123071. declare module BABYLON {
  123072. /**
  123073. * This represents a full screen 2d layer.
  123074. * This can be useful to display a picture in the background of your scene for instance.
  123075. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123076. */
  123077. export class Layer {
  123078. /**
  123079. * Define the name of the layer.
  123080. */
  123081. name: string;
  123082. /**
  123083. * Define the texture the layer should display.
  123084. */
  123085. texture: Nullable<Texture>;
  123086. /**
  123087. * Is the layer in background or foreground.
  123088. */
  123089. isBackground: boolean;
  123090. /**
  123091. * Define the color of the layer (instead of texture).
  123092. */
  123093. color: Color4;
  123094. /**
  123095. * Define the scale of the layer in order to zoom in out of the texture.
  123096. */
  123097. scale: Vector2;
  123098. /**
  123099. * Define an offset for the layer in order to shift the texture.
  123100. */
  123101. offset: Vector2;
  123102. /**
  123103. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  123104. */
  123105. alphaBlendingMode: number;
  123106. /**
  123107. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  123108. * Alpha test will not mix with the background color in case of transparency.
  123109. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  123110. */
  123111. alphaTest: boolean;
  123112. /**
  123113. * Define a mask to restrict the layer to only some of the scene cameras.
  123114. */
  123115. layerMask: number;
  123116. /**
  123117. * Define the list of render target the layer is visible into.
  123118. */
  123119. renderTargetTextures: RenderTargetTexture[];
  123120. /**
  123121. * Define if the layer is only used in renderTarget or if it also
  123122. * renders in the main frame buffer of the canvas.
  123123. */
  123124. renderOnlyInRenderTargetTextures: boolean;
  123125. private _scene;
  123126. private _vertexBuffers;
  123127. private _indexBuffer;
  123128. private _effect;
  123129. private _previousDefines;
  123130. /**
  123131. * An event triggered when the layer is disposed.
  123132. */
  123133. onDisposeObservable: Observable<Layer>;
  123134. private _onDisposeObserver;
  123135. /**
  123136. * Back compatibility with callback before the onDisposeObservable existed.
  123137. * The set callback will be triggered when the layer has been disposed.
  123138. */
  123139. set onDispose(callback: () => void);
  123140. /**
  123141. * An event triggered before rendering the scene
  123142. */
  123143. onBeforeRenderObservable: Observable<Layer>;
  123144. private _onBeforeRenderObserver;
  123145. /**
  123146. * Back compatibility with callback before the onBeforeRenderObservable existed.
  123147. * The set callback will be triggered just before rendering the layer.
  123148. */
  123149. set onBeforeRender(callback: () => void);
  123150. /**
  123151. * An event triggered after rendering the scene
  123152. */
  123153. onAfterRenderObservable: Observable<Layer>;
  123154. private _onAfterRenderObserver;
  123155. /**
  123156. * Back compatibility with callback before the onAfterRenderObservable existed.
  123157. * The set callback will be triggered just after rendering the layer.
  123158. */
  123159. set onAfterRender(callback: () => void);
  123160. /**
  123161. * Instantiates a new layer.
  123162. * This represents a full screen 2d layer.
  123163. * This can be useful to display a picture in the background of your scene for instance.
  123164. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123165. * @param name Define the name of the layer in the scene
  123166. * @param imgUrl Define the url of the texture to display in the layer
  123167. * @param scene Define the scene the layer belongs to
  123168. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  123169. * @param color Defines a color for the layer
  123170. */
  123171. constructor(
  123172. /**
  123173. * Define the name of the layer.
  123174. */
  123175. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  123176. private _createIndexBuffer;
  123177. /** @hidden */
  123178. _rebuild(): void;
  123179. /**
  123180. * Renders the layer in the scene.
  123181. */
  123182. render(): void;
  123183. /**
  123184. * Disposes and releases the associated ressources.
  123185. */
  123186. dispose(): void;
  123187. }
  123188. }
  123189. declare module BABYLON {
  123190. /** @hidden */
  123191. export var lensFlarePixelShader: {
  123192. name: string;
  123193. shader: string;
  123194. };
  123195. }
  123196. declare module BABYLON {
  123197. /** @hidden */
  123198. export var lensFlareVertexShader: {
  123199. name: string;
  123200. shader: string;
  123201. };
  123202. }
  123203. declare module BABYLON {
  123204. /**
  123205. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123206. * It is usually composed of several `lensFlare`.
  123207. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123208. */
  123209. export class LensFlareSystem {
  123210. /**
  123211. * Define the name of the lens flare system
  123212. */
  123213. name: string;
  123214. /**
  123215. * List of lens flares used in this system.
  123216. */
  123217. lensFlares: LensFlare[];
  123218. /**
  123219. * Define a limit from the border the lens flare can be visible.
  123220. */
  123221. borderLimit: number;
  123222. /**
  123223. * Define a viewport border we do not want to see the lens flare in.
  123224. */
  123225. viewportBorder: number;
  123226. /**
  123227. * Define a predicate which could limit the list of meshes able to occlude the effect.
  123228. */
  123229. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  123230. /**
  123231. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  123232. */
  123233. layerMask: number;
  123234. /**
  123235. * Define the id of the lens flare system in the scene.
  123236. * (equal to name by default)
  123237. */
  123238. id: string;
  123239. private _scene;
  123240. private _emitter;
  123241. private _vertexBuffers;
  123242. private _indexBuffer;
  123243. private _effect;
  123244. private _positionX;
  123245. private _positionY;
  123246. private _isEnabled;
  123247. /** @hidden */
  123248. static _SceneComponentInitialization: (scene: Scene) => void;
  123249. /**
  123250. * Instantiates a lens flare system.
  123251. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123252. * It is usually composed of several `lensFlare`.
  123253. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123254. * @param name Define the name of the lens flare system in the scene
  123255. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  123256. * @param scene Define the scene the lens flare system belongs to
  123257. */
  123258. constructor(
  123259. /**
  123260. * Define the name of the lens flare system
  123261. */
  123262. name: string, emitter: any, scene: Scene);
  123263. /**
  123264. * Define if the lens flare system is enabled.
  123265. */
  123266. get isEnabled(): boolean;
  123267. set isEnabled(value: boolean);
  123268. /**
  123269. * Get the scene the effects belongs to.
  123270. * @returns the scene holding the lens flare system
  123271. */
  123272. getScene(): Scene;
  123273. /**
  123274. * Get the emitter of the lens flare system.
  123275. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123276. * @returns the emitter of the lens flare system
  123277. */
  123278. getEmitter(): any;
  123279. /**
  123280. * Set the emitter of the lens flare system.
  123281. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123282. * @param newEmitter Define the new emitter of the system
  123283. */
  123284. setEmitter(newEmitter: any): void;
  123285. /**
  123286. * Get the lens flare system emitter position.
  123287. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  123288. * @returns the position
  123289. */
  123290. getEmitterPosition(): Vector3;
  123291. /**
  123292. * @hidden
  123293. */
  123294. computeEffectivePosition(globalViewport: Viewport): boolean;
  123295. /** @hidden */
  123296. _isVisible(): boolean;
  123297. /**
  123298. * @hidden
  123299. */
  123300. render(): boolean;
  123301. /**
  123302. * Dispose and release the lens flare with its associated resources.
  123303. */
  123304. dispose(): void;
  123305. /**
  123306. * Parse a lens flare system from a JSON repressentation
  123307. * @param parsedLensFlareSystem Define the JSON to parse
  123308. * @param scene Define the scene the parsed system should be instantiated in
  123309. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  123310. * @returns the parsed system
  123311. */
  123312. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  123313. /**
  123314. * Serialize the current Lens Flare System into a JSON representation.
  123315. * @returns the serialized JSON
  123316. */
  123317. serialize(): any;
  123318. }
  123319. }
  123320. declare module BABYLON {
  123321. /**
  123322. * This represents one of the lens effect in a `lensFlareSystem`.
  123323. * It controls one of the indiviual texture used in the effect.
  123324. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123325. */
  123326. export class LensFlare {
  123327. /**
  123328. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123329. */
  123330. size: number;
  123331. /**
  123332. * 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.
  123333. */
  123334. position: number;
  123335. /**
  123336. * Define the lens color.
  123337. */
  123338. color: Color3;
  123339. /**
  123340. * Define the lens texture.
  123341. */
  123342. texture: Nullable<Texture>;
  123343. /**
  123344. * Define the alpha mode to render this particular lens.
  123345. */
  123346. alphaMode: number;
  123347. private _system;
  123348. /**
  123349. * Creates a new Lens Flare.
  123350. * This represents one of the lens effect in a `lensFlareSystem`.
  123351. * It controls one of the indiviual texture used in the effect.
  123352. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123353. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  123354. * @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.
  123355. * @param color Define the lens color
  123356. * @param imgUrl Define the lens texture url
  123357. * @param system Define the `lensFlareSystem` this flare is part of
  123358. * @returns The newly created Lens Flare
  123359. */
  123360. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  123361. /**
  123362. * Instantiates a new Lens Flare.
  123363. * This represents one of the lens effect in a `lensFlareSystem`.
  123364. * It controls one of the indiviual texture used in the effect.
  123365. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123366. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  123367. * @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.
  123368. * @param color Define the lens color
  123369. * @param imgUrl Define the lens texture url
  123370. * @param system Define the `lensFlareSystem` this flare is part of
  123371. */
  123372. constructor(
  123373. /**
  123374. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123375. */
  123376. size: number,
  123377. /**
  123378. * 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.
  123379. */
  123380. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  123381. /**
  123382. * Dispose and release the lens flare with its associated resources.
  123383. */
  123384. dispose(): void;
  123385. }
  123386. }
  123387. declare module BABYLON {
  123388. interface AbstractScene {
  123389. /**
  123390. * The list of lens flare system added to the scene
  123391. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123392. */
  123393. lensFlareSystems: Array<LensFlareSystem>;
  123394. /**
  123395. * Removes the given lens flare system from this scene.
  123396. * @param toRemove The lens flare system to remove
  123397. * @returns The index of the removed lens flare system
  123398. */
  123399. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  123400. /**
  123401. * Adds the given lens flare system to this scene
  123402. * @param newLensFlareSystem The lens flare system to add
  123403. */
  123404. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  123405. /**
  123406. * Gets a lens flare system using its name
  123407. * @param name defines the name to look for
  123408. * @returns the lens flare system or null if not found
  123409. */
  123410. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  123411. /**
  123412. * Gets a lens flare system using its id
  123413. * @param id defines the id to look for
  123414. * @returns the lens flare system or null if not found
  123415. */
  123416. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  123417. }
  123418. /**
  123419. * Defines the lens flare scene component responsible to manage any lens flares
  123420. * in a given scene.
  123421. */
  123422. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  123423. /**
  123424. * The component name helpfull to identify the component in the list of scene components.
  123425. */
  123426. readonly name: string;
  123427. /**
  123428. * The scene the component belongs to.
  123429. */
  123430. scene: Scene;
  123431. /**
  123432. * Creates a new instance of the component for the given scene
  123433. * @param scene Defines the scene to register the component in
  123434. */
  123435. constructor(scene: Scene);
  123436. /**
  123437. * Registers the component in a given scene
  123438. */
  123439. register(): void;
  123440. /**
  123441. * Rebuilds the elements related to this component in case of
  123442. * context lost for instance.
  123443. */
  123444. rebuild(): void;
  123445. /**
  123446. * Adds all the elements from the container to the scene
  123447. * @param container the container holding the elements
  123448. */
  123449. addFromContainer(container: AbstractScene): void;
  123450. /**
  123451. * Removes all the elements in the container from the scene
  123452. * @param container contains the elements to remove
  123453. * @param dispose if the removed element should be disposed (default: false)
  123454. */
  123455. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123456. /**
  123457. * Serializes the component data to the specified json object
  123458. * @param serializationObject The object to serialize to
  123459. */
  123460. serialize(serializationObject: any): void;
  123461. /**
  123462. * Disposes the component and the associated ressources.
  123463. */
  123464. dispose(): void;
  123465. private _draw;
  123466. }
  123467. }
  123468. declare module BABYLON {
  123469. /**
  123470. * Defines the shadow generator component responsible to manage any shadow generators
  123471. * in a given scene.
  123472. */
  123473. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  123474. /**
  123475. * The component name helpfull to identify the component in the list of scene components.
  123476. */
  123477. readonly name: string;
  123478. /**
  123479. * The scene the component belongs to.
  123480. */
  123481. scene: Scene;
  123482. /**
  123483. * Creates a new instance of the component for the given scene
  123484. * @param scene Defines the scene to register the component in
  123485. */
  123486. constructor(scene: Scene);
  123487. /**
  123488. * Registers the component in a given scene
  123489. */
  123490. register(): void;
  123491. /**
  123492. * Rebuilds the elements related to this component in case of
  123493. * context lost for instance.
  123494. */
  123495. rebuild(): void;
  123496. /**
  123497. * Serializes the component data to the specified json object
  123498. * @param serializationObject The object to serialize to
  123499. */
  123500. serialize(serializationObject: any): void;
  123501. /**
  123502. * Adds all the elements from the container to the scene
  123503. * @param container the container holding the elements
  123504. */
  123505. addFromContainer(container: AbstractScene): void;
  123506. /**
  123507. * Removes all the elements in the container from the scene
  123508. * @param container contains the elements to remove
  123509. * @param dispose if the removed element should be disposed (default: false)
  123510. */
  123511. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123512. /**
  123513. * Rebuilds the elements related to this component in case of
  123514. * context lost for instance.
  123515. */
  123516. dispose(): void;
  123517. private _gatherRenderTargets;
  123518. }
  123519. }
  123520. declare module BABYLON {
  123521. /**
  123522. * A point light is a light defined by an unique point in world space.
  123523. * The light is emitted in every direction from this point.
  123524. * A good example of a point light is a standard light bulb.
  123525. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123526. */
  123527. export class PointLight extends ShadowLight {
  123528. private _shadowAngle;
  123529. /**
  123530. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123531. * This specifies what angle the shadow will use to be created.
  123532. *
  123533. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123534. */
  123535. get shadowAngle(): number;
  123536. /**
  123537. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123538. * This specifies what angle the shadow will use to be created.
  123539. *
  123540. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123541. */
  123542. set shadowAngle(value: number);
  123543. /**
  123544. * Gets the direction if it has been set.
  123545. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123546. */
  123547. get direction(): Vector3;
  123548. /**
  123549. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123550. */
  123551. set direction(value: Vector3);
  123552. /**
  123553. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  123554. * A PointLight emits the light in every direction.
  123555. * It can cast shadows.
  123556. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  123557. * ```javascript
  123558. * var pointLight = new PointLight("pl", camera.position, scene);
  123559. * ```
  123560. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123561. * @param name The light friendly name
  123562. * @param position The position of the point light in the scene
  123563. * @param scene The scene the lights belongs to
  123564. */
  123565. constructor(name: string, position: Vector3, scene: Scene);
  123566. /**
  123567. * Returns the string "PointLight"
  123568. * @returns the class name
  123569. */
  123570. getClassName(): string;
  123571. /**
  123572. * Returns the integer 0.
  123573. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123574. */
  123575. getTypeID(): number;
  123576. /**
  123577. * Specifies wether or not the shadowmap should be a cube texture.
  123578. * @returns true if the shadowmap needs to be a cube texture.
  123579. */
  123580. needCube(): boolean;
  123581. /**
  123582. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  123583. * @param faceIndex The index of the face we are computed the direction to generate shadow
  123584. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  123585. */
  123586. getShadowDirection(faceIndex?: number): Vector3;
  123587. /**
  123588. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  123589. * - fov = PI / 2
  123590. * - aspect ratio : 1.0
  123591. * - z-near and far equal to the active camera minZ and maxZ.
  123592. * Returns the PointLight.
  123593. */
  123594. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123595. protected _buildUniformLayout(): void;
  123596. /**
  123597. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  123598. * @param effect The effect to update
  123599. * @param lightIndex The index of the light in the effect to update
  123600. * @returns The point light
  123601. */
  123602. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  123603. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123604. /**
  123605. * Prepares the list of defines specific to the light type.
  123606. * @param defines the list of defines
  123607. * @param lightIndex defines the index of the light for the effect
  123608. */
  123609. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123610. }
  123611. }
  123612. declare module BABYLON {
  123613. /**
  123614. * Header information of HDR texture files.
  123615. */
  123616. export interface HDRInfo {
  123617. /**
  123618. * The height of the texture in pixels.
  123619. */
  123620. height: number;
  123621. /**
  123622. * The width of the texture in pixels.
  123623. */
  123624. width: number;
  123625. /**
  123626. * The index of the beginning of the data in the binary file.
  123627. */
  123628. dataPosition: number;
  123629. }
  123630. /**
  123631. * This groups tools to convert HDR texture to native colors array.
  123632. */
  123633. export class HDRTools {
  123634. private static Ldexp;
  123635. private static Rgbe2float;
  123636. private static readStringLine;
  123637. /**
  123638. * Reads header information from an RGBE texture stored in a native array.
  123639. * More information on this format are available here:
  123640. * https://en.wikipedia.org/wiki/RGBE_image_format
  123641. *
  123642. * @param uint8array The binary file stored in native array.
  123643. * @return The header information.
  123644. */
  123645. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  123646. /**
  123647. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  123648. * This RGBE texture needs to store the information as a panorama.
  123649. *
  123650. * More information on this format are available here:
  123651. * https://en.wikipedia.org/wiki/RGBE_image_format
  123652. *
  123653. * @param buffer The binary file stored in an array buffer.
  123654. * @param size The expected size of the extracted cubemap.
  123655. * @return The Cube Map information.
  123656. */
  123657. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  123658. /**
  123659. * Returns the pixels data extracted from an RGBE texture.
  123660. * This pixels will be stored left to right up to down in the R G B order in one array.
  123661. *
  123662. * More information on this format are available here:
  123663. * https://en.wikipedia.org/wiki/RGBE_image_format
  123664. *
  123665. * @param uint8array The binary file stored in an array buffer.
  123666. * @param hdrInfo The header information of the file.
  123667. * @return The pixels data in RGB right to left up to down order.
  123668. */
  123669. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  123670. private static RGBE_ReadPixels_RLE;
  123671. }
  123672. }
  123673. declare module BABYLON {
  123674. /**
  123675. * This represents a texture coming from an HDR input.
  123676. *
  123677. * The only supported format is currently panorama picture stored in RGBE format.
  123678. * Example of such files can be found on HDRLib: http://hdrlib.com/
  123679. */
  123680. export class HDRCubeTexture extends BaseTexture {
  123681. private static _facesMapping;
  123682. private _generateHarmonics;
  123683. private _noMipmap;
  123684. private _textureMatrix;
  123685. private _size;
  123686. private _onLoad;
  123687. private _onError;
  123688. /**
  123689. * The texture URL.
  123690. */
  123691. url: string;
  123692. /**
  123693. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  123694. */
  123695. coordinatesMode: number;
  123696. protected _isBlocking: boolean;
  123697. /**
  123698. * Sets wether or not the texture is blocking during loading.
  123699. */
  123700. set isBlocking(value: boolean);
  123701. /**
  123702. * Gets wether or not the texture is blocking during loading.
  123703. */
  123704. get isBlocking(): boolean;
  123705. protected _rotationY: number;
  123706. /**
  123707. * Sets texture matrix rotation angle around Y axis in radians.
  123708. */
  123709. set rotationY(value: number);
  123710. /**
  123711. * Gets texture matrix rotation angle around Y axis radians.
  123712. */
  123713. get rotationY(): number;
  123714. /**
  123715. * Gets or sets the center of the bounding box associated with the cube texture
  123716. * It must define where the camera used to render the texture was set
  123717. */
  123718. boundingBoxPosition: Vector3;
  123719. private _boundingBoxSize;
  123720. /**
  123721. * Gets or sets the size of the bounding box associated with the cube texture
  123722. * When defined, the cubemap will switch to local mode
  123723. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  123724. * @example https://www.babylonjs-playground.com/#RNASML
  123725. */
  123726. set boundingBoxSize(value: Vector3);
  123727. get boundingBoxSize(): Vector3;
  123728. /**
  123729. * Instantiates an HDRTexture from the following parameters.
  123730. *
  123731. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  123732. * @param scene The scene the texture will be used in
  123733. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  123734. * @param noMipmap Forces to not generate the mipmap if true
  123735. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  123736. * @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)
  123737. * @param reserved Reserved flag for internal use.
  123738. */
  123739. 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>);
  123740. /**
  123741. * Get the current class name of the texture useful for serialization or dynamic coding.
  123742. * @returns "HDRCubeTexture"
  123743. */
  123744. getClassName(): string;
  123745. /**
  123746. * Occurs when the file is raw .hdr file.
  123747. */
  123748. private loadTexture;
  123749. clone(): HDRCubeTexture;
  123750. delayLoad(): void;
  123751. /**
  123752. * Get the texture reflection matrix used to rotate/transform the reflection.
  123753. * @returns the reflection matrix
  123754. */
  123755. getReflectionTextureMatrix(): Matrix;
  123756. /**
  123757. * Set the texture reflection matrix used to rotate/transform the reflection.
  123758. * @param value Define the reflection matrix to set
  123759. */
  123760. setReflectionTextureMatrix(value: Matrix): void;
  123761. /**
  123762. * Parses a JSON representation of an HDR Texture in order to create the texture
  123763. * @param parsedTexture Define the JSON representation
  123764. * @param scene Define the scene the texture should be created in
  123765. * @param rootUrl Define the root url in case we need to load relative dependencies
  123766. * @returns the newly created texture after parsing
  123767. */
  123768. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  123769. serialize(): any;
  123770. }
  123771. }
  123772. declare module BABYLON {
  123773. /**
  123774. * Class used to control physics engine
  123775. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123776. */
  123777. export class PhysicsEngine implements IPhysicsEngine {
  123778. private _physicsPlugin;
  123779. /**
  123780. * Global value used to control the smallest number supported by the simulation
  123781. */
  123782. static Epsilon: number;
  123783. private _impostors;
  123784. private _joints;
  123785. private _subTimeStep;
  123786. /**
  123787. * Gets the gravity vector used by the simulation
  123788. */
  123789. gravity: Vector3;
  123790. /**
  123791. * Factory used to create the default physics plugin.
  123792. * @returns The default physics plugin
  123793. */
  123794. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  123795. /**
  123796. * Creates a new Physics Engine
  123797. * @param gravity defines the gravity vector used by the simulation
  123798. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  123799. */
  123800. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  123801. /**
  123802. * Sets the gravity vector used by the simulation
  123803. * @param gravity defines the gravity vector to use
  123804. */
  123805. setGravity(gravity: Vector3): void;
  123806. /**
  123807. * Set the time step of the physics engine.
  123808. * Default is 1/60.
  123809. * To slow it down, enter 1/600 for example.
  123810. * To speed it up, 1/30
  123811. * @param newTimeStep defines the new timestep to apply to this world.
  123812. */
  123813. setTimeStep(newTimeStep?: number): void;
  123814. /**
  123815. * Get the time step of the physics engine.
  123816. * @returns the current time step
  123817. */
  123818. getTimeStep(): number;
  123819. /**
  123820. * Set the sub time step of the physics engine.
  123821. * Default is 0 meaning there is no sub steps
  123822. * To increase physics resolution precision, set a small value (like 1 ms)
  123823. * @param subTimeStep defines the new sub timestep used for physics resolution.
  123824. */
  123825. setSubTimeStep(subTimeStep?: number): void;
  123826. /**
  123827. * Get the sub time step of the physics engine.
  123828. * @returns the current sub time step
  123829. */
  123830. getSubTimeStep(): number;
  123831. /**
  123832. * Release all resources
  123833. */
  123834. dispose(): void;
  123835. /**
  123836. * Gets the name of the current physics plugin
  123837. * @returns the name of the plugin
  123838. */
  123839. getPhysicsPluginName(): string;
  123840. /**
  123841. * Adding a new impostor for the impostor tracking.
  123842. * This will be done by the impostor itself.
  123843. * @param impostor the impostor to add
  123844. */
  123845. addImpostor(impostor: PhysicsImpostor): void;
  123846. /**
  123847. * Remove an impostor from the engine.
  123848. * This impostor and its mesh will not longer be updated by the physics engine.
  123849. * @param impostor the impostor to remove
  123850. */
  123851. removeImpostor(impostor: PhysicsImpostor): void;
  123852. /**
  123853. * Add a joint to the physics engine
  123854. * @param mainImpostor defines the main impostor to which the joint is added.
  123855. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  123856. * @param joint defines the joint that will connect both impostors.
  123857. */
  123858. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123859. /**
  123860. * Removes a joint from the simulation
  123861. * @param mainImpostor defines the impostor used with the joint
  123862. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  123863. * @param joint defines the joint to remove
  123864. */
  123865. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123866. /**
  123867. * Called by the scene. No need to call it.
  123868. * @param delta defines the timespam between frames
  123869. */
  123870. _step(delta: number): void;
  123871. /**
  123872. * Gets the current plugin used to run the simulation
  123873. * @returns current plugin
  123874. */
  123875. getPhysicsPlugin(): IPhysicsEnginePlugin;
  123876. /**
  123877. * Gets the list of physic impostors
  123878. * @returns an array of PhysicsImpostor
  123879. */
  123880. getImpostors(): Array<PhysicsImpostor>;
  123881. /**
  123882. * Gets the impostor for a physics enabled object
  123883. * @param object defines the object impersonated by the impostor
  123884. * @returns the PhysicsImpostor or null if not found
  123885. */
  123886. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  123887. /**
  123888. * Gets the impostor for a physics body object
  123889. * @param body defines physics body used by the impostor
  123890. * @returns the PhysicsImpostor or null if not found
  123891. */
  123892. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  123893. /**
  123894. * Does a raycast in the physics world
  123895. * @param from when should the ray start?
  123896. * @param to when should the ray end?
  123897. * @returns PhysicsRaycastResult
  123898. */
  123899. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  123900. }
  123901. }
  123902. declare module BABYLON {
  123903. /** @hidden */
  123904. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  123905. private _useDeltaForWorldStep;
  123906. world: any;
  123907. name: string;
  123908. private _physicsMaterials;
  123909. private _fixedTimeStep;
  123910. private _cannonRaycastResult;
  123911. private _raycastResult;
  123912. private _physicsBodysToRemoveAfterStep;
  123913. BJSCANNON: any;
  123914. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  123915. setGravity(gravity: Vector3): void;
  123916. setTimeStep(timeStep: number): void;
  123917. getTimeStep(): number;
  123918. executeStep(delta: number): void;
  123919. private _removeMarkedPhysicsBodiesFromWorld;
  123920. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123921. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123922. generatePhysicsBody(impostor: PhysicsImpostor): void;
  123923. private _processChildMeshes;
  123924. removePhysicsBody(impostor: PhysicsImpostor): void;
  123925. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  123926. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  123927. private _addMaterial;
  123928. private _checkWithEpsilon;
  123929. private _createShape;
  123930. private _createHeightmap;
  123931. private _minus90X;
  123932. private _plus90X;
  123933. private _tmpPosition;
  123934. private _tmpDeltaPosition;
  123935. private _tmpUnityRotation;
  123936. private _updatePhysicsBodyTransformation;
  123937. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  123938. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  123939. isSupported(): boolean;
  123940. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123941. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123942. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123943. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123944. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  123945. getBodyMass(impostor: PhysicsImpostor): number;
  123946. getBodyFriction(impostor: PhysicsImpostor): number;
  123947. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  123948. getBodyRestitution(impostor: PhysicsImpostor): number;
  123949. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  123950. sleepBody(impostor: PhysicsImpostor): void;
  123951. wakeUpBody(impostor: PhysicsImpostor): void;
  123952. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  123953. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  123954. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  123955. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  123956. getRadius(impostor: PhysicsImpostor): number;
  123957. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  123958. dispose(): void;
  123959. private _extendNamespace;
  123960. /**
  123961. * Does a raycast in the physics world
  123962. * @param from when should the ray start?
  123963. * @param to when should the ray end?
  123964. * @returns PhysicsRaycastResult
  123965. */
  123966. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  123967. }
  123968. }
  123969. declare module BABYLON {
  123970. /** @hidden */
  123971. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  123972. world: any;
  123973. name: string;
  123974. BJSOIMO: any;
  123975. private _raycastResult;
  123976. constructor(iterations?: number, oimoInjection?: any);
  123977. setGravity(gravity: Vector3): void;
  123978. setTimeStep(timeStep: number): void;
  123979. getTimeStep(): number;
  123980. private _tmpImpostorsArray;
  123981. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  123982. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123983. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  123984. generatePhysicsBody(impostor: PhysicsImpostor): void;
  123985. private _tmpPositionVector;
  123986. removePhysicsBody(impostor: PhysicsImpostor): void;
  123987. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  123988. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  123989. isSupported(): boolean;
  123990. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  123991. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  123992. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123993. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  123994. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123995. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  123996. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  123997. getBodyMass(impostor: PhysicsImpostor): number;
  123998. getBodyFriction(impostor: PhysicsImpostor): number;
  123999. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124000. getBodyRestitution(impostor: PhysicsImpostor): number;
  124001. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124002. sleepBody(impostor: PhysicsImpostor): void;
  124003. wakeUpBody(impostor: PhysicsImpostor): void;
  124004. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124005. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  124006. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  124007. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124008. getRadius(impostor: PhysicsImpostor): number;
  124009. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124010. dispose(): void;
  124011. /**
  124012. * Does a raycast in the physics world
  124013. * @param from when should the ray start?
  124014. * @param to when should the ray end?
  124015. * @returns PhysicsRaycastResult
  124016. */
  124017. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124018. }
  124019. }
  124020. declare module BABYLON {
  124021. /**
  124022. * Class containing static functions to help procedurally build meshes
  124023. */
  124024. export class RibbonBuilder {
  124025. /**
  124026. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124027. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124028. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124029. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124030. * * 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
  124031. * * 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
  124032. * * 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
  124033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124035. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124036. * * 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
  124037. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124038. * * 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
  124039. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124041. * @param name defines the name of the mesh
  124042. * @param options defines the options used to create the mesh
  124043. * @param scene defines the hosting scene
  124044. * @returns the ribbon mesh
  124045. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124046. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124047. */
  124048. static CreateRibbon(name: string, options: {
  124049. pathArray: Vector3[][];
  124050. closeArray?: boolean;
  124051. closePath?: boolean;
  124052. offset?: number;
  124053. updatable?: boolean;
  124054. sideOrientation?: number;
  124055. frontUVs?: Vector4;
  124056. backUVs?: Vector4;
  124057. instance?: Mesh;
  124058. invertUV?: boolean;
  124059. uvs?: Vector2[];
  124060. colors?: Color4[];
  124061. }, scene?: Nullable<Scene>): Mesh;
  124062. }
  124063. }
  124064. declare module BABYLON {
  124065. /**
  124066. * Class containing static functions to help procedurally build meshes
  124067. */
  124068. export class ShapeBuilder {
  124069. /**
  124070. * 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.
  124071. * * 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.
  124072. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124073. * * 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.
  124074. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124075. * * 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
  124076. * * 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
  124077. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124082. * @param name defines the name of the mesh
  124083. * @param options defines the options used to create the mesh
  124084. * @param scene defines the hosting scene
  124085. * @returns the extruded shape mesh
  124086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124088. */
  124089. static ExtrudeShape(name: string, options: {
  124090. shape: Vector3[];
  124091. path: Vector3[];
  124092. scale?: number;
  124093. rotation?: number;
  124094. cap?: number;
  124095. updatable?: boolean;
  124096. sideOrientation?: number;
  124097. frontUVs?: Vector4;
  124098. backUVs?: Vector4;
  124099. instance?: Mesh;
  124100. invertUV?: boolean;
  124101. }, scene?: Nullable<Scene>): Mesh;
  124102. /**
  124103. * Creates an custom extruded shape mesh.
  124104. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124105. * * 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.
  124106. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124107. * * 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
  124108. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124109. * * 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
  124110. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124111. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124112. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124113. * * 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
  124114. * * 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
  124115. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124118. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124120. * @param name defines the name of the mesh
  124121. * @param options defines the options used to create the mesh
  124122. * @param scene defines the hosting scene
  124123. * @returns the custom extruded shape mesh
  124124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124125. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124127. */
  124128. static ExtrudeShapeCustom(name: string, options: {
  124129. shape: Vector3[];
  124130. path: Vector3[];
  124131. scaleFunction?: any;
  124132. rotationFunction?: any;
  124133. ribbonCloseArray?: boolean;
  124134. ribbonClosePath?: boolean;
  124135. cap?: number;
  124136. updatable?: boolean;
  124137. sideOrientation?: number;
  124138. frontUVs?: Vector4;
  124139. backUVs?: Vector4;
  124140. instance?: Mesh;
  124141. invertUV?: boolean;
  124142. }, scene?: Nullable<Scene>): Mesh;
  124143. private static _ExtrudeShapeGeneric;
  124144. }
  124145. }
  124146. declare module BABYLON {
  124147. /**
  124148. * AmmoJS Physics plugin
  124149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  124150. * @see https://github.com/kripken/ammo.js/
  124151. */
  124152. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  124153. private _useDeltaForWorldStep;
  124154. /**
  124155. * Reference to the Ammo library
  124156. */
  124157. bjsAMMO: any;
  124158. /**
  124159. * Created ammoJS world which physics bodies are added to
  124160. */
  124161. world: any;
  124162. /**
  124163. * Name of the plugin
  124164. */
  124165. name: string;
  124166. private _timeStep;
  124167. private _fixedTimeStep;
  124168. private _maxSteps;
  124169. private _tmpQuaternion;
  124170. private _tmpAmmoTransform;
  124171. private _tmpAmmoQuaternion;
  124172. private _tmpAmmoConcreteContactResultCallback;
  124173. private _collisionConfiguration;
  124174. private _dispatcher;
  124175. private _overlappingPairCache;
  124176. private _solver;
  124177. private _softBodySolver;
  124178. private _tmpAmmoVectorA;
  124179. private _tmpAmmoVectorB;
  124180. private _tmpAmmoVectorC;
  124181. private _tmpAmmoVectorD;
  124182. private _tmpContactCallbackResult;
  124183. private _tmpAmmoVectorRCA;
  124184. private _tmpAmmoVectorRCB;
  124185. private _raycastResult;
  124186. private static readonly DISABLE_COLLISION_FLAG;
  124187. private static readonly KINEMATIC_FLAG;
  124188. private static readonly DISABLE_DEACTIVATION_FLAG;
  124189. /**
  124190. * Initializes the ammoJS plugin
  124191. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  124192. * @param ammoInjection can be used to inject your own ammo reference
  124193. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  124194. */
  124195. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  124196. /**
  124197. * Sets the gravity of the physics world (m/(s^2))
  124198. * @param gravity Gravity to set
  124199. */
  124200. setGravity(gravity: Vector3): void;
  124201. /**
  124202. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  124203. * @param timeStep timestep to use in seconds
  124204. */
  124205. setTimeStep(timeStep: number): void;
  124206. /**
  124207. * 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)
  124208. * @param fixedTimeStep fixedTimeStep to use in seconds
  124209. */
  124210. setFixedTimeStep(fixedTimeStep: number): void;
  124211. /**
  124212. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  124213. * @param maxSteps the maximum number of steps by the physics engine per frame
  124214. */
  124215. setMaxSteps(maxSteps: number): void;
  124216. /**
  124217. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  124218. * @returns the current timestep in seconds
  124219. */
  124220. getTimeStep(): number;
  124221. /**
  124222. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  124223. */
  124224. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  124225. private _isImpostorInContact;
  124226. private _isImpostorPairInContact;
  124227. private _stepSimulation;
  124228. /**
  124229. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  124230. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  124231. * After the step the babylon meshes are set to the position of the physics imposters
  124232. * @param delta amount of time to step forward
  124233. * @param impostors array of imposters to update before/after the step
  124234. */
  124235. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124236. /**
  124237. * Update babylon mesh to match physics world object
  124238. * @param impostor imposter to match
  124239. */
  124240. private _afterSoftStep;
  124241. /**
  124242. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124243. * @param impostor imposter to match
  124244. */
  124245. private _ropeStep;
  124246. /**
  124247. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124248. * @param impostor imposter to match
  124249. */
  124250. private _softbodyOrClothStep;
  124251. private _tmpVector;
  124252. private _tmpMatrix;
  124253. /**
  124254. * Applies an impulse on the imposter
  124255. * @param impostor imposter to apply impulse to
  124256. * @param force amount of force to be applied to the imposter
  124257. * @param contactPoint the location to apply the impulse on the imposter
  124258. */
  124259. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124260. /**
  124261. * Applies a force on the imposter
  124262. * @param impostor imposter to apply force
  124263. * @param force amount of force to be applied to the imposter
  124264. * @param contactPoint the location to apply the force on the imposter
  124265. */
  124266. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124267. /**
  124268. * Creates a physics body using the plugin
  124269. * @param impostor the imposter to create the physics body on
  124270. */
  124271. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124272. /**
  124273. * Removes the physics body from the imposter and disposes of the body's memory
  124274. * @param impostor imposter to remove the physics body from
  124275. */
  124276. removePhysicsBody(impostor: PhysicsImpostor): void;
  124277. /**
  124278. * Generates a joint
  124279. * @param impostorJoint the imposter joint to create the joint with
  124280. */
  124281. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124282. /**
  124283. * Removes a joint
  124284. * @param impostorJoint the imposter joint to remove the joint from
  124285. */
  124286. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124287. private _addMeshVerts;
  124288. /**
  124289. * Initialise the soft body vertices to match its object's (mesh) vertices
  124290. * Softbody vertices (nodes) are in world space and to match this
  124291. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  124292. * @param impostor to create the softbody for
  124293. */
  124294. private _softVertexData;
  124295. /**
  124296. * Create an impostor's soft body
  124297. * @param impostor to create the softbody for
  124298. */
  124299. private _createSoftbody;
  124300. /**
  124301. * Create cloth for an impostor
  124302. * @param impostor to create the softbody for
  124303. */
  124304. private _createCloth;
  124305. /**
  124306. * Create rope for an impostor
  124307. * @param impostor to create the softbody for
  124308. */
  124309. private _createRope;
  124310. /**
  124311. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  124312. * @param impostor to create the custom physics shape for
  124313. */
  124314. private _createCustom;
  124315. private _addHullVerts;
  124316. private _createShape;
  124317. /**
  124318. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  124319. * @param impostor imposter containing the physics body and babylon object
  124320. */
  124321. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124322. /**
  124323. * Sets the babylon object's position/rotation from the physics body's position/rotation
  124324. * @param impostor imposter containing the physics body and babylon object
  124325. * @param newPosition new position
  124326. * @param newRotation new rotation
  124327. */
  124328. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124329. /**
  124330. * If this plugin is supported
  124331. * @returns true if its supported
  124332. */
  124333. isSupported(): boolean;
  124334. /**
  124335. * Sets the linear velocity of the physics body
  124336. * @param impostor imposter to set the velocity on
  124337. * @param velocity velocity to set
  124338. */
  124339. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124340. /**
  124341. * Sets the angular velocity of the physics body
  124342. * @param impostor imposter to set the velocity on
  124343. * @param velocity velocity to set
  124344. */
  124345. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124346. /**
  124347. * gets the linear velocity
  124348. * @param impostor imposter to get linear velocity from
  124349. * @returns linear velocity
  124350. */
  124351. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124352. /**
  124353. * gets the angular velocity
  124354. * @param impostor imposter to get angular velocity from
  124355. * @returns angular velocity
  124356. */
  124357. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124358. /**
  124359. * Sets the mass of physics body
  124360. * @param impostor imposter to set the mass on
  124361. * @param mass mass to set
  124362. */
  124363. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124364. /**
  124365. * Gets the mass of the physics body
  124366. * @param impostor imposter to get the mass from
  124367. * @returns mass
  124368. */
  124369. getBodyMass(impostor: PhysicsImpostor): number;
  124370. /**
  124371. * Gets friction of the impostor
  124372. * @param impostor impostor to get friction from
  124373. * @returns friction value
  124374. */
  124375. getBodyFriction(impostor: PhysicsImpostor): number;
  124376. /**
  124377. * Sets friction of the impostor
  124378. * @param impostor impostor to set friction on
  124379. * @param friction friction value
  124380. */
  124381. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124382. /**
  124383. * Gets restitution of the impostor
  124384. * @param impostor impostor to get restitution from
  124385. * @returns restitution value
  124386. */
  124387. getBodyRestitution(impostor: PhysicsImpostor): number;
  124388. /**
  124389. * Sets resitution of the impostor
  124390. * @param impostor impostor to set resitution on
  124391. * @param restitution resitution value
  124392. */
  124393. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124394. /**
  124395. * Gets pressure inside the impostor
  124396. * @param impostor impostor to get pressure from
  124397. * @returns pressure value
  124398. */
  124399. getBodyPressure(impostor: PhysicsImpostor): number;
  124400. /**
  124401. * Sets pressure inside a soft body impostor
  124402. * Cloth and rope must remain 0 pressure
  124403. * @param impostor impostor to set pressure on
  124404. * @param pressure pressure value
  124405. */
  124406. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  124407. /**
  124408. * Gets stiffness of the impostor
  124409. * @param impostor impostor to get stiffness from
  124410. * @returns pressure value
  124411. */
  124412. getBodyStiffness(impostor: PhysicsImpostor): number;
  124413. /**
  124414. * Sets stiffness of the impostor
  124415. * @param impostor impostor to set stiffness on
  124416. * @param stiffness stiffness value from 0 to 1
  124417. */
  124418. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  124419. /**
  124420. * Gets velocityIterations of the impostor
  124421. * @param impostor impostor to get velocity iterations from
  124422. * @returns velocityIterations value
  124423. */
  124424. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  124425. /**
  124426. * Sets velocityIterations of the impostor
  124427. * @param impostor impostor to set velocity iterations on
  124428. * @param velocityIterations velocityIterations value
  124429. */
  124430. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  124431. /**
  124432. * Gets positionIterations of the impostor
  124433. * @param impostor impostor to get position iterations from
  124434. * @returns positionIterations value
  124435. */
  124436. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  124437. /**
  124438. * Sets positionIterations of the impostor
  124439. * @param impostor impostor to set position on
  124440. * @param positionIterations positionIterations value
  124441. */
  124442. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  124443. /**
  124444. * Append an anchor to a cloth object
  124445. * @param impostor is the cloth impostor to add anchor to
  124446. * @param otherImpostor is the rigid impostor to anchor to
  124447. * @param width ratio across width from 0 to 1
  124448. * @param height ratio up height from 0 to 1
  124449. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  124450. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124451. */
  124452. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124453. /**
  124454. * Append an hook to a rope object
  124455. * @param impostor is the rope impostor to add hook to
  124456. * @param otherImpostor is the rigid impostor to hook to
  124457. * @param length ratio along the rope from 0 to 1
  124458. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  124459. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124460. */
  124461. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124462. /**
  124463. * Sleeps the physics body and stops it from being active
  124464. * @param impostor impostor to sleep
  124465. */
  124466. sleepBody(impostor: PhysicsImpostor): void;
  124467. /**
  124468. * Activates the physics body
  124469. * @param impostor impostor to activate
  124470. */
  124471. wakeUpBody(impostor: PhysicsImpostor): void;
  124472. /**
  124473. * Updates the distance parameters of the joint
  124474. * @param joint joint to update
  124475. * @param maxDistance maximum distance of the joint
  124476. * @param minDistance minimum distance of the joint
  124477. */
  124478. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124479. /**
  124480. * Sets a motor on the joint
  124481. * @param joint joint to set motor on
  124482. * @param speed speed of the motor
  124483. * @param maxForce maximum force of the motor
  124484. * @param motorIndex index of the motor
  124485. */
  124486. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124487. /**
  124488. * Sets the motors limit
  124489. * @param joint joint to set limit on
  124490. * @param upperLimit upper limit
  124491. * @param lowerLimit lower limit
  124492. */
  124493. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124494. /**
  124495. * Syncs the position and rotation of a mesh with the impostor
  124496. * @param mesh mesh to sync
  124497. * @param impostor impostor to update the mesh with
  124498. */
  124499. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124500. /**
  124501. * Gets the radius of the impostor
  124502. * @param impostor impostor to get radius from
  124503. * @returns the radius
  124504. */
  124505. getRadius(impostor: PhysicsImpostor): number;
  124506. /**
  124507. * Gets the box size of the impostor
  124508. * @param impostor impostor to get box size from
  124509. * @param result the resulting box size
  124510. */
  124511. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124512. /**
  124513. * Disposes of the impostor
  124514. */
  124515. dispose(): void;
  124516. /**
  124517. * Does a raycast in the physics world
  124518. * @param from when should the ray start?
  124519. * @param to when should the ray end?
  124520. * @returns PhysicsRaycastResult
  124521. */
  124522. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124523. }
  124524. }
  124525. declare module BABYLON {
  124526. interface AbstractScene {
  124527. /**
  124528. * The list of reflection probes added to the scene
  124529. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124530. */
  124531. reflectionProbes: Array<ReflectionProbe>;
  124532. /**
  124533. * Removes the given reflection probe from this scene.
  124534. * @param toRemove The reflection probe to remove
  124535. * @returns The index of the removed reflection probe
  124536. */
  124537. removeReflectionProbe(toRemove: ReflectionProbe): number;
  124538. /**
  124539. * Adds the given reflection probe to this scene.
  124540. * @param newReflectionProbe The reflection probe to add
  124541. */
  124542. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  124543. }
  124544. /**
  124545. * Class used to generate realtime reflection / refraction cube textures
  124546. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124547. */
  124548. export class ReflectionProbe {
  124549. /** defines the name of the probe */
  124550. name: string;
  124551. private _scene;
  124552. private _renderTargetTexture;
  124553. private _projectionMatrix;
  124554. private _viewMatrix;
  124555. private _target;
  124556. private _add;
  124557. private _attachedMesh;
  124558. private _invertYAxis;
  124559. /** Gets or sets probe position (center of the cube map) */
  124560. position: Vector3;
  124561. /**
  124562. * Creates a new reflection probe
  124563. * @param name defines the name of the probe
  124564. * @param size defines the texture resolution (for each face)
  124565. * @param scene defines the hosting scene
  124566. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  124567. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  124568. */
  124569. constructor(
  124570. /** defines the name of the probe */
  124571. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  124572. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  124573. get samples(): number;
  124574. set samples(value: number);
  124575. /** Gets or sets the refresh rate to use (on every frame by default) */
  124576. get refreshRate(): number;
  124577. set refreshRate(value: number);
  124578. /**
  124579. * Gets the hosting scene
  124580. * @returns a Scene
  124581. */
  124582. getScene(): Scene;
  124583. /** Gets the internal CubeTexture used to render to */
  124584. get cubeTexture(): RenderTargetTexture;
  124585. /** Gets the list of meshes to render */
  124586. get renderList(): Nullable<AbstractMesh[]>;
  124587. /**
  124588. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  124589. * @param mesh defines the mesh to attach to
  124590. */
  124591. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  124592. /**
  124593. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  124594. * @param renderingGroupId The rendering group id corresponding to its index
  124595. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124596. */
  124597. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  124598. /**
  124599. * Clean all associated resources
  124600. */
  124601. dispose(): void;
  124602. /**
  124603. * Converts the reflection probe information to a readable string for debug purpose.
  124604. * @param fullDetails Supports for multiple levels of logging within scene loading
  124605. * @returns the human readable reflection probe info
  124606. */
  124607. toString(fullDetails?: boolean): string;
  124608. /**
  124609. * Get the class name of the relfection probe.
  124610. * @returns "ReflectionProbe"
  124611. */
  124612. getClassName(): string;
  124613. /**
  124614. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  124615. * @returns The JSON representation of the texture
  124616. */
  124617. serialize(): any;
  124618. /**
  124619. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  124620. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  124621. * @param scene Define the scene the parsed reflection probe should be instantiated in
  124622. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  124623. * @returns The parsed reflection probe if successful
  124624. */
  124625. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  124626. }
  124627. }
  124628. declare module BABYLON {
  124629. /** @hidden */
  124630. export var _BabylonLoaderRegistered: boolean;
  124631. /**
  124632. * Helps setting up some configuration for the babylon file loader.
  124633. */
  124634. export class BabylonFileLoaderConfiguration {
  124635. /**
  124636. * The loader does not allow injecting custom physix engine into the plugins.
  124637. * Unfortunately in ES6, we need to manually inject them into the plugin.
  124638. * So you could set this variable to your engine import to make it work.
  124639. */
  124640. static LoaderInjectedPhysicsEngine: any;
  124641. }
  124642. }
  124643. declare module BABYLON {
  124644. /**
  124645. * The Physically based simple base material of BJS.
  124646. *
  124647. * This enables better naming and convention enforcements on top of the pbrMaterial.
  124648. * It is used as the base class for both the specGloss and metalRough conventions.
  124649. */
  124650. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  124651. /**
  124652. * Number of Simultaneous lights allowed on the material.
  124653. */
  124654. maxSimultaneousLights: number;
  124655. /**
  124656. * If sets to true, disables all the lights affecting the material.
  124657. */
  124658. disableLighting: boolean;
  124659. /**
  124660. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  124661. */
  124662. environmentTexture: BaseTexture;
  124663. /**
  124664. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124665. */
  124666. invertNormalMapX: boolean;
  124667. /**
  124668. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124669. */
  124670. invertNormalMapY: boolean;
  124671. /**
  124672. * Normal map used in the model.
  124673. */
  124674. normalTexture: BaseTexture;
  124675. /**
  124676. * Emissivie color used to self-illuminate the model.
  124677. */
  124678. emissiveColor: Color3;
  124679. /**
  124680. * Emissivie texture used to self-illuminate the model.
  124681. */
  124682. emissiveTexture: BaseTexture;
  124683. /**
  124684. * Occlusion Channel Strenght.
  124685. */
  124686. occlusionStrength: number;
  124687. /**
  124688. * Occlusion Texture of the material (adding extra occlusion effects).
  124689. */
  124690. occlusionTexture: BaseTexture;
  124691. /**
  124692. * Defines the alpha limits in alpha test mode.
  124693. */
  124694. alphaCutOff: number;
  124695. /**
  124696. * Gets the current double sided mode.
  124697. */
  124698. get doubleSided(): boolean;
  124699. /**
  124700. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124701. */
  124702. set doubleSided(value: boolean);
  124703. /**
  124704. * Stores the pre-calculated light information of a mesh in a texture.
  124705. */
  124706. lightmapTexture: BaseTexture;
  124707. /**
  124708. * If true, the light map contains occlusion information instead of lighting info.
  124709. */
  124710. useLightmapAsShadowmap: boolean;
  124711. /**
  124712. * Instantiates a new PBRMaterial instance.
  124713. *
  124714. * @param name The material name
  124715. * @param scene The scene the material will be use in.
  124716. */
  124717. constructor(name: string, scene: Scene);
  124718. getClassName(): string;
  124719. }
  124720. }
  124721. declare module BABYLON {
  124722. /**
  124723. * The PBR material of BJS following the metal roughness convention.
  124724. *
  124725. * This fits to the PBR convention in the GLTF definition:
  124726. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  124727. */
  124728. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  124729. /**
  124730. * The base color has two different interpretations depending on the value of metalness.
  124731. * When the material is a metal, the base color is the specific measured reflectance value
  124732. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  124733. * of the material.
  124734. */
  124735. baseColor: Color3;
  124736. /**
  124737. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  124738. * well as opacity information in the alpha channel.
  124739. */
  124740. baseTexture: BaseTexture;
  124741. /**
  124742. * Specifies the metallic scalar value of the material.
  124743. * Can also be used to scale the metalness values of the metallic texture.
  124744. */
  124745. metallic: number;
  124746. /**
  124747. * Specifies the roughness scalar value of the material.
  124748. * Can also be used to scale the roughness values of the metallic texture.
  124749. */
  124750. roughness: number;
  124751. /**
  124752. * Texture containing both the metallic value in the B channel and the
  124753. * roughness value in the G channel to keep better precision.
  124754. */
  124755. metallicRoughnessTexture: BaseTexture;
  124756. /**
  124757. * Instantiates a new PBRMetalRoughnessMaterial instance.
  124758. *
  124759. * @param name The material name
  124760. * @param scene The scene the material will be use in.
  124761. */
  124762. constructor(name: string, scene: Scene);
  124763. /**
  124764. * Return the currrent class name of the material.
  124765. */
  124766. getClassName(): string;
  124767. /**
  124768. * Makes a duplicate of the current material.
  124769. * @param name - name to use for the new material.
  124770. */
  124771. clone(name: string): PBRMetallicRoughnessMaterial;
  124772. /**
  124773. * Serialize the material to a parsable JSON object.
  124774. */
  124775. serialize(): any;
  124776. /**
  124777. * Parses a JSON object correponding to the serialize function.
  124778. */
  124779. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  124780. }
  124781. }
  124782. declare module BABYLON {
  124783. /**
  124784. * The PBR material of BJS following the specular glossiness convention.
  124785. *
  124786. * This fits to the PBR convention in the GLTF definition:
  124787. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  124788. */
  124789. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  124790. /**
  124791. * Specifies the diffuse color of the material.
  124792. */
  124793. diffuseColor: Color3;
  124794. /**
  124795. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  124796. * channel.
  124797. */
  124798. diffuseTexture: BaseTexture;
  124799. /**
  124800. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  124801. */
  124802. specularColor: Color3;
  124803. /**
  124804. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  124805. */
  124806. glossiness: number;
  124807. /**
  124808. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  124809. */
  124810. specularGlossinessTexture: BaseTexture;
  124811. /**
  124812. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  124813. *
  124814. * @param name The material name
  124815. * @param scene The scene the material will be use in.
  124816. */
  124817. constructor(name: string, scene: Scene);
  124818. /**
  124819. * Return the currrent class name of the material.
  124820. */
  124821. getClassName(): string;
  124822. /**
  124823. * Makes a duplicate of the current material.
  124824. * @param name - name to use for the new material.
  124825. */
  124826. clone(name: string): PBRSpecularGlossinessMaterial;
  124827. /**
  124828. * Serialize the material to a parsable JSON object.
  124829. */
  124830. serialize(): any;
  124831. /**
  124832. * Parses a JSON object correponding to the serialize function.
  124833. */
  124834. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  124835. }
  124836. }
  124837. declare module BABYLON {
  124838. /**
  124839. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  124840. * It can help converting any input color in a desired output one. This can then be used to create effects
  124841. * from sepia, black and white to sixties or futuristic rendering...
  124842. *
  124843. * The only supported format is currently 3dl.
  124844. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  124845. */
  124846. export class ColorGradingTexture extends BaseTexture {
  124847. /**
  124848. * The current texture matrix. (will always be identity in color grading texture)
  124849. */
  124850. private _textureMatrix;
  124851. /**
  124852. * The texture URL.
  124853. */
  124854. url: string;
  124855. /**
  124856. * Empty line regex stored for GC.
  124857. */
  124858. private static _noneEmptyLineRegex;
  124859. private _engine;
  124860. /**
  124861. * Instantiates a ColorGradingTexture from the following parameters.
  124862. *
  124863. * @param url The location of the color gradind data (currently only supporting 3dl)
  124864. * @param scene The scene the texture will be used in
  124865. */
  124866. constructor(url: string, scene: Scene);
  124867. /**
  124868. * Returns the texture matrix used in most of the material.
  124869. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  124870. */
  124871. getTextureMatrix(): Matrix;
  124872. /**
  124873. * Occurs when the file being loaded is a .3dl LUT file.
  124874. */
  124875. private load3dlTexture;
  124876. /**
  124877. * Starts the loading process of the texture.
  124878. */
  124879. private loadTexture;
  124880. /**
  124881. * Clones the color gradind texture.
  124882. */
  124883. clone(): ColorGradingTexture;
  124884. /**
  124885. * Called during delayed load for textures.
  124886. */
  124887. delayLoad(): void;
  124888. /**
  124889. * Parses a color grading texture serialized by Babylon.
  124890. * @param parsedTexture The texture information being parsedTexture
  124891. * @param scene The scene to load the texture in
  124892. * @param rootUrl The root url of the data assets to load
  124893. * @return A color gradind texture
  124894. */
  124895. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  124896. /**
  124897. * Serializes the LUT texture to json format.
  124898. */
  124899. serialize(): any;
  124900. }
  124901. }
  124902. declare module BABYLON {
  124903. /**
  124904. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  124905. */
  124906. export class EquiRectangularCubeTexture extends BaseTexture {
  124907. /** The six faces of the cube. */
  124908. private static _FacesMapping;
  124909. private _noMipmap;
  124910. private _onLoad;
  124911. private _onError;
  124912. /** The size of the cubemap. */
  124913. private _size;
  124914. /** The buffer of the image. */
  124915. private _buffer;
  124916. /** The width of the input image. */
  124917. private _width;
  124918. /** The height of the input image. */
  124919. private _height;
  124920. /** The URL to the image. */
  124921. url: string;
  124922. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  124923. coordinatesMode: number;
  124924. /**
  124925. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  124926. * @param url The location of the image
  124927. * @param scene The scene the texture will be used in
  124928. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  124929. * @param noMipmap Forces to not generate the mipmap if true
  124930. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  124931. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  124932. * @param onLoad — defines a callback called when texture is loaded
  124933. * @param onError — defines a callback called if there is an error
  124934. */
  124935. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  124936. /**
  124937. * Load the image data, by putting the image on a canvas and extracting its buffer.
  124938. */
  124939. private loadImage;
  124940. /**
  124941. * Convert the image buffer into a cubemap and create a CubeTexture.
  124942. */
  124943. private loadTexture;
  124944. /**
  124945. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  124946. * @param buffer The ArrayBuffer that should be converted.
  124947. * @returns The buffer as Float32Array.
  124948. */
  124949. private getFloat32ArrayFromArrayBuffer;
  124950. /**
  124951. * Get the current class name of the texture useful for serialization or dynamic coding.
  124952. * @returns "EquiRectangularCubeTexture"
  124953. */
  124954. getClassName(): string;
  124955. /**
  124956. * Create a clone of the current EquiRectangularCubeTexture and return it.
  124957. * @returns A clone of the current EquiRectangularCubeTexture.
  124958. */
  124959. clone(): EquiRectangularCubeTexture;
  124960. }
  124961. }
  124962. declare module BABYLON {
  124963. /**
  124964. * Based on jsTGALoader - Javascript loader for TGA file
  124965. * By Vincent Thibault
  124966. * @see http://blog.robrowser.com/javascript-tga-loader.html
  124967. */
  124968. export class TGATools {
  124969. private static _TYPE_INDEXED;
  124970. private static _TYPE_RGB;
  124971. private static _TYPE_GREY;
  124972. private static _TYPE_RLE_INDEXED;
  124973. private static _TYPE_RLE_RGB;
  124974. private static _TYPE_RLE_GREY;
  124975. private static _ORIGIN_MASK;
  124976. private static _ORIGIN_SHIFT;
  124977. private static _ORIGIN_BL;
  124978. private static _ORIGIN_BR;
  124979. private static _ORIGIN_UL;
  124980. private static _ORIGIN_UR;
  124981. /**
  124982. * Gets the header of a TGA file
  124983. * @param data defines the TGA data
  124984. * @returns the header
  124985. */
  124986. static GetTGAHeader(data: Uint8Array): any;
  124987. /**
  124988. * Uploads TGA content to a Babylon Texture
  124989. * @hidden
  124990. */
  124991. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  124992. /** @hidden */
  124993. 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;
  124994. /** @hidden */
  124995. 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;
  124996. /** @hidden */
  124997. 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;
  124998. /** @hidden */
  124999. 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;
  125000. /** @hidden */
  125001. 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;
  125002. /** @hidden */
  125003. 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;
  125004. }
  125005. }
  125006. declare module BABYLON {
  125007. /**
  125008. * Implementation of the TGA Texture Loader.
  125009. * @hidden
  125010. */
  125011. export class _TGATextureLoader implements IInternalTextureLoader {
  125012. /**
  125013. * Defines wether the loader supports cascade loading the different faces.
  125014. */
  125015. readonly supportCascades: boolean;
  125016. /**
  125017. * This returns if the loader support the current file information.
  125018. * @param extension defines the file extension of the file being loaded
  125019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125020. * @param fallback defines the fallback internal texture if any
  125021. * @param isBase64 defines whether the texture is encoded as a base64
  125022. * @param isBuffer defines whether the texture data are stored as a buffer
  125023. * @returns true if the loader can load the specified file
  125024. */
  125025. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125026. /**
  125027. * Transform the url before loading if required.
  125028. * @param rootUrl the url of the texture
  125029. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125030. * @returns the transformed texture
  125031. */
  125032. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125033. /**
  125034. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125035. * @param rootUrl the url of the texture
  125036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125037. * @returns the fallback texture
  125038. */
  125039. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125040. /**
  125041. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125042. * @param data contains the texture data
  125043. * @param texture defines the BabylonJS internal texture
  125044. * @param createPolynomials will be true if polynomials have been requested
  125045. * @param onLoad defines the callback to trigger once the texture is ready
  125046. * @param onError defines the callback to trigger in case of error
  125047. */
  125048. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125049. /**
  125050. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125051. * @param data contains the texture data
  125052. * @param texture defines the BabylonJS internal texture
  125053. * @param callback defines the method to call once ready to upload
  125054. */
  125055. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125056. }
  125057. }
  125058. declare module BABYLON {
  125059. /**
  125060. * Info about the .basis files
  125061. */
  125062. class BasisFileInfo {
  125063. /**
  125064. * If the file has alpha
  125065. */
  125066. hasAlpha: boolean;
  125067. /**
  125068. * Info about each image of the basis file
  125069. */
  125070. images: Array<{
  125071. levels: Array<{
  125072. width: number;
  125073. height: number;
  125074. transcodedPixels: ArrayBufferView;
  125075. }>;
  125076. }>;
  125077. }
  125078. /**
  125079. * Result of transcoding a basis file
  125080. */
  125081. class TranscodeResult {
  125082. /**
  125083. * Info about the .basis file
  125084. */
  125085. fileInfo: BasisFileInfo;
  125086. /**
  125087. * Format to use when loading the file
  125088. */
  125089. format: number;
  125090. }
  125091. /**
  125092. * Configuration options for the Basis transcoder
  125093. */
  125094. export class BasisTranscodeConfiguration {
  125095. /**
  125096. * Supported compression formats used to determine the supported output format of the transcoder
  125097. */
  125098. supportedCompressionFormats?: {
  125099. /**
  125100. * etc1 compression format
  125101. */
  125102. etc1?: boolean;
  125103. /**
  125104. * s3tc compression format
  125105. */
  125106. s3tc?: boolean;
  125107. /**
  125108. * pvrtc compression format
  125109. */
  125110. pvrtc?: boolean;
  125111. /**
  125112. * etc2 compression format
  125113. */
  125114. etc2?: boolean;
  125115. };
  125116. /**
  125117. * If mipmap levels should be loaded for transcoded images (Default: true)
  125118. */
  125119. loadMipmapLevels?: boolean;
  125120. /**
  125121. * Index of a single image to load (Default: all images)
  125122. */
  125123. loadSingleImage?: number;
  125124. }
  125125. /**
  125126. * Used to load .Basis files
  125127. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  125128. */
  125129. export class BasisTools {
  125130. private static _IgnoreSupportedFormats;
  125131. /**
  125132. * URL to use when loading the basis transcoder
  125133. */
  125134. static JSModuleURL: string;
  125135. /**
  125136. * URL to use when loading the wasm module for the transcoder
  125137. */
  125138. static WasmModuleURL: string;
  125139. /**
  125140. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  125141. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  125142. * @returns internal format corresponding to the Basis format
  125143. */
  125144. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  125145. private static _WorkerPromise;
  125146. private static _Worker;
  125147. private static _actionId;
  125148. private static _CreateWorkerAsync;
  125149. /**
  125150. * Transcodes a loaded image file to compressed pixel data
  125151. * @param imageData image data to transcode
  125152. * @param config configuration options for the transcoding
  125153. * @returns a promise resulting in the transcoded image
  125154. */
  125155. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  125156. /**
  125157. * Loads a texture from the transcode result
  125158. * @param texture texture load to
  125159. * @param transcodeResult the result of transcoding the basis file to load from
  125160. */
  125161. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  125162. }
  125163. }
  125164. declare module BABYLON {
  125165. /**
  125166. * Loader for .basis file format
  125167. */
  125168. export class _BasisTextureLoader implements IInternalTextureLoader {
  125169. /**
  125170. * Defines whether the loader supports cascade loading the different faces.
  125171. */
  125172. readonly supportCascades: boolean;
  125173. /**
  125174. * This returns if the loader support the current file information.
  125175. * @param extension defines the file extension of the file being loaded
  125176. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125177. * @param fallback defines the fallback internal texture if any
  125178. * @param isBase64 defines whether the texture is encoded as a base64
  125179. * @param isBuffer defines whether the texture data are stored as a buffer
  125180. * @returns true if the loader can load the specified file
  125181. */
  125182. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125183. /**
  125184. * Transform the url before loading if required.
  125185. * @param rootUrl the url of the texture
  125186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125187. * @returns the transformed texture
  125188. */
  125189. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125190. /**
  125191. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125192. * @param rootUrl the url of the texture
  125193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125194. * @returns the fallback texture
  125195. */
  125196. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125197. /**
  125198. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  125199. * @param data contains the texture data
  125200. * @param texture defines the BabylonJS internal texture
  125201. * @param createPolynomials will be true if polynomials have been requested
  125202. * @param onLoad defines the callback to trigger once the texture is ready
  125203. * @param onError defines the callback to trigger in case of error
  125204. */
  125205. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125206. /**
  125207. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125208. * @param data contains the texture data
  125209. * @param texture defines the BabylonJS internal texture
  125210. * @param callback defines the method to call once ready to upload
  125211. */
  125212. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125213. }
  125214. }
  125215. declare module BABYLON {
  125216. /**
  125217. * 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.
  125218. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125219. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125220. */
  125221. export class CustomProceduralTexture extends ProceduralTexture {
  125222. private _animate;
  125223. private _time;
  125224. private _config;
  125225. private _texturePath;
  125226. /**
  125227. * Instantiates a new Custom Procedural Texture.
  125228. * 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.
  125229. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125230. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125231. * @param name Define the name of the texture
  125232. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  125233. * @param size Define the size of the texture to create
  125234. * @param scene Define the scene the texture belongs to
  125235. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  125236. * @param generateMipMaps Define if the texture should creates mip maps or not
  125237. */
  125238. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125239. private _loadJson;
  125240. /**
  125241. * Is the texture ready to be used ? (rendered at least once)
  125242. * @returns true if ready, otherwise, false.
  125243. */
  125244. isReady(): boolean;
  125245. /**
  125246. * Render the texture to its associated render target.
  125247. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  125248. */
  125249. render(useCameraPostProcess?: boolean): void;
  125250. /**
  125251. * Update the list of dependant textures samplers in the shader.
  125252. */
  125253. updateTextures(): void;
  125254. /**
  125255. * Update the uniform values of the procedural texture in the shader.
  125256. */
  125257. updateShaderUniforms(): void;
  125258. /**
  125259. * Define if the texture animates or not.
  125260. */
  125261. get animate(): boolean;
  125262. set animate(value: boolean);
  125263. }
  125264. }
  125265. declare module BABYLON {
  125266. /** @hidden */
  125267. export var noisePixelShader: {
  125268. name: string;
  125269. shader: string;
  125270. };
  125271. }
  125272. declare module BABYLON {
  125273. /**
  125274. * Class used to generate noise procedural textures
  125275. */
  125276. export class NoiseProceduralTexture extends ProceduralTexture {
  125277. private _time;
  125278. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  125279. brightness: number;
  125280. /** Defines the number of octaves to process */
  125281. octaves: number;
  125282. /** Defines the level of persistence (0.8 by default) */
  125283. persistence: number;
  125284. /** Gets or sets animation speed factor (default is 1) */
  125285. animationSpeedFactor: number;
  125286. /**
  125287. * Creates a new NoiseProceduralTexture
  125288. * @param name defines the name fo the texture
  125289. * @param size defines the size of the texture (default is 256)
  125290. * @param scene defines the hosting scene
  125291. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  125292. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  125293. */
  125294. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125295. private _updateShaderUniforms;
  125296. protected _getDefines(): string;
  125297. /** Generate the current state of the procedural texture */
  125298. render(useCameraPostProcess?: boolean): void;
  125299. /**
  125300. * Serializes this noise procedural texture
  125301. * @returns a serialized noise procedural texture object
  125302. */
  125303. serialize(): any;
  125304. /**
  125305. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  125306. * @param parsedTexture defines parsed texture data
  125307. * @param scene defines the current scene
  125308. * @param rootUrl defines the root URL containing noise procedural texture information
  125309. * @returns a parsed NoiseProceduralTexture
  125310. */
  125311. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  125312. }
  125313. }
  125314. declare module BABYLON {
  125315. /**
  125316. * Raw cube texture where the raw buffers are passed in
  125317. */
  125318. export class RawCubeTexture extends CubeTexture {
  125319. /**
  125320. * Creates a cube texture where the raw buffers are passed in.
  125321. * @param scene defines the scene the texture is attached to
  125322. * @param data defines the array of data to use to create each face
  125323. * @param size defines the size of the textures
  125324. * @param format defines the format of the data
  125325. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  125326. * @param generateMipMaps defines if the engine should generate the mip levels
  125327. * @param invertY defines if data must be stored with Y axis inverted
  125328. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  125329. * @param compression defines the compression used (null by default)
  125330. */
  125331. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  125332. /**
  125333. * Updates the raw cube texture.
  125334. * @param data defines the data to store
  125335. * @param format defines the data format
  125336. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125337. * @param invertY defines if data must be stored with Y axis inverted
  125338. * @param compression defines the compression used (null by default)
  125339. * @param level defines which level of the texture to update
  125340. */
  125341. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  125342. /**
  125343. * Updates a raw cube texture with RGBD encoded data.
  125344. * @param data defines the array of data [mipmap][face] to use to create each face
  125345. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  125346. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  125347. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  125348. * @returns a promsie that resolves when the operation is complete
  125349. */
  125350. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  125351. /**
  125352. * Clones the raw cube texture.
  125353. * @return a new cube texture
  125354. */
  125355. clone(): CubeTexture;
  125356. /** @hidden */
  125357. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  125358. }
  125359. }
  125360. declare module BABYLON {
  125361. /**
  125362. * Class used to store 3D textures containing user data
  125363. */
  125364. export class RawTexture3D extends Texture {
  125365. /** Gets or sets the texture format to use */
  125366. format: number;
  125367. private _engine;
  125368. /**
  125369. * Create a new RawTexture3D
  125370. * @param data defines the data of the texture
  125371. * @param width defines the width of the texture
  125372. * @param height defines the height of the texture
  125373. * @param depth defines the depth of the texture
  125374. * @param format defines the texture format to use
  125375. * @param scene defines the hosting scene
  125376. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125377. * @param invertY defines if texture must be stored with Y axis inverted
  125378. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125379. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125380. */
  125381. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125382. /** Gets or sets the texture format to use */
  125383. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125384. /**
  125385. * Update the texture with new data
  125386. * @param data defines the data to store in the texture
  125387. */
  125388. update(data: ArrayBufferView): void;
  125389. }
  125390. }
  125391. declare module BABYLON {
  125392. /**
  125393. * Class used to store 2D array textures containing user data
  125394. */
  125395. export class RawTexture2DArray extends Texture {
  125396. /** Gets or sets the texture format to use */
  125397. format: number;
  125398. private _engine;
  125399. /**
  125400. * Create a new RawTexture2DArray
  125401. * @param data defines the data of the texture
  125402. * @param width defines the width of the texture
  125403. * @param height defines the height of the texture
  125404. * @param depth defines the number of layers of the texture
  125405. * @param format defines the texture format to use
  125406. * @param scene defines the hosting scene
  125407. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125408. * @param invertY defines if texture must be stored with Y axis inverted
  125409. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125410. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125411. */
  125412. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125413. /** Gets or sets the texture format to use */
  125414. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125415. /**
  125416. * Update the texture with new data
  125417. * @param data defines the data to store in the texture
  125418. */
  125419. update(data: ArrayBufferView): void;
  125420. }
  125421. }
  125422. declare module BABYLON {
  125423. /**
  125424. * Creates a refraction texture used by refraction channel of the standard material.
  125425. * It is like a mirror but to see through a material.
  125426. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125427. */
  125428. export class RefractionTexture extends RenderTargetTexture {
  125429. /**
  125430. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  125431. * 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.
  125432. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125433. */
  125434. refractionPlane: Plane;
  125435. /**
  125436. * Define how deep under the surface we should see.
  125437. */
  125438. depth: number;
  125439. /**
  125440. * Creates a refraction texture used by refraction channel of the standard material.
  125441. * It is like a mirror but to see through a material.
  125442. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125443. * @param name Define the texture name
  125444. * @param size Define the size of the underlying texture
  125445. * @param scene Define the scene the refraction belongs to
  125446. * @param generateMipMaps Define if we need to generate mips level for the refraction
  125447. */
  125448. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  125449. /**
  125450. * Clone the refraction texture.
  125451. * @returns the cloned texture
  125452. */
  125453. clone(): RefractionTexture;
  125454. /**
  125455. * Serialize the texture to a JSON representation you could use in Parse later on
  125456. * @returns the serialized JSON representation
  125457. */
  125458. serialize(): any;
  125459. }
  125460. }
  125461. declare module BABYLON {
  125462. /**
  125463. * Defines the options related to the creation of an HtmlElementTexture
  125464. */
  125465. export interface IHtmlElementTextureOptions {
  125466. /**
  125467. * Defines wether mip maps should be created or not.
  125468. */
  125469. generateMipMaps?: boolean;
  125470. /**
  125471. * Defines the sampling mode of the texture.
  125472. */
  125473. samplingMode?: number;
  125474. /**
  125475. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  125476. */
  125477. engine: Nullable<ThinEngine>;
  125478. /**
  125479. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  125480. */
  125481. scene: Nullable<Scene>;
  125482. }
  125483. /**
  125484. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  125485. * To be as efficient as possible depending on your constraints nothing aside the first upload
  125486. * is automatically managed.
  125487. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  125488. * in your application.
  125489. *
  125490. * As the update is not automatic, you need to call them manually.
  125491. */
  125492. export class HtmlElementTexture extends BaseTexture {
  125493. /**
  125494. * The texture URL.
  125495. */
  125496. element: HTMLVideoElement | HTMLCanvasElement;
  125497. private static readonly DefaultOptions;
  125498. private _textureMatrix;
  125499. private _engine;
  125500. private _isVideo;
  125501. private _generateMipMaps;
  125502. private _samplingMode;
  125503. /**
  125504. * Instantiates a HtmlElementTexture from the following parameters.
  125505. *
  125506. * @param name Defines the name of the texture
  125507. * @param element Defines the video or canvas the texture is filled with
  125508. * @param options Defines the other none mandatory texture creation options
  125509. */
  125510. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  125511. private _createInternalTexture;
  125512. /**
  125513. * Returns the texture matrix used in most of the material.
  125514. */
  125515. getTextureMatrix(): Matrix;
  125516. /**
  125517. * Updates the content of the texture.
  125518. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  125519. */
  125520. update(invertY?: Nullable<boolean>): void;
  125521. }
  125522. }
  125523. declare module BABYLON {
  125524. /**
  125525. * Enum used to define the target of a block
  125526. */
  125527. export enum NodeMaterialBlockTargets {
  125528. /** Vertex shader */
  125529. Vertex = 1,
  125530. /** Fragment shader */
  125531. Fragment = 2,
  125532. /** Neutral */
  125533. Neutral = 4,
  125534. /** Vertex and Fragment */
  125535. VertexAndFragment = 3
  125536. }
  125537. }
  125538. declare module BABYLON {
  125539. /**
  125540. * Defines the kind of connection point for node based material
  125541. */
  125542. export enum NodeMaterialBlockConnectionPointTypes {
  125543. /** Float */
  125544. Float = 1,
  125545. /** Int */
  125546. Int = 2,
  125547. /** Vector2 */
  125548. Vector2 = 4,
  125549. /** Vector3 */
  125550. Vector3 = 8,
  125551. /** Vector4 */
  125552. Vector4 = 16,
  125553. /** Color3 */
  125554. Color3 = 32,
  125555. /** Color4 */
  125556. Color4 = 64,
  125557. /** Matrix */
  125558. Matrix = 128,
  125559. /** Detect type based on connection */
  125560. AutoDetect = 1024,
  125561. /** Output type that will be defined by input type */
  125562. BasedOnInput = 2048
  125563. }
  125564. }
  125565. declare module BABYLON {
  125566. /**
  125567. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  125568. */
  125569. export enum NodeMaterialBlockConnectionPointMode {
  125570. /** Value is an uniform */
  125571. Uniform = 0,
  125572. /** Value is a mesh attribute */
  125573. Attribute = 1,
  125574. /** Value is a varying between vertex and fragment shaders */
  125575. Varying = 2,
  125576. /** Mode is undefined */
  125577. Undefined = 3
  125578. }
  125579. }
  125580. declare module BABYLON {
  125581. /**
  125582. * Enum used to define system values e.g. values automatically provided by the system
  125583. */
  125584. export enum NodeMaterialSystemValues {
  125585. /** World */
  125586. World = 1,
  125587. /** View */
  125588. View = 2,
  125589. /** Projection */
  125590. Projection = 3,
  125591. /** ViewProjection */
  125592. ViewProjection = 4,
  125593. /** WorldView */
  125594. WorldView = 5,
  125595. /** WorldViewProjection */
  125596. WorldViewProjection = 6,
  125597. /** CameraPosition */
  125598. CameraPosition = 7,
  125599. /** Fog Color */
  125600. FogColor = 8,
  125601. /** Delta time */
  125602. DeltaTime = 9
  125603. }
  125604. }
  125605. declare module BABYLON {
  125606. /**
  125607. * Root class for all node material optimizers
  125608. */
  125609. export class NodeMaterialOptimizer {
  125610. /**
  125611. * Function used to optimize a NodeMaterial graph
  125612. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  125613. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  125614. */
  125615. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  125616. }
  125617. }
  125618. declare module BABYLON {
  125619. /**
  125620. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  125621. */
  125622. export class TransformBlock extends NodeMaterialBlock {
  125623. /**
  125624. * Defines the value to use to complement W value to transform it to a Vector4
  125625. */
  125626. complementW: number;
  125627. /**
  125628. * Defines the value to use to complement z value to transform it to a Vector4
  125629. */
  125630. complementZ: number;
  125631. /**
  125632. * Creates a new TransformBlock
  125633. * @param name defines the block name
  125634. */
  125635. constructor(name: string);
  125636. /**
  125637. * Gets the current class name
  125638. * @returns the class name
  125639. */
  125640. getClassName(): string;
  125641. /**
  125642. * Gets the vector input
  125643. */
  125644. get vector(): NodeMaterialConnectionPoint;
  125645. /**
  125646. * Gets the output component
  125647. */
  125648. get output(): NodeMaterialConnectionPoint;
  125649. /**
  125650. * Gets the matrix transform input
  125651. */
  125652. get transform(): NodeMaterialConnectionPoint;
  125653. protected _buildBlock(state: NodeMaterialBuildState): this;
  125654. serialize(): any;
  125655. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125656. protected _dumpPropertiesCode(): string;
  125657. }
  125658. }
  125659. declare module BABYLON {
  125660. /**
  125661. * Block used to output the vertex position
  125662. */
  125663. export class VertexOutputBlock extends NodeMaterialBlock {
  125664. /**
  125665. * Creates a new VertexOutputBlock
  125666. * @param name defines the block name
  125667. */
  125668. constructor(name: string);
  125669. /**
  125670. * Gets the current class name
  125671. * @returns the class name
  125672. */
  125673. getClassName(): string;
  125674. /**
  125675. * Gets the vector input component
  125676. */
  125677. get vector(): NodeMaterialConnectionPoint;
  125678. protected _buildBlock(state: NodeMaterialBuildState): this;
  125679. }
  125680. }
  125681. declare module BABYLON {
  125682. /**
  125683. * Block used to output the final color
  125684. */
  125685. export class FragmentOutputBlock extends NodeMaterialBlock {
  125686. /**
  125687. * Create a new FragmentOutputBlock
  125688. * @param name defines the block name
  125689. */
  125690. constructor(name: string);
  125691. /**
  125692. * Gets the current class name
  125693. * @returns the class name
  125694. */
  125695. getClassName(): string;
  125696. /**
  125697. * Gets the rgba input component
  125698. */
  125699. get rgba(): NodeMaterialConnectionPoint;
  125700. /**
  125701. * Gets the rgb input component
  125702. */
  125703. get rgb(): NodeMaterialConnectionPoint;
  125704. /**
  125705. * Gets the a input component
  125706. */
  125707. get a(): NodeMaterialConnectionPoint;
  125708. protected _buildBlock(state: NodeMaterialBuildState): this;
  125709. }
  125710. }
  125711. declare module BABYLON {
  125712. /**
  125713. * Block used to read a reflection texture from a sampler
  125714. */
  125715. export class ReflectionTextureBlock extends NodeMaterialBlock {
  125716. private _define3DName;
  125717. private _defineCubicName;
  125718. private _defineExplicitName;
  125719. private _defineProjectionName;
  125720. private _defineLocalCubicName;
  125721. private _defineSphericalName;
  125722. private _definePlanarName;
  125723. private _defineEquirectangularName;
  125724. private _defineMirroredEquirectangularFixedName;
  125725. private _defineEquirectangularFixedName;
  125726. private _defineSkyboxName;
  125727. private _cubeSamplerName;
  125728. private _2DSamplerName;
  125729. private _positionUVWName;
  125730. private _directionWName;
  125731. private _reflectionCoordsName;
  125732. private _reflection2DCoordsName;
  125733. private _reflectionColorName;
  125734. private _reflectionMatrixName;
  125735. /**
  125736. * Gets or sets the texture associated with the node
  125737. */
  125738. texture: Nullable<BaseTexture>;
  125739. /**
  125740. * Create a new TextureBlock
  125741. * @param name defines the block name
  125742. */
  125743. constructor(name: string);
  125744. /**
  125745. * Gets the current class name
  125746. * @returns the class name
  125747. */
  125748. getClassName(): string;
  125749. /**
  125750. * Gets the world position input component
  125751. */
  125752. get position(): NodeMaterialConnectionPoint;
  125753. /**
  125754. * Gets the world position input component
  125755. */
  125756. get worldPosition(): NodeMaterialConnectionPoint;
  125757. /**
  125758. * Gets the world normal input component
  125759. */
  125760. get worldNormal(): NodeMaterialConnectionPoint;
  125761. /**
  125762. * Gets the world input component
  125763. */
  125764. get world(): NodeMaterialConnectionPoint;
  125765. /**
  125766. * Gets the camera (or eye) position component
  125767. */
  125768. get cameraPosition(): NodeMaterialConnectionPoint;
  125769. /**
  125770. * Gets the view input component
  125771. */
  125772. get view(): NodeMaterialConnectionPoint;
  125773. /**
  125774. * Gets the rgb output component
  125775. */
  125776. get rgb(): NodeMaterialConnectionPoint;
  125777. /**
  125778. * Gets the r output component
  125779. */
  125780. get r(): NodeMaterialConnectionPoint;
  125781. /**
  125782. * Gets the g output component
  125783. */
  125784. get g(): NodeMaterialConnectionPoint;
  125785. /**
  125786. * Gets the b output component
  125787. */
  125788. get b(): NodeMaterialConnectionPoint;
  125789. autoConfigure(material: NodeMaterial): void;
  125790. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125791. isReady(): boolean;
  125792. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125793. private _injectVertexCode;
  125794. private _writeOutput;
  125795. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125796. protected _dumpPropertiesCode(): string;
  125797. serialize(): any;
  125798. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125799. }
  125800. }
  125801. declare module BABYLON {
  125802. /**
  125803. * Interface used to configure the node material editor
  125804. */
  125805. export interface INodeMaterialEditorOptions {
  125806. /** Define the URl to load node editor script */
  125807. editorURL?: string;
  125808. }
  125809. /** @hidden */
  125810. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  125811. /** BONES */
  125812. NUM_BONE_INFLUENCERS: number;
  125813. BonesPerMesh: number;
  125814. BONETEXTURE: boolean;
  125815. /** MORPH TARGETS */
  125816. MORPHTARGETS: boolean;
  125817. MORPHTARGETS_NORMAL: boolean;
  125818. MORPHTARGETS_TANGENT: boolean;
  125819. MORPHTARGETS_UV: boolean;
  125820. NUM_MORPH_INFLUENCERS: number;
  125821. /** IMAGE PROCESSING */
  125822. IMAGEPROCESSING: boolean;
  125823. VIGNETTE: boolean;
  125824. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125825. VIGNETTEBLENDMODEOPAQUE: boolean;
  125826. TONEMAPPING: boolean;
  125827. TONEMAPPING_ACES: boolean;
  125828. CONTRAST: boolean;
  125829. EXPOSURE: boolean;
  125830. COLORCURVES: boolean;
  125831. COLORGRADING: boolean;
  125832. COLORGRADING3D: boolean;
  125833. SAMPLER3DGREENDEPTH: boolean;
  125834. SAMPLER3DBGRMAP: boolean;
  125835. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125836. /** MISC. */
  125837. BUMPDIRECTUV: number;
  125838. constructor();
  125839. setValue(name: string, value: boolean): void;
  125840. }
  125841. /**
  125842. * Class used to configure NodeMaterial
  125843. */
  125844. export interface INodeMaterialOptions {
  125845. /**
  125846. * Defines if blocks should emit comments
  125847. */
  125848. emitComments: boolean;
  125849. }
  125850. /**
  125851. * Class used to create a node based material built by assembling shader blocks
  125852. */
  125853. export class NodeMaterial extends PushMaterial {
  125854. private static _BuildIdGenerator;
  125855. private _options;
  125856. private _vertexCompilationState;
  125857. private _fragmentCompilationState;
  125858. private _sharedData;
  125859. private _buildId;
  125860. private _buildWasSuccessful;
  125861. private _cachedWorldViewMatrix;
  125862. private _cachedWorldViewProjectionMatrix;
  125863. private _optimizers;
  125864. private _animationFrame;
  125865. /** Define the URl to load node editor script */
  125866. static EditorURL: string;
  125867. private BJSNODEMATERIALEDITOR;
  125868. /** Get the inspector from bundle or global */
  125869. private _getGlobalNodeMaterialEditor;
  125870. /**
  125871. * Gets or sets data used by visual editor
  125872. * @see https://nme.babylonjs.com
  125873. */
  125874. editorData: any;
  125875. /**
  125876. * 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)
  125877. */
  125878. ignoreAlpha: boolean;
  125879. /**
  125880. * Defines the maximum number of lights that can be used in the material
  125881. */
  125882. maxSimultaneousLights: number;
  125883. /**
  125884. * Observable raised when the material is built
  125885. */
  125886. onBuildObservable: Observable<NodeMaterial>;
  125887. /**
  125888. * Gets or sets the root nodes of the material vertex shader
  125889. */
  125890. _vertexOutputNodes: NodeMaterialBlock[];
  125891. /**
  125892. * Gets or sets the root nodes of the material fragment (pixel) shader
  125893. */
  125894. _fragmentOutputNodes: NodeMaterialBlock[];
  125895. /** Gets or sets options to control the node material overall behavior */
  125896. get options(): INodeMaterialOptions;
  125897. set options(options: INodeMaterialOptions);
  125898. /**
  125899. * Default configuration related to image processing available in the standard Material.
  125900. */
  125901. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  125902. /**
  125903. * Gets the image processing configuration used either in this material.
  125904. */
  125905. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125906. /**
  125907. * Sets the Default image processing configuration used either in the this material.
  125908. *
  125909. * If sets to null, the scene one is in use.
  125910. */
  125911. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125912. /**
  125913. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  125914. */
  125915. attachedBlocks: NodeMaterialBlock[];
  125916. /**
  125917. * Create a new node based material
  125918. * @param name defines the material name
  125919. * @param scene defines the hosting scene
  125920. * @param options defines creation option
  125921. */
  125922. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  125923. /**
  125924. * Gets the current class name of the material e.g. "NodeMaterial"
  125925. * @returns the class name
  125926. */
  125927. getClassName(): string;
  125928. /**
  125929. * Keep track of the image processing observer to allow dispose and replace.
  125930. */
  125931. private _imageProcessingObserver;
  125932. /**
  125933. * Attaches a new image processing configuration to the Standard Material.
  125934. * @param configuration
  125935. */
  125936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  125937. /**
  125938. * Get a block by its name
  125939. * @param name defines the name of the block to retrieve
  125940. * @returns the required block or null if not found
  125941. */
  125942. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  125943. /**
  125944. * Get a block by its name
  125945. * @param predicate defines the predicate used to find the good candidate
  125946. * @returns the required block or null if not found
  125947. */
  125948. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  125949. /**
  125950. * Get an input block by its name
  125951. * @param predicate defines the predicate used to find the good candidate
  125952. * @returns the required input block or null if not found
  125953. */
  125954. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  125955. /**
  125956. * Gets the list of input blocks attached to this material
  125957. * @returns an array of InputBlocks
  125958. */
  125959. getInputBlocks(): InputBlock[];
  125960. /**
  125961. * Adds a new optimizer to the list of optimizers
  125962. * @param optimizer defines the optimizers to add
  125963. * @returns the current material
  125964. */
  125965. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  125966. /**
  125967. * Remove an optimizer from the list of optimizers
  125968. * @param optimizer defines the optimizers to remove
  125969. * @returns the current material
  125970. */
  125971. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  125972. /**
  125973. * Add a new block to the list of output nodes
  125974. * @param node defines the node to add
  125975. * @returns the current material
  125976. */
  125977. addOutputNode(node: NodeMaterialBlock): this;
  125978. /**
  125979. * Remove a block from the list of root nodes
  125980. * @param node defines the node to remove
  125981. * @returns the current material
  125982. */
  125983. removeOutputNode(node: NodeMaterialBlock): this;
  125984. private _addVertexOutputNode;
  125985. private _removeVertexOutputNode;
  125986. private _addFragmentOutputNode;
  125987. private _removeFragmentOutputNode;
  125988. /**
  125989. * Specifies if the material will require alpha blending
  125990. * @returns a boolean specifying if alpha blending is needed
  125991. */
  125992. needAlphaBlending(): boolean;
  125993. /**
  125994. * Specifies if this material should be rendered in alpha test mode
  125995. * @returns a boolean specifying if an alpha test is needed.
  125996. */
  125997. needAlphaTesting(): boolean;
  125998. private _initializeBlock;
  125999. private _resetDualBlocks;
  126000. /**
  126001. * Remove a block from the current node material
  126002. * @param block defines the block to remove
  126003. */
  126004. removeBlock(block: NodeMaterialBlock): void;
  126005. /**
  126006. * Build the material and generates the inner effect
  126007. * @param verbose defines if the build should log activity
  126008. */
  126009. build(verbose?: boolean): void;
  126010. /**
  126011. * Runs an otpimization phase to try to improve the shader code
  126012. */
  126013. optimize(): void;
  126014. private _prepareDefinesForAttributes;
  126015. /**
  126016. * Get if the submesh is ready to be used and all its information available.
  126017. * Child classes can use it to update shaders
  126018. * @param mesh defines the mesh to check
  126019. * @param subMesh defines which submesh to check
  126020. * @param useInstances specifies that instances should be used
  126021. * @returns a boolean indicating that the submesh is ready or not
  126022. */
  126023. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126024. /**
  126025. * Get a string representing the shaders built by the current node graph
  126026. */
  126027. get compiledShaders(): string;
  126028. /**
  126029. * Binds the world matrix to the material
  126030. * @param world defines the world transformation matrix
  126031. */
  126032. bindOnlyWorldMatrix(world: Matrix): void;
  126033. /**
  126034. * Binds the submesh to this material by preparing the effect and shader to draw
  126035. * @param world defines the world transformation matrix
  126036. * @param mesh defines the mesh containing the submesh
  126037. * @param subMesh defines the submesh to bind the material to
  126038. */
  126039. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126040. /**
  126041. * Gets the active textures from the material
  126042. * @returns an array of textures
  126043. */
  126044. getActiveTextures(): BaseTexture[];
  126045. /**
  126046. * Gets the list of texture blocks
  126047. * @returns an array of texture blocks
  126048. */
  126049. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  126050. /**
  126051. * Specifies if the material uses a texture
  126052. * @param texture defines the texture to check against the material
  126053. * @returns a boolean specifying if the material uses the texture
  126054. */
  126055. hasTexture(texture: BaseTexture): boolean;
  126056. /**
  126057. * Disposes the material
  126058. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  126059. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  126060. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  126061. */
  126062. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  126063. /** Creates the node editor window. */
  126064. private _createNodeEditor;
  126065. /**
  126066. * Launch the node material editor
  126067. * @param config Define the configuration of the editor
  126068. * @return a promise fulfilled when the node editor is visible
  126069. */
  126070. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  126071. /**
  126072. * Clear the current material
  126073. */
  126074. clear(): void;
  126075. /**
  126076. * Clear the current material and set it to a default state
  126077. */
  126078. setToDefault(): void;
  126079. /**
  126080. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  126081. * @param url defines the url to load from
  126082. * @returns a promise that will fullfil when the material is fully loaded
  126083. */
  126084. loadAsync(url: string): Promise<void>;
  126085. private _gatherBlocks;
  126086. /**
  126087. * Generate a string containing the code declaration required to create an equivalent of this material
  126088. * @returns a string
  126089. */
  126090. generateCode(): string;
  126091. /**
  126092. * Serializes this material in a JSON representation
  126093. * @returns the serialized material object
  126094. */
  126095. serialize(): any;
  126096. private _restoreConnections;
  126097. /**
  126098. * Clear the current graph and load a new one from a serialization object
  126099. * @param source defines the JSON representation of the material
  126100. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126101. */
  126102. loadFromSerialization(source: any, rootUrl?: string): void;
  126103. /**
  126104. * Creates a node material from parsed material data
  126105. * @param source defines the JSON representation of the material
  126106. * @param scene defines the hosting scene
  126107. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126108. * @returns a new node material
  126109. */
  126110. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  126111. /**
  126112. * Creates a new node material set to default basic configuration
  126113. * @param name defines the name of the material
  126114. * @param scene defines the hosting scene
  126115. * @returns a new NodeMaterial
  126116. */
  126117. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  126118. }
  126119. }
  126120. declare module BABYLON {
  126121. /**
  126122. * Block used to read a texture from a sampler
  126123. */
  126124. export class TextureBlock extends NodeMaterialBlock {
  126125. private _defineName;
  126126. private _linearDefineName;
  126127. private _tempTextureRead;
  126128. private _samplerName;
  126129. private _transformedUVName;
  126130. private _textureTransformName;
  126131. private _textureInfoName;
  126132. private _mainUVName;
  126133. private _mainUVDefineName;
  126134. /**
  126135. * Gets or sets the texture associated with the node
  126136. */
  126137. texture: Nullable<Texture>;
  126138. /**
  126139. * Create a new TextureBlock
  126140. * @param name defines the block name
  126141. */
  126142. constructor(name: string);
  126143. /**
  126144. * Gets the current class name
  126145. * @returns the class name
  126146. */
  126147. getClassName(): string;
  126148. /**
  126149. * Gets the uv input component
  126150. */
  126151. get uv(): NodeMaterialConnectionPoint;
  126152. /**
  126153. * Gets the rgba output component
  126154. */
  126155. get rgba(): NodeMaterialConnectionPoint;
  126156. /**
  126157. * Gets the rgb output component
  126158. */
  126159. get rgb(): NodeMaterialConnectionPoint;
  126160. /**
  126161. * Gets the r output component
  126162. */
  126163. get r(): NodeMaterialConnectionPoint;
  126164. /**
  126165. * Gets the g output component
  126166. */
  126167. get g(): NodeMaterialConnectionPoint;
  126168. /**
  126169. * Gets the b output component
  126170. */
  126171. get b(): NodeMaterialConnectionPoint;
  126172. /**
  126173. * Gets the a output component
  126174. */
  126175. get a(): NodeMaterialConnectionPoint;
  126176. get target(): NodeMaterialBlockTargets;
  126177. autoConfigure(material: NodeMaterial): void;
  126178. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126179. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126180. private _getTextureBase;
  126181. isReady(): boolean;
  126182. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126183. private get _isMixed();
  126184. private _injectVertexCode;
  126185. private _writeTextureRead;
  126186. private _writeOutput;
  126187. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126188. protected _dumpPropertiesCode(): string;
  126189. serialize(): any;
  126190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126191. }
  126192. }
  126193. declare module BABYLON {
  126194. /**
  126195. * Class used to store shared data between 2 NodeMaterialBuildState
  126196. */
  126197. export class NodeMaterialBuildStateSharedData {
  126198. /**
  126199. * Gets the list of emitted varyings
  126200. */
  126201. temps: string[];
  126202. /**
  126203. * Gets the list of emitted varyings
  126204. */
  126205. varyings: string[];
  126206. /**
  126207. * Gets the varying declaration string
  126208. */
  126209. varyingDeclaration: string;
  126210. /**
  126211. * Input blocks
  126212. */
  126213. inputBlocks: InputBlock[];
  126214. /**
  126215. * Input blocks
  126216. */
  126217. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  126218. /**
  126219. * Bindable blocks (Blocks that need to set data to the effect)
  126220. */
  126221. bindableBlocks: NodeMaterialBlock[];
  126222. /**
  126223. * List of blocks that can provide a compilation fallback
  126224. */
  126225. blocksWithFallbacks: NodeMaterialBlock[];
  126226. /**
  126227. * List of blocks that can provide a define update
  126228. */
  126229. blocksWithDefines: NodeMaterialBlock[];
  126230. /**
  126231. * List of blocks that can provide a repeatable content
  126232. */
  126233. repeatableContentBlocks: NodeMaterialBlock[];
  126234. /**
  126235. * List of blocks that can provide a dynamic list of uniforms
  126236. */
  126237. dynamicUniformBlocks: NodeMaterialBlock[];
  126238. /**
  126239. * List of blocks that can block the isReady function for the material
  126240. */
  126241. blockingBlocks: NodeMaterialBlock[];
  126242. /**
  126243. * Gets the list of animated inputs
  126244. */
  126245. animatedInputs: InputBlock[];
  126246. /**
  126247. * Build Id used to avoid multiple recompilations
  126248. */
  126249. buildId: number;
  126250. /** List of emitted variables */
  126251. variableNames: {
  126252. [key: string]: number;
  126253. };
  126254. /** List of emitted defines */
  126255. defineNames: {
  126256. [key: string]: number;
  126257. };
  126258. /** Should emit comments? */
  126259. emitComments: boolean;
  126260. /** Emit build activity */
  126261. verbose: boolean;
  126262. /** Gets or sets the hosting scene */
  126263. scene: Scene;
  126264. /**
  126265. * Gets the compilation hints emitted at compilation time
  126266. */
  126267. hints: {
  126268. needWorldViewMatrix: boolean;
  126269. needWorldViewProjectionMatrix: boolean;
  126270. needAlphaBlending: boolean;
  126271. needAlphaTesting: boolean;
  126272. };
  126273. /**
  126274. * List of compilation checks
  126275. */
  126276. checks: {
  126277. emitVertex: boolean;
  126278. emitFragment: boolean;
  126279. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  126280. };
  126281. /** Creates a new shared data */
  126282. constructor();
  126283. /**
  126284. * Emits console errors and exceptions if there is a failing check
  126285. */
  126286. emitErrors(): void;
  126287. }
  126288. }
  126289. declare module BABYLON {
  126290. /**
  126291. * Class used to store node based material build state
  126292. */
  126293. export class NodeMaterialBuildState {
  126294. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  126295. supportUniformBuffers: boolean;
  126296. /**
  126297. * Gets the list of emitted attributes
  126298. */
  126299. attributes: string[];
  126300. /**
  126301. * Gets the list of emitted uniforms
  126302. */
  126303. uniforms: string[];
  126304. /**
  126305. * Gets the list of emitted constants
  126306. */
  126307. constants: string[];
  126308. /**
  126309. * Gets the list of emitted samplers
  126310. */
  126311. samplers: string[];
  126312. /**
  126313. * Gets the list of emitted functions
  126314. */
  126315. functions: {
  126316. [key: string]: string;
  126317. };
  126318. /**
  126319. * Gets the list of emitted extensions
  126320. */
  126321. extensions: {
  126322. [key: string]: string;
  126323. };
  126324. /**
  126325. * Gets the target of the compilation state
  126326. */
  126327. target: NodeMaterialBlockTargets;
  126328. /**
  126329. * Gets the list of emitted counters
  126330. */
  126331. counters: {
  126332. [key: string]: number;
  126333. };
  126334. /**
  126335. * Shared data between multiple NodeMaterialBuildState instances
  126336. */
  126337. sharedData: NodeMaterialBuildStateSharedData;
  126338. /** @hidden */
  126339. _vertexState: NodeMaterialBuildState;
  126340. /** @hidden */
  126341. _attributeDeclaration: string;
  126342. /** @hidden */
  126343. _uniformDeclaration: string;
  126344. /** @hidden */
  126345. _constantDeclaration: string;
  126346. /** @hidden */
  126347. _samplerDeclaration: string;
  126348. /** @hidden */
  126349. _varyingTransfer: string;
  126350. private _repeatableContentAnchorIndex;
  126351. /** @hidden */
  126352. _builtCompilationString: string;
  126353. /**
  126354. * Gets the emitted compilation strings
  126355. */
  126356. compilationString: string;
  126357. /**
  126358. * Finalize the compilation strings
  126359. * @param state defines the current compilation state
  126360. */
  126361. finalize(state: NodeMaterialBuildState): void;
  126362. /** @hidden */
  126363. get _repeatableContentAnchor(): string;
  126364. /** @hidden */
  126365. _getFreeVariableName(prefix: string): string;
  126366. /** @hidden */
  126367. _getFreeDefineName(prefix: string): string;
  126368. /** @hidden */
  126369. _excludeVariableName(name: string): void;
  126370. /** @hidden */
  126371. _emit2DSampler(name: string): void;
  126372. /** @hidden */
  126373. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  126374. /** @hidden */
  126375. _emitExtension(name: string, extension: string): void;
  126376. /** @hidden */
  126377. _emitFunction(name: string, code: string, comments: string): void;
  126378. /** @hidden */
  126379. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  126380. replaceStrings?: {
  126381. search: RegExp;
  126382. replace: string;
  126383. }[];
  126384. repeatKey?: string;
  126385. }): string;
  126386. /** @hidden */
  126387. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  126388. repeatKey?: string;
  126389. removeAttributes?: boolean;
  126390. removeUniforms?: boolean;
  126391. removeVaryings?: boolean;
  126392. removeIfDef?: boolean;
  126393. replaceStrings?: {
  126394. search: RegExp;
  126395. replace: string;
  126396. }[];
  126397. }, storeKey?: string): void;
  126398. /** @hidden */
  126399. _registerTempVariable(name: string): boolean;
  126400. /** @hidden */
  126401. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  126402. /** @hidden */
  126403. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  126404. /** @hidden */
  126405. _emitFloat(value: number): string;
  126406. }
  126407. }
  126408. declare module BABYLON {
  126409. /**
  126410. * Defines a block that can be used inside a node based material
  126411. */
  126412. export class NodeMaterialBlock {
  126413. private _buildId;
  126414. private _buildTarget;
  126415. private _target;
  126416. private _isFinalMerger;
  126417. private _isInput;
  126418. protected _isUnique: boolean;
  126419. /** @hidden */
  126420. _codeVariableName: string;
  126421. /** @hidden */
  126422. _inputs: NodeMaterialConnectionPoint[];
  126423. /** @hidden */
  126424. _outputs: NodeMaterialConnectionPoint[];
  126425. /** @hidden */
  126426. _preparationId: number;
  126427. /**
  126428. * Gets or sets the name of the block
  126429. */
  126430. name: string;
  126431. /**
  126432. * Gets or sets the unique id of the node
  126433. */
  126434. uniqueId: number;
  126435. /**
  126436. * Gets or sets the comments associated with this block
  126437. */
  126438. comments: string;
  126439. /**
  126440. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  126441. */
  126442. get isUnique(): boolean;
  126443. /**
  126444. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  126445. */
  126446. get isFinalMerger(): boolean;
  126447. /**
  126448. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  126449. */
  126450. get isInput(): boolean;
  126451. /**
  126452. * Gets or sets the build Id
  126453. */
  126454. get buildId(): number;
  126455. set buildId(value: number);
  126456. /**
  126457. * Gets or sets the target of the block
  126458. */
  126459. get target(): NodeMaterialBlockTargets;
  126460. set target(value: NodeMaterialBlockTargets);
  126461. /**
  126462. * Gets the list of input points
  126463. */
  126464. get inputs(): NodeMaterialConnectionPoint[];
  126465. /** Gets the list of output points */
  126466. get outputs(): NodeMaterialConnectionPoint[];
  126467. /**
  126468. * Find an input by its name
  126469. * @param name defines the name of the input to look for
  126470. * @returns the input or null if not found
  126471. */
  126472. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126473. /**
  126474. * Find an output by its name
  126475. * @param name defines the name of the outputto look for
  126476. * @returns the output or null if not found
  126477. */
  126478. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126479. /**
  126480. * Creates a new NodeMaterialBlock
  126481. * @param name defines the block name
  126482. * @param target defines the target of that block (Vertex by default)
  126483. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  126484. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  126485. */
  126486. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  126487. /**
  126488. * Initialize the block and prepare the context for build
  126489. * @param state defines the state that will be used for the build
  126490. */
  126491. initialize(state: NodeMaterialBuildState): void;
  126492. /**
  126493. * Bind data to effect. Will only be called for blocks with isBindable === true
  126494. * @param effect defines the effect to bind data to
  126495. * @param nodeMaterial defines the hosting NodeMaterial
  126496. * @param mesh defines the mesh that will be rendered
  126497. */
  126498. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126499. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  126500. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  126501. protected _writeFloat(value: number): string;
  126502. /**
  126503. * Gets the current class name e.g. "NodeMaterialBlock"
  126504. * @returns the class name
  126505. */
  126506. getClassName(): string;
  126507. /**
  126508. * Register a new input. Must be called inside a block constructor
  126509. * @param name defines the connection point name
  126510. * @param type defines the connection point type
  126511. * @param isOptional defines a boolean indicating that this input can be omitted
  126512. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126513. * @returns the current block
  126514. */
  126515. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  126516. /**
  126517. * Register a new output. Must be called inside a block constructor
  126518. * @param name defines the connection point name
  126519. * @param type defines the connection point type
  126520. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126521. * @returns the current block
  126522. */
  126523. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  126524. /**
  126525. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  126526. * @param forOutput defines an optional connection point to check compatibility with
  126527. * @returns the first available input or null
  126528. */
  126529. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  126530. /**
  126531. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  126532. * @param forBlock defines an optional block to check compatibility with
  126533. * @returns the first available input or null
  126534. */
  126535. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  126536. /**
  126537. * Gets the sibling of the given output
  126538. * @param current defines the current output
  126539. * @returns the next output in the list or null
  126540. */
  126541. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  126542. /**
  126543. * Connect current block with another block
  126544. * @param other defines the block to connect with
  126545. * @param options define the various options to help pick the right connections
  126546. * @returns the current block
  126547. */
  126548. connectTo(other: NodeMaterialBlock, options?: {
  126549. input?: string;
  126550. output?: string;
  126551. outputSwizzle?: string;
  126552. }): this | undefined;
  126553. protected _buildBlock(state: NodeMaterialBuildState): void;
  126554. /**
  126555. * Add uniforms, samplers and uniform buffers at compilation time
  126556. * @param state defines the state to update
  126557. * @param nodeMaterial defines the node material requesting the update
  126558. * @param defines defines the material defines to update
  126559. * @param uniformBuffers defines the list of uniform buffer names
  126560. */
  126561. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  126562. /**
  126563. * Add potential fallbacks if shader compilation fails
  126564. * @param mesh defines the mesh to be rendered
  126565. * @param fallbacks defines the current prioritized list of fallbacks
  126566. */
  126567. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  126568. /**
  126569. * Initialize defines for shader compilation
  126570. * @param mesh defines the mesh to be rendered
  126571. * @param nodeMaterial defines the node material requesting the update
  126572. * @param defines defines the material defines to update
  126573. * @param useInstances specifies that instances should be used
  126574. */
  126575. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126576. /**
  126577. * Update defines for shader compilation
  126578. * @param mesh defines the mesh to be rendered
  126579. * @param nodeMaterial defines the node material requesting the update
  126580. * @param defines defines the material defines to update
  126581. * @param useInstances specifies that instances should be used
  126582. */
  126583. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126584. /**
  126585. * Lets the block try to connect some inputs automatically
  126586. * @param material defines the hosting NodeMaterial
  126587. */
  126588. autoConfigure(material: NodeMaterial): void;
  126589. /**
  126590. * Function called when a block is declared as repeatable content generator
  126591. * @param vertexShaderState defines the current compilation state for the vertex shader
  126592. * @param fragmentShaderState defines the current compilation state for the fragment shader
  126593. * @param mesh defines the mesh to be rendered
  126594. * @param defines defines the material defines to update
  126595. */
  126596. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  126597. /**
  126598. * Checks if the block is ready
  126599. * @param mesh defines the mesh to be rendered
  126600. * @param nodeMaterial defines the node material requesting the update
  126601. * @param defines defines the material defines to update
  126602. * @param useInstances specifies that instances should be used
  126603. * @returns true if the block is ready
  126604. */
  126605. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  126606. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  126607. private _processBuild;
  126608. /**
  126609. * Compile the current node and generate the shader code
  126610. * @param state defines the current compilation state (uniforms, samplers, current string)
  126611. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  126612. * @returns true if already built
  126613. */
  126614. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  126615. protected _inputRename(name: string): string;
  126616. protected _outputRename(name: string): string;
  126617. protected _dumpPropertiesCode(): string;
  126618. /** @hidden */
  126619. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  126620. /** @hidden */
  126621. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  126622. /**
  126623. * Clone the current block to a new identical block
  126624. * @param scene defines the hosting scene
  126625. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126626. * @returns a copy of the current block
  126627. */
  126628. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  126629. /**
  126630. * Serializes this block in a JSON representation
  126631. * @returns the serialized block object
  126632. */
  126633. serialize(): any;
  126634. /** @hidden */
  126635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126636. /**
  126637. * Release resources
  126638. */
  126639. dispose(): void;
  126640. }
  126641. }
  126642. declare module BABYLON {
  126643. /**
  126644. * Enum defining the type of animations supported by InputBlock
  126645. */
  126646. export enum AnimatedInputBlockTypes {
  126647. /** No animation */
  126648. None = 0,
  126649. /** Time based animation. Will only work for floats */
  126650. Time = 1
  126651. }
  126652. }
  126653. declare module BABYLON {
  126654. /**
  126655. * Block used to expose an input value
  126656. */
  126657. export class InputBlock extends NodeMaterialBlock {
  126658. private _mode;
  126659. private _associatedVariableName;
  126660. private _storedValue;
  126661. private _valueCallback;
  126662. private _type;
  126663. private _animationType;
  126664. /** Gets or set a value used to limit the range of float values */
  126665. min: number;
  126666. /** Gets or set a value used to limit the range of float values */
  126667. max: number;
  126668. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  126669. matrixMode: number;
  126670. /** @hidden */
  126671. _systemValue: Nullable<NodeMaterialSystemValues>;
  126672. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  126673. visibleInInspector: boolean;
  126674. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  126675. isConstant: boolean;
  126676. /** Gets or sets the group to use to display this block in the Inspector */
  126677. groupInInspector: string;
  126678. /**
  126679. * Gets or sets the connection point type (default is float)
  126680. */
  126681. get type(): NodeMaterialBlockConnectionPointTypes;
  126682. /**
  126683. * Creates a new InputBlock
  126684. * @param name defines the block name
  126685. * @param target defines the target of that block (Vertex by default)
  126686. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  126687. */
  126688. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  126689. /**
  126690. * Gets the output component
  126691. */
  126692. get output(): NodeMaterialConnectionPoint;
  126693. /**
  126694. * Set the source of this connection point to a vertex attribute
  126695. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  126696. * @returns the current connection point
  126697. */
  126698. setAsAttribute(attributeName?: string): InputBlock;
  126699. /**
  126700. * Set the source of this connection point to a system value
  126701. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  126702. * @returns the current connection point
  126703. */
  126704. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  126705. /**
  126706. * Gets or sets the value of that point.
  126707. * Please note that this value will be ignored if valueCallback is defined
  126708. */
  126709. get value(): any;
  126710. set value(value: any);
  126711. /**
  126712. * Gets or sets a callback used to get the value of that point.
  126713. * Please note that setting this value will force the connection point to ignore the value property
  126714. */
  126715. get valueCallback(): () => any;
  126716. set valueCallback(value: () => any);
  126717. /**
  126718. * Gets or sets the associated variable name in the shader
  126719. */
  126720. get associatedVariableName(): string;
  126721. set associatedVariableName(value: string);
  126722. /** Gets or sets the type of animation applied to the input */
  126723. get animationType(): AnimatedInputBlockTypes;
  126724. set animationType(value: AnimatedInputBlockTypes);
  126725. /**
  126726. * Gets a boolean indicating that this connection point not defined yet
  126727. */
  126728. get isUndefined(): boolean;
  126729. /**
  126730. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  126731. * In this case the connection point name must be the name of the uniform to use.
  126732. * Can only be set on inputs
  126733. */
  126734. get isUniform(): boolean;
  126735. set isUniform(value: boolean);
  126736. /**
  126737. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  126738. * In this case the connection point name must be the name of the attribute to use
  126739. * Can only be set on inputs
  126740. */
  126741. get isAttribute(): boolean;
  126742. set isAttribute(value: boolean);
  126743. /**
  126744. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  126745. * Can only be set on exit points
  126746. */
  126747. get isVarying(): boolean;
  126748. set isVarying(value: boolean);
  126749. /**
  126750. * Gets a boolean indicating that the current connection point is a system value
  126751. */
  126752. get isSystemValue(): boolean;
  126753. /**
  126754. * Gets or sets the current well known value or null if not defined as a system value
  126755. */
  126756. get systemValue(): Nullable<NodeMaterialSystemValues>;
  126757. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  126758. /**
  126759. * Gets the current class name
  126760. * @returns the class name
  126761. */
  126762. getClassName(): string;
  126763. /**
  126764. * Animate the input if animationType !== None
  126765. * @param scene defines the rendering scene
  126766. */
  126767. animate(scene: Scene): void;
  126768. private _emitDefine;
  126769. initialize(state: NodeMaterialBuildState): void;
  126770. /**
  126771. * Set the input block to its default value (based on its type)
  126772. */
  126773. setDefaultValue(): void;
  126774. private _emitConstant;
  126775. private _emit;
  126776. /** @hidden */
  126777. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  126778. /** @hidden */
  126779. _transmit(effect: Effect, scene: Scene): void;
  126780. protected _buildBlock(state: NodeMaterialBuildState): void;
  126781. protected _dumpPropertiesCode(): string;
  126782. serialize(): any;
  126783. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126784. }
  126785. }
  126786. declare module BABYLON {
  126787. /**
  126788. * Enum used to define the compatibility state between two connection points
  126789. */
  126790. export enum NodeMaterialConnectionPointCompatibilityStates {
  126791. /** Points are compatibles */
  126792. Compatible = 0,
  126793. /** Points are incompatible because of their types */
  126794. TypeIncompatible = 1,
  126795. /** Points are incompatible because of their targets (vertex vs fragment) */
  126796. TargetIncompatible = 2
  126797. }
  126798. /**
  126799. * Defines the direction of a connection point
  126800. */
  126801. export enum NodeMaterialConnectionPointDirection {
  126802. /** Input */
  126803. Input = 0,
  126804. /** Output */
  126805. Output = 1
  126806. }
  126807. /**
  126808. * Defines a connection point for a block
  126809. */
  126810. export class NodeMaterialConnectionPoint {
  126811. /** @hidden */
  126812. _ownerBlock: NodeMaterialBlock;
  126813. /** @hidden */
  126814. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  126815. private _endpoints;
  126816. private _associatedVariableName;
  126817. private _direction;
  126818. /** @hidden */
  126819. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126820. /** @hidden */
  126821. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126822. private _type;
  126823. /** @hidden */
  126824. _enforceAssociatedVariableName: boolean;
  126825. /** Gets the direction of the point */
  126826. get direction(): NodeMaterialConnectionPointDirection;
  126827. /**
  126828. * Gets or sets the additional types supported by this connection point
  126829. */
  126830. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126831. /**
  126832. * Gets or sets the additional types excluded by this connection point
  126833. */
  126834. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126835. /**
  126836. * Observable triggered when this point is connected
  126837. */
  126838. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  126839. /**
  126840. * Gets or sets the associated variable name in the shader
  126841. */
  126842. get associatedVariableName(): string;
  126843. set associatedVariableName(value: string);
  126844. /**
  126845. * Gets or sets the connection point type (default is float)
  126846. */
  126847. get type(): NodeMaterialBlockConnectionPointTypes;
  126848. set type(value: NodeMaterialBlockConnectionPointTypes);
  126849. /**
  126850. * Gets or sets the connection point name
  126851. */
  126852. name: string;
  126853. /**
  126854. * Gets or sets a boolean indicating that this connection point can be omitted
  126855. */
  126856. isOptional: boolean;
  126857. /**
  126858. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  126859. */
  126860. define: string;
  126861. /** @hidden */
  126862. _prioritizeVertex: boolean;
  126863. private _target;
  126864. /** Gets or sets the target of that connection point */
  126865. get target(): NodeMaterialBlockTargets;
  126866. set target(value: NodeMaterialBlockTargets);
  126867. /**
  126868. * Gets a boolean indicating that the current point is connected
  126869. */
  126870. get isConnected(): boolean;
  126871. /**
  126872. * Gets a boolean indicating that the current point is connected to an input block
  126873. */
  126874. get isConnectedToInputBlock(): boolean;
  126875. /**
  126876. * Gets a the connected input block (if any)
  126877. */
  126878. get connectInputBlock(): Nullable<InputBlock>;
  126879. /** Get the other side of the connection (if any) */
  126880. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  126881. /** Get the block that owns this connection point */
  126882. get ownerBlock(): NodeMaterialBlock;
  126883. /** Get the block connected on the other side of this connection (if any) */
  126884. get sourceBlock(): Nullable<NodeMaterialBlock>;
  126885. /** Get the block connected on the endpoints of this connection (if any) */
  126886. get connectedBlocks(): Array<NodeMaterialBlock>;
  126887. /** Gets the list of connected endpoints */
  126888. get endpoints(): NodeMaterialConnectionPoint[];
  126889. /** Gets a boolean indicating if that output point is connected to at least one input */
  126890. get hasEndpoints(): boolean;
  126891. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  126892. get isConnectedInVertexShader(): boolean;
  126893. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  126894. get isConnectedInFragmentShader(): boolean;
  126895. /**
  126896. * Creates a new connection point
  126897. * @param name defines the connection point name
  126898. * @param ownerBlock defines the block hosting this connection point
  126899. * @param direction defines the direction of the connection point
  126900. */
  126901. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  126902. /**
  126903. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  126904. * @returns the class name
  126905. */
  126906. getClassName(): string;
  126907. /**
  126908. * Gets a boolean indicating if the current point can be connected to another point
  126909. * @param connectionPoint defines the other connection point
  126910. * @returns a boolean
  126911. */
  126912. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  126913. /**
  126914. * Gets a number indicating if the current point can be connected to another point
  126915. * @param connectionPoint defines the other connection point
  126916. * @returns a number defining the compatibility state
  126917. */
  126918. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  126919. /**
  126920. * Connect this point to another connection point
  126921. * @param connectionPoint defines the other connection point
  126922. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  126923. * @returns the current connection point
  126924. */
  126925. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  126926. /**
  126927. * Disconnect this point from one of his endpoint
  126928. * @param endpoint defines the other connection point
  126929. * @returns the current connection point
  126930. */
  126931. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  126932. /**
  126933. * Serializes this point in a JSON representation
  126934. * @returns the serialized point object
  126935. */
  126936. serialize(): any;
  126937. /**
  126938. * Release resources
  126939. */
  126940. dispose(): void;
  126941. }
  126942. }
  126943. declare module BABYLON {
  126944. /**
  126945. * Block used to add support for vertex skinning (bones)
  126946. */
  126947. export class BonesBlock extends NodeMaterialBlock {
  126948. /**
  126949. * Creates a new BonesBlock
  126950. * @param name defines the block name
  126951. */
  126952. constructor(name: string);
  126953. /**
  126954. * Initialize the block and prepare the context for build
  126955. * @param state defines the state that will be used for the build
  126956. */
  126957. initialize(state: NodeMaterialBuildState): void;
  126958. /**
  126959. * Gets the current class name
  126960. * @returns the class name
  126961. */
  126962. getClassName(): string;
  126963. /**
  126964. * Gets the matrix indices input component
  126965. */
  126966. get matricesIndices(): NodeMaterialConnectionPoint;
  126967. /**
  126968. * Gets the matrix weights input component
  126969. */
  126970. get matricesWeights(): NodeMaterialConnectionPoint;
  126971. /**
  126972. * Gets the extra matrix indices input component
  126973. */
  126974. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  126975. /**
  126976. * Gets the extra matrix weights input component
  126977. */
  126978. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  126979. /**
  126980. * Gets the world input component
  126981. */
  126982. get world(): NodeMaterialConnectionPoint;
  126983. /**
  126984. * Gets the output component
  126985. */
  126986. get output(): NodeMaterialConnectionPoint;
  126987. autoConfigure(material: NodeMaterial): void;
  126988. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  126989. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126990. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126991. protected _buildBlock(state: NodeMaterialBuildState): this;
  126992. }
  126993. }
  126994. declare module BABYLON {
  126995. /**
  126996. * Block used to add support for instances
  126997. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  126998. */
  126999. export class InstancesBlock extends NodeMaterialBlock {
  127000. /**
  127001. * Creates a new InstancesBlock
  127002. * @param name defines the block name
  127003. */
  127004. constructor(name: string);
  127005. /**
  127006. * Gets the current class name
  127007. * @returns the class name
  127008. */
  127009. getClassName(): string;
  127010. /**
  127011. * Gets the first world row input component
  127012. */
  127013. get world0(): NodeMaterialConnectionPoint;
  127014. /**
  127015. * Gets the second world row input component
  127016. */
  127017. get world1(): NodeMaterialConnectionPoint;
  127018. /**
  127019. * Gets the third world row input component
  127020. */
  127021. get world2(): NodeMaterialConnectionPoint;
  127022. /**
  127023. * Gets the forth world row input component
  127024. */
  127025. get world3(): NodeMaterialConnectionPoint;
  127026. /**
  127027. * Gets the world input component
  127028. */
  127029. get world(): NodeMaterialConnectionPoint;
  127030. /**
  127031. * Gets the output component
  127032. */
  127033. get output(): NodeMaterialConnectionPoint;
  127034. autoConfigure(material: NodeMaterial): void;
  127035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  127036. protected _buildBlock(state: NodeMaterialBuildState): this;
  127037. }
  127038. }
  127039. declare module BABYLON {
  127040. /**
  127041. * Block used to add morph targets support to vertex shader
  127042. */
  127043. export class MorphTargetsBlock extends NodeMaterialBlock {
  127044. private _repeatableContentAnchor;
  127045. private _repeatebleContentGenerated;
  127046. /**
  127047. * Create a new MorphTargetsBlock
  127048. * @param name defines the block name
  127049. */
  127050. constructor(name: string);
  127051. /**
  127052. * Gets the current class name
  127053. * @returns the class name
  127054. */
  127055. getClassName(): string;
  127056. /**
  127057. * Gets the position input component
  127058. */
  127059. get position(): NodeMaterialConnectionPoint;
  127060. /**
  127061. * Gets the normal input component
  127062. */
  127063. get normal(): NodeMaterialConnectionPoint;
  127064. /**
  127065. * Gets the tangent input component
  127066. */
  127067. get tangent(): NodeMaterialConnectionPoint;
  127068. /**
  127069. * Gets the tangent input component
  127070. */
  127071. get uv(): NodeMaterialConnectionPoint;
  127072. /**
  127073. * Gets the position output component
  127074. */
  127075. get positionOutput(): NodeMaterialConnectionPoint;
  127076. /**
  127077. * Gets the normal output component
  127078. */
  127079. get normalOutput(): NodeMaterialConnectionPoint;
  127080. /**
  127081. * Gets the tangent output component
  127082. */
  127083. get tangentOutput(): NodeMaterialConnectionPoint;
  127084. /**
  127085. * Gets the tangent output component
  127086. */
  127087. get uvOutput(): NodeMaterialConnectionPoint;
  127088. initialize(state: NodeMaterialBuildState): void;
  127089. autoConfigure(material: NodeMaterial): void;
  127090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127091. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127092. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  127093. protected _buildBlock(state: NodeMaterialBuildState): this;
  127094. }
  127095. }
  127096. declare module BABYLON {
  127097. /**
  127098. * Block used to get data information from a light
  127099. */
  127100. export class LightInformationBlock extends NodeMaterialBlock {
  127101. private _lightDataUniformName;
  127102. private _lightColorUniformName;
  127103. private _lightTypeDefineName;
  127104. /**
  127105. * Gets or sets the light associated with this block
  127106. */
  127107. light: Nullable<Light>;
  127108. /**
  127109. * Creates a new LightInformationBlock
  127110. * @param name defines the block name
  127111. */
  127112. constructor(name: string);
  127113. /**
  127114. * Gets the current class name
  127115. * @returns the class name
  127116. */
  127117. getClassName(): string;
  127118. /**
  127119. * Gets the world position input component
  127120. */
  127121. get worldPosition(): NodeMaterialConnectionPoint;
  127122. /**
  127123. * Gets the direction output component
  127124. */
  127125. get direction(): NodeMaterialConnectionPoint;
  127126. /**
  127127. * Gets the direction output component
  127128. */
  127129. get color(): NodeMaterialConnectionPoint;
  127130. /**
  127131. * Gets the direction output component
  127132. */
  127133. get intensity(): NodeMaterialConnectionPoint;
  127134. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127135. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127136. protected _buildBlock(state: NodeMaterialBuildState): this;
  127137. serialize(): any;
  127138. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127139. }
  127140. }
  127141. declare module BABYLON {
  127142. /**
  127143. * Block used to add image processing support to fragment shader
  127144. */
  127145. export class ImageProcessingBlock extends NodeMaterialBlock {
  127146. /**
  127147. * Create a new ImageProcessingBlock
  127148. * @param name defines the block name
  127149. */
  127150. constructor(name: string);
  127151. /**
  127152. * Gets the current class name
  127153. * @returns the class name
  127154. */
  127155. getClassName(): string;
  127156. /**
  127157. * Gets the color input component
  127158. */
  127159. get color(): NodeMaterialConnectionPoint;
  127160. /**
  127161. * Gets the output component
  127162. */
  127163. get output(): NodeMaterialConnectionPoint;
  127164. /**
  127165. * Initialize the block and prepare the context for build
  127166. * @param state defines the state that will be used for the build
  127167. */
  127168. initialize(state: NodeMaterialBuildState): void;
  127169. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  127170. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127171. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127172. protected _buildBlock(state: NodeMaterialBuildState): this;
  127173. }
  127174. }
  127175. declare module BABYLON {
  127176. /**
  127177. * Block used to pertub normals based on a normal map
  127178. */
  127179. export class PerturbNormalBlock extends NodeMaterialBlock {
  127180. private _tangentSpaceParameterName;
  127181. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  127182. invertX: boolean;
  127183. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  127184. invertY: boolean;
  127185. /**
  127186. * Create a new PerturbNormalBlock
  127187. * @param name defines the block name
  127188. */
  127189. constructor(name: string);
  127190. /**
  127191. * Gets the current class name
  127192. * @returns the class name
  127193. */
  127194. getClassName(): string;
  127195. /**
  127196. * Gets the world position input component
  127197. */
  127198. get worldPosition(): NodeMaterialConnectionPoint;
  127199. /**
  127200. * Gets the world normal input component
  127201. */
  127202. get worldNormal(): NodeMaterialConnectionPoint;
  127203. /**
  127204. * Gets the uv input component
  127205. */
  127206. get uv(): NodeMaterialConnectionPoint;
  127207. /**
  127208. * Gets the normal map color input component
  127209. */
  127210. get normalMapColor(): NodeMaterialConnectionPoint;
  127211. /**
  127212. * Gets the strength input component
  127213. */
  127214. get strength(): NodeMaterialConnectionPoint;
  127215. /**
  127216. * Gets the output component
  127217. */
  127218. get output(): NodeMaterialConnectionPoint;
  127219. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127220. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127221. autoConfigure(material: NodeMaterial): void;
  127222. protected _buildBlock(state: NodeMaterialBuildState): this;
  127223. protected _dumpPropertiesCode(): string;
  127224. serialize(): any;
  127225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127226. }
  127227. }
  127228. declare module BABYLON {
  127229. /**
  127230. * Block used to discard a pixel if a value is smaller than a cutoff
  127231. */
  127232. export class DiscardBlock extends NodeMaterialBlock {
  127233. /**
  127234. * Create a new DiscardBlock
  127235. * @param name defines the block name
  127236. */
  127237. constructor(name: string);
  127238. /**
  127239. * Gets the current class name
  127240. * @returns the class name
  127241. */
  127242. getClassName(): string;
  127243. /**
  127244. * Gets the color input component
  127245. */
  127246. get value(): NodeMaterialConnectionPoint;
  127247. /**
  127248. * Gets the cutoff input component
  127249. */
  127250. get cutoff(): NodeMaterialConnectionPoint;
  127251. protected _buildBlock(state: NodeMaterialBuildState): this;
  127252. }
  127253. }
  127254. declare module BABYLON {
  127255. /**
  127256. * Block used to test if the fragment shader is front facing
  127257. */
  127258. export class FrontFacingBlock extends NodeMaterialBlock {
  127259. /**
  127260. * Creates a new FrontFacingBlock
  127261. * @param name defines the block name
  127262. */
  127263. constructor(name: string);
  127264. /**
  127265. * Gets the current class name
  127266. * @returns the class name
  127267. */
  127268. getClassName(): string;
  127269. /**
  127270. * Gets the output component
  127271. */
  127272. get output(): NodeMaterialConnectionPoint;
  127273. protected _buildBlock(state: NodeMaterialBuildState): this;
  127274. }
  127275. }
  127276. declare module BABYLON {
  127277. /**
  127278. * Block used to get the derivative value on x and y of a given input
  127279. */
  127280. export class DerivativeBlock extends NodeMaterialBlock {
  127281. /**
  127282. * Create a new DerivativeBlock
  127283. * @param name defines the block name
  127284. */
  127285. constructor(name: string);
  127286. /**
  127287. * Gets the current class name
  127288. * @returns the class name
  127289. */
  127290. getClassName(): string;
  127291. /**
  127292. * Gets the input component
  127293. */
  127294. get input(): NodeMaterialConnectionPoint;
  127295. /**
  127296. * Gets the derivative output on x
  127297. */
  127298. get dx(): NodeMaterialConnectionPoint;
  127299. /**
  127300. * Gets the derivative output on y
  127301. */
  127302. get dy(): NodeMaterialConnectionPoint;
  127303. protected _buildBlock(state: NodeMaterialBuildState): this;
  127304. }
  127305. }
  127306. declare module BABYLON {
  127307. /**
  127308. * Block used to add support for scene fog
  127309. */
  127310. export class FogBlock extends NodeMaterialBlock {
  127311. private _fogDistanceName;
  127312. private _fogParameters;
  127313. /**
  127314. * Create a new FogBlock
  127315. * @param name defines the block name
  127316. */
  127317. constructor(name: string);
  127318. /**
  127319. * Gets the current class name
  127320. * @returns the class name
  127321. */
  127322. getClassName(): string;
  127323. /**
  127324. * Gets the world position input component
  127325. */
  127326. get worldPosition(): NodeMaterialConnectionPoint;
  127327. /**
  127328. * Gets the view input component
  127329. */
  127330. get view(): NodeMaterialConnectionPoint;
  127331. /**
  127332. * Gets the color input component
  127333. */
  127334. get input(): NodeMaterialConnectionPoint;
  127335. /**
  127336. * Gets the fog color input component
  127337. */
  127338. get fogColor(): NodeMaterialConnectionPoint;
  127339. /**
  127340. * Gets the output component
  127341. */
  127342. get output(): NodeMaterialConnectionPoint;
  127343. autoConfigure(material: NodeMaterial): void;
  127344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127346. protected _buildBlock(state: NodeMaterialBuildState): this;
  127347. }
  127348. }
  127349. declare module BABYLON {
  127350. /**
  127351. * Block used to add light in the fragment shader
  127352. */
  127353. export class LightBlock extends NodeMaterialBlock {
  127354. private _lightId;
  127355. /**
  127356. * Gets or sets the light associated with this block
  127357. */
  127358. light: Nullable<Light>;
  127359. /**
  127360. * Create a new LightBlock
  127361. * @param name defines the block name
  127362. */
  127363. constructor(name: string);
  127364. /**
  127365. * Gets the current class name
  127366. * @returns the class name
  127367. */
  127368. getClassName(): string;
  127369. /**
  127370. * Gets the world position input component
  127371. */
  127372. get worldPosition(): NodeMaterialConnectionPoint;
  127373. /**
  127374. * Gets the world normal input component
  127375. */
  127376. get worldNormal(): NodeMaterialConnectionPoint;
  127377. /**
  127378. * Gets the camera (or eye) position component
  127379. */
  127380. get cameraPosition(): NodeMaterialConnectionPoint;
  127381. /**
  127382. * Gets the glossiness component
  127383. */
  127384. get glossiness(): NodeMaterialConnectionPoint;
  127385. /**
  127386. * Gets the glossinness power component
  127387. */
  127388. get glossPower(): NodeMaterialConnectionPoint;
  127389. /**
  127390. * Gets the diffuse color component
  127391. */
  127392. get diffuseColor(): NodeMaterialConnectionPoint;
  127393. /**
  127394. * Gets the specular color component
  127395. */
  127396. get specularColor(): NodeMaterialConnectionPoint;
  127397. /**
  127398. * Gets the diffuse output component
  127399. */
  127400. get diffuseOutput(): NodeMaterialConnectionPoint;
  127401. /**
  127402. * Gets the specular output component
  127403. */
  127404. get specularOutput(): NodeMaterialConnectionPoint;
  127405. autoConfigure(material: NodeMaterial): void;
  127406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127407. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  127408. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127409. private _injectVertexCode;
  127410. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127411. serialize(): any;
  127412. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127413. }
  127414. }
  127415. declare module BABYLON {
  127416. /**
  127417. * Block used to multiply 2 values
  127418. */
  127419. export class MultiplyBlock extends NodeMaterialBlock {
  127420. /**
  127421. * Creates a new MultiplyBlock
  127422. * @param name defines the block name
  127423. */
  127424. constructor(name: string);
  127425. /**
  127426. * Gets the current class name
  127427. * @returns the class name
  127428. */
  127429. getClassName(): string;
  127430. /**
  127431. * Gets the left operand input component
  127432. */
  127433. get left(): NodeMaterialConnectionPoint;
  127434. /**
  127435. * Gets the right operand input component
  127436. */
  127437. get right(): NodeMaterialConnectionPoint;
  127438. /**
  127439. * Gets the output component
  127440. */
  127441. get output(): NodeMaterialConnectionPoint;
  127442. protected _buildBlock(state: NodeMaterialBuildState): this;
  127443. }
  127444. }
  127445. declare module BABYLON {
  127446. /**
  127447. * Block used to add 2 vectors
  127448. */
  127449. export class AddBlock extends NodeMaterialBlock {
  127450. /**
  127451. * Creates a new AddBlock
  127452. * @param name defines the block name
  127453. */
  127454. constructor(name: string);
  127455. /**
  127456. * Gets the current class name
  127457. * @returns the class name
  127458. */
  127459. getClassName(): string;
  127460. /**
  127461. * Gets the left operand input component
  127462. */
  127463. get left(): NodeMaterialConnectionPoint;
  127464. /**
  127465. * Gets the right operand input component
  127466. */
  127467. get right(): NodeMaterialConnectionPoint;
  127468. /**
  127469. * Gets the output component
  127470. */
  127471. get output(): NodeMaterialConnectionPoint;
  127472. protected _buildBlock(state: NodeMaterialBuildState): this;
  127473. }
  127474. }
  127475. declare module BABYLON {
  127476. /**
  127477. * Block used to scale a vector by a float
  127478. */
  127479. export class ScaleBlock extends NodeMaterialBlock {
  127480. /**
  127481. * Creates a new ScaleBlock
  127482. * @param name defines the block name
  127483. */
  127484. constructor(name: string);
  127485. /**
  127486. * Gets the current class name
  127487. * @returns the class name
  127488. */
  127489. getClassName(): string;
  127490. /**
  127491. * Gets the input component
  127492. */
  127493. get input(): NodeMaterialConnectionPoint;
  127494. /**
  127495. * Gets the factor input component
  127496. */
  127497. get factor(): NodeMaterialConnectionPoint;
  127498. /**
  127499. * Gets the output component
  127500. */
  127501. get output(): NodeMaterialConnectionPoint;
  127502. protected _buildBlock(state: NodeMaterialBuildState): this;
  127503. }
  127504. }
  127505. declare module BABYLON {
  127506. /**
  127507. * Block used to clamp a float
  127508. */
  127509. export class ClampBlock extends NodeMaterialBlock {
  127510. /** Gets or sets the minimum range */
  127511. minimum: number;
  127512. /** Gets or sets the maximum range */
  127513. maximum: number;
  127514. /**
  127515. * Creates a new ClampBlock
  127516. * @param name defines the block name
  127517. */
  127518. constructor(name: string);
  127519. /**
  127520. * Gets the current class name
  127521. * @returns the class name
  127522. */
  127523. getClassName(): string;
  127524. /**
  127525. * Gets the value input component
  127526. */
  127527. get value(): NodeMaterialConnectionPoint;
  127528. /**
  127529. * Gets the output component
  127530. */
  127531. get output(): NodeMaterialConnectionPoint;
  127532. protected _buildBlock(state: NodeMaterialBuildState): this;
  127533. protected _dumpPropertiesCode(): string;
  127534. serialize(): any;
  127535. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127536. }
  127537. }
  127538. declare module BABYLON {
  127539. /**
  127540. * Block used to apply a cross product between 2 vectors
  127541. */
  127542. export class CrossBlock extends NodeMaterialBlock {
  127543. /**
  127544. * Creates a new CrossBlock
  127545. * @param name defines the block name
  127546. */
  127547. constructor(name: string);
  127548. /**
  127549. * Gets the current class name
  127550. * @returns the class name
  127551. */
  127552. getClassName(): string;
  127553. /**
  127554. * Gets the left operand input component
  127555. */
  127556. get left(): NodeMaterialConnectionPoint;
  127557. /**
  127558. * Gets the right operand input component
  127559. */
  127560. get right(): NodeMaterialConnectionPoint;
  127561. /**
  127562. * Gets the output component
  127563. */
  127564. get output(): NodeMaterialConnectionPoint;
  127565. protected _buildBlock(state: NodeMaterialBuildState): this;
  127566. }
  127567. }
  127568. declare module BABYLON {
  127569. /**
  127570. * Block used to apply a dot product between 2 vectors
  127571. */
  127572. export class DotBlock extends NodeMaterialBlock {
  127573. /**
  127574. * Creates a new DotBlock
  127575. * @param name defines the block name
  127576. */
  127577. constructor(name: string);
  127578. /**
  127579. * Gets the current class name
  127580. * @returns the class name
  127581. */
  127582. getClassName(): string;
  127583. /**
  127584. * Gets the left operand input component
  127585. */
  127586. get left(): NodeMaterialConnectionPoint;
  127587. /**
  127588. * Gets the right operand input component
  127589. */
  127590. get right(): NodeMaterialConnectionPoint;
  127591. /**
  127592. * Gets the output component
  127593. */
  127594. get output(): NodeMaterialConnectionPoint;
  127595. protected _buildBlock(state: NodeMaterialBuildState): this;
  127596. }
  127597. }
  127598. declare module BABYLON {
  127599. /**
  127600. * Block used to remap a float from a range to a new one
  127601. */
  127602. export class RemapBlock extends NodeMaterialBlock {
  127603. /**
  127604. * Gets or sets the source range
  127605. */
  127606. sourceRange: Vector2;
  127607. /**
  127608. * Gets or sets the target range
  127609. */
  127610. targetRange: Vector2;
  127611. /**
  127612. * Creates a new RemapBlock
  127613. * @param name defines the block name
  127614. */
  127615. constructor(name: string);
  127616. /**
  127617. * Gets the current class name
  127618. * @returns the class name
  127619. */
  127620. getClassName(): string;
  127621. /**
  127622. * Gets the input component
  127623. */
  127624. get input(): NodeMaterialConnectionPoint;
  127625. /**
  127626. * Gets the source min input component
  127627. */
  127628. get sourceMin(): NodeMaterialConnectionPoint;
  127629. /**
  127630. * Gets the source max input component
  127631. */
  127632. get sourceMax(): NodeMaterialConnectionPoint;
  127633. /**
  127634. * Gets the target min input component
  127635. */
  127636. get targetMin(): NodeMaterialConnectionPoint;
  127637. /**
  127638. * Gets the target max input component
  127639. */
  127640. get targetMax(): NodeMaterialConnectionPoint;
  127641. /**
  127642. * Gets the output component
  127643. */
  127644. get output(): NodeMaterialConnectionPoint;
  127645. protected _buildBlock(state: NodeMaterialBuildState): this;
  127646. protected _dumpPropertiesCode(): string;
  127647. serialize(): any;
  127648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127649. }
  127650. }
  127651. declare module BABYLON {
  127652. /**
  127653. * Block used to normalize a vector
  127654. */
  127655. export class NormalizeBlock extends NodeMaterialBlock {
  127656. /**
  127657. * Creates a new NormalizeBlock
  127658. * @param name defines the block name
  127659. */
  127660. constructor(name: string);
  127661. /**
  127662. * Gets the current class name
  127663. * @returns the class name
  127664. */
  127665. getClassName(): string;
  127666. /**
  127667. * Gets the input component
  127668. */
  127669. get input(): NodeMaterialConnectionPoint;
  127670. /**
  127671. * Gets the output component
  127672. */
  127673. get output(): NodeMaterialConnectionPoint;
  127674. protected _buildBlock(state: NodeMaterialBuildState): this;
  127675. }
  127676. }
  127677. declare module BABYLON {
  127678. /**
  127679. * Operations supported by the Trigonometry block
  127680. */
  127681. export enum TrigonometryBlockOperations {
  127682. /** Cos */
  127683. Cos = 0,
  127684. /** Sin */
  127685. Sin = 1,
  127686. /** Abs */
  127687. Abs = 2,
  127688. /** Exp */
  127689. Exp = 3,
  127690. /** Exp2 */
  127691. Exp2 = 4,
  127692. /** Round */
  127693. Round = 5,
  127694. /** Floor */
  127695. Floor = 6,
  127696. /** Ceiling */
  127697. Ceiling = 7,
  127698. /** Square root */
  127699. Sqrt = 8,
  127700. /** Log */
  127701. Log = 9,
  127702. /** Tangent */
  127703. Tan = 10,
  127704. /** Arc tangent */
  127705. ArcTan = 11,
  127706. /** Arc cosinus */
  127707. ArcCos = 12,
  127708. /** Arc sinus */
  127709. ArcSin = 13,
  127710. /** Fraction */
  127711. Fract = 14,
  127712. /** Sign */
  127713. Sign = 15,
  127714. /** To radians (from degrees) */
  127715. Radians = 16,
  127716. /** To degrees (from radians) */
  127717. Degrees = 17
  127718. }
  127719. /**
  127720. * Block used to apply trigonometry operation to floats
  127721. */
  127722. export class TrigonometryBlock extends NodeMaterialBlock {
  127723. /**
  127724. * Gets or sets the operation applied by the block
  127725. */
  127726. operation: TrigonometryBlockOperations;
  127727. /**
  127728. * Creates a new TrigonometryBlock
  127729. * @param name defines the block name
  127730. */
  127731. constructor(name: string);
  127732. /**
  127733. * Gets the current class name
  127734. * @returns the class name
  127735. */
  127736. getClassName(): string;
  127737. /**
  127738. * Gets the input component
  127739. */
  127740. get input(): NodeMaterialConnectionPoint;
  127741. /**
  127742. * Gets the output component
  127743. */
  127744. get output(): NodeMaterialConnectionPoint;
  127745. protected _buildBlock(state: NodeMaterialBuildState): this;
  127746. serialize(): any;
  127747. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127748. protected _dumpPropertiesCode(): string;
  127749. }
  127750. }
  127751. declare module BABYLON {
  127752. /**
  127753. * Block used to create a Color3/4 out of individual inputs (one for each component)
  127754. */
  127755. export class ColorMergerBlock extends NodeMaterialBlock {
  127756. /**
  127757. * Create a new ColorMergerBlock
  127758. * @param name defines the block name
  127759. */
  127760. constructor(name: string);
  127761. /**
  127762. * Gets the current class name
  127763. * @returns the class name
  127764. */
  127765. getClassName(): string;
  127766. /**
  127767. * Gets the rgb component (input)
  127768. */
  127769. get rgbIn(): NodeMaterialConnectionPoint;
  127770. /**
  127771. * Gets the r component (input)
  127772. */
  127773. get r(): NodeMaterialConnectionPoint;
  127774. /**
  127775. * Gets the g component (input)
  127776. */
  127777. get g(): NodeMaterialConnectionPoint;
  127778. /**
  127779. * Gets the b component (input)
  127780. */
  127781. get b(): NodeMaterialConnectionPoint;
  127782. /**
  127783. * Gets the a component (input)
  127784. */
  127785. get a(): NodeMaterialConnectionPoint;
  127786. /**
  127787. * Gets the rgba component (output)
  127788. */
  127789. get rgba(): NodeMaterialConnectionPoint;
  127790. /**
  127791. * Gets the rgb component (output)
  127792. */
  127793. get rgbOut(): NodeMaterialConnectionPoint;
  127794. /**
  127795. * Gets the rgb component (output)
  127796. * @deprecated Please use rgbOut instead.
  127797. */
  127798. get rgb(): NodeMaterialConnectionPoint;
  127799. protected _buildBlock(state: NodeMaterialBuildState): this;
  127800. }
  127801. }
  127802. declare module BABYLON {
  127803. /**
  127804. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  127805. */
  127806. export class VectorMergerBlock extends NodeMaterialBlock {
  127807. /**
  127808. * Create a new VectorMergerBlock
  127809. * @param name defines the block name
  127810. */
  127811. constructor(name: string);
  127812. /**
  127813. * Gets the current class name
  127814. * @returns the class name
  127815. */
  127816. getClassName(): string;
  127817. /**
  127818. * Gets the xyz component (input)
  127819. */
  127820. get xyzIn(): NodeMaterialConnectionPoint;
  127821. /**
  127822. * Gets the xy component (input)
  127823. */
  127824. get xyIn(): NodeMaterialConnectionPoint;
  127825. /**
  127826. * Gets the x component (input)
  127827. */
  127828. get x(): NodeMaterialConnectionPoint;
  127829. /**
  127830. * Gets the y component (input)
  127831. */
  127832. get y(): NodeMaterialConnectionPoint;
  127833. /**
  127834. * Gets the z component (input)
  127835. */
  127836. get z(): NodeMaterialConnectionPoint;
  127837. /**
  127838. * Gets the w component (input)
  127839. */
  127840. get w(): NodeMaterialConnectionPoint;
  127841. /**
  127842. * Gets the xyzw component (output)
  127843. */
  127844. get xyzw(): NodeMaterialConnectionPoint;
  127845. /**
  127846. * Gets the xyz component (output)
  127847. */
  127848. get xyzOut(): NodeMaterialConnectionPoint;
  127849. /**
  127850. * Gets the xy component (output)
  127851. */
  127852. get xyOut(): NodeMaterialConnectionPoint;
  127853. /**
  127854. * Gets the xy component (output)
  127855. * @deprecated Please use xyOut instead.
  127856. */
  127857. get xy(): NodeMaterialConnectionPoint;
  127858. /**
  127859. * Gets the xyz component (output)
  127860. * @deprecated Please use xyzOut instead.
  127861. */
  127862. get xyz(): NodeMaterialConnectionPoint;
  127863. protected _buildBlock(state: NodeMaterialBuildState): this;
  127864. }
  127865. }
  127866. declare module BABYLON {
  127867. /**
  127868. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  127869. */
  127870. export class ColorSplitterBlock extends NodeMaterialBlock {
  127871. /**
  127872. * Create a new ColorSplitterBlock
  127873. * @param name defines the block name
  127874. */
  127875. constructor(name: string);
  127876. /**
  127877. * Gets the current class name
  127878. * @returns the class name
  127879. */
  127880. getClassName(): string;
  127881. /**
  127882. * Gets the rgba component (input)
  127883. */
  127884. get rgba(): NodeMaterialConnectionPoint;
  127885. /**
  127886. * Gets the rgb component (input)
  127887. */
  127888. get rgbIn(): NodeMaterialConnectionPoint;
  127889. /**
  127890. * Gets the rgb component (output)
  127891. */
  127892. get rgbOut(): NodeMaterialConnectionPoint;
  127893. /**
  127894. * Gets the r component (output)
  127895. */
  127896. get r(): NodeMaterialConnectionPoint;
  127897. /**
  127898. * Gets the g component (output)
  127899. */
  127900. get g(): NodeMaterialConnectionPoint;
  127901. /**
  127902. * Gets the b component (output)
  127903. */
  127904. get b(): NodeMaterialConnectionPoint;
  127905. /**
  127906. * Gets the a component (output)
  127907. */
  127908. get a(): NodeMaterialConnectionPoint;
  127909. protected _inputRename(name: string): string;
  127910. protected _outputRename(name: string): string;
  127911. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127912. }
  127913. }
  127914. declare module BABYLON {
  127915. /**
  127916. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  127917. */
  127918. export class VectorSplitterBlock extends NodeMaterialBlock {
  127919. /**
  127920. * Create a new VectorSplitterBlock
  127921. * @param name defines the block name
  127922. */
  127923. constructor(name: string);
  127924. /**
  127925. * Gets the current class name
  127926. * @returns the class name
  127927. */
  127928. getClassName(): string;
  127929. /**
  127930. * Gets the xyzw component (input)
  127931. */
  127932. get xyzw(): NodeMaterialConnectionPoint;
  127933. /**
  127934. * Gets the xyz component (input)
  127935. */
  127936. get xyzIn(): NodeMaterialConnectionPoint;
  127937. /**
  127938. * Gets the xy component (input)
  127939. */
  127940. get xyIn(): NodeMaterialConnectionPoint;
  127941. /**
  127942. * Gets the xyz component (output)
  127943. */
  127944. get xyzOut(): NodeMaterialConnectionPoint;
  127945. /**
  127946. * Gets the xy component (output)
  127947. */
  127948. get xyOut(): NodeMaterialConnectionPoint;
  127949. /**
  127950. * Gets the x component (output)
  127951. */
  127952. get x(): NodeMaterialConnectionPoint;
  127953. /**
  127954. * Gets the y component (output)
  127955. */
  127956. get y(): NodeMaterialConnectionPoint;
  127957. /**
  127958. * Gets the z component (output)
  127959. */
  127960. get z(): NodeMaterialConnectionPoint;
  127961. /**
  127962. * Gets the w component (output)
  127963. */
  127964. get w(): NodeMaterialConnectionPoint;
  127965. protected _inputRename(name: string): string;
  127966. protected _outputRename(name: string): string;
  127967. protected _buildBlock(state: NodeMaterialBuildState): this;
  127968. }
  127969. }
  127970. declare module BABYLON {
  127971. /**
  127972. * Block used to lerp between 2 values
  127973. */
  127974. export class LerpBlock extends NodeMaterialBlock {
  127975. /**
  127976. * Creates a new LerpBlock
  127977. * @param name defines the block name
  127978. */
  127979. constructor(name: string);
  127980. /**
  127981. * Gets the current class name
  127982. * @returns the class name
  127983. */
  127984. getClassName(): string;
  127985. /**
  127986. * Gets the left operand input component
  127987. */
  127988. get left(): NodeMaterialConnectionPoint;
  127989. /**
  127990. * Gets the right operand input component
  127991. */
  127992. get right(): NodeMaterialConnectionPoint;
  127993. /**
  127994. * Gets the gradient operand input component
  127995. */
  127996. get gradient(): NodeMaterialConnectionPoint;
  127997. /**
  127998. * Gets the output component
  127999. */
  128000. get output(): NodeMaterialConnectionPoint;
  128001. protected _buildBlock(state: NodeMaterialBuildState): this;
  128002. }
  128003. }
  128004. declare module BABYLON {
  128005. /**
  128006. * Block used to divide 2 vectors
  128007. */
  128008. export class DivideBlock extends NodeMaterialBlock {
  128009. /**
  128010. * Creates a new DivideBlock
  128011. * @param name defines the block name
  128012. */
  128013. constructor(name: string);
  128014. /**
  128015. * Gets the current class name
  128016. * @returns the class name
  128017. */
  128018. getClassName(): string;
  128019. /**
  128020. * Gets the left operand input component
  128021. */
  128022. get left(): NodeMaterialConnectionPoint;
  128023. /**
  128024. * Gets the right operand input component
  128025. */
  128026. get right(): NodeMaterialConnectionPoint;
  128027. /**
  128028. * Gets the output component
  128029. */
  128030. get output(): NodeMaterialConnectionPoint;
  128031. protected _buildBlock(state: NodeMaterialBuildState): this;
  128032. }
  128033. }
  128034. declare module BABYLON {
  128035. /**
  128036. * Block used to subtract 2 vectors
  128037. */
  128038. export class SubtractBlock extends NodeMaterialBlock {
  128039. /**
  128040. * Creates a new SubtractBlock
  128041. * @param name defines the block name
  128042. */
  128043. constructor(name: string);
  128044. /**
  128045. * Gets the current class name
  128046. * @returns the class name
  128047. */
  128048. getClassName(): string;
  128049. /**
  128050. * Gets the left operand input component
  128051. */
  128052. get left(): NodeMaterialConnectionPoint;
  128053. /**
  128054. * Gets the right operand input component
  128055. */
  128056. get right(): NodeMaterialConnectionPoint;
  128057. /**
  128058. * Gets the output component
  128059. */
  128060. get output(): NodeMaterialConnectionPoint;
  128061. protected _buildBlock(state: NodeMaterialBuildState): this;
  128062. }
  128063. }
  128064. declare module BABYLON {
  128065. /**
  128066. * Block used to step a value
  128067. */
  128068. export class StepBlock extends NodeMaterialBlock {
  128069. /**
  128070. * Creates a new StepBlock
  128071. * @param name defines the block name
  128072. */
  128073. constructor(name: string);
  128074. /**
  128075. * Gets the current class name
  128076. * @returns the class name
  128077. */
  128078. getClassName(): string;
  128079. /**
  128080. * Gets the value operand input component
  128081. */
  128082. get value(): NodeMaterialConnectionPoint;
  128083. /**
  128084. * Gets the edge operand input component
  128085. */
  128086. get edge(): NodeMaterialConnectionPoint;
  128087. /**
  128088. * Gets the output component
  128089. */
  128090. get output(): NodeMaterialConnectionPoint;
  128091. protected _buildBlock(state: NodeMaterialBuildState): this;
  128092. }
  128093. }
  128094. declare module BABYLON {
  128095. /**
  128096. * Block used to get the opposite (1 - x) of a value
  128097. */
  128098. export class OneMinusBlock extends NodeMaterialBlock {
  128099. /**
  128100. * Creates a new OneMinusBlock
  128101. * @param name defines the block name
  128102. */
  128103. constructor(name: string);
  128104. /**
  128105. * Gets the current class name
  128106. * @returns the class name
  128107. */
  128108. getClassName(): string;
  128109. /**
  128110. * Gets the input component
  128111. */
  128112. get input(): NodeMaterialConnectionPoint;
  128113. /**
  128114. * Gets the output component
  128115. */
  128116. get output(): NodeMaterialConnectionPoint;
  128117. protected _buildBlock(state: NodeMaterialBuildState): this;
  128118. }
  128119. }
  128120. declare module BABYLON {
  128121. /**
  128122. * Block used to get the view direction
  128123. */
  128124. export class ViewDirectionBlock extends NodeMaterialBlock {
  128125. /**
  128126. * Creates a new ViewDirectionBlock
  128127. * @param name defines the block name
  128128. */
  128129. constructor(name: string);
  128130. /**
  128131. * Gets the current class name
  128132. * @returns the class name
  128133. */
  128134. getClassName(): string;
  128135. /**
  128136. * Gets the world position component
  128137. */
  128138. get worldPosition(): NodeMaterialConnectionPoint;
  128139. /**
  128140. * Gets the camera position component
  128141. */
  128142. get cameraPosition(): NodeMaterialConnectionPoint;
  128143. /**
  128144. * Gets the output component
  128145. */
  128146. get output(): NodeMaterialConnectionPoint;
  128147. autoConfigure(material: NodeMaterial): void;
  128148. protected _buildBlock(state: NodeMaterialBuildState): this;
  128149. }
  128150. }
  128151. declare module BABYLON {
  128152. /**
  128153. * Block used to compute fresnel value
  128154. */
  128155. export class FresnelBlock extends NodeMaterialBlock {
  128156. /**
  128157. * Create a new FresnelBlock
  128158. * @param name defines the block name
  128159. */
  128160. constructor(name: string);
  128161. /**
  128162. * Gets the current class name
  128163. * @returns the class name
  128164. */
  128165. getClassName(): string;
  128166. /**
  128167. * Gets the world normal input component
  128168. */
  128169. get worldNormal(): NodeMaterialConnectionPoint;
  128170. /**
  128171. * Gets the view direction input component
  128172. */
  128173. get viewDirection(): NodeMaterialConnectionPoint;
  128174. /**
  128175. * Gets the bias input component
  128176. */
  128177. get bias(): NodeMaterialConnectionPoint;
  128178. /**
  128179. * Gets the camera (or eye) position component
  128180. */
  128181. get power(): NodeMaterialConnectionPoint;
  128182. /**
  128183. * Gets the fresnel output component
  128184. */
  128185. get fresnel(): NodeMaterialConnectionPoint;
  128186. autoConfigure(material: NodeMaterial): void;
  128187. protected _buildBlock(state: NodeMaterialBuildState): this;
  128188. }
  128189. }
  128190. declare module BABYLON {
  128191. /**
  128192. * Block used to get the max of 2 values
  128193. */
  128194. export class MaxBlock extends NodeMaterialBlock {
  128195. /**
  128196. * Creates a new MaxBlock
  128197. * @param name defines the block name
  128198. */
  128199. constructor(name: string);
  128200. /**
  128201. * Gets the current class name
  128202. * @returns the class name
  128203. */
  128204. getClassName(): string;
  128205. /**
  128206. * Gets the left operand input component
  128207. */
  128208. get left(): NodeMaterialConnectionPoint;
  128209. /**
  128210. * Gets the right operand input component
  128211. */
  128212. get right(): NodeMaterialConnectionPoint;
  128213. /**
  128214. * Gets the output component
  128215. */
  128216. get output(): NodeMaterialConnectionPoint;
  128217. protected _buildBlock(state: NodeMaterialBuildState): this;
  128218. }
  128219. }
  128220. declare module BABYLON {
  128221. /**
  128222. * Block used to get the min of 2 values
  128223. */
  128224. export class MinBlock extends NodeMaterialBlock {
  128225. /**
  128226. * Creates a new MinBlock
  128227. * @param name defines the block name
  128228. */
  128229. constructor(name: string);
  128230. /**
  128231. * Gets the current class name
  128232. * @returns the class name
  128233. */
  128234. getClassName(): string;
  128235. /**
  128236. * Gets the left operand input component
  128237. */
  128238. get left(): NodeMaterialConnectionPoint;
  128239. /**
  128240. * Gets the right operand input component
  128241. */
  128242. get right(): NodeMaterialConnectionPoint;
  128243. /**
  128244. * Gets the output component
  128245. */
  128246. get output(): NodeMaterialConnectionPoint;
  128247. protected _buildBlock(state: NodeMaterialBuildState): this;
  128248. }
  128249. }
  128250. declare module BABYLON {
  128251. /**
  128252. * Block used to get the distance between 2 values
  128253. */
  128254. export class DistanceBlock extends NodeMaterialBlock {
  128255. /**
  128256. * Creates a new DistanceBlock
  128257. * @param name defines the block name
  128258. */
  128259. constructor(name: string);
  128260. /**
  128261. * Gets the current class name
  128262. * @returns the class name
  128263. */
  128264. getClassName(): string;
  128265. /**
  128266. * Gets the left operand input component
  128267. */
  128268. get left(): NodeMaterialConnectionPoint;
  128269. /**
  128270. * Gets the right operand input component
  128271. */
  128272. get right(): NodeMaterialConnectionPoint;
  128273. /**
  128274. * Gets the output component
  128275. */
  128276. get output(): NodeMaterialConnectionPoint;
  128277. protected _buildBlock(state: NodeMaterialBuildState): this;
  128278. }
  128279. }
  128280. declare module BABYLON {
  128281. /**
  128282. * Block used to get the length of a vector
  128283. */
  128284. export class LengthBlock extends NodeMaterialBlock {
  128285. /**
  128286. * Creates a new LengthBlock
  128287. * @param name defines the block name
  128288. */
  128289. constructor(name: string);
  128290. /**
  128291. * Gets the current class name
  128292. * @returns the class name
  128293. */
  128294. getClassName(): string;
  128295. /**
  128296. * Gets the value input component
  128297. */
  128298. get value(): NodeMaterialConnectionPoint;
  128299. /**
  128300. * Gets the output component
  128301. */
  128302. get output(): NodeMaterialConnectionPoint;
  128303. protected _buildBlock(state: NodeMaterialBuildState): this;
  128304. }
  128305. }
  128306. declare module BABYLON {
  128307. /**
  128308. * Block used to get negative version of a value (i.e. x * -1)
  128309. */
  128310. export class NegateBlock extends NodeMaterialBlock {
  128311. /**
  128312. * Creates a new NegateBlock
  128313. * @param name defines the block name
  128314. */
  128315. constructor(name: string);
  128316. /**
  128317. * Gets the current class name
  128318. * @returns the class name
  128319. */
  128320. getClassName(): string;
  128321. /**
  128322. * Gets the value input component
  128323. */
  128324. get value(): NodeMaterialConnectionPoint;
  128325. /**
  128326. * Gets the output component
  128327. */
  128328. get output(): NodeMaterialConnectionPoint;
  128329. protected _buildBlock(state: NodeMaterialBuildState): this;
  128330. }
  128331. }
  128332. declare module BABYLON {
  128333. /**
  128334. * Block used to get the value of the first parameter raised to the power of the second
  128335. */
  128336. export class PowBlock extends NodeMaterialBlock {
  128337. /**
  128338. * Creates a new PowBlock
  128339. * @param name defines the block name
  128340. */
  128341. constructor(name: string);
  128342. /**
  128343. * Gets the current class name
  128344. * @returns the class name
  128345. */
  128346. getClassName(): string;
  128347. /**
  128348. * Gets the value operand input component
  128349. */
  128350. get value(): NodeMaterialConnectionPoint;
  128351. /**
  128352. * Gets the power operand input component
  128353. */
  128354. get power(): NodeMaterialConnectionPoint;
  128355. /**
  128356. * Gets the output component
  128357. */
  128358. get output(): NodeMaterialConnectionPoint;
  128359. protected _buildBlock(state: NodeMaterialBuildState): this;
  128360. }
  128361. }
  128362. declare module BABYLON {
  128363. /**
  128364. * Block used to get a random number
  128365. */
  128366. export class RandomNumberBlock extends NodeMaterialBlock {
  128367. /**
  128368. * Creates a new RandomNumberBlock
  128369. * @param name defines the block name
  128370. */
  128371. constructor(name: string);
  128372. /**
  128373. * Gets the current class name
  128374. * @returns the class name
  128375. */
  128376. getClassName(): string;
  128377. /**
  128378. * Gets the seed input component
  128379. */
  128380. get seed(): NodeMaterialConnectionPoint;
  128381. /**
  128382. * Gets the output component
  128383. */
  128384. get output(): NodeMaterialConnectionPoint;
  128385. protected _buildBlock(state: NodeMaterialBuildState): this;
  128386. }
  128387. }
  128388. declare module BABYLON {
  128389. /**
  128390. * Block used to compute arc tangent of 2 values
  128391. */
  128392. export class ArcTan2Block extends NodeMaterialBlock {
  128393. /**
  128394. * Creates a new ArcTan2Block
  128395. * @param name defines the block name
  128396. */
  128397. constructor(name: string);
  128398. /**
  128399. * Gets the current class name
  128400. * @returns the class name
  128401. */
  128402. getClassName(): string;
  128403. /**
  128404. * Gets the x operand input component
  128405. */
  128406. get x(): NodeMaterialConnectionPoint;
  128407. /**
  128408. * Gets the y operand input component
  128409. */
  128410. get y(): NodeMaterialConnectionPoint;
  128411. /**
  128412. * Gets the output component
  128413. */
  128414. get output(): NodeMaterialConnectionPoint;
  128415. protected _buildBlock(state: NodeMaterialBuildState): this;
  128416. }
  128417. }
  128418. declare module BABYLON {
  128419. /**
  128420. * Block used to smooth step a value
  128421. */
  128422. export class SmoothStepBlock extends NodeMaterialBlock {
  128423. /**
  128424. * Creates a new SmoothStepBlock
  128425. * @param name defines the block name
  128426. */
  128427. constructor(name: string);
  128428. /**
  128429. * Gets the current class name
  128430. * @returns the class name
  128431. */
  128432. getClassName(): string;
  128433. /**
  128434. * Gets the value operand input component
  128435. */
  128436. get value(): NodeMaterialConnectionPoint;
  128437. /**
  128438. * Gets the first edge operand input component
  128439. */
  128440. get edge0(): NodeMaterialConnectionPoint;
  128441. /**
  128442. * Gets the second edge operand input component
  128443. */
  128444. get edge1(): NodeMaterialConnectionPoint;
  128445. /**
  128446. * Gets the output component
  128447. */
  128448. get output(): NodeMaterialConnectionPoint;
  128449. protected _buildBlock(state: NodeMaterialBuildState): this;
  128450. }
  128451. }
  128452. declare module BABYLON {
  128453. /**
  128454. * Block used to get the reciprocal (1 / x) of a value
  128455. */
  128456. export class ReciprocalBlock extends NodeMaterialBlock {
  128457. /**
  128458. * Creates a new ReciprocalBlock
  128459. * @param name defines the block name
  128460. */
  128461. constructor(name: string);
  128462. /**
  128463. * Gets the current class name
  128464. * @returns the class name
  128465. */
  128466. getClassName(): string;
  128467. /**
  128468. * Gets the input component
  128469. */
  128470. get input(): NodeMaterialConnectionPoint;
  128471. /**
  128472. * Gets the output component
  128473. */
  128474. get output(): NodeMaterialConnectionPoint;
  128475. protected _buildBlock(state: NodeMaterialBuildState): this;
  128476. }
  128477. }
  128478. declare module BABYLON {
  128479. /**
  128480. * Block used to replace a color by another one
  128481. */
  128482. export class ReplaceColorBlock extends NodeMaterialBlock {
  128483. /**
  128484. * Creates a new ReplaceColorBlock
  128485. * @param name defines the block name
  128486. */
  128487. constructor(name: string);
  128488. /**
  128489. * Gets the current class name
  128490. * @returns the class name
  128491. */
  128492. getClassName(): string;
  128493. /**
  128494. * Gets the value input component
  128495. */
  128496. get value(): NodeMaterialConnectionPoint;
  128497. /**
  128498. * Gets the reference input component
  128499. */
  128500. get reference(): NodeMaterialConnectionPoint;
  128501. /**
  128502. * Gets the distance input component
  128503. */
  128504. get distance(): NodeMaterialConnectionPoint;
  128505. /**
  128506. * Gets the replacement input component
  128507. */
  128508. get replacement(): NodeMaterialConnectionPoint;
  128509. /**
  128510. * Gets the output component
  128511. */
  128512. get output(): NodeMaterialConnectionPoint;
  128513. protected _buildBlock(state: NodeMaterialBuildState): this;
  128514. }
  128515. }
  128516. declare module BABYLON {
  128517. /**
  128518. * Block used to posterize a value
  128519. * @see https://en.wikipedia.org/wiki/Posterization
  128520. */
  128521. export class PosterizeBlock extends NodeMaterialBlock {
  128522. /**
  128523. * Creates a new PosterizeBlock
  128524. * @param name defines the block name
  128525. */
  128526. constructor(name: string);
  128527. /**
  128528. * Gets the current class name
  128529. * @returns the class name
  128530. */
  128531. getClassName(): string;
  128532. /**
  128533. * Gets the value input component
  128534. */
  128535. get value(): NodeMaterialConnectionPoint;
  128536. /**
  128537. * Gets the steps input component
  128538. */
  128539. get steps(): NodeMaterialConnectionPoint;
  128540. /**
  128541. * Gets the output component
  128542. */
  128543. get output(): NodeMaterialConnectionPoint;
  128544. protected _buildBlock(state: NodeMaterialBuildState): this;
  128545. }
  128546. }
  128547. declare module BABYLON {
  128548. /**
  128549. * Operations supported by the Wave block
  128550. */
  128551. export enum WaveBlockKind {
  128552. /** SawTooth */
  128553. SawTooth = 0,
  128554. /** Square */
  128555. Square = 1,
  128556. /** Triangle */
  128557. Triangle = 2
  128558. }
  128559. /**
  128560. * Block used to apply wave operation to floats
  128561. */
  128562. export class WaveBlock extends NodeMaterialBlock {
  128563. /**
  128564. * Gets or sets the kibnd of wave to be applied by the block
  128565. */
  128566. kind: WaveBlockKind;
  128567. /**
  128568. * Creates a new WaveBlock
  128569. * @param name defines the block name
  128570. */
  128571. constructor(name: string);
  128572. /**
  128573. * Gets the current class name
  128574. * @returns the class name
  128575. */
  128576. getClassName(): string;
  128577. /**
  128578. * Gets the input component
  128579. */
  128580. get input(): NodeMaterialConnectionPoint;
  128581. /**
  128582. * Gets the output component
  128583. */
  128584. get output(): NodeMaterialConnectionPoint;
  128585. protected _buildBlock(state: NodeMaterialBuildState): this;
  128586. serialize(): any;
  128587. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128588. }
  128589. }
  128590. declare module BABYLON {
  128591. /**
  128592. * Class used to store a color step for the GradientBlock
  128593. */
  128594. export class GradientBlockColorStep {
  128595. /**
  128596. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128597. */
  128598. step: number;
  128599. /**
  128600. * Gets or sets the color associated with this step
  128601. */
  128602. color: Color3;
  128603. /**
  128604. * Creates a new GradientBlockColorStep
  128605. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  128606. * @param color defines the color associated with this step
  128607. */
  128608. constructor(
  128609. /**
  128610. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128611. */
  128612. step: number,
  128613. /**
  128614. * Gets or sets the color associated with this step
  128615. */
  128616. color: Color3);
  128617. }
  128618. /**
  128619. * Block used to return a color from a gradient based on an input value between 0 and 1
  128620. */
  128621. export class GradientBlock extends NodeMaterialBlock {
  128622. /**
  128623. * Gets or sets the list of color steps
  128624. */
  128625. colorSteps: GradientBlockColorStep[];
  128626. /**
  128627. * Creates a new GradientBlock
  128628. * @param name defines the block name
  128629. */
  128630. constructor(name: string);
  128631. /**
  128632. * Gets the current class name
  128633. * @returns the class name
  128634. */
  128635. getClassName(): string;
  128636. /**
  128637. * Gets the gradient input component
  128638. */
  128639. get gradient(): NodeMaterialConnectionPoint;
  128640. /**
  128641. * Gets the output component
  128642. */
  128643. get output(): NodeMaterialConnectionPoint;
  128644. private _writeColorConstant;
  128645. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128646. serialize(): any;
  128647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128648. protected _dumpPropertiesCode(): string;
  128649. }
  128650. }
  128651. declare module BABYLON {
  128652. /**
  128653. * Block used to normalize lerp between 2 values
  128654. */
  128655. export class NLerpBlock extends NodeMaterialBlock {
  128656. /**
  128657. * Creates a new NLerpBlock
  128658. * @param name defines the block name
  128659. */
  128660. constructor(name: string);
  128661. /**
  128662. * Gets the current class name
  128663. * @returns the class name
  128664. */
  128665. getClassName(): string;
  128666. /**
  128667. * Gets the left operand input component
  128668. */
  128669. get left(): NodeMaterialConnectionPoint;
  128670. /**
  128671. * Gets the right operand input component
  128672. */
  128673. get right(): NodeMaterialConnectionPoint;
  128674. /**
  128675. * Gets the gradient operand input component
  128676. */
  128677. get gradient(): NodeMaterialConnectionPoint;
  128678. /**
  128679. * Gets the output component
  128680. */
  128681. get output(): NodeMaterialConnectionPoint;
  128682. protected _buildBlock(state: NodeMaterialBuildState): this;
  128683. }
  128684. }
  128685. declare module BABYLON {
  128686. /**
  128687. * block used to Generate a Worley Noise 3D Noise Pattern
  128688. */
  128689. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  128690. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  128691. manhattanDistance: boolean;
  128692. /**
  128693. * Creates a new WorleyNoise3DBlock
  128694. * @param name defines the block name
  128695. */
  128696. constructor(name: string);
  128697. /**
  128698. * Gets the current class name
  128699. * @returns the class name
  128700. */
  128701. getClassName(): string;
  128702. /**
  128703. * Gets the seed input component
  128704. */
  128705. get seed(): NodeMaterialConnectionPoint;
  128706. /**
  128707. * Gets the jitter input component
  128708. */
  128709. get jitter(): NodeMaterialConnectionPoint;
  128710. /**
  128711. * Gets the output component
  128712. */
  128713. get output(): NodeMaterialConnectionPoint;
  128714. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128715. /**
  128716. * Exposes the properties to the UI?
  128717. */
  128718. protected _dumpPropertiesCode(): string;
  128719. /**
  128720. * Exposes the properties to the Seralize?
  128721. */
  128722. serialize(): any;
  128723. /**
  128724. * Exposes the properties to the deseralize?
  128725. */
  128726. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128727. }
  128728. }
  128729. declare module BABYLON {
  128730. /**
  128731. * block used to Generate a Simplex Perlin 3d Noise Pattern
  128732. */
  128733. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  128734. /**
  128735. * Creates a new SimplexPerlin3DBlock
  128736. * @param name defines the block name
  128737. */
  128738. constructor(name: string);
  128739. /**
  128740. * Gets the current class name
  128741. * @returns the class name
  128742. */
  128743. getClassName(): string;
  128744. /**
  128745. * Gets the seed operand input component
  128746. */
  128747. get seed(): NodeMaterialConnectionPoint;
  128748. /**
  128749. * Gets the output component
  128750. */
  128751. get output(): NodeMaterialConnectionPoint;
  128752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128753. }
  128754. }
  128755. declare module BABYLON {
  128756. /**
  128757. * Block used to blend normals
  128758. */
  128759. export class NormalBlendBlock extends NodeMaterialBlock {
  128760. /**
  128761. * Creates a new NormalBlendBlock
  128762. * @param name defines the block name
  128763. */
  128764. constructor(name: string);
  128765. /**
  128766. * Gets the current class name
  128767. * @returns the class name
  128768. */
  128769. getClassName(): string;
  128770. /**
  128771. * Gets the first input component
  128772. */
  128773. get normalMap0(): NodeMaterialConnectionPoint;
  128774. /**
  128775. * Gets the second input component
  128776. */
  128777. get normalMap1(): NodeMaterialConnectionPoint;
  128778. /**
  128779. * Gets the output component
  128780. */
  128781. get output(): NodeMaterialConnectionPoint;
  128782. protected _buildBlock(state: NodeMaterialBuildState): this;
  128783. }
  128784. }
  128785. declare module BABYLON {
  128786. /**
  128787. * Block used to rotate a 2d vector by a given angle
  128788. */
  128789. export class Rotate2dBlock extends NodeMaterialBlock {
  128790. /**
  128791. * Creates a new Rotate2dBlock
  128792. * @param name defines the block name
  128793. */
  128794. constructor(name: string);
  128795. /**
  128796. * Gets the current class name
  128797. * @returns the class name
  128798. */
  128799. getClassName(): string;
  128800. /**
  128801. * Gets the input vector
  128802. */
  128803. get input(): NodeMaterialConnectionPoint;
  128804. /**
  128805. * Gets the input angle
  128806. */
  128807. get angle(): NodeMaterialConnectionPoint;
  128808. /**
  128809. * Gets the output component
  128810. */
  128811. get output(): NodeMaterialConnectionPoint;
  128812. autoConfigure(material: NodeMaterial): void;
  128813. protected _buildBlock(state: NodeMaterialBuildState): this;
  128814. }
  128815. }
  128816. declare module BABYLON {
  128817. /**
  128818. * Block used to get the reflected vector from a direction and a normal
  128819. */
  128820. export class ReflectBlock extends NodeMaterialBlock {
  128821. /**
  128822. * Creates a new ReflectBlock
  128823. * @param name defines the block name
  128824. */
  128825. constructor(name: string);
  128826. /**
  128827. * Gets the current class name
  128828. * @returns the class name
  128829. */
  128830. getClassName(): string;
  128831. /**
  128832. * Gets the incident component
  128833. */
  128834. get incident(): NodeMaterialConnectionPoint;
  128835. /**
  128836. * Gets the normal component
  128837. */
  128838. get normal(): NodeMaterialConnectionPoint;
  128839. /**
  128840. * Gets the output component
  128841. */
  128842. get output(): NodeMaterialConnectionPoint;
  128843. protected _buildBlock(state: NodeMaterialBuildState): this;
  128844. }
  128845. }
  128846. declare module BABYLON {
  128847. /**
  128848. * Block used to get the refracted vector from a direction and a normal
  128849. */
  128850. export class RefractBlock extends NodeMaterialBlock {
  128851. /**
  128852. * Creates a new RefractBlock
  128853. * @param name defines the block name
  128854. */
  128855. constructor(name: string);
  128856. /**
  128857. * Gets the current class name
  128858. * @returns the class name
  128859. */
  128860. getClassName(): string;
  128861. /**
  128862. * Gets the incident component
  128863. */
  128864. get incident(): NodeMaterialConnectionPoint;
  128865. /**
  128866. * Gets the normal component
  128867. */
  128868. get normal(): NodeMaterialConnectionPoint;
  128869. /**
  128870. * Gets the index of refraction component
  128871. */
  128872. get ior(): NodeMaterialConnectionPoint;
  128873. /**
  128874. * Gets the output component
  128875. */
  128876. get output(): NodeMaterialConnectionPoint;
  128877. protected _buildBlock(state: NodeMaterialBuildState): this;
  128878. }
  128879. }
  128880. declare module BABYLON {
  128881. /**
  128882. * Block used to desaturate a color
  128883. */
  128884. export class DesaturateBlock extends NodeMaterialBlock {
  128885. /**
  128886. * Creates a new DesaturateBlock
  128887. * @param name defines the block name
  128888. */
  128889. constructor(name: string);
  128890. /**
  128891. * Gets the current class name
  128892. * @returns the class name
  128893. */
  128894. getClassName(): string;
  128895. /**
  128896. * Gets the color operand input component
  128897. */
  128898. get color(): NodeMaterialConnectionPoint;
  128899. /**
  128900. * Gets the level operand input component
  128901. */
  128902. get level(): NodeMaterialConnectionPoint;
  128903. /**
  128904. * Gets the output component
  128905. */
  128906. get output(): NodeMaterialConnectionPoint;
  128907. protected _buildBlock(state: NodeMaterialBuildState): this;
  128908. }
  128909. }
  128910. declare module BABYLON {
  128911. /**
  128912. * Effect Render Options
  128913. */
  128914. export interface IEffectRendererOptions {
  128915. /**
  128916. * Defines the vertices positions.
  128917. */
  128918. positions?: number[];
  128919. /**
  128920. * Defines the indices.
  128921. */
  128922. indices?: number[];
  128923. }
  128924. /**
  128925. * Helper class to render one or more effects
  128926. */
  128927. export class EffectRenderer {
  128928. private engine;
  128929. private static _DefaultOptions;
  128930. private _vertexBuffers;
  128931. private _indexBuffer;
  128932. private _ringBufferIndex;
  128933. private _ringScreenBuffer;
  128934. private _fullscreenViewport;
  128935. private _getNextFrameBuffer;
  128936. /**
  128937. * Creates an effect renderer
  128938. * @param engine the engine to use for rendering
  128939. * @param options defines the options of the effect renderer
  128940. */
  128941. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  128942. /**
  128943. * Sets the current viewport in normalized coordinates 0-1
  128944. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  128945. */
  128946. setViewport(viewport?: Viewport): void;
  128947. /**
  128948. * Binds the embedded attributes buffer to the effect.
  128949. * @param effect Defines the effect to bind the attributes for
  128950. */
  128951. bindBuffers(effect: Effect): void;
  128952. /**
  128953. * Sets the current effect wrapper to use during draw.
  128954. * The effect needs to be ready before calling this api.
  128955. * This also sets the default full screen position attribute.
  128956. * @param effectWrapper Defines the effect to draw with
  128957. */
  128958. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  128959. /**
  128960. * Draws a full screen quad.
  128961. */
  128962. draw(): void;
  128963. /**
  128964. * renders one or more effects to a specified texture
  128965. * @param effectWrappers list of effects to renderer
  128966. * @param outputTexture texture to draw to, if null it will render to the screen
  128967. */
  128968. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  128969. /**
  128970. * Disposes of the effect renderer
  128971. */
  128972. dispose(): void;
  128973. }
  128974. /**
  128975. * Options to create an EffectWrapper
  128976. */
  128977. interface EffectWrapperCreationOptions {
  128978. /**
  128979. * Engine to use to create the effect
  128980. */
  128981. engine: ThinEngine;
  128982. /**
  128983. * Fragment shader for the effect
  128984. */
  128985. fragmentShader: string;
  128986. /**
  128987. * Vertex shader for the effect
  128988. */
  128989. vertexShader?: string;
  128990. /**
  128991. * Attributes to use in the shader
  128992. */
  128993. attributeNames?: Array<string>;
  128994. /**
  128995. * Uniforms to use in the shader
  128996. */
  128997. uniformNames?: Array<string>;
  128998. /**
  128999. * Texture sampler names to use in the shader
  129000. */
  129001. samplerNames?: Array<string>;
  129002. /**
  129003. * The friendly name of the effect displayed in Spector.
  129004. */
  129005. name?: string;
  129006. }
  129007. /**
  129008. * Wraps an effect to be used for rendering
  129009. */
  129010. export class EffectWrapper {
  129011. /**
  129012. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  129013. */
  129014. onApplyObservable: Observable<{}>;
  129015. /**
  129016. * The underlying effect
  129017. */
  129018. effect: Effect;
  129019. /**
  129020. * Creates an effect to be renderer
  129021. * @param creationOptions options to create the effect
  129022. */
  129023. constructor(creationOptions: EffectWrapperCreationOptions);
  129024. /**
  129025. * Disposes of the effect wrapper
  129026. */
  129027. dispose(): void;
  129028. }
  129029. }
  129030. declare module BABYLON {
  129031. /**
  129032. * Helper class to push actions to a pool of workers.
  129033. */
  129034. export class WorkerPool implements IDisposable {
  129035. private _workerInfos;
  129036. private _pendingActions;
  129037. /**
  129038. * Constructor
  129039. * @param workers Array of workers to use for actions
  129040. */
  129041. constructor(workers: Array<Worker>);
  129042. /**
  129043. * Terminates all workers and clears any pending actions.
  129044. */
  129045. dispose(): void;
  129046. /**
  129047. * Pushes an action to the worker pool. If all the workers are active, the action will be
  129048. * pended until a worker has completed its action.
  129049. * @param action The action to perform. Call onComplete when the action is complete.
  129050. */
  129051. push(action: (worker: Worker, onComplete: () => void) => void): void;
  129052. private _execute;
  129053. }
  129054. }
  129055. declare module BABYLON {
  129056. /**
  129057. * Configuration for Draco compression
  129058. */
  129059. export interface IDracoCompressionConfiguration {
  129060. /**
  129061. * Configuration for the decoder.
  129062. */
  129063. decoder: {
  129064. /**
  129065. * The url to the WebAssembly module.
  129066. */
  129067. wasmUrl?: string;
  129068. /**
  129069. * The url to the WebAssembly binary.
  129070. */
  129071. wasmBinaryUrl?: string;
  129072. /**
  129073. * The url to the fallback JavaScript module.
  129074. */
  129075. fallbackUrl?: string;
  129076. };
  129077. }
  129078. /**
  129079. * Draco compression (https://google.github.io/draco/)
  129080. *
  129081. * This class wraps the Draco module.
  129082. *
  129083. * **Encoder**
  129084. *
  129085. * The encoder is not currently implemented.
  129086. *
  129087. * **Decoder**
  129088. *
  129089. * 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.
  129090. *
  129091. * To update the configuration, use the following code:
  129092. * ```javascript
  129093. * DracoCompression.Configuration = {
  129094. * decoder: {
  129095. * wasmUrl: "<url to the WebAssembly library>",
  129096. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  129097. * fallbackUrl: "<url to the fallback JavaScript library>",
  129098. * }
  129099. * };
  129100. * ```
  129101. *
  129102. * 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.
  129103. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  129104. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  129105. *
  129106. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  129107. * ```javascript
  129108. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  129109. * ```
  129110. *
  129111. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  129112. */
  129113. export class DracoCompression implements IDisposable {
  129114. private _workerPoolPromise?;
  129115. private _decoderModulePromise?;
  129116. /**
  129117. * The configuration. Defaults to the following urls:
  129118. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  129119. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  129120. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  129121. */
  129122. static Configuration: IDracoCompressionConfiguration;
  129123. /**
  129124. * Returns true if the decoder configuration is available.
  129125. */
  129126. static get DecoderAvailable(): boolean;
  129127. /**
  129128. * Default number of workers to create when creating the draco compression object.
  129129. */
  129130. static DefaultNumWorkers: number;
  129131. private static GetDefaultNumWorkers;
  129132. private static _Default;
  129133. /**
  129134. * Default instance for the draco compression object.
  129135. */
  129136. static get Default(): DracoCompression;
  129137. /**
  129138. * Constructor
  129139. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  129140. */
  129141. constructor(numWorkers?: number);
  129142. /**
  129143. * Stop all async operations and release resources.
  129144. */
  129145. dispose(): void;
  129146. /**
  129147. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  129148. * @returns a promise that resolves when ready
  129149. */
  129150. whenReadyAsync(): Promise<void>;
  129151. /**
  129152. * Decode Draco compressed mesh data to vertex data.
  129153. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  129154. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  129155. * @returns A promise that resolves with the decoded vertex data
  129156. */
  129157. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  129158. [kind: string]: number;
  129159. }): Promise<VertexData>;
  129160. }
  129161. }
  129162. declare module BABYLON {
  129163. /**
  129164. * Class for building Constructive Solid Geometry
  129165. */
  129166. export class CSG {
  129167. private polygons;
  129168. /**
  129169. * The world matrix
  129170. */
  129171. matrix: Matrix;
  129172. /**
  129173. * Stores the position
  129174. */
  129175. position: Vector3;
  129176. /**
  129177. * Stores the rotation
  129178. */
  129179. rotation: Vector3;
  129180. /**
  129181. * Stores the rotation quaternion
  129182. */
  129183. rotationQuaternion: Nullable<Quaternion>;
  129184. /**
  129185. * Stores the scaling vector
  129186. */
  129187. scaling: Vector3;
  129188. /**
  129189. * Convert the Mesh to CSG
  129190. * @param mesh The Mesh to convert to CSG
  129191. * @returns A new CSG from the Mesh
  129192. */
  129193. static FromMesh(mesh: Mesh): CSG;
  129194. /**
  129195. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  129196. * @param polygons Polygons used to construct a CSG solid
  129197. */
  129198. private static FromPolygons;
  129199. /**
  129200. * Clones, or makes a deep copy, of the CSG
  129201. * @returns A new CSG
  129202. */
  129203. clone(): CSG;
  129204. /**
  129205. * Unions this CSG with another CSG
  129206. * @param csg The CSG to union against this CSG
  129207. * @returns The unioned CSG
  129208. */
  129209. union(csg: CSG): CSG;
  129210. /**
  129211. * Unions this CSG with another CSG in place
  129212. * @param csg The CSG to union against this CSG
  129213. */
  129214. unionInPlace(csg: CSG): void;
  129215. /**
  129216. * Subtracts this CSG with another CSG
  129217. * @param csg The CSG to subtract against this CSG
  129218. * @returns A new CSG
  129219. */
  129220. subtract(csg: CSG): CSG;
  129221. /**
  129222. * Subtracts this CSG with another CSG in place
  129223. * @param csg The CSG to subtact against this CSG
  129224. */
  129225. subtractInPlace(csg: CSG): void;
  129226. /**
  129227. * Intersect this CSG with another CSG
  129228. * @param csg The CSG to intersect against this CSG
  129229. * @returns A new CSG
  129230. */
  129231. intersect(csg: CSG): CSG;
  129232. /**
  129233. * Intersects this CSG with another CSG in place
  129234. * @param csg The CSG to intersect against this CSG
  129235. */
  129236. intersectInPlace(csg: CSG): void;
  129237. /**
  129238. * Return a new CSG solid with solid and empty space switched. This solid is
  129239. * not modified.
  129240. * @returns A new CSG solid with solid and empty space switched
  129241. */
  129242. inverse(): CSG;
  129243. /**
  129244. * Inverses the CSG in place
  129245. */
  129246. inverseInPlace(): void;
  129247. /**
  129248. * This is used to keep meshes transformations so they can be restored
  129249. * when we build back a Babylon Mesh
  129250. * NB : All CSG operations are performed in world coordinates
  129251. * @param csg The CSG to copy the transform attributes from
  129252. * @returns This CSG
  129253. */
  129254. copyTransformAttributes(csg: CSG): CSG;
  129255. /**
  129256. * Build Raw mesh from CSG
  129257. * Coordinates here are in world space
  129258. * @param name The name of the mesh geometry
  129259. * @param scene The Scene
  129260. * @param keepSubMeshes Specifies if the submeshes should be kept
  129261. * @returns A new Mesh
  129262. */
  129263. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129264. /**
  129265. * Build Mesh from CSG taking material and transforms into account
  129266. * @param name The name of the Mesh
  129267. * @param material The material of the Mesh
  129268. * @param scene The Scene
  129269. * @param keepSubMeshes Specifies if submeshes should be kept
  129270. * @returns The new Mesh
  129271. */
  129272. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129273. }
  129274. }
  129275. declare module BABYLON {
  129276. /**
  129277. * Class used to create a trail following a mesh
  129278. */
  129279. export class TrailMesh extends Mesh {
  129280. private _generator;
  129281. private _autoStart;
  129282. private _running;
  129283. private _diameter;
  129284. private _length;
  129285. private _sectionPolygonPointsCount;
  129286. private _sectionVectors;
  129287. private _sectionNormalVectors;
  129288. private _beforeRenderObserver;
  129289. /**
  129290. * @constructor
  129291. * @param name The value used by scene.getMeshByName() to do a lookup.
  129292. * @param generator The mesh to generate a trail.
  129293. * @param scene The scene to add this mesh to.
  129294. * @param diameter Diameter of trailing mesh. Default is 1.
  129295. * @param length Length of trailing mesh. Default is 60.
  129296. * @param autoStart Automatically start trailing mesh. Default true.
  129297. */
  129298. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  129299. /**
  129300. * "TrailMesh"
  129301. * @returns "TrailMesh"
  129302. */
  129303. getClassName(): string;
  129304. private _createMesh;
  129305. /**
  129306. * Start trailing mesh.
  129307. */
  129308. start(): void;
  129309. /**
  129310. * Stop trailing mesh.
  129311. */
  129312. stop(): void;
  129313. /**
  129314. * Update trailing mesh geometry.
  129315. */
  129316. update(): void;
  129317. /**
  129318. * Returns a new TrailMesh object.
  129319. * @param name is a string, the name given to the new mesh
  129320. * @param newGenerator use new generator object for cloned trail mesh
  129321. * @returns a new mesh
  129322. */
  129323. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  129324. /**
  129325. * Serializes this trail mesh
  129326. * @param serializationObject object to write serialization to
  129327. */
  129328. serialize(serializationObject: any): void;
  129329. /**
  129330. * Parses a serialized trail mesh
  129331. * @param parsedMesh the serialized mesh
  129332. * @param scene the scene to create the trail mesh in
  129333. * @returns the created trail mesh
  129334. */
  129335. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  129336. }
  129337. }
  129338. declare module BABYLON {
  129339. /**
  129340. * Class containing static functions to help procedurally build meshes
  129341. */
  129342. export class TiledBoxBuilder {
  129343. /**
  129344. * Creates a box mesh
  129345. * 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)
  129346. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129350. * @param name defines the name of the mesh
  129351. * @param options defines the options used to create the mesh
  129352. * @param scene defines the hosting scene
  129353. * @returns the box mesh
  129354. */
  129355. static CreateTiledBox(name: string, options: {
  129356. pattern?: number;
  129357. width?: number;
  129358. height?: number;
  129359. depth?: number;
  129360. tileSize?: number;
  129361. tileWidth?: number;
  129362. tileHeight?: number;
  129363. alignHorizontal?: number;
  129364. alignVertical?: number;
  129365. faceUV?: Vector4[];
  129366. faceColors?: Color4[];
  129367. sideOrientation?: number;
  129368. updatable?: boolean;
  129369. }, scene?: Nullable<Scene>): Mesh;
  129370. }
  129371. }
  129372. declare module BABYLON {
  129373. /**
  129374. * Class containing static functions to help procedurally build meshes
  129375. */
  129376. export class TorusKnotBuilder {
  129377. /**
  129378. * Creates a torus knot mesh
  129379. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  129380. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  129381. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  129382. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  129383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129386. * @param name defines the name of the mesh
  129387. * @param options defines the options used to create the mesh
  129388. * @param scene defines the hosting scene
  129389. * @returns the torus knot mesh
  129390. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  129391. */
  129392. static CreateTorusKnot(name: string, options: {
  129393. radius?: number;
  129394. tube?: number;
  129395. radialSegments?: number;
  129396. tubularSegments?: number;
  129397. p?: number;
  129398. q?: number;
  129399. updatable?: boolean;
  129400. sideOrientation?: number;
  129401. frontUVs?: Vector4;
  129402. backUVs?: Vector4;
  129403. }, scene: any): Mesh;
  129404. }
  129405. }
  129406. declare module BABYLON {
  129407. /**
  129408. * Polygon
  129409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  129410. */
  129411. export class Polygon {
  129412. /**
  129413. * Creates a rectangle
  129414. * @param xmin bottom X coord
  129415. * @param ymin bottom Y coord
  129416. * @param xmax top X coord
  129417. * @param ymax top Y coord
  129418. * @returns points that make the resulting rectation
  129419. */
  129420. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  129421. /**
  129422. * Creates a circle
  129423. * @param radius radius of circle
  129424. * @param cx scale in x
  129425. * @param cy scale in y
  129426. * @param numberOfSides number of sides that make up the circle
  129427. * @returns points that make the resulting circle
  129428. */
  129429. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  129430. /**
  129431. * Creates a polygon from input string
  129432. * @param input Input polygon data
  129433. * @returns the parsed points
  129434. */
  129435. static Parse(input: string): Vector2[];
  129436. /**
  129437. * Starts building a polygon from x and y coordinates
  129438. * @param x x coordinate
  129439. * @param y y coordinate
  129440. * @returns the started path2
  129441. */
  129442. static StartingAt(x: number, y: number): Path2;
  129443. }
  129444. /**
  129445. * Builds a polygon
  129446. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  129447. */
  129448. export class PolygonMeshBuilder {
  129449. private _points;
  129450. private _outlinepoints;
  129451. private _holes;
  129452. private _name;
  129453. private _scene;
  129454. private _epoints;
  129455. private _eholes;
  129456. private _addToepoint;
  129457. /**
  129458. * Babylon reference to the earcut plugin.
  129459. */
  129460. bjsEarcut: any;
  129461. /**
  129462. * Creates a PolygonMeshBuilder
  129463. * @param name name of the builder
  129464. * @param contours Path of the polygon
  129465. * @param scene scene to add to when creating the mesh
  129466. * @param earcutInjection can be used to inject your own earcut reference
  129467. */
  129468. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  129469. /**
  129470. * Adds a whole within the polygon
  129471. * @param hole Array of points defining the hole
  129472. * @returns this
  129473. */
  129474. addHole(hole: Vector2[]): PolygonMeshBuilder;
  129475. /**
  129476. * Creates the polygon
  129477. * @param updatable If the mesh should be updatable
  129478. * @param depth The depth of the mesh created
  129479. * @returns the created mesh
  129480. */
  129481. build(updatable?: boolean, depth?: number): Mesh;
  129482. /**
  129483. * Creates the polygon
  129484. * @param depth The depth of the mesh created
  129485. * @returns the created VertexData
  129486. */
  129487. buildVertexData(depth?: number): VertexData;
  129488. /**
  129489. * Adds a side to the polygon
  129490. * @param positions points that make the polygon
  129491. * @param normals normals of the polygon
  129492. * @param uvs uvs of the polygon
  129493. * @param indices indices of the polygon
  129494. * @param bounds bounds of the polygon
  129495. * @param points points of the polygon
  129496. * @param depth depth of the polygon
  129497. * @param flip flip of the polygon
  129498. */
  129499. private addSide;
  129500. }
  129501. }
  129502. declare module BABYLON {
  129503. /**
  129504. * Class containing static functions to help procedurally build meshes
  129505. */
  129506. export class PolygonBuilder {
  129507. /**
  129508. * Creates a polygon mesh
  129509. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  129510. * * 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
  129511. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  129514. * * Remember you can only change the shape positions, not their number when updating a polygon
  129515. * @param name defines the name of the mesh
  129516. * @param options defines the options used to create the mesh
  129517. * @param scene defines the hosting scene
  129518. * @param earcutInjection can be used to inject your own earcut reference
  129519. * @returns the polygon mesh
  129520. */
  129521. static CreatePolygon(name: string, options: {
  129522. shape: Vector3[];
  129523. holes?: Vector3[][];
  129524. depth?: number;
  129525. faceUV?: Vector4[];
  129526. faceColors?: Color4[];
  129527. updatable?: boolean;
  129528. sideOrientation?: number;
  129529. frontUVs?: Vector4;
  129530. backUVs?: Vector4;
  129531. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129532. /**
  129533. * Creates an extruded polygon mesh, with depth in the Y direction.
  129534. * * 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)
  129535. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129536. * @param name defines the name of the mesh
  129537. * @param options defines the options used to create the mesh
  129538. * @param scene defines the hosting scene
  129539. * @param earcutInjection can be used to inject your own earcut reference
  129540. * @returns the polygon mesh
  129541. */
  129542. static ExtrudePolygon(name: string, options: {
  129543. shape: Vector3[];
  129544. holes?: Vector3[][];
  129545. depth?: number;
  129546. faceUV?: Vector4[];
  129547. faceColors?: Color4[];
  129548. updatable?: boolean;
  129549. sideOrientation?: number;
  129550. frontUVs?: Vector4;
  129551. backUVs?: Vector4;
  129552. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129553. }
  129554. }
  129555. declare module BABYLON {
  129556. /**
  129557. * Class containing static functions to help procedurally build meshes
  129558. */
  129559. export class LatheBuilder {
  129560. /**
  129561. * Creates lathe mesh.
  129562. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  129563. * * 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
  129564. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  129565. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  129566. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  129567. * * 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
  129568. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  129569. * * 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
  129570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129571. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129572. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129574. * @param name defines the name of the mesh
  129575. * @param options defines the options used to create the mesh
  129576. * @param scene defines the hosting scene
  129577. * @returns the lathe mesh
  129578. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  129579. */
  129580. static CreateLathe(name: string, options: {
  129581. shape: Vector3[];
  129582. radius?: number;
  129583. tessellation?: number;
  129584. clip?: number;
  129585. arc?: number;
  129586. closed?: boolean;
  129587. updatable?: boolean;
  129588. sideOrientation?: number;
  129589. frontUVs?: Vector4;
  129590. backUVs?: Vector4;
  129591. cap?: number;
  129592. invertUV?: boolean;
  129593. }, scene?: Nullable<Scene>): Mesh;
  129594. }
  129595. }
  129596. declare module BABYLON {
  129597. /**
  129598. * Class containing static functions to help procedurally build meshes
  129599. */
  129600. export class TiledPlaneBuilder {
  129601. /**
  129602. * Creates a tiled plane mesh
  129603. * * The parameter `pattern` will, depending on value, do nothing or
  129604. * * * flip (reflect about central vertical) alternate tiles across and up
  129605. * * * flip every tile on alternate rows
  129606. * * * rotate (180 degs) alternate tiles across and up
  129607. * * * rotate every tile on alternate rows
  129608. * * * flip and rotate alternate tiles across and up
  129609. * * * flip and rotate every tile on alternate rows
  129610. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  129611. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  129612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129614. * * 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)
  129615. * * 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)
  129616. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129617. * @param name defines the name of the mesh
  129618. * @param options defines the options used to create the mesh
  129619. * @param scene defines the hosting scene
  129620. * @returns the box mesh
  129621. */
  129622. static CreateTiledPlane(name: string, options: {
  129623. pattern?: number;
  129624. tileSize?: number;
  129625. tileWidth?: number;
  129626. tileHeight?: number;
  129627. size?: number;
  129628. width?: number;
  129629. height?: number;
  129630. alignHorizontal?: number;
  129631. alignVertical?: number;
  129632. sideOrientation?: number;
  129633. frontUVs?: Vector4;
  129634. backUVs?: Vector4;
  129635. updatable?: boolean;
  129636. }, scene?: Nullable<Scene>): Mesh;
  129637. }
  129638. }
  129639. declare module BABYLON {
  129640. /**
  129641. * Class containing static functions to help procedurally build meshes
  129642. */
  129643. export class TubeBuilder {
  129644. /**
  129645. * Creates a tube mesh.
  129646. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129647. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  129648. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  129649. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  129650. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  129651. * * 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)
  129652. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  129653. * * 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
  129654. * * 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
  129655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129657. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129659. * @param name defines the name of the mesh
  129660. * @param options defines the options used to create the mesh
  129661. * @param scene defines the hosting scene
  129662. * @returns the tube mesh
  129663. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129664. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  129665. */
  129666. static CreateTube(name: string, options: {
  129667. path: Vector3[];
  129668. radius?: number;
  129669. tessellation?: number;
  129670. radiusFunction?: {
  129671. (i: number, distance: number): number;
  129672. };
  129673. cap?: number;
  129674. arc?: number;
  129675. updatable?: boolean;
  129676. sideOrientation?: number;
  129677. frontUVs?: Vector4;
  129678. backUVs?: Vector4;
  129679. instance?: Mesh;
  129680. invertUV?: boolean;
  129681. }, scene?: Nullable<Scene>): Mesh;
  129682. }
  129683. }
  129684. declare module BABYLON {
  129685. /**
  129686. * Class containing static functions to help procedurally build meshes
  129687. */
  129688. export class IcoSphereBuilder {
  129689. /**
  129690. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129691. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129692. * * 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`)
  129693. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129694. * * 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
  129695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129698. * @param name defines the name of the mesh
  129699. * @param options defines the options used to create the mesh
  129700. * @param scene defines the hosting scene
  129701. * @returns the icosahedron mesh
  129702. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129703. */
  129704. static CreateIcoSphere(name: string, options: {
  129705. radius?: number;
  129706. radiusX?: number;
  129707. radiusY?: number;
  129708. radiusZ?: number;
  129709. flat?: boolean;
  129710. subdivisions?: number;
  129711. sideOrientation?: number;
  129712. frontUVs?: Vector4;
  129713. backUVs?: Vector4;
  129714. updatable?: boolean;
  129715. }, scene?: Nullable<Scene>): Mesh;
  129716. }
  129717. }
  129718. declare module BABYLON {
  129719. /**
  129720. * Class containing static functions to help procedurally build meshes
  129721. */
  129722. export class DecalBuilder {
  129723. /**
  129724. * Creates a decal mesh.
  129725. * 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
  129726. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  129727. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  129728. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  129729. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  129730. * @param name defines the name of the mesh
  129731. * @param sourceMesh defines the mesh where the decal must be applied
  129732. * @param options defines the options used to create the mesh
  129733. * @param scene defines the hosting scene
  129734. * @returns the decal mesh
  129735. * @see https://doc.babylonjs.com/how_to/decals
  129736. */
  129737. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  129738. position?: Vector3;
  129739. normal?: Vector3;
  129740. size?: Vector3;
  129741. angle?: number;
  129742. }): Mesh;
  129743. }
  129744. }
  129745. declare module BABYLON {
  129746. /**
  129747. * Class containing static functions to help procedurally build meshes
  129748. */
  129749. export class MeshBuilder {
  129750. /**
  129751. * Creates a box mesh
  129752. * * The parameter `size` sets the size (float) of each box side (default 1)
  129753. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129754. * * 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)
  129755. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129759. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129760. * @param name defines the name of the mesh
  129761. * @param options defines the options used to create the mesh
  129762. * @param scene defines the hosting scene
  129763. * @returns the box mesh
  129764. */
  129765. static CreateBox(name: string, options: {
  129766. size?: number;
  129767. width?: number;
  129768. height?: number;
  129769. depth?: number;
  129770. faceUV?: Vector4[];
  129771. faceColors?: Color4[];
  129772. sideOrientation?: number;
  129773. frontUVs?: Vector4;
  129774. backUVs?: Vector4;
  129775. updatable?: boolean;
  129776. }, scene?: Nullable<Scene>): Mesh;
  129777. /**
  129778. * Creates a tiled box mesh
  129779. * * faceTiles sets the pattern, tile size and number of tiles for a face
  129780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129781. * @param name defines the name of the mesh
  129782. * @param options defines the options used to create the mesh
  129783. * @param scene defines the hosting scene
  129784. * @returns the tiled box mesh
  129785. */
  129786. static CreateTiledBox(name: string, options: {
  129787. pattern?: number;
  129788. size?: number;
  129789. width?: number;
  129790. height?: number;
  129791. depth: number;
  129792. tileSize?: number;
  129793. tileWidth?: number;
  129794. tileHeight?: number;
  129795. faceUV?: Vector4[];
  129796. faceColors?: Color4[];
  129797. alignHorizontal?: number;
  129798. alignVertical?: number;
  129799. sideOrientation?: number;
  129800. updatable?: boolean;
  129801. }, scene?: Nullable<Scene>): Mesh;
  129802. /**
  129803. * Creates a sphere mesh
  129804. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  129805. * * 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`)
  129806. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  129807. * * 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
  129808. * * 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)
  129809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129812. * @param name defines the name of the mesh
  129813. * @param options defines the options used to create the mesh
  129814. * @param scene defines the hosting scene
  129815. * @returns the sphere mesh
  129816. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  129817. */
  129818. static CreateSphere(name: string, options: {
  129819. segments?: number;
  129820. diameter?: number;
  129821. diameterX?: number;
  129822. diameterY?: number;
  129823. diameterZ?: number;
  129824. arc?: number;
  129825. slice?: number;
  129826. sideOrientation?: number;
  129827. frontUVs?: Vector4;
  129828. backUVs?: Vector4;
  129829. updatable?: boolean;
  129830. }, scene?: Nullable<Scene>): Mesh;
  129831. /**
  129832. * Creates a plane polygonal mesh. By default, this is a disc
  129833. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  129834. * * 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
  129835. * * 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
  129836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129839. * @param name defines the name of the mesh
  129840. * @param options defines the options used to create the mesh
  129841. * @param scene defines the hosting scene
  129842. * @returns the plane polygonal mesh
  129843. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  129844. */
  129845. static CreateDisc(name: string, options: {
  129846. radius?: number;
  129847. tessellation?: number;
  129848. arc?: number;
  129849. updatable?: boolean;
  129850. sideOrientation?: number;
  129851. frontUVs?: Vector4;
  129852. backUVs?: Vector4;
  129853. }, scene?: Nullable<Scene>): Mesh;
  129854. /**
  129855. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129856. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129857. * * 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`)
  129858. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129859. * * 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
  129860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129863. * @param name defines the name of the mesh
  129864. * @param options defines the options used to create the mesh
  129865. * @param scene defines the hosting scene
  129866. * @returns the icosahedron mesh
  129867. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129868. */
  129869. static CreateIcoSphere(name: string, options: {
  129870. radius?: number;
  129871. radiusX?: number;
  129872. radiusY?: number;
  129873. radiusZ?: number;
  129874. flat?: boolean;
  129875. subdivisions?: number;
  129876. sideOrientation?: number;
  129877. frontUVs?: Vector4;
  129878. backUVs?: Vector4;
  129879. updatable?: boolean;
  129880. }, scene?: Nullable<Scene>): Mesh;
  129881. /**
  129882. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129883. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129884. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129885. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129886. * * 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
  129887. * * 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
  129888. * * 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
  129889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129891. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129892. * * 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
  129893. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129894. * * 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
  129895. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129897. * @param name defines the name of the mesh
  129898. * @param options defines the options used to create the mesh
  129899. * @param scene defines the hosting scene
  129900. * @returns the ribbon mesh
  129901. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129902. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129903. */
  129904. static CreateRibbon(name: string, options: {
  129905. pathArray: Vector3[][];
  129906. closeArray?: boolean;
  129907. closePath?: boolean;
  129908. offset?: number;
  129909. updatable?: boolean;
  129910. sideOrientation?: number;
  129911. frontUVs?: Vector4;
  129912. backUVs?: Vector4;
  129913. instance?: Mesh;
  129914. invertUV?: boolean;
  129915. uvs?: Vector2[];
  129916. colors?: Color4[];
  129917. }, scene?: Nullable<Scene>): Mesh;
  129918. /**
  129919. * Creates a cylinder or a cone mesh
  129920. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  129921. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  129922. * * 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.
  129923. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  129924. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  129925. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  129926. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  129927. * * 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).
  129928. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  129929. * * 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).
  129930. * * 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
  129931. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  129932. * * 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
  129933. * * 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.
  129934. * * If `enclose` is false, a ring surface is one element.
  129935. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  129936. * * 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
  129937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129940. * @param name defines the name of the mesh
  129941. * @param options defines the options used to create the mesh
  129942. * @param scene defines the hosting scene
  129943. * @returns the cylinder mesh
  129944. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  129945. */
  129946. static CreateCylinder(name: string, options: {
  129947. height?: number;
  129948. diameterTop?: number;
  129949. diameterBottom?: number;
  129950. diameter?: number;
  129951. tessellation?: number;
  129952. subdivisions?: number;
  129953. arc?: number;
  129954. faceColors?: Color4[];
  129955. faceUV?: Vector4[];
  129956. updatable?: boolean;
  129957. hasRings?: boolean;
  129958. enclose?: boolean;
  129959. cap?: number;
  129960. sideOrientation?: number;
  129961. frontUVs?: Vector4;
  129962. backUVs?: Vector4;
  129963. }, scene?: Nullable<Scene>): Mesh;
  129964. /**
  129965. * Creates a torus mesh
  129966. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  129967. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  129968. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  129969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129972. * @param name defines the name of the mesh
  129973. * @param options defines the options used to create the mesh
  129974. * @param scene defines the hosting scene
  129975. * @returns the torus mesh
  129976. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  129977. */
  129978. static CreateTorus(name: string, options: {
  129979. diameter?: number;
  129980. thickness?: number;
  129981. tessellation?: number;
  129982. updatable?: boolean;
  129983. sideOrientation?: number;
  129984. frontUVs?: Vector4;
  129985. backUVs?: Vector4;
  129986. }, scene?: Nullable<Scene>): Mesh;
  129987. /**
  129988. * Creates a torus knot mesh
  129989. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  129990. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  129991. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  129992. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  129993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129996. * @param name defines the name of the mesh
  129997. * @param options defines the options used to create the mesh
  129998. * @param scene defines the hosting scene
  129999. * @returns the torus knot mesh
  130000. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  130001. */
  130002. static CreateTorusKnot(name: string, options: {
  130003. radius?: number;
  130004. tube?: number;
  130005. radialSegments?: number;
  130006. tubularSegments?: number;
  130007. p?: number;
  130008. q?: number;
  130009. updatable?: boolean;
  130010. sideOrientation?: number;
  130011. frontUVs?: Vector4;
  130012. backUVs?: Vector4;
  130013. }, scene?: Nullable<Scene>): Mesh;
  130014. /**
  130015. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  130016. * * 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
  130017. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  130018. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  130019. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  130020. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  130021. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  130022. * * 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
  130023. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  130024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  130026. * @param name defines the name of the new line system
  130027. * @param options defines the options used to create the line system
  130028. * @param scene defines the hosting scene
  130029. * @returns a new line system mesh
  130030. */
  130031. static CreateLineSystem(name: string, options: {
  130032. lines: Vector3[][];
  130033. updatable?: boolean;
  130034. instance?: Nullable<LinesMesh>;
  130035. colors?: Nullable<Color4[][]>;
  130036. useVertexAlpha?: boolean;
  130037. }, scene: Nullable<Scene>): LinesMesh;
  130038. /**
  130039. * Creates a line mesh
  130040. * 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
  130041. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130042. * * The parameter `points` is an array successive Vector3
  130043. * * 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
  130044. * * The optional parameter `colors` is an array of successive Color4, one per line point
  130045. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  130046. * * When updating an instance, remember that only point positions can change, not the number of points
  130047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  130049. * @param name defines the name of the new line system
  130050. * @param options defines the options used to create the line system
  130051. * @param scene defines the hosting scene
  130052. * @returns a new line mesh
  130053. */
  130054. static CreateLines(name: string, options: {
  130055. points: Vector3[];
  130056. updatable?: boolean;
  130057. instance?: Nullable<LinesMesh>;
  130058. colors?: Color4[];
  130059. useVertexAlpha?: boolean;
  130060. }, scene?: Nullable<Scene>): LinesMesh;
  130061. /**
  130062. * Creates a dashed line mesh
  130063. * * 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
  130064. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130065. * * The parameter `points` is an array successive Vector3
  130066. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  130067. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  130068. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  130069. * * 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
  130070. * * When updating an instance, remember that only point positions can change, not the number of points
  130071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130072. * @param name defines the name of the mesh
  130073. * @param options defines the options used to create the mesh
  130074. * @param scene defines the hosting scene
  130075. * @returns the dashed line mesh
  130076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  130077. */
  130078. static CreateDashedLines(name: string, options: {
  130079. points: Vector3[];
  130080. dashSize?: number;
  130081. gapSize?: number;
  130082. dashNb?: number;
  130083. updatable?: boolean;
  130084. instance?: LinesMesh;
  130085. }, scene?: Nullable<Scene>): LinesMesh;
  130086. /**
  130087. * 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.
  130088. * * 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.
  130089. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130090. * * 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.
  130091. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130092. * * 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
  130093. * * 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
  130094. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130097. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130099. * @param name defines the name of the mesh
  130100. * @param options defines the options used to create the mesh
  130101. * @param scene defines the hosting scene
  130102. * @returns the extruded shape mesh
  130103. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130105. */
  130106. static ExtrudeShape(name: string, options: {
  130107. shape: Vector3[];
  130108. path: Vector3[];
  130109. scale?: number;
  130110. rotation?: number;
  130111. cap?: number;
  130112. updatable?: boolean;
  130113. sideOrientation?: number;
  130114. frontUVs?: Vector4;
  130115. backUVs?: Vector4;
  130116. instance?: Mesh;
  130117. invertUV?: boolean;
  130118. }, scene?: Nullable<Scene>): Mesh;
  130119. /**
  130120. * Creates an custom extruded shape mesh.
  130121. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130122. * * 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.
  130123. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130124. * * 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
  130125. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130126. * * 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
  130127. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130128. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130129. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130130. * * 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
  130131. * * 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
  130132. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130135. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130137. * @param name defines the name of the mesh
  130138. * @param options defines the options used to create the mesh
  130139. * @param scene defines the hosting scene
  130140. * @returns the custom extruded shape mesh
  130141. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130142. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130143. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130144. */
  130145. static ExtrudeShapeCustom(name: string, options: {
  130146. shape: Vector3[];
  130147. path: Vector3[];
  130148. scaleFunction?: any;
  130149. rotationFunction?: any;
  130150. ribbonCloseArray?: boolean;
  130151. ribbonClosePath?: boolean;
  130152. cap?: number;
  130153. updatable?: boolean;
  130154. sideOrientation?: number;
  130155. frontUVs?: Vector4;
  130156. backUVs?: Vector4;
  130157. instance?: Mesh;
  130158. invertUV?: boolean;
  130159. }, scene?: Nullable<Scene>): Mesh;
  130160. /**
  130161. * Creates lathe mesh.
  130162. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  130163. * * 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
  130164. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  130165. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  130166. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  130167. * * 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
  130168. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  130169. * * 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
  130170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130174. * @param name defines the name of the mesh
  130175. * @param options defines the options used to create the mesh
  130176. * @param scene defines the hosting scene
  130177. * @returns the lathe mesh
  130178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  130179. */
  130180. static CreateLathe(name: string, options: {
  130181. shape: Vector3[];
  130182. radius?: number;
  130183. tessellation?: number;
  130184. clip?: number;
  130185. arc?: number;
  130186. closed?: boolean;
  130187. updatable?: boolean;
  130188. sideOrientation?: number;
  130189. frontUVs?: Vector4;
  130190. backUVs?: Vector4;
  130191. cap?: number;
  130192. invertUV?: boolean;
  130193. }, scene?: Nullable<Scene>): Mesh;
  130194. /**
  130195. * Creates a tiled plane mesh
  130196. * * You can set a limited pattern arrangement with the tiles
  130197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130200. * @param name defines the name of the mesh
  130201. * @param options defines the options used to create the mesh
  130202. * @param scene defines the hosting scene
  130203. * @returns the plane mesh
  130204. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130205. */
  130206. static CreateTiledPlane(name: string, options: {
  130207. pattern?: number;
  130208. tileSize?: number;
  130209. tileWidth?: number;
  130210. tileHeight?: number;
  130211. size?: number;
  130212. width?: number;
  130213. height?: number;
  130214. alignHorizontal?: number;
  130215. alignVertical?: number;
  130216. sideOrientation?: number;
  130217. frontUVs?: Vector4;
  130218. backUVs?: Vector4;
  130219. updatable?: boolean;
  130220. }, scene?: Nullable<Scene>): Mesh;
  130221. /**
  130222. * Creates a plane mesh
  130223. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  130224. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  130225. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  130226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130229. * @param name defines the name of the mesh
  130230. * @param options defines the options used to create the mesh
  130231. * @param scene defines the hosting scene
  130232. * @returns the plane mesh
  130233. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130234. */
  130235. static CreatePlane(name: string, options: {
  130236. size?: number;
  130237. width?: number;
  130238. height?: number;
  130239. sideOrientation?: number;
  130240. frontUVs?: Vector4;
  130241. backUVs?: Vector4;
  130242. updatable?: boolean;
  130243. sourcePlane?: Plane;
  130244. }, scene?: Nullable<Scene>): Mesh;
  130245. /**
  130246. * Creates a ground mesh
  130247. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130248. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130250. * @param name defines the name of the mesh
  130251. * @param options defines the options used to create the mesh
  130252. * @param scene defines the hosting scene
  130253. * @returns the ground mesh
  130254. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130255. */
  130256. static CreateGround(name: string, options: {
  130257. width?: number;
  130258. height?: number;
  130259. subdivisions?: number;
  130260. subdivisionsX?: number;
  130261. subdivisionsY?: number;
  130262. updatable?: boolean;
  130263. }, scene?: Nullable<Scene>): Mesh;
  130264. /**
  130265. * Creates a tiled ground mesh
  130266. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130267. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130268. * * 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
  130269. * * 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
  130270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130271. * @param name defines the name of the mesh
  130272. * @param options defines the options used to create the mesh
  130273. * @param scene defines the hosting scene
  130274. * @returns the tiled ground mesh
  130275. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130276. */
  130277. static CreateTiledGround(name: string, options: {
  130278. xmin: number;
  130279. zmin: number;
  130280. xmax: number;
  130281. zmax: number;
  130282. subdivisions?: {
  130283. w: number;
  130284. h: number;
  130285. };
  130286. precision?: {
  130287. w: number;
  130288. h: number;
  130289. };
  130290. updatable?: boolean;
  130291. }, scene?: Nullable<Scene>): Mesh;
  130292. /**
  130293. * Creates a ground mesh from a height map
  130294. * * The parameter `url` sets the URL of the height map image resource.
  130295. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130296. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130297. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130298. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130299. * * 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.
  130300. * * 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).
  130301. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130303. * @param name defines the name of the mesh
  130304. * @param url defines the url to the height map
  130305. * @param options defines the options used to create the mesh
  130306. * @param scene defines the hosting scene
  130307. * @returns the ground mesh
  130308. * @see https://doc.babylonjs.com/babylon101/height_map
  130309. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130310. */
  130311. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130312. width?: number;
  130313. height?: number;
  130314. subdivisions?: number;
  130315. minHeight?: number;
  130316. maxHeight?: number;
  130317. colorFilter?: Color3;
  130318. alphaFilter?: number;
  130319. updatable?: boolean;
  130320. onReady?: (mesh: GroundMesh) => void;
  130321. }, scene?: Nullable<Scene>): GroundMesh;
  130322. /**
  130323. * Creates a polygon mesh
  130324. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  130325. * * 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
  130326. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  130327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  130329. * * Remember you can only change the shape positions, not their number when updating a polygon
  130330. * @param name defines the name of the mesh
  130331. * @param options defines the options used to create the mesh
  130332. * @param scene defines the hosting scene
  130333. * @param earcutInjection can be used to inject your own earcut reference
  130334. * @returns the polygon mesh
  130335. */
  130336. static CreatePolygon(name: string, options: {
  130337. shape: Vector3[];
  130338. holes?: Vector3[][];
  130339. depth?: number;
  130340. faceUV?: Vector4[];
  130341. faceColors?: Color4[];
  130342. updatable?: boolean;
  130343. sideOrientation?: number;
  130344. frontUVs?: Vector4;
  130345. backUVs?: Vector4;
  130346. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130347. /**
  130348. * Creates an extruded polygon mesh, with depth in the Y direction.
  130349. * * 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)
  130350. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130351. * @param name defines the name of the mesh
  130352. * @param options defines the options used to create the mesh
  130353. * @param scene defines the hosting scene
  130354. * @param earcutInjection can be used to inject your own earcut reference
  130355. * @returns the polygon mesh
  130356. */
  130357. static ExtrudePolygon(name: string, options: {
  130358. shape: Vector3[];
  130359. holes?: Vector3[][];
  130360. depth?: number;
  130361. faceUV?: Vector4[];
  130362. faceColors?: Color4[];
  130363. updatable?: boolean;
  130364. sideOrientation?: number;
  130365. frontUVs?: Vector4;
  130366. backUVs?: Vector4;
  130367. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130368. /**
  130369. * Creates a tube mesh.
  130370. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130371. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  130372. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  130373. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  130374. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  130375. * * 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)
  130376. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  130377. * * 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
  130378. * * 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
  130379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130380. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130381. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130383. * @param name defines the name of the mesh
  130384. * @param options defines the options used to create the mesh
  130385. * @param scene defines the hosting scene
  130386. * @returns the tube mesh
  130387. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130388. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  130389. */
  130390. static CreateTube(name: string, options: {
  130391. path: Vector3[];
  130392. radius?: number;
  130393. tessellation?: number;
  130394. radiusFunction?: {
  130395. (i: number, distance: number): number;
  130396. };
  130397. cap?: number;
  130398. arc?: number;
  130399. updatable?: boolean;
  130400. sideOrientation?: number;
  130401. frontUVs?: Vector4;
  130402. backUVs?: Vector4;
  130403. instance?: Mesh;
  130404. invertUV?: boolean;
  130405. }, scene?: Nullable<Scene>): Mesh;
  130406. /**
  130407. * Creates a polyhedron mesh
  130408. * * 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
  130409. * * The parameter `size` (positive float, default 1) sets the polygon size
  130410. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130411. * * 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`
  130412. * * 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
  130413. * * 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)`)
  130414. * * 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
  130415. * * 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
  130416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130419. * @param name defines the name of the mesh
  130420. * @param options defines the options used to create the mesh
  130421. * @param scene defines the hosting scene
  130422. * @returns the polyhedron mesh
  130423. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130424. */
  130425. static CreatePolyhedron(name: string, options: {
  130426. type?: number;
  130427. size?: number;
  130428. sizeX?: number;
  130429. sizeY?: number;
  130430. sizeZ?: number;
  130431. custom?: any;
  130432. faceUV?: Vector4[];
  130433. faceColors?: Color4[];
  130434. flat?: boolean;
  130435. updatable?: boolean;
  130436. sideOrientation?: number;
  130437. frontUVs?: Vector4;
  130438. backUVs?: Vector4;
  130439. }, scene?: Nullable<Scene>): Mesh;
  130440. /**
  130441. * Creates a decal mesh.
  130442. * 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
  130443. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  130444. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  130445. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  130446. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  130447. * @param name defines the name of the mesh
  130448. * @param sourceMesh defines the mesh where the decal must be applied
  130449. * @param options defines the options used to create the mesh
  130450. * @param scene defines the hosting scene
  130451. * @returns the decal mesh
  130452. * @see https://doc.babylonjs.com/how_to/decals
  130453. */
  130454. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  130455. position?: Vector3;
  130456. normal?: Vector3;
  130457. size?: Vector3;
  130458. angle?: number;
  130459. }): Mesh;
  130460. }
  130461. }
  130462. declare module BABYLON {
  130463. /**
  130464. * A simplifier interface for future simplification implementations
  130465. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130466. */
  130467. export interface ISimplifier {
  130468. /**
  130469. * Simplification of a given mesh according to the given settings.
  130470. * Since this requires computation, it is assumed that the function runs async.
  130471. * @param settings The settings of the simplification, including quality and distance
  130472. * @param successCallback A callback that will be called after the mesh was simplified.
  130473. * @param errorCallback in case of an error, this callback will be called. optional.
  130474. */
  130475. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  130476. }
  130477. /**
  130478. * Expected simplification settings.
  130479. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  130480. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130481. */
  130482. export interface ISimplificationSettings {
  130483. /**
  130484. * Gets or sets the expected quality
  130485. */
  130486. quality: number;
  130487. /**
  130488. * Gets or sets the distance when this optimized version should be used
  130489. */
  130490. distance: number;
  130491. /**
  130492. * Gets an already optimized mesh
  130493. */
  130494. optimizeMesh?: boolean;
  130495. }
  130496. /**
  130497. * Class used to specify simplification options
  130498. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130499. */
  130500. export class SimplificationSettings implements ISimplificationSettings {
  130501. /** expected quality */
  130502. quality: number;
  130503. /** distance when this optimized version should be used */
  130504. distance: number;
  130505. /** already optimized mesh */
  130506. optimizeMesh?: boolean | undefined;
  130507. /**
  130508. * Creates a SimplificationSettings
  130509. * @param quality expected quality
  130510. * @param distance distance when this optimized version should be used
  130511. * @param optimizeMesh already optimized mesh
  130512. */
  130513. constructor(
  130514. /** expected quality */
  130515. quality: number,
  130516. /** distance when this optimized version should be used */
  130517. distance: number,
  130518. /** already optimized mesh */
  130519. optimizeMesh?: boolean | undefined);
  130520. }
  130521. /**
  130522. * Interface used to define a simplification task
  130523. */
  130524. export interface ISimplificationTask {
  130525. /**
  130526. * Array of settings
  130527. */
  130528. settings: Array<ISimplificationSettings>;
  130529. /**
  130530. * Simplification type
  130531. */
  130532. simplificationType: SimplificationType;
  130533. /**
  130534. * Mesh to simplify
  130535. */
  130536. mesh: Mesh;
  130537. /**
  130538. * Callback called on success
  130539. */
  130540. successCallback?: () => void;
  130541. /**
  130542. * Defines if parallel processing can be used
  130543. */
  130544. parallelProcessing: boolean;
  130545. }
  130546. /**
  130547. * Queue used to order the simplification tasks
  130548. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130549. */
  130550. export class SimplificationQueue {
  130551. private _simplificationArray;
  130552. /**
  130553. * Gets a boolean indicating that the process is still running
  130554. */
  130555. running: boolean;
  130556. /**
  130557. * Creates a new queue
  130558. */
  130559. constructor();
  130560. /**
  130561. * Adds a new simplification task
  130562. * @param task defines a task to add
  130563. */
  130564. addTask(task: ISimplificationTask): void;
  130565. /**
  130566. * Execute next task
  130567. */
  130568. executeNext(): void;
  130569. /**
  130570. * Execute a simplification task
  130571. * @param task defines the task to run
  130572. */
  130573. runSimplification(task: ISimplificationTask): void;
  130574. private getSimplifier;
  130575. }
  130576. /**
  130577. * The implemented types of simplification
  130578. * At the moment only Quadratic Error Decimation is implemented
  130579. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130580. */
  130581. export enum SimplificationType {
  130582. /** Quadratic error decimation */
  130583. QUADRATIC = 0
  130584. }
  130585. }
  130586. declare module BABYLON {
  130587. interface Scene {
  130588. /** @hidden (Backing field) */
  130589. _simplificationQueue: SimplificationQueue;
  130590. /**
  130591. * Gets or sets the simplification queue attached to the scene
  130592. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130593. */
  130594. simplificationQueue: SimplificationQueue;
  130595. }
  130596. interface Mesh {
  130597. /**
  130598. * Simplify the mesh according to the given array of settings.
  130599. * Function will return immediately and will simplify async
  130600. * @param settings a collection of simplification settings
  130601. * @param parallelProcessing should all levels calculate parallel or one after the other
  130602. * @param simplificationType the type of simplification to run
  130603. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  130604. * @returns the current mesh
  130605. */
  130606. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  130607. }
  130608. /**
  130609. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  130610. * created in a scene
  130611. */
  130612. export class SimplicationQueueSceneComponent implements ISceneComponent {
  130613. /**
  130614. * The component name helpfull to identify the component in the list of scene components.
  130615. */
  130616. readonly name: string;
  130617. /**
  130618. * The scene the component belongs to.
  130619. */
  130620. scene: Scene;
  130621. /**
  130622. * Creates a new instance of the component for the given scene
  130623. * @param scene Defines the scene to register the component in
  130624. */
  130625. constructor(scene: Scene);
  130626. /**
  130627. * Registers the component in a given scene
  130628. */
  130629. register(): void;
  130630. /**
  130631. * Rebuilds the elements related to this component in case of
  130632. * context lost for instance.
  130633. */
  130634. rebuild(): void;
  130635. /**
  130636. * Disposes the component and the associated ressources
  130637. */
  130638. dispose(): void;
  130639. private _beforeCameraUpdate;
  130640. }
  130641. }
  130642. declare module BABYLON {
  130643. /**
  130644. * Navigation plugin interface to add navigation constrained by a navigation mesh
  130645. */
  130646. export interface INavigationEnginePlugin {
  130647. /**
  130648. * plugin name
  130649. */
  130650. name: string;
  130651. /**
  130652. * Creates a navigation mesh
  130653. * @param meshes array of all the geometry used to compute the navigatio mesh
  130654. * @param parameters bunch of parameters used to filter geometry
  130655. */
  130656. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130657. /**
  130658. * Create a navigation mesh debug mesh
  130659. * @param scene is where the mesh will be added
  130660. * @returns debug display mesh
  130661. */
  130662. createDebugNavMesh(scene: Scene): Mesh;
  130663. /**
  130664. * Get a navigation mesh constrained position, closest to the parameter position
  130665. * @param position world position
  130666. * @returns the closest point to position constrained by the navigation mesh
  130667. */
  130668. getClosestPoint(position: Vector3): Vector3;
  130669. /**
  130670. * Get a navigation mesh constrained position, within a particular radius
  130671. * @param position world position
  130672. * @param maxRadius the maximum distance to the constrained world position
  130673. * @returns the closest point to position constrained by the navigation mesh
  130674. */
  130675. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130676. /**
  130677. * Compute the final position from a segment made of destination-position
  130678. * @param position world position
  130679. * @param destination world position
  130680. * @returns the resulting point along the navmesh
  130681. */
  130682. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130683. /**
  130684. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130685. * @param start world position
  130686. * @param end world position
  130687. * @returns array containing world position composing the path
  130688. */
  130689. computePath(start: Vector3, end: Vector3): Vector3[];
  130690. /**
  130691. * If this plugin is supported
  130692. * @returns true if plugin is supported
  130693. */
  130694. isSupported(): boolean;
  130695. /**
  130696. * Create a new Crowd so you can add agents
  130697. * @param maxAgents the maximum agent count in the crowd
  130698. * @param maxAgentRadius the maximum radius an agent can have
  130699. * @param scene to attach the crowd to
  130700. * @returns the crowd you can add agents to
  130701. */
  130702. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130703. /**
  130704. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130705. * The queries will try to find a solution within those bounds
  130706. * default is (1,1,1)
  130707. * @param extent x,y,z value that define the extent around the queries point of reference
  130708. */
  130709. setDefaultQueryExtent(extent: Vector3): void;
  130710. /**
  130711. * Get the Bounding box extent specified by setDefaultQueryExtent
  130712. * @returns the box extent values
  130713. */
  130714. getDefaultQueryExtent(): Vector3;
  130715. /**
  130716. * Release all resources
  130717. */
  130718. dispose(): void;
  130719. }
  130720. /**
  130721. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  130722. */
  130723. export interface ICrowd {
  130724. /**
  130725. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  130726. * You can attach anything to that node. The node position is updated in the scene update tick.
  130727. * @param pos world position that will be constrained by the navigation mesh
  130728. * @param parameters agent parameters
  130729. * @param transform hooked to the agent that will be update by the scene
  130730. * @returns agent index
  130731. */
  130732. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  130733. /**
  130734. * Returns the agent position in world space
  130735. * @param index agent index returned by addAgent
  130736. * @returns world space position
  130737. */
  130738. getAgentPosition(index: number): Vector3;
  130739. /**
  130740. * Gets the agent velocity in world space
  130741. * @param index agent index returned by addAgent
  130742. * @returns world space velocity
  130743. */
  130744. getAgentVelocity(index: number): Vector3;
  130745. /**
  130746. * remove a particular agent previously created
  130747. * @param index agent index returned by addAgent
  130748. */
  130749. removeAgent(index: number): void;
  130750. /**
  130751. * get the list of all agents attached to this crowd
  130752. * @returns list of agent indices
  130753. */
  130754. getAgents(): number[];
  130755. /**
  130756. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  130757. * @param deltaTime in seconds
  130758. */
  130759. update(deltaTime: number): void;
  130760. /**
  130761. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  130762. * @param index agent index returned by addAgent
  130763. * @param destination targeted world position
  130764. */
  130765. agentGoto(index: number, destination: Vector3): void;
  130766. /**
  130767. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130768. * The queries will try to find a solution within those bounds
  130769. * default is (1,1,1)
  130770. * @param extent x,y,z value that define the extent around the queries point of reference
  130771. */
  130772. setDefaultQueryExtent(extent: Vector3): void;
  130773. /**
  130774. * Get the Bounding box extent specified by setDefaultQueryExtent
  130775. * @returns the box extent values
  130776. */
  130777. getDefaultQueryExtent(): Vector3;
  130778. /**
  130779. * Release all resources
  130780. */
  130781. dispose(): void;
  130782. }
  130783. /**
  130784. * Configures an agent
  130785. */
  130786. export interface IAgentParameters {
  130787. /**
  130788. * Agent radius. [Limit: >= 0]
  130789. */
  130790. radius: number;
  130791. /**
  130792. * Agent height. [Limit: > 0]
  130793. */
  130794. height: number;
  130795. /**
  130796. * Maximum allowed acceleration. [Limit: >= 0]
  130797. */
  130798. maxAcceleration: number;
  130799. /**
  130800. * Maximum allowed speed. [Limit: >= 0]
  130801. */
  130802. maxSpeed: number;
  130803. /**
  130804. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  130805. */
  130806. collisionQueryRange: number;
  130807. /**
  130808. * The path visibility optimization range. [Limit: > 0]
  130809. */
  130810. pathOptimizationRange: number;
  130811. /**
  130812. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  130813. */
  130814. separationWeight: number;
  130815. }
  130816. /**
  130817. * Configures the navigation mesh creation
  130818. */
  130819. export interface INavMeshParameters {
  130820. /**
  130821. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  130822. */
  130823. cs: number;
  130824. /**
  130825. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  130826. */
  130827. ch: number;
  130828. /**
  130829. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  130830. */
  130831. walkableSlopeAngle: number;
  130832. /**
  130833. * Minimum floor to 'ceiling' height that will still allow the floor area to
  130834. * be considered walkable. [Limit: >= 3] [Units: vx]
  130835. */
  130836. walkableHeight: number;
  130837. /**
  130838. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  130839. */
  130840. walkableClimb: number;
  130841. /**
  130842. * The distance to erode/shrink the walkable area of the heightfield away from
  130843. * obstructions. [Limit: >=0] [Units: vx]
  130844. */
  130845. walkableRadius: number;
  130846. /**
  130847. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  130848. */
  130849. maxEdgeLen: number;
  130850. /**
  130851. * The maximum distance a simplfied contour's border edges should deviate
  130852. * the original raw contour. [Limit: >=0] [Units: vx]
  130853. */
  130854. maxSimplificationError: number;
  130855. /**
  130856. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  130857. */
  130858. minRegionArea: number;
  130859. /**
  130860. * Any regions with a span count smaller than this value will, if possible,
  130861. * be merged with larger regions. [Limit: >=0] [Units: vx]
  130862. */
  130863. mergeRegionArea: number;
  130864. /**
  130865. * The maximum number of vertices allowed for polygons generated during the
  130866. * contour to polygon conversion process. [Limit: >= 3]
  130867. */
  130868. maxVertsPerPoly: number;
  130869. /**
  130870. * Sets the sampling distance to use when generating the detail mesh.
  130871. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  130872. */
  130873. detailSampleDist: number;
  130874. /**
  130875. * The maximum distance the detail mesh surface should deviate from heightfield
  130876. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  130877. */
  130878. detailSampleMaxError: number;
  130879. }
  130880. }
  130881. declare module BABYLON {
  130882. /**
  130883. * RecastJS navigation plugin
  130884. */
  130885. export class RecastJSPlugin implements INavigationEnginePlugin {
  130886. /**
  130887. * Reference to the Recast library
  130888. */
  130889. bjsRECAST: any;
  130890. /**
  130891. * plugin name
  130892. */
  130893. name: string;
  130894. /**
  130895. * the first navmesh created. We might extend this to support multiple navmeshes
  130896. */
  130897. navMesh: any;
  130898. /**
  130899. * Initializes the recastJS plugin
  130900. * @param recastInjection can be used to inject your own recast reference
  130901. */
  130902. constructor(recastInjection?: any);
  130903. /**
  130904. * Creates a navigation mesh
  130905. * @param meshes array of all the geometry used to compute the navigatio mesh
  130906. * @param parameters bunch of parameters used to filter geometry
  130907. */
  130908. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130909. /**
  130910. * Create a navigation mesh debug mesh
  130911. * @param scene is where the mesh will be added
  130912. * @returns debug display mesh
  130913. */
  130914. createDebugNavMesh(scene: Scene): Mesh;
  130915. /**
  130916. * Get a navigation mesh constrained position, closest to the parameter position
  130917. * @param position world position
  130918. * @returns the closest point to position constrained by the navigation mesh
  130919. */
  130920. getClosestPoint(position: Vector3): Vector3;
  130921. /**
  130922. * Get a navigation mesh constrained position, within a particular radius
  130923. * @param position world position
  130924. * @param maxRadius the maximum distance to the constrained world position
  130925. * @returns the closest point to position constrained by the navigation mesh
  130926. */
  130927. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130928. /**
  130929. * Compute the final position from a segment made of destination-position
  130930. * @param position world position
  130931. * @param destination world position
  130932. * @returns the resulting point along the navmesh
  130933. */
  130934. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130935. /**
  130936. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130937. * @param start world position
  130938. * @param end world position
  130939. * @returns array containing world position composing the path
  130940. */
  130941. computePath(start: Vector3, end: Vector3): Vector3[];
  130942. /**
  130943. * Create a new Crowd so you can add agents
  130944. * @param maxAgents the maximum agent count in the crowd
  130945. * @param maxAgentRadius the maximum radius an agent can have
  130946. * @param scene to attach the crowd to
  130947. * @returns the crowd you can add agents to
  130948. */
  130949. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130950. /**
  130951. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130952. * The queries will try to find a solution within those bounds
  130953. * default is (1,1,1)
  130954. * @param extent x,y,z value that define the extent around the queries point of reference
  130955. */
  130956. setDefaultQueryExtent(extent: Vector3): void;
  130957. /**
  130958. * Get the Bounding box extent specified by setDefaultQueryExtent
  130959. * @returns the box extent values
  130960. */
  130961. getDefaultQueryExtent(): Vector3;
  130962. /**
  130963. * Disposes
  130964. */
  130965. dispose(): void;
  130966. /**
  130967. * If this plugin is supported
  130968. * @returns true if plugin is supported
  130969. */
  130970. isSupported(): boolean;
  130971. }
  130972. /**
  130973. * Recast detour crowd implementation
  130974. */
  130975. export class RecastJSCrowd implements ICrowd {
  130976. /**
  130977. * Recast/detour plugin
  130978. */
  130979. bjsRECASTPlugin: RecastJSPlugin;
  130980. /**
  130981. * Link to the detour crowd
  130982. */
  130983. recastCrowd: any;
  130984. /**
  130985. * One transform per agent
  130986. */
  130987. transforms: TransformNode[];
  130988. /**
  130989. * All agents created
  130990. */
  130991. agents: number[];
  130992. /**
  130993. * Link to the scene is kept to unregister the crowd from the scene
  130994. */
  130995. private _scene;
  130996. /**
  130997. * Observer for crowd updates
  130998. */
  130999. private _onBeforeAnimationsObserver;
  131000. /**
  131001. * Constructor
  131002. * @param plugin recastJS plugin
  131003. * @param maxAgents the maximum agent count in the crowd
  131004. * @param maxAgentRadius the maximum radius an agent can have
  131005. * @param scene to attach the crowd to
  131006. * @returns the crowd you can add agents to
  131007. */
  131008. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  131009. /**
  131010. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  131011. * You can attach anything to that node. The node position is updated in the scene update tick.
  131012. * @param pos world position that will be constrained by the navigation mesh
  131013. * @param parameters agent parameters
  131014. * @param transform hooked to the agent that will be update by the scene
  131015. * @returns agent index
  131016. */
  131017. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  131018. /**
  131019. * Returns the agent position in world space
  131020. * @param index agent index returned by addAgent
  131021. * @returns world space position
  131022. */
  131023. getAgentPosition(index: number): Vector3;
  131024. /**
  131025. * Returns the agent velocity in world space
  131026. * @param index agent index returned by addAgent
  131027. * @returns world space velocity
  131028. */
  131029. getAgentVelocity(index: number): Vector3;
  131030. /**
  131031. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  131032. * @param index agent index returned by addAgent
  131033. * @param destination targeted world position
  131034. */
  131035. agentGoto(index: number, destination: Vector3): void;
  131036. /**
  131037. * remove a particular agent previously created
  131038. * @param index agent index returned by addAgent
  131039. */
  131040. removeAgent(index: number): void;
  131041. /**
  131042. * get the list of all agents attached to this crowd
  131043. * @returns list of agent indices
  131044. */
  131045. getAgents(): number[];
  131046. /**
  131047. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  131048. * @param deltaTime in seconds
  131049. */
  131050. update(deltaTime: number): void;
  131051. /**
  131052. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131053. * The queries will try to find a solution within those bounds
  131054. * default is (1,1,1)
  131055. * @param extent x,y,z value that define the extent around the queries point of reference
  131056. */
  131057. setDefaultQueryExtent(extent: Vector3): void;
  131058. /**
  131059. * Get the Bounding box extent specified by setDefaultQueryExtent
  131060. * @returns the box extent values
  131061. */
  131062. getDefaultQueryExtent(): Vector3;
  131063. /**
  131064. * Release all resources
  131065. */
  131066. dispose(): void;
  131067. }
  131068. }
  131069. declare module BABYLON {
  131070. /**
  131071. * Class used to enable access to IndexedDB
  131072. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  131073. */
  131074. export class Database implements IOfflineProvider {
  131075. private _callbackManifestChecked;
  131076. private _currentSceneUrl;
  131077. private _db;
  131078. private _enableSceneOffline;
  131079. private _enableTexturesOffline;
  131080. private _manifestVersionFound;
  131081. private _mustUpdateRessources;
  131082. private _hasReachedQuota;
  131083. private _isSupported;
  131084. private _idbFactory;
  131085. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  131086. private static IsUASupportingBlobStorage;
  131087. /**
  131088. * Gets a boolean indicating if Database storate is enabled (off by default)
  131089. */
  131090. static IDBStorageEnabled: boolean;
  131091. /**
  131092. * Gets a boolean indicating if scene must be saved in the database
  131093. */
  131094. get enableSceneOffline(): boolean;
  131095. /**
  131096. * Gets a boolean indicating if textures must be saved in the database
  131097. */
  131098. get enableTexturesOffline(): boolean;
  131099. /**
  131100. * Creates a new Database
  131101. * @param urlToScene defines the url to load the scene
  131102. * @param callbackManifestChecked defines the callback to use when manifest is checked
  131103. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  131104. */
  131105. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  131106. private static _ParseURL;
  131107. private static _ReturnFullUrlLocation;
  131108. private _checkManifestFile;
  131109. /**
  131110. * Open the database and make it available
  131111. * @param successCallback defines the callback to call on success
  131112. * @param errorCallback defines the callback to call on error
  131113. */
  131114. open(successCallback: () => void, errorCallback: () => void): void;
  131115. /**
  131116. * Loads an image from the database
  131117. * @param url defines the url to load from
  131118. * @param image defines the target DOM image
  131119. */
  131120. loadImage(url: string, image: HTMLImageElement): void;
  131121. private _loadImageFromDBAsync;
  131122. private _saveImageIntoDBAsync;
  131123. private _checkVersionFromDB;
  131124. private _loadVersionFromDBAsync;
  131125. private _saveVersionIntoDBAsync;
  131126. /**
  131127. * Loads a file from database
  131128. * @param url defines the URL to load from
  131129. * @param sceneLoaded defines a callback to call on success
  131130. * @param progressCallBack defines a callback to call when progress changed
  131131. * @param errorCallback defines a callback to call on error
  131132. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  131133. */
  131134. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  131135. private _loadFileAsync;
  131136. private _saveFileAsync;
  131137. /**
  131138. * Validates if xhr data is correct
  131139. * @param xhr defines the request to validate
  131140. * @param dataType defines the expected data type
  131141. * @returns true if data is correct
  131142. */
  131143. private static _ValidateXHRData;
  131144. }
  131145. }
  131146. declare module BABYLON {
  131147. /** @hidden */
  131148. export var gpuUpdateParticlesPixelShader: {
  131149. name: string;
  131150. shader: string;
  131151. };
  131152. }
  131153. declare module BABYLON {
  131154. /** @hidden */
  131155. export var gpuUpdateParticlesVertexShader: {
  131156. name: string;
  131157. shader: string;
  131158. };
  131159. }
  131160. declare module BABYLON {
  131161. /** @hidden */
  131162. export var clipPlaneFragmentDeclaration2: {
  131163. name: string;
  131164. shader: string;
  131165. };
  131166. }
  131167. declare module BABYLON {
  131168. /** @hidden */
  131169. export var gpuRenderParticlesPixelShader: {
  131170. name: string;
  131171. shader: string;
  131172. };
  131173. }
  131174. declare module BABYLON {
  131175. /** @hidden */
  131176. export var clipPlaneVertexDeclaration2: {
  131177. name: string;
  131178. shader: string;
  131179. };
  131180. }
  131181. declare module BABYLON {
  131182. /** @hidden */
  131183. export var gpuRenderParticlesVertexShader: {
  131184. name: string;
  131185. shader: string;
  131186. };
  131187. }
  131188. declare module BABYLON {
  131189. /**
  131190. * This represents a GPU particle system in Babylon
  131191. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  131192. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  131193. */
  131194. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  131195. /**
  131196. * The layer mask we are rendering the particles through.
  131197. */
  131198. layerMask: number;
  131199. private _capacity;
  131200. private _activeCount;
  131201. private _currentActiveCount;
  131202. private _accumulatedCount;
  131203. private _renderEffect;
  131204. private _updateEffect;
  131205. private _buffer0;
  131206. private _buffer1;
  131207. private _spriteBuffer;
  131208. private _updateVAO;
  131209. private _renderVAO;
  131210. private _targetIndex;
  131211. private _sourceBuffer;
  131212. private _targetBuffer;
  131213. private _engine;
  131214. private _currentRenderId;
  131215. private _started;
  131216. private _stopped;
  131217. private _timeDelta;
  131218. private _randomTexture;
  131219. private _randomTexture2;
  131220. private _attributesStrideSize;
  131221. private _updateEffectOptions;
  131222. private _randomTextureSize;
  131223. private _actualFrame;
  131224. private readonly _rawTextureWidth;
  131225. /**
  131226. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  131227. */
  131228. static get IsSupported(): boolean;
  131229. /**
  131230. * An event triggered when the system is disposed.
  131231. */
  131232. onDisposeObservable: Observable<GPUParticleSystem>;
  131233. /**
  131234. * Gets the maximum number of particles active at the same time.
  131235. * @returns The max number of active particles.
  131236. */
  131237. getCapacity(): number;
  131238. /**
  131239. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  131240. * to override the particles.
  131241. */
  131242. forceDepthWrite: boolean;
  131243. /**
  131244. * Gets or set the number of active particles
  131245. */
  131246. get activeParticleCount(): number;
  131247. set activeParticleCount(value: number);
  131248. private _preWarmDone;
  131249. /**
  131250. * Is this system ready to be used/rendered
  131251. * @return true if the system is ready
  131252. */
  131253. isReady(): boolean;
  131254. /**
  131255. * Gets if the system has been started. (Note: this will still be true after stop is called)
  131256. * @returns True if it has been started, otherwise false.
  131257. */
  131258. isStarted(): boolean;
  131259. /**
  131260. * Starts the particle system and begins to emit
  131261. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  131262. */
  131263. start(delay?: number): void;
  131264. /**
  131265. * Stops the particle system.
  131266. */
  131267. stop(): void;
  131268. /**
  131269. * Remove all active particles
  131270. */
  131271. reset(): void;
  131272. /**
  131273. * Returns the string "GPUParticleSystem"
  131274. * @returns a string containing the class name
  131275. */
  131276. getClassName(): string;
  131277. private _colorGradientsTexture;
  131278. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  131279. /**
  131280. * Adds a new color gradient
  131281. * @param gradient defines the gradient to use (between 0 and 1)
  131282. * @param color1 defines the color to affect to the specified gradient
  131283. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  131284. * @returns the current particle system
  131285. */
  131286. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  131287. /**
  131288. * Remove a specific color gradient
  131289. * @param gradient defines the gradient to remove
  131290. * @returns the current particle system
  131291. */
  131292. removeColorGradient(gradient: number): GPUParticleSystem;
  131293. private _angularSpeedGradientsTexture;
  131294. private _sizeGradientsTexture;
  131295. private _velocityGradientsTexture;
  131296. private _limitVelocityGradientsTexture;
  131297. private _dragGradientsTexture;
  131298. private _addFactorGradient;
  131299. /**
  131300. * Adds a new size gradient
  131301. * @param gradient defines the gradient to use (between 0 and 1)
  131302. * @param factor defines the size factor to affect to the specified gradient
  131303. * @returns the current particle system
  131304. */
  131305. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  131306. /**
  131307. * Remove a specific size gradient
  131308. * @param gradient defines the gradient to remove
  131309. * @returns the current particle system
  131310. */
  131311. removeSizeGradient(gradient: number): GPUParticleSystem;
  131312. /**
  131313. * Adds a new angular speed gradient
  131314. * @param gradient defines the gradient to use (between 0 and 1)
  131315. * @param factor defines the angular speed to affect to the specified gradient
  131316. * @returns the current particle system
  131317. */
  131318. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  131319. /**
  131320. * Remove a specific angular speed gradient
  131321. * @param gradient defines the gradient to remove
  131322. * @returns the current particle system
  131323. */
  131324. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  131325. /**
  131326. * Adds a new velocity gradient
  131327. * @param gradient defines the gradient to use (between 0 and 1)
  131328. * @param factor defines the velocity to affect to the specified gradient
  131329. * @returns the current particle system
  131330. */
  131331. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131332. /**
  131333. * Remove a specific velocity gradient
  131334. * @param gradient defines the gradient to remove
  131335. * @returns the current particle system
  131336. */
  131337. removeVelocityGradient(gradient: number): GPUParticleSystem;
  131338. /**
  131339. * Adds a new limit velocity gradient
  131340. * @param gradient defines the gradient to use (between 0 and 1)
  131341. * @param factor defines the limit velocity value to affect to the specified gradient
  131342. * @returns the current particle system
  131343. */
  131344. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131345. /**
  131346. * Remove a specific limit velocity gradient
  131347. * @param gradient defines the gradient to remove
  131348. * @returns the current particle system
  131349. */
  131350. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  131351. /**
  131352. * Adds a new drag gradient
  131353. * @param gradient defines the gradient to use (between 0 and 1)
  131354. * @param factor defines the drag value to affect to the specified gradient
  131355. * @returns the current particle system
  131356. */
  131357. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  131358. /**
  131359. * Remove a specific drag gradient
  131360. * @param gradient defines the gradient to remove
  131361. * @returns the current particle system
  131362. */
  131363. removeDragGradient(gradient: number): GPUParticleSystem;
  131364. /**
  131365. * Not supported by GPUParticleSystem
  131366. * @param gradient defines the gradient to use (between 0 and 1)
  131367. * @param factor defines the emit rate value to affect to the specified gradient
  131368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131369. * @returns the current particle system
  131370. */
  131371. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131372. /**
  131373. * Not supported by GPUParticleSystem
  131374. * @param gradient defines the gradient to remove
  131375. * @returns the current particle system
  131376. */
  131377. removeEmitRateGradient(gradient: number): IParticleSystem;
  131378. /**
  131379. * Not supported by GPUParticleSystem
  131380. * @param gradient defines the gradient to use (between 0 and 1)
  131381. * @param factor defines the start size value to affect to the specified gradient
  131382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131383. * @returns the current particle system
  131384. */
  131385. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131386. /**
  131387. * Not supported by GPUParticleSystem
  131388. * @param gradient defines the gradient to remove
  131389. * @returns the current particle system
  131390. */
  131391. removeStartSizeGradient(gradient: number): IParticleSystem;
  131392. /**
  131393. * Not supported by GPUParticleSystem
  131394. * @param gradient defines the gradient to use (between 0 and 1)
  131395. * @param min defines the color remap minimal range
  131396. * @param max defines the color remap maximal range
  131397. * @returns the current particle system
  131398. */
  131399. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131400. /**
  131401. * Not supported by GPUParticleSystem
  131402. * @param gradient defines the gradient to remove
  131403. * @returns the current particle system
  131404. */
  131405. removeColorRemapGradient(): IParticleSystem;
  131406. /**
  131407. * Not supported by GPUParticleSystem
  131408. * @param gradient defines the gradient to use (between 0 and 1)
  131409. * @param min defines the alpha remap minimal range
  131410. * @param max defines the alpha remap maximal range
  131411. * @returns the current particle system
  131412. */
  131413. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131414. /**
  131415. * Not supported by GPUParticleSystem
  131416. * @param gradient defines the gradient to remove
  131417. * @returns the current particle system
  131418. */
  131419. removeAlphaRemapGradient(): IParticleSystem;
  131420. /**
  131421. * Not supported by GPUParticleSystem
  131422. * @param gradient defines the gradient to use (between 0 and 1)
  131423. * @param color defines the color to affect to the specified gradient
  131424. * @returns the current particle system
  131425. */
  131426. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  131427. /**
  131428. * Not supported by GPUParticleSystem
  131429. * @param gradient defines the gradient to remove
  131430. * @returns the current particle system
  131431. */
  131432. removeRampGradient(): IParticleSystem;
  131433. /**
  131434. * Not supported by GPUParticleSystem
  131435. * @returns the list of ramp gradients
  131436. */
  131437. getRampGradients(): Nullable<Array<Color3Gradient>>;
  131438. /**
  131439. * Not supported by GPUParticleSystem
  131440. * Gets or sets a boolean indicating that ramp gradients must be used
  131441. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  131442. */
  131443. get useRampGradients(): boolean;
  131444. set useRampGradients(value: boolean);
  131445. /**
  131446. * Not supported by GPUParticleSystem
  131447. * @param gradient defines the gradient to use (between 0 and 1)
  131448. * @param factor defines the life time factor to affect to the specified gradient
  131449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131450. * @returns the current particle system
  131451. */
  131452. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131453. /**
  131454. * Not supported by GPUParticleSystem
  131455. * @param gradient defines the gradient to remove
  131456. * @returns the current particle system
  131457. */
  131458. removeLifeTimeGradient(gradient: number): IParticleSystem;
  131459. /**
  131460. * Instantiates a GPU particle system.
  131461. * 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.
  131462. * @param name The name of the particle system
  131463. * @param options The options used to create the system
  131464. * @param scene The scene the particle system belongs to
  131465. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  131466. */
  131467. constructor(name: string, options: Partial<{
  131468. capacity: number;
  131469. randomTextureSize: number;
  131470. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  131471. protected _reset(): void;
  131472. private _createUpdateVAO;
  131473. private _createRenderVAO;
  131474. private _initialize;
  131475. /** @hidden */
  131476. _recreateUpdateEffect(): void;
  131477. /** @hidden */
  131478. _recreateRenderEffect(): void;
  131479. /**
  131480. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  131481. * @param preWarm defines if we are in the pre-warmimg phase
  131482. */
  131483. animate(preWarm?: boolean): void;
  131484. private _createFactorGradientTexture;
  131485. private _createSizeGradientTexture;
  131486. private _createAngularSpeedGradientTexture;
  131487. private _createVelocityGradientTexture;
  131488. private _createLimitVelocityGradientTexture;
  131489. private _createDragGradientTexture;
  131490. private _createColorGradientTexture;
  131491. /**
  131492. * Renders the particle system in its current state
  131493. * @param preWarm defines if the system should only update the particles but not render them
  131494. * @returns the current number of particles
  131495. */
  131496. render(preWarm?: boolean): number;
  131497. /**
  131498. * Rebuilds the particle system
  131499. */
  131500. rebuild(): void;
  131501. private _releaseBuffers;
  131502. private _releaseVAOs;
  131503. /**
  131504. * Disposes the particle system and free the associated resources
  131505. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  131506. */
  131507. dispose(disposeTexture?: boolean): void;
  131508. /**
  131509. * Clones the particle system.
  131510. * @param name The name of the cloned object
  131511. * @param newEmitter The new emitter to use
  131512. * @returns the cloned particle system
  131513. */
  131514. clone(name: string, newEmitter: any): GPUParticleSystem;
  131515. /**
  131516. * Serializes the particle system to a JSON object.
  131517. * @returns the JSON object
  131518. */
  131519. serialize(): any;
  131520. /**
  131521. * Parses a JSON object to create a GPU particle system.
  131522. * @param parsedParticleSystem The JSON object to parse
  131523. * @param scene The scene to create the particle system in
  131524. * @param rootUrl The root url to use to load external dependencies like texture
  131525. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  131526. * @returns the parsed GPU particle system
  131527. */
  131528. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  131529. }
  131530. }
  131531. declare module BABYLON {
  131532. /**
  131533. * Represents a set of particle systems working together to create a specific effect
  131534. */
  131535. export class ParticleSystemSet implements IDisposable {
  131536. /**
  131537. * Gets or sets base Assets URL
  131538. */
  131539. static BaseAssetsUrl: string;
  131540. private _emitterCreationOptions;
  131541. private _emitterNode;
  131542. /**
  131543. * Gets the particle system list
  131544. */
  131545. systems: IParticleSystem[];
  131546. /**
  131547. * Gets the emitter node used with this set
  131548. */
  131549. get emitterNode(): Nullable<TransformNode>;
  131550. /**
  131551. * Creates a new emitter mesh as a sphere
  131552. * @param options defines the options used to create the sphere
  131553. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  131554. * @param scene defines the hosting scene
  131555. */
  131556. setEmitterAsSphere(options: {
  131557. diameter: number;
  131558. segments: number;
  131559. color: Color3;
  131560. }, renderingGroupId: number, scene: Scene): void;
  131561. /**
  131562. * Starts all particle systems of the set
  131563. * @param emitter defines an optional mesh to use as emitter for the particle systems
  131564. */
  131565. start(emitter?: AbstractMesh): void;
  131566. /**
  131567. * Release all associated resources
  131568. */
  131569. dispose(): void;
  131570. /**
  131571. * Serialize the set into a JSON compatible object
  131572. * @returns a JSON compatible representation of the set
  131573. */
  131574. serialize(): any;
  131575. /**
  131576. * Parse a new ParticleSystemSet from a serialized source
  131577. * @param data defines a JSON compatible representation of the set
  131578. * @param scene defines the hosting scene
  131579. * @param gpu defines if we want GPU particles or CPU particles
  131580. * @returns a new ParticleSystemSet
  131581. */
  131582. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  131583. }
  131584. }
  131585. declare module BABYLON {
  131586. /**
  131587. * This class is made for on one-liner static method to help creating particle system set.
  131588. */
  131589. export class ParticleHelper {
  131590. /**
  131591. * Gets or sets base Assets URL
  131592. */
  131593. static BaseAssetsUrl: string;
  131594. /**
  131595. * Create a default particle system that you can tweak
  131596. * @param emitter defines the emitter to use
  131597. * @param capacity defines the system capacity (default is 500 particles)
  131598. * @param scene defines the hosting scene
  131599. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  131600. * @returns the new Particle system
  131601. */
  131602. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  131603. /**
  131604. * This is the main static method (one-liner) of this helper to create different particle systems
  131605. * @param type This string represents the type to the particle system to create
  131606. * @param scene The scene where the particle system should live
  131607. * @param gpu If the system will use gpu
  131608. * @returns the ParticleSystemSet created
  131609. */
  131610. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  131611. /**
  131612. * Static function used to export a particle system to a ParticleSystemSet variable.
  131613. * Please note that the emitter shape is not exported
  131614. * @param systems defines the particle systems to export
  131615. * @returns the created particle system set
  131616. */
  131617. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  131618. }
  131619. }
  131620. declare module BABYLON {
  131621. interface Engine {
  131622. /**
  131623. * Create an effect to use with particle systems.
  131624. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  131625. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  131626. * @param uniformsNames defines a list of attribute names
  131627. * @param samplers defines an array of string used to represent textures
  131628. * @param defines defines the string containing the defines to use to compile the shaders
  131629. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  131630. * @param onCompiled defines a function to call when the effect creation is successful
  131631. * @param onError defines a function to call when the effect creation has failed
  131632. * @returns the new Effect
  131633. */
  131634. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  131635. }
  131636. interface Mesh {
  131637. /**
  131638. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  131639. * @returns an array of IParticleSystem
  131640. */
  131641. getEmittedParticleSystems(): IParticleSystem[];
  131642. /**
  131643. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  131644. * @returns an array of IParticleSystem
  131645. */
  131646. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  131647. }
  131648. /**
  131649. * @hidden
  131650. */
  131651. export var _IDoNeedToBeInTheBuild: number;
  131652. }
  131653. declare module BABYLON {
  131654. /** Defines the 4 color options */
  131655. export enum PointColor {
  131656. /** color value */
  131657. Color = 2,
  131658. /** uv value */
  131659. UV = 1,
  131660. /** random value */
  131661. Random = 0,
  131662. /** stated value */
  131663. Stated = 3
  131664. }
  131665. /**
  131666. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  131667. * 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.
  131668. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  131669. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  131670. *
  131671. * Full documentation here : TO BE ENTERED
  131672. */
  131673. export class PointsCloudSystem implements IDisposable {
  131674. /**
  131675. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  131676. * Example : var p = SPS.particles[i];
  131677. */
  131678. particles: CloudPoint[];
  131679. /**
  131680. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  131681. */
  131682. nbParticles: number;
  131683. /**
  131684. * This a counter for your own usage. It's not set by any SPS functions.
  131685. */
  131686. counter: number;
  131687. /**
  131688. * The PCS name. This name is also given to the underlying mesh.
  131689. */
  131690. name: string;
  131691. /**
  131692. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  131693. */
  131694. mesh: Mesh;
  131695. /**
  131696. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  131697. * Please read :
  131698. */
  131699. vars: any;
  131700. /**
  131701. * @hidden
  131702. */
  131703. _size: number;
  131704. private _scene;
  131705. private _promises;
  131706. private _positions;
  131707. private _indices;
  131708. private _normals;
  131709. private _colors;
  131710. private _uvs;
  131711. private _indices32;
  131712. private _positions32;
  131713. private _colors32;
  131714. private _uvs32;
  131715. private _updatable;
  131716. private _isVisibilityBoxLocked;
  131717. private _alwaysVisible;
  131718. private _groups;
  131719. private _groupCounter;
  131720. private _computeParticleColor;
  131721. private _computeParticleTexture;
  131722. private _computeParticleRotation;
  131723. private _computeBoundingBox;
  131724. private _isReady;
  131725. /**
  131726. * Creates a PCS (Points Cloud System) object
  131727. * @param name (String) is the PCS name, this will be the underlying mesh name
  131728. * @param pointSize (number) is the size for each point
  131729. * @param scene (Scene) is the scene in which the PCS is added
  131730. * @param options defines the options of the PCS e.g.
  131731. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  131732. */
  131733. constructor(name: string, pointSize: number, scene: Scene, options?: {
  131734. updatable?: boolean;
  131735. });
  131736. /**
  131737. * Builds the PCS underlying mesh. Returns a standard Mesh.
  131738. * If no points were added to the PCS, the returned mesh is just a single point.
  131739. * @returns a promise for the created mesh
  131740. */
  131741. buildMeshAsync(): Promise<Mesh>;
  131742. /**
  131743. * @hidden
  131744. */
  131745. private _buildMesh;
  131746. private _addParticle;
  131747. private _randomUnitVector;
  131748. private _getColorIndicesForCoord;
  131749. private _setPointsColorOrUV;
  131750. private _colorFromTexture;
  131751. private _calculateDensity;
  131752. /**
  131753. * Adds points to the PCS in random positions within a unit sphere
  131754. * @param nb (positive integer) the number of particles to be created from this model
  131755. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  131756. * @returns the number of groups in the system
  131757. */
  131758. addPoints(nb: number, pointFunction?: any): number;
  131759. /**
  131760. * Adds points to the PCS from the surface of the model shape
  131761. * @param mesh is any Mesh object that will be used as a surface model for the points
  131762. * @param nb (positive integer) the number of particles to be created from this model
  131763. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131764. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131765. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131766. * @returns the number of groups in the system
  131767. */
  131768. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131769. /**
  131770. * Adds points to the PCS inside the model shape
  131771. * @param mesh is any Mesh object that will be used as a surface model for the points
  131772. * @param nb (positive integer) the number of particles to be created from this model
  131773. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131774. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131775. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131776. * @returns the number of groups in the system
  131777. */
  131778. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131779. /**
  131780. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  131781. * This method calls `updateParticle()` for each particle of the SPS.
  131782. * For an animated SPS, it is usually called within the render loop.
  131783. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  131784. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  131785. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  131786. * @returns the PCS.
  131787. */
  131788. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  131789. /**
  131790. * Disposes the PCS.
  131791. */
  131792. dispose(): void;
  131793. /**
  131794. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  131795. * doc :
  131796. * @returns the PCS.
  131797. */
  131798. refreshVisibleSize(): PointsCloudSystem;
  131799. /**
  131800. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  131801. * @param size the size (float) of the visibility box
  131802. * note : this doesn't lock the PCS mesh bounding box.
  131803. * doc :
  131804. */
  131805. setVisibilityBox(size: number): void;
  131806. /**
  131807. * Gets whether the PCS is always visible or not
  131808. * doc :
  131809. */
  131810. get isAlwaysVisible(): boolean;
  131811. /**
  131812. * Sets the PCS as always visible or not
  131813. * doc :
  131814. */
  131815. set isAlwaysVisible(val: boolean);
  131816. /**
  131817. * Tells to `setParticles()` to compute the particle rotations or not
  131818. * Default value : false. The PCS is faster when it's set to false
  131819. * Note : particle rotations are only applied to parent particles
  131820. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  131821. */
  131822. set computeParticleRotation(val: boolean);
  131823. /**
  131824. * Tells to `setParticles()` to compute the particle colors or not.
  131825. * Default value : true. The PCS is faster when it's set to false.
  131826. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131827. */
  131828. set computeParticleColor(val: boolean);
  131829. set computeParticleTexture(val: boolean);
  131830. /**
  131831. * Gets if `setParticles()` computes the particle colors or not.
  131832. * Default value : false. The PCS is faster when it's set to false.
  131833. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131834. */
  131835. get computeParticleColor(): boolean;
  131836. /**
  131837. * Gets if `setParticles()` computes the particle textures or not.
  131838. * Default value : false. The PCS is faster when it's set to false.
  131839. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  131840. */
  131841. get computeParticleTexture(): boolean;
  131842. /**
  131843. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  131844. */
  131845. set computeBoundingBox(val: boolean);
  131846. /**
  131847. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  131848. */
  131849. get computeBoundingBox(): boolean;
  131850. /**
  131851. * This function does nothing. It may be overwritten to set all the particle first values.
  131852. * The PCS doesn't call this function, you may have to call it by your own.
  131853. * doc :
  131854. */
  131855. initParticles(): void;
  131856. /**
  131857. * This function does nothing. It may be overwritten to recycle a particle
  131858. * The PCS doesn't call this function, you can to call it
  131859. * doc :
  131860. * @param particle The particle to recycle
  131861. * @returns the recycled particle
  131862. */
  131863. recycleParticle(particle: CloudPoint): CloudPoint;
  131864. /**
  131865. * Updates a particle : this function should be overwritten by the user.
  131866. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  131867. * doc :
  131868. * @example : just set a particle position or velocity and recycle conditions
  131869. * @param particle The particle to update
  131870. * @returns the updated particle
  131871. */
  131872. updateParticle(particle: CloudPoint): CloudPoint;
  131873. /**
  131874. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  131875. * This does nothing and may be overwritten by the user.
  131876. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  131877. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  131878. * @param update the boolean update value actually passed to setParticles()
  131879. */
  131880. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  131881. /**
  131882. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  131883. * This will be passed three parameters.
  131884. * This does nothing and may be overwritten by the user.
  131885. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  131886. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  131887. * @param update the boolean update value actually passed to setParticles()
  131888. */
  131889. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  131890. }
  131891. }
  131892. declare module BABYLON {
  131893. /**
  131894. * Represents one particle of a points cloud system.
  131895. */
  131896. export class CloudPoint {
  131897. /**
  131898. * particle global index
  131899. */
  131900. idx: number;
  131901. /**
  131902. * The color of the particle
  131903. */
  131904. color: Nullable<Color4>;
  131905. /**
  131906. * The world space position of the particle.
  131907. */
  131908. position: Vector3;
  131909. /**
  131910. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  131911. */
  131912. rotation: Vector3;
  131913. /**
  131914. * The world space rotation quaternion of the particle.
  131915. */
  131916. rotationQuaternion: Nullable<Quaternion>;
  131917. /**
  131918. * The uv of the particle.
  131919. */
  131920. uv: Nullable<Vector2>;
  131921. /**
  131922. * The current speed of the particle.
  131923. */
  131924. velocity: Vector3;
  131925. /**
  131926. * The pivot point in the particle local space.
  131927. */
  131928. pivot: Vector3;
  131929. /**
  131930. * Must the particle be translated from its pivot point in its local space ?
  131931. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  131932. * Default : false
  131933. */
  131934. translateFromPivot: boolean;
  131935. /**
  131936. * Index of this particle in the global "positions" array (Internal use)
  131937. * @hidden
  131938. */
  131939. _pos: number;
  131940. /**
  131941. * @hidden Index of this particle in the global "indices" array (Internal use)
  131942. */
  131943. _ind: number;
  131944. /**
  131945. * Group this particle belongs to
  131946. */
  131947. _group: PointsGroup;
  131948. /**
  131949. * Group id of this particle
  131950. */
  131951. groupId: number;
  131952. /**
  131953. * Index of the particle in its group id (Internal use)
  131954. */
  131955. idxInGroup: number;
  131956. /**
  131957. * @hidden Particle BoundingInfo object (Internal use)
  131958. */
  131959. _boundingInfo: BoundingInfo;
  131960. /**
  131961. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  131962. */
  131963. _pcs: PointsCloudSystem;
  131964. /**
  131965. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  131966. */
  131967. _stillInvisible: boolean;
  131968. /**
  131969. * @hidden Last computed particle rotation matrix
  131970. */
  131971. _rotationMatrix: number[];
  131972. /**
  131973. * Parent particle Id, if any.
  131974. * Default null.
  131975. */
  131976. parentId: Nullable<number>;
  131977. /**
  131978. * @hidden Internal global position in the PCS.
  131979. */
  131980. _globalPosition: Vector3;
  131981. /**
  131982. * Creates a Point Cloud object.
  131983. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  131984. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  131985. * @param group (PointsGroup) is the group the particle belongs to
  131986. * @param groupId (integer) is the group identifier in the PCS.
  131987. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  131988. * @param pcs defines the PCS it is associated to
  131989. */
  131990. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  131991. /**
  131992. * get point size
  131993. */
  131994. get size(): Vector3;
  131995. /**
  131996. * Set point size
  131997. */
  131998. set size(scale: Vector3);
  131999. /**
  132000. * Legacy support, changed quaternion to rotationQuaternion
  132001. */
  132002. get quaternion(): Nullable<Quaternion>;
  132003. /**
  132004. * Legacy support, changed quaternion to rotationQuaternion
  132005. */
  132006. set quaternion(q: Nullable<Quaternion>);
  132007. /**
  132008. * Returns a boolean. True if the particle intersects a mesh, else false
  132009. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  132010. * @param target is the object (point or mesh) what the intersection is computed against
  132011. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  132012. * @returns true if it intersects
  132013. */
  132014. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  132015. /**
  132016. * get the rotation matrix of the particle
  132017. * @hidden
  132018. */
  132019. getRotationMatrix(m: Matrix): void;
  132020. }
  132021. /**
  132022. * Represents a group of points in a points cloud system
  132023. * * PCS internal tool, don't use it manually.
  132024. */
  132025. export class PointsGroup {
  132026. /**
  132027. * The group id
  132028. * @hidden
  132029. */
  132030. groupID: number;
  132031. /**
  132032. * image data for group (internal use)
  132033. * @hidden
  132034. */
  132035. _groupImageData: Nullable<ArrayBufferView>;
  132036. /**
  132037. * Image Width (internal use)
  132038. * @hidden
  132039. */
  132040. _groupImgWidth: number;
  132041. /**
  132042. * Image Height (internal use)
  132043. * @hidden
  132044. */
  132045. _groupImgHeight: number;
  132046. /**
  132047. * Custom position function (internal use)
  132048. * @hidden
  132049. */
  132050. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  132051. /**
  132052. * density per facet for surface points
  132053. * @hidden
  132054. */
  132055. _groupDensity: number[];
  132056. /**
  132057. * Only when points are colored by texture carries pointer to texture list array
  132058. * @hidden
  132059. */
  132060. _textureNb: number;
  132061. /**
  132062. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  132063. * PCS internal tool, don't use it manually.
  132064. * @hidden
  132065. */
  132066. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  132067. }
  132068. }
  132069. declare module BABYLON {
  132070. interface Scene {
  132071. /** @hidden (Backing field) */
  132072. _physicsEngine: Nullable<IPhysicsEngine>;
  132073. /** @hidden */
  132074. _physicsTimeAccumulator: number;
  132075. /**
  132076. * Gets the current physics engine
  132077. * @returns a IPhysicsEngine or null if none attached
  132078. */
  132079. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  132080. /**
  132081. * Enables physics to the current scene
  132082. * @param gravity defines the scene's gravity for the physics engine
  132083. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  132084. * @return a boolean indicating if the physics engine was initialized
  132085. */
  132086. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  132087. /**
  132088. * Disables and disposes the physics engine associated with the scene
  132089. */
  132090. disablePhysicsEngine(): void;
  132091. /**
  132092. * Gets a boolean indicating if there is an active physics engine
  132093. * @returns a boolean indicating if there is an active physics engine
  132094. */
  132095. isPhysicsEnabled(): boolean;
  132096. /**
  132097. * Deletes a physics compound impostor
  132098. * @param compound defines the compound to delete
  132099. */
  132100. deleteCompoundImpostor(compound: any): void;
  132101. /**
  132102. * An event triggered when physic simulation is about to be run
  132103. */
  132104. onBeforePhysicsObservable: Observable<Scene>;
  132105. /**
  132106. * An event triggered when physic simulation has been done
  132107. */
  132108. onAfterPhysicsObservable: Observable<Scene>;
  132109. }
  132110. interface AbstractMesh {
  132111. /** @hidden */
  132112. _physicsImpostor: Nullable<PhysicsImpostor>;
  132113. /**
  132114. * Gets or sets impostor used for physic simulation
  132115. * @see http://doc.babylonjs.com/features/physics_engine
  132116. */
  132117. physicsImpostor: Nullable<PhysicsImpostor>;
  132118. /**
  132119. * Gets the current physics impostor
  132120. * @see http://doc.babylonjs.com/features/physics_engine
  132121. * @returns a physics impostor or null
  132122. */
  132123. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  132124. /** Apply a physic impulse to the mesh
  132125. * @param force defines the force to apply
  132126. * @param contactPoint defines where to apply the force
  132127. * @returns the current mesh
  132128. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  132129. */
  132130. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  132131. /**
  132132. * Creates a physic joint between two meshes
  132133. * @param otherMesh defines the other mesh to use
  132134. * @param pivot1 defines the pivot to use on this mesh
  132135. * @param pivot2 defines the pivot to use on the other mesh
  132136. * @param options defines additional options (can be plugin dependent)
  132137. * @returns the current mesh
  132138. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  132139. */
  132140. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  132141. /** @hidden */
  132142. _disposePhysicsObserver: Nullable<Observer<Node>>;
  132143. }
  132144. /**
  132145. * Defines the physics engine scene component responsible to manage a physics engine
  132146. */
  132147. export class PhysicsEngineSceneComponent implements ISceneComponent {
  132148. /**
  132149. * The component name helpful to identify the component in the list of scene components.
  132150. */
  132151. readonly name: string;
  132152. /**
  132153. * The scene the component belongs to.
  132154. */
  132155. scene: Scene;
  132156. /**
  132157. * Creates a new instance of the component for the given scene
  132158. * @param scene Defines the scene to register the component in
  132159. */
  132160. constructor(scene: Scene);
  132161. /**
  132162. * Registers the component in a given scene
  132163. */
  132164. register(): void;
  132165. /**
  132166. * Rebuilds the elements related to this component in case of
  132167. * context lost for instance.
  132168. */
  132169. rebuild(): void;
  132170. /**
  132171. * Disposes the component and the associated ressources
  132172. */
  132173. dispose(): void;
  132174. }
  132175. }
  132176. declare module BABYLON {
  132177. /**
  132178. * A helper for physics simulations
  132179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132180. */
  132181. export class PhysicsHelper {
  132182. private _scene;
  132183. private _physicsEngine;
  132184. /**
  132185. * Initializes the Physics helper
  132186. * @param scene Babylon.js scene
  132187. */
  132188. constructor(scene: Scene);
  132189. /**
  132190. * Applies a radial explosion impulse
  132191. * @param origin the origin of the explosion
  132192. * @param radiusOrEventOptions the radius or the options of radial explosion
  132193. * @param strength the explosion strength
  132194. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132195. * @returns A physics radial explosion event, or null
  132196. */
  132197. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132198. /**
  132199. * Applies a radial explosion force
  132200. * @param origin the origin of the explosion
  132201. * @param radiusOrEventOptions the radius or the options of radial explosion
  132202. * @param strength the explosion strength
  132203. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132204. * @returns A physics radial explosion event, or null
  132205. */
  132206. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132207. /**
  132208. * Creates a gravitational field
  132209. * @param origin the origin of the explosion
  132210. * @param radiusOrEventOptions the radius or the options of radial explosion
  132211. * @param strength the explosion strength
  132212. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132213. * @returns A physics gravitational field event, or null
  132214. */
  132215. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  132216. /**
  132217. * Creates a physics updraft event
  132218. * @param origin the origin of the updraft
  132219. * @param radiusOrEventOptions the radius or the options of the updraft
  132220. * @param strength the strength of the updraft
  132221. * @param height the height of the updraft
  132222. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  132223. * @returns A physics updraft event, or null
  132224. */
  132225. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  132226. /**
  132227. * Creates a physics vortex event
  132228. * @param origin the of the vortex
  132229. * @param radiusOrEventOptions the radius or the options of the vortex
  132230. * @param strength the strength of the vortex
  132231. * @param height the height of the vortex
  132232. * @returns a Physics vortex event, or null
  132233. * A physics vortex event or null
  132234. */
  132235. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  132236. }
  132237. /**
  132238. * Represents a physics radial explosion event
  132239. */
  132240. class PhysicsRadialExplosionEvent {
  132241. private _scene;
  132242. private _options;
  132243. private _sphere;
  132244. private _dataFetched;
  132245. /**
  132246. * Initializes a radial explosioin event
  132247. * @param _scene BabylonJS scene
  132248. * @param _options The options for the vortex event
  132249. */
  132250. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  132251. /**
  132252. * Returns the data related to the radial explosion event (sphere).
  132253. * @returns The radial explosion event data
  132254. */
  132255. getData(): PhysicsRadialExplosionEventData;
  132256. /**
  132257. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  132258. * @param impostor A physics imposter
  132259. * @param origin the origin of the explosion
  132260. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  132261. */
  132262. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  132263. /**
  132264. * Triggers affecterd impostors callbacks
  132265. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  132266. */
  132267. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  132268. /**
  132269. * Disposes the sphere.
  132270. * @param force Specifies if the sphere should be disposed by force
  132271. */
  132272. dispose(force?: boolean): void;
  132273. /*** Helpers ***/
  132274. private _prepareSphere;
  132275. private _intersectsWithSphere;
  132276. }
  132277. /**
  132278. * Represents a gravitational field event
  132279. */
  132280. class PhysicsGravitationalFieldEvent {
  132281. private _physicsHelper;
  132282. private _scene;
  132283. private _origin;
  132284. private _options;
  132285. private _tickCallback;
  132286. private _sphere;
  132287. private _dataFetched;
  132288. /**
  132289. * Initializes the physics gravitational field event
  132290. * @param _physicsHelper A physics helper
  132291. * @param _scene BabylonJS scene
  132292. * @param _origin The origin position of the gravitational field event
  132293. * @param _options The options for the vortex event
  132294. */
  132295. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  132296. /**
  132297. * Returns the data related to the gravitational field event (sphere).
  132298. * @returns A gravitational field event
  132299. */
  132300. getData(): PhysicsGravitationalFieldEventData;
  132301. /**
  132302. * Enables the gravitational field.
  132303. */
  132304. enable(): void;
  132305. /**
  132306. * Disables the gravitational field.
  132307. */
  132308. disable(): void;
  132309. /**
  132310. * Disposes the sphere.
  132311. * @param force The force to dispose from the gravitational field event
  132312. */
  132313. dispose(force?: boolean): void;
  132314. private _tick;
  132315. }
  132316. /**
  132317. * Represents a physics updraft event
  132318. */
  132319. class PhysicsUpdraftEvent {
  132320. private _scene;
  132321. private _origin;
  132322. private _options;
  132323. private _physicsEngine;
  132324. private _originTop;
  132325. private _originDirection;
  132326. private _tickCallback;
  132327. private _cylinder;
  132328. private _cylinderPosition;
  132329. private _dataFetched;
  132330. /**
  132331. * Initializes the physics updraft event
  132332. * @param _scene BabylonJS scene
  132333. * @param _origin The origin position of the updraft
  132334. * @param _options The options for the updraft event
  132335. */
  132336. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  132337. /**
  132338. * Returns the data related to the updraft event (cylinder).
  132339. * @returns A physics updraft event
  132340. */
  132341. getData(): PhysicsUpdraftEventData;
  132342. /**
  132343. * Enables the updraft.
  132344. */
  132345. enable(): void;
  132346. /**
  132347. * Disables the updraft.
  132348. */
  132349. disable(): void;
  132350. /**
  132351. * Disposes the cylinder.
  132352. * @param force Specifies if the updraft should be disposed by force
  132353. */
  132354. dispose(force?: boolean): void;
  132355. private getImpostorHitData;
  132356. private _tick;
  132357. /*** Helpers ***/
  132358. private _prepareCylinder;
  132359. private _intersectsWithCylinder;
  132360. }
  132361. /**
  132362. * Represents a physics vortex event
  132363. */
  132364. class PhysicsVortexEvent {
  132365. private _scene;
  132366. private _origin;
  132367. private _options;
  132368. private _physicsEngine;
  132369. private _originTop;
  132370. private _tickCallback;
  132371. private _cylinder;
  132372. private _cylinderPosition;
  132373. private _dataFetched;
  132374. /**
  132375. * Initializes the physics vortex event
  132376. * @param _scene The BabylonJS scene
  132377. * @param _origin The origin position of the vortex
  132378. * @param _options The options for the vortex event
  132379. */
  132380. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  132381. /**
  132382. * Returns the data related to the vortex event (cylinder).
  132383. * @returns The physics vortex event data
  132384. */
  132385. getData(): PhysicsVortexEventData;
  132386. /**
  132387. * Enables the vortex.
  132388. */
  132389. enable(): void;
  132390. /**
  132391. * Disables the cortex.
  132392. */
  132393. disable(): void;
  132394. /**
  132395. * Disposes the sphere.
  132396. * @param force
  132397. */
  132398. dispose(force?: boolean): void;
  132399. private getImpostorHitData;
  132400. private _tick;
  132401. /*** Helpers ***/
  132402. private _prepareCylinder;
  132403. private _intersectsWithCylinder;
  132404. }
  132405. /**
  132406. * Options fot the radial explosion event
  132407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132408. */
  132409. export class PhysicsRadialExplosionEventOptions {
  132410. /**
  132411. * The radius of the sphere for the radial explosion.
  132412. */
  132413. radius: number;
  132414. /**
  132415. * The strenth of the explosion.
  132416. */
  132417. strength: number;
  132418. /**
  132419. * The strenght of the force in correspondence to the distance of the affected object
  132420. */
  132421. falloff: PhysicsRadialImpulseFalloff;
  132422. /**
  132423. * Sphere options for the radial explosion.
  132424. */
  132425. sphere: {
  132426. segments: number;
  132427. diameter: number;
  132428. };
  132429. /**
  132430. * Sphere options for the radial explosion.
  132431. */
  132432. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  132433. }
  132434. /**
  132435. * Options fot the updraft event
  132436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132437. */
  132438. export class PhysicsUpdraftEventOptions {
  132439. /**
  132440. * The radius of the cylinder for the vortex
  132441. */
  132442. radius: number;
  132443. /**
  132444. * The strenth of the updraft.
  132445. */
  132446. strength: number;
  132447. /**
  132448. * The height of the cylinder for the updraft.
  132449. */
  132450. height: number;
  132451. /**
  132452. * The mode for the the updraft.
  132453. */
  132454. updraftMode: PhysicsUpdraftMode;
  132455. }
  132456. /**
  132457. * Options fot the vortex event
  132458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132459. */
  132460. export class PhysicsVortexEventOptions {
  132461. /**
  132462. * The radius of the cylinder for the vortex
  132463. */
  132464. radius: number;
  132465. /**
  132466. * The strenth of the vortex.
  132467. */
  132468. strength: number;
  132469. /**
  132470. * The height of the cylinder for the vortex.
  132471. */
  132472. height: number;
  132473. /**
  132474. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  132475. */
  132476. centripetalForceThreshold: number;
  132477. /**
  132478. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  132479. */
  132480. centripetalForceMultiplier: number;
  132481. /**
  132482. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  132483. */
  132484. centrifugalForceMultiplier: number;
  132485. /**
  132486. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  132487. */
  132488. updraftForceMultiplier: number;
  132489. }
  132490. /**
  132491. * The strenght of the force in correspondence to the distance of the affected object
  132492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132493. */
  132494. export enum PhysicsRadialImpulseFalloff {
  132495. /** Defines that impulse is constant in strength across it's whole radius */
  132496. Constant = 0,
  132497. /** Defines that impulse gets weaker if it's further from the origin */
  132498. Linear = 1
  132499. }
  132500. /**
  132501. * The strength of the force in correspondence to the distance of the affected object
  132502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132503. */
  132504. export enum PhysicsUpdraftMode {
  132505. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  132506. Center = 0,
  132507. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  132508. Perpendicular = 1
  132509. }
  132510. /**
  132511. * Interface for a physics hit data
  132512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132513. */
  132514. export interface PhysicsHitData {
  132515. /**
  132516. * The force applied at the contact point
  132517. */
  132518. force: Vector3;
  132519. /**
  132520. * The contact point
  132521. */
  132522. contactPoint: Vector3;
  132523. /**
  132524. * The distance from the origin to the contact point
  132525. */
  132526. distanceFromOrigin: number;
  132527. }
  132528. /**
  132529. * Interface for radial explosion event data
  132530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132531. */
  132532. export interface PhysicsRadialExplosionEventData {
  132533. /**
  132534. * A sphere used for the radial explosion event
  132535. */
  132536. sphere: Mesh;
  132537. }
  132538. /**
  132539. * Interface for gravitational field event data
  132540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132541. */
  132542. export interface PhysicsGravitationalFieldEventData {
  132543. /**
  132544. * A sphere mesh used for the gravitational field event
  132545. */
  132546. sphere: Mesh;
  132547. }
  132548. /**
  132549. * Interface for updraft event data
  132550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132551. */
  132552. export interface PhysicsUpdraftEventData {
  132553. /**
  132554. * A cylinder used for the updraft event
  132555. */
  132556. cylinder: Mesh;
  132557. }
  132558. /**
  132559. * Interface for vortex event data
  132560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132561. */
  132562. export interface PhysicsVortexEventData {
  132563. /**
  132564. * A cylinder used for the vortex event
  132565. */
  132566. cylinder: Mesh;
  132567. }
  132568. /**
  132569. * Interface for an affected physics impostor
  132570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132571. */
  132572. export interface PhysicsAffectedImpostorWithData {
  132573. /**
  132574. * The impostor affected by the effect
  132575. */
  132576. impostor: PhysicsImpostor;
  132577. /**
  132578. * The data about the hit/horce from the explosion
  132579. */
  132580. hitData: PhysicsHitData;
  132581. }
  132582. }
  132583. declare module BABYLON {
  132584. /** @hidden */
  132585. export var blackAndWhitePixelShader: {
  132586. name: string;
  132587. shader: string;
  132588. };
  132589. }
  132590. declare module BABYLON {
  132591. /**
  132592. * Post process used to render in black and white
  132593. */
  132594. export class BlackAndWhitePostProcess extends PostProcess {
  132595. /**
  132596. * Linear about to convert he result to black and white (default: 1)
  132597. */
  132598. degree: number;
  132599. /**
  132600. * Creates a black and white post process
  132601. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  132602. * @param name The name of the effect.
  132603. * @param options The required width/height ratio to downsize to before computing the render pass.
  132604. * @param camera The camera to apply the render pass to.
  132605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132606. * @param engine The engine which the post process will be applied. (default: current engine)
  132607. * @param reusable If the post process can be reused on the same frame. (default: false)
  132608. */
  132609. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132610. }
  132611. }
  132612. declare module BABYLON {
  132613. /**
  132614. * This represents a set of one or more post processes in Babylon.
  132615. * A post process can be used to apply a shader to a texture after it is rendered.
  132616. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132617. */
  132618. export class PostProcessRenderEffect {
  132619. private _postProcesses;
  132620. private _getPostProcesses;
  132621. private _singleInstance;
  132622. private _cameras;
  132623. private _indicesForCamera;
  132624. /**
  132625. * Name of the effect
  132626. * @hidden
  132627. */
  132628. _name: string;
  132629. /**
  132630. * Instantiates a post process render effect.
  132631. * A post process can be used to apply a shader to a texture after it is rendered.
  132632. * @param engine The engine the effect is tied to
  132633. * @param name The name of the effect
  132634. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  132635. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  132636. */
  132637. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  132638. /**
  132639. * Checks if all the post processes in the effect are supported.
  132640. */
  132641. get isSupported(): boolean;
  132642. /**
  132643. * Updates the current state of the effect
  132644. * @hidden
  132645. */
  132646. _update(): void;
  132647. /**
  132648. * Attaches the effect on cameras
  132649. * @param cameras The camera to attach to.
  132650. * @hidden
  132651. */
  132652. _attachCameras(cameras: Camera): void;
  132653. /**
  132654. * Attaches the effect on cameras
  132655. * @param cameras The camera to attach to.
  132656. * @hidden
  132657. */
  132658. _attachCameras(cameras: Camera[]): void;
  132659. /**
  132660. * Detaches the effect on cameras
  132661. * @param cameras The camera to detatch from.
  132662. * @hidden
  132663. */
  132664. _detachCameras(cameras: Camera): void;
  132665. /**
  132666. * Detatches the effect on cameras
  132667. * @param cameras The camera to detatch from.
  132668. * @hidden
  132669. */
  132670. _detachCameras(cameras: Camera[]): void;
  132671. /**
  132672. * Enables the effect on given cameras
  132673. * @param cameras The camera to enable.
  132674. * @hidden
  132675. */
  132676. _enable(cameras: Camera): void;
  132677. /**
  132678. * Enables the effect on given cameras
  132679. * @param cameras The camera to enable.
  132680. * @hidden
  132681. */
  132682. _enable(cameras: Nullable<Camera[]>): void;
  132683. /**
  132684. * Disables the effect on the given cameras
  132685. * @param cameras The camera to disable.
  132686. * @hidden
  132687. */
  132688. _disable(cameras: Camera): void;
  132689. /**
  132690. * Disables the effect on the given cameras
  132691. * @param cameras The camera to disable.
  132692. * @hidden
  132693. */
  132694. _disable(cameras: Nullable<Camera[]>): void;
  132695. /**
  132696. * Gets a list of the post processes contained in the effect.
  132697. * @param camera The camera to get the post processes on.
  132698. * @returns The list of the post processes in the effect.
  132699. */
  132700. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  132701. }
  132702. }
  132703. declare module BABYLON {
  132704. /** @hidden */
  132705. export var extractHighlightsPixelShader: {
  132706. name: string;
  132707. shader: string;
  132708. };
  132709. }
  132710. declare module BABYLON {
  132711. /**
  132712. * 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.
  132713. */
  132714. export class ExtractHighlightsPostProcess extends PostProcess {
  132715. /**
  132716. * The luminance threshold, pixels below this value will be set to black.
  132717. */
  132718. threshold: number;
  132719. /** @hidden */
  132720. _exposure: number;
  132721. /**
  132722. * Post process which has the input texture to be used when performing highlight extraction
  132723. * @hidden
  132724. */
  132725. _inputPostProcess: Nullable<PostProcess>;
  132726. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132727. }
  132728. }
  132729. declare module BABYLON {
  132730. /** @hidden */
  132731. export var bloomMergePixelShader: {
  132732. name: string;
  132733. shader: string;
  132734. };
  132735. }
  132736. declare module BABYLON {
  132737. /**
  132738. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  132739. */
  132740. export class BloomMergePostProcess extends PostProcess {
  132741. /** Weight of the bloom to be added to the original input. */
  132742. weight: number;
  132743. /**
  132744. * Creates a new instance of @see BloomMergePostProcess
  132745. * @param name The name of the effect.
  132746. * @param originalFromInput Post process which's input will be used for the merge.
  132747. * @param blurred Blurred highlights post process which's output will be used.
  132748. * @param weight Weight of the bloom to be added to the original input.
  132749. * @param options The required width/height ratio to downsize to before computing the render pass.
  132750. * @param camera The camera to apply the render pass to.
  132751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132752. * @param engine The engine which the post process will be applied. (default: current engine)
  132753. * @param reusable If the post process can be reused on the same frame. (default: false)
  132754. * @param textureType Type of textures used when performing the post process. (default: 0)
  132755. * @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)
  132756. */
  132757. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  132758. /** Weight of the bloom to be added to the original input. */
  132759. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132760. }
  132761. }
  132762. declare module BABYLON {
  132763. /**
  132764. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  132765. */
  132766. export class BloomEffect extends PostProcessRenderEffect {
  132767. private bloomScale;
  132768. /**
  132769. * @hidden Internal
  132770. */
  132771. _effects: Array<PostProcess>;
  132772. /**
  132773. * @hidden Internal
  132774. */
  132775. _downscale: ExtractHighlightsPostProcess;
  132776. private _blurX;
  132777. private _blurY;
  132778. private _merge;
  132779. /**
  132780. * The luminance threshold to find bright areas of the image to bloom.
  132781. */
  132782. get threshold(): number;
  132783. set threshold(value: number);
  132784. /**
  132785. * The strength of the bloom.
  132786. */
  132787. get weight(): number;
  132788. set weight(value: number);
  132789. /**
  132790. * Specifies the size of the bloom blur kernel, relative to the final output size
  132791. */
  132792. get kernel(): number;
  132793. set kernel(value: number);
  132794. /**
  132795. * Creates a new instance of @see BloomEffect
  132796. * @param scene The scene the effect belongs to.
  132797. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  132798. * @param bloomKernel The size of the kernel to be used when applying the blur.
  132799. * @param bloomWeight The the strength of bloom.
  132800. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  132801. * @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)
  132802. */
  132803. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  132804. /**
  132805. * Disposes each of the internal effects for a given camera.
  132806. * @param camera The camera to dispose the effect on.
  132807. */
  132808. disposeEffects(camera: Camera): void;
  132809. /**
  132810. * @hidden Internal
  132811. */
  132812. _updateEffects(): void;
  132813. /**
  132814. * Internal
  132815. * @returns if all the contained post processes are ready.
  132816. * @hidden
  132817. */
  132818. _isReady(): boolean;
  132819. }
  132820. }
  132821. declare module BABYLON {
  132822. /** @hidden */
  132823. export var chromaticAberrationPixelShader: {
  132824. name: string;
  132825. shader: string;
  132826. };
  132827. }
  132828. declare module BABYLON {
  132829. /**
  132830. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  132831. */
  132832. export class ChromaticAberrationPostProcess extends PostProcess {
  132833. /**
  132834. * The amount of seperation of rgb channels (default: 30)
  132835. */
  132836. aberrationAmount: number;
  132837. /**
  132838. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  132839. */
  132840. radialIntensity: number;
  132841. /**
  132842. * 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))
  132843. */
  132844. direction: Vector2;
  132845. /**
  132846. * 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))
  132847. */
  132848. centerPosition: Vector2;
  132849. /**
  132850. * Creates a new instance ChromaticAberrationPostProcess
  132851. * @param name The name of the effect.
  132852. * @param screenWidth The width of the screen to apply the effect on.
  132853. * @param screenHeight The height of the screen to apply the effect on.
  132854. * @param options The required width/height ratio to downsize to before computing the render pass.
  132855. * @param camera The camera to apply the render pass to.
  132856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132857. * @param engine The engine which the post process will be applied. (default: current engine)
  132858. * @param reusable If the post process can be reused on the same frame. (default: false)
  132859. * @param textureType Type of textures used when performing the post process. (default: 0)
  132860. * @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)
  132861. */
  132862. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132863. }
  132864. }
  132865. declare module BABYLON {
  132866. /** @hidden */
  132867. export var circleOfConfusionPixelShader: {
  132868. name: string;
  132869. shader: string;
  132870. };
  132871. }
  132872. declare module BABYLON {
  132873. /**
  132874. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  132875. */
  132876. export class CircleOfConfusionPostProcess extends PostProcess {
  132877. /**
  132878. * 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.
  132879. */
  132880. lensSize: number;
  132881. /**
  132882. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  132883. */
  132884. fStop: number;
  132885. /**
  132886. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  132887. */
  132888. focusDistance: number;
  132889. /**
  132890. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  132891. */
  132892. focalLength: number;
  132893. private _depthTexture;
  132894. /**
  132895. * Creates a new instance CircleOfConfusionPostProcess
  132896. * @param name The name of the effect.
  132897. * @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.
  132898. * @param options The required width/height ratio to downsize to before computing the render pass.
  132899. * @param camera The camera to apply the render pass to.
  132900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132901. * @param engine The engine which the post process will be applied. (default: current engine)
  132902. * @param reusable If the post process can be reused on the same frame. (default: false)
  132903. * @param textureType Type of textures used when performing the post process. (default: 0)
  132904. * @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)
  132905. */
  132906. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132907. /**
  132908. * 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.
  132909. */
  132910. set depthTexture(value: RenderTargetTexture);
  132911. }
  132912. }
  132913. declare module BABYLON {
  132914. /** @hidden */
  132915. export var colorCorrectionPixelShader: {
  132916. name: string;
  132917. shader: string;
  132918. };
  132919. }
  132920. declare module BABYLON {
  132921. /**
  132922. *
  132923. * This post-process allows the modification of rendered colors by using
  132924. * a 'look-up table' (LUT). This effect is also called Color Grading.
  132925. *
  132926. * The object needs to be provided an url to a texture containing the color
  132927. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  132928. * Use an image editing software to tweak the LUT to match your needs.
  132929. *
  132930. * For an example of a color LUT, see here:
  132931. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  132932. * For explanations on color grading, see here:
  132933. * @see http://udn.epicgames.com/Three/ColorGrading.html
  132934. *
  132935. */
  132936. export class ColorCorrectionPostProcess extends PostProcess {
  132937. private _colorTableTexture;
  132938. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132939. }
  132940. }
  132941. declare module BABYLON {
  132942. /** @hidden */
  132943. export var convolutionPixelShader: {
  132944. name: string;
  132945. shader: string;
  132946. };
  132947. }
  132948. declare module BABYLON {
  132949. /**
  132950. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  132951. * input texture to perform effects such as edge detection or sharpening
  132952. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  132953. */
  132954. export class ConvolutionPostProcess extends PostProcess {
  132955. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  132956. kernel: number[];
  132957. /**
  132958. * Creates a new instance ConvolutionPostProcess
  132959. * @param name The name of the effect.
  132960. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  132961. * @param options The required width/height ratio to downsize to before computing the render pass.
  132962. * @param camera The camera to apply the render pass to.
  132963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132964. * @param engine The engine which the post process will be applied. (default: current engine)
  132965. * @param reusable If the post process can be reused on the same frame. (default: false)
  132966. * @param textureType Type of textures used when performing the post process. (default: 0)
  132967. */
  132968. constructor(name: string,
  132969. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  132970. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  132971. /**
  132972. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132973. */
  132974. static EdgeDetect0Kernel: number[];
  132975. /**
  132976. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132977. */
  132978. static EdgeDetect1Kernel: number[];
  132979. /**
  132980. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132981. */
  132982. static EdgeDetect2Kernel: number[];
  132983. /**
  132984. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132985. */
  132986. static SharpenKernel: number[];
  132987. /**
  132988. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132989. */
  132990. static EmbossKernel: number[];
  132991. /**
  132992. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  132993. */
  132994. static GaussianKernel: number[];
  132995. }
  132996. }
  132997. declare module BABYLON {
  132998. /**
  132999. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  133000. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  133001. * based on samples that have a large difference in distance than the center pixel.
  133002. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  133003. */
  133004. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  133005. direction: Vector2;
  133006. /**
  133007. * Creates a new instance CircleOfConfusionPostProcess
  133008. * @param name The name of the effect.
  133009. * @param scene The scene the effect belongs to.
  133010. * @param direction The direction the blur should be applied.
  133011. * @param kernel The size of the kernel used to blur.
  133012. * @param options The required width/height ratio to downsize to before computing the render pass.
  133013. * @param camera The camera to apply the render pass to.
  133014. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  133015. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  133016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133017. * @param engine The engine which the post process will be applied. (default: current engine)
  133018. * @param reusable If the post process can be reused on the same frame. (default: false)
  133019. * @param textureType Type of textures used when performing the post process. (default: 0)
  133020. * @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)
  133021. */
  133022. 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);
  133023. }
  133024. }
  133025. declare module BABYLON {
  133026. /** @hidden */
  133027. export var depthOfFieldMergePixelShader: {
  133028. name: string;
  133029. shader: string;
  133030. };
  133031. }
  133032. declare module BABYLON {
  133033. /**
  133034. * Options to be set when merging outputs from the default pipeline.
  133035. */
  133036. export class DepthOfFieldMergePostProcessOptions {
  133037. /**
  133038. * The original image to merge on top of
  133039. */
  133040. originalFromInput: PostProcess;
  133041. /**
  133042. * Parameters to perform the merge of the depth of field effect
  133043. */
  133044. depthOfField?: {
  133045. circleOfConfusion: PostProcess;
  133046. blurSteps: Array<PostProcess>;
  133047. };
  133048. /**
  133049. * Parameters to perform the merge of bloom effect
  133050. */
  133051. bloom?: {
  133052. blurred: PostProcess;
  133053. weight: number;
  133054. };
  133055. }
  133056. /**
  133057. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  133058. */
  133059. export class DepthOfFieldMergePostProcess extends PostProcess {
  133060. private blurSteps;
  133061. /**
  133062. * Creates a new instance of DepthOfFieldMergePostProcess
  133063. * @param name The name of the effect.
  133064. * @param originalFromInput Post process which's input will be used for the merge.
  133065. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  133066. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  133067. * @param options The required width/height ratio to downsize to before computing the render pass.
  133068. * @param camera The camera to apply the render pass to.
  133069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133070. * @param engine The engine which the post process will be applied. (default: current engine)
  133071. * @param reusable If the post process can be reused on the same frame. (default: false)
  133072. * @param textureType Type of textures used when performing the post process. (default: 0)
  133073. * @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)
  133074. */
  133075. 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);
  133076. /**
  133077. * Updates the effect with the current post process compile time values and recompiles the shader.
  133078. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  133079. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  133080. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  133081. * @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
  133082. * @param onCompiled Called when the shader has been compiled.
  133083. * @param onError Called if there is an error when compiling a shader.
  133084. */
  133085. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  133086. }
  133087. }
  133088. declare module BABYLON {
  133089. /**
  133090. * Specifies the level of max blur that should be applied when using the depth of field effect
  133091. */
  133092. export enum DepthOfFieldEffectBlurLevel {
  133093. /**
  133094. * Subtle blur
  133095. */
  133096. Low = 0,
  133097. /**
  133098. * Medium blur
  133099. */
  133100. Medium = 1,
  133101. /**
  133102. * Large blur
  133103. */
  133104. High = 2
  133105. }
  133106. /**
  133107. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  133108. */
  133109. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  133110. private _circleOfConfusion;
  133111. /**
  133112. * @hidden Internal, blurs from high to low
  133113. */
  133114. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  133115. private _depthOfFieldBlurY;
  133116. private _dofMerge;
  133117. /**
  133118. * @hidden Internal post processes in depth of field effect
  133119. */
  133120. _effects: Array<PostProcess>;
  133121. /**
  133122. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  133123. */
  133124. set focalLength(value: number);
  133125. get focalLength(): number;
  133126. /**
  133127. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133128. */
  133129. set fStop(value: number);
  133130. get fStop(): number;
  133131. /**
  133132. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133133. */
  133134. set focusDistance(value: number);
  133135. get focusDistance(): number;
  133136. /**
  133137. * 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.
  133138. */
  133139. set lensSize(value: number);
  133140. get lensSize(): number;
  133141. /**
  133142. * Creates a new instance DepthOfFieldEffect
  133143. * @param scene The scene the effect belongs to.
  133144. * @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.
  133145. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  133146. * @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)
  133147. */
  133148. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  133149. /**
  133150. * Get the current class name of the current effet
  133151. * @returns "DepthOfFieldEffect"
  133152. */
  133153. getClassName(): string;
  133154. /**
  133155. * 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.
  133156. */
  133157. set depthTexture(value: RenderTargetTexture);
  133158. /**
  133159. * Disposes each of the internal effects for a given camera.
  133160. * @param camera The camera to dispose the effect on.
  133161. */
  133162. disposeEffects(camera: Camera): void;
  133163. /**
  133164. * @hidden Internal
  133165. */
  133166. _updateEffects(): void;
  133167. /**
  133168. * Internal
  133169. * @returns if all the contained post processes are ready.
  133170. * @hidden
  133171. */
  133172. _isReady(): boolean;
  133173. }
  133174. }
  133175. declare module BABYLON {
  133176. /** @hidden */
  133177. export var displayPassPixelShader: {
  133178. name: string;
  133179. shader: string;
  133180. };
  133181. }
  133182. declare module BABYLON {
  133183. /**
  133184. * DisplayPassPostProcess which produces an output the same as it's input
  133185. */
  133186. export class DisplayPassPostProcess extends PostProcess {
  133187. /**
  133188. * Creates the DisplayPassPostProcess
  133189. * @param name The name of the effect.
  133190. * @param options The required width/height ratio to downsize to before computing the render pass.
  133191. * @param camera The camera to apply the render pass to.
  133192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133193. * @param engine The engine which the post process will be applied. (default: current engine)
  133194. * @param reusable If the post process can be reused on the same frame. (default: false)
  133195. */
  133196. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133197. }
  133198. }
  133199. declare module BABYLON {
  133200. /** @hidden */
  133201. export var filterPixelShader: {
  133202. name: string;
  133203. shader: string;
  133204. };
  133205. }
  133206. declare module BABYLON {
  133207. /**
  133208. * Applies a kernel filter to the image
  133209. */
  133210. export class FilterPostProcess extends PostProcess {
  133211. /** The matrix to be applied to the image */
  133212. kernelMatrix: Matrix;
  133213. /**
  133214. *
  133215. * @param name The name of the effect.
  133216. * @param kernelMatrix The matrix to be applied to the image
  133217. * @param options The required width/height ratio to downsize to before computing the render pass.
  133218. * @param camera The camera to apply the render pass to.
  133219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133220. * @param engine The engine which the post process will be applied. (default: current engine)
  133221. * @param reusable If the post process can be reused on the same frame. (default: false)
  133222. */
  133223. constructor(name: string,
  133224. /** The matrix to be applied to the image */
  133225. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133226. }
  133227. }
  133228. declare module BABYLON {
  133229. /** @hidden */
  133230. export var fxaaPixelShader: {
  133231. name: string;
  133232. shader: string;
  133233. };
  133234. }
  133235. declare module BABYLON {
  133236. /** @hidden */
  133237. export var fxaaVertexShader: {
  133238. name: string;
  133239. shader: string;
  133240. };
  133241. }
  133242. declare module BABYLON {
  133243. /**
  133244. * Fxaa post process
  133245. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  133246. */
  133247. export class FxaaPostProcess extends PostProcess {
  133248. /** @hidden */
  133249. texelWidth: number;
  133250. /** @hidden */
  133251. texelHeight: number;
  133252. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133253. private _getDefines;
  133254. }
  133255. }
  133256. declare module BABYLON {
  133257. /** @hidden */
  133258. export var grainPixelShader: {
  133259. name: string;
  133260. shader: string;
  133261. };
  133262. }
  133263. declare module BABYLON {
  133264. /**
  133265. * The GrainPostProcess adds noise to the image at mid luminance levels
  133266. */
  133267. export class GrainPostProcess extends PostProcess {
  133268. /**
  133269. * The intensity of the grain added (default: 30)
  133270. */
  133271. intensity: number;
  133272. /**
  133273. * If the grain should be randomized on every frame
  133274. */
  133275. animated: boolean;
  133276. /**
  133277. * Creates a new instance of @see GrainPostProcess
  133278. * @param name The name of the effect.
  133279. * @param options The required width/height ratio to downsize to before computing the render pass.
  133280. * @param camera The camera to apply the render pass to.
  133281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133282. * @param engine The engine which the post process will be applied. (default: current engine)
  133283. * @param reusable If the post process can be reused on the same frame. (default: false)
  133284. * @param textureType Type of textures used when performing the post process. (default: 0)
  133285. * @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)
  133286. */
  133287. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133288. }
  133289. }
  133290. declare module BABYLON {
  133291. /** @hidden */
  133292. export var highlightsPixelShader: {
  133293. name: string;
  133294. shader: string;
  133295. };
  133296. }
  133297. declare module BABYLON {
  133298. /**
  133299. * Extracts highlights from the image
  133300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133301. */
  133302. export class HighlightsPostProcess extends PostProcess {
  133303. /**
  133304. * Extracts highlights from the image
  133305. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133306. * @param name The name of the effect.
  133307. * @param options The required width/height ratio to downsize to before computing the render pass.
  133308. * @param camera The camera to apply the render pass to.
  133309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133310. * @param engine The engine which the post process will be applied. (default: current engine)
  133311. * @param reusable If the post process can be reused on the same frame. (default: false)
  133312. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  133313. */
  133314. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133315. }
  133316. }
  133317. declare module BABYLON {
  133318. /** @hidden */
  133319. export var mrtFragmentDeclaration: {
  133320. name: string;
  133321. shader: string;
  133322. };
  133323. }
  133324. declare module BABYLON {
  133325. /** @hidden */
  133326. export var geometryPixelShader: {
  133327. name: string;
  133328. shader: string;
  133329. };
  133330. }
  133331. declare module BABYLON {
  133332. /** @hidden */
  133333. export var geometryVertexShader: {
  133334. name: string;
  133335. shader: string;
  133336. };
  133337. }
  133338. declare module BABYLON {
  133339. /** @hidden */
  133340. interface ISavedTransformationMatrix {
  133341. world: Matrix;
  133342. viewProjection: Matrix;
  133343. }
  133344. /**
  133345. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  133346. */
  133347. export class GeometryBufferRenderer {
  133348. /**
  133349. * Constant used to retrieve the position texture index in the G-Buffer textures array
  133350. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  133351. */
  133352. static readonly POSITION_TEXTURE_TYPE: number;
  133353. /**
  133354. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  133355. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  133356. */
  133357. static readonly VELOCITY_TEXTURE_TYPE: number;
  133358. /**
  133359. * Dictionary used to store the previous transformation matrices of each rendered mesh
  133360. * in order to compute objects velocities when enableVelocity is set to "true"
  133361. * @hidden
  133362. */
  133363. _previousTransformationMatrices: {
  133364. [index: number]: ISavedTransformationMatrix;
  133365. };
  133366. /**
  133367. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  133368. * in order to compute objects velocities when enableVelocity is set to "true"
  133369. * @hidden
  133370. */
  133371. _previousBonesTransformationMatrices: {
  133372. [index: number]: Float32Array;
  133373. };
  133374. /**
  133375. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  133376. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  133377. */
  133378. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  133379. private _scene;
  133380. private _multiRenderTarget;
  133381. private _ratio;
  133382. private _enablePosition;
  133383. private _enableVelocity;
  133384. private _positionIndex;
  133385. private _velocityIndex;
  133386. protected _effect: Effect;
  133387. protected _cachedDefines: string;
  133388. /**
  133389. * Set the render list (meshes to be rendered) used in the G buffer.
  133390. */
  133391. set renderList(meshes: Mesh[]);
  133392. /**
  133393. * Gets wether or not G buffer are supported by the running hardware.
  133394. * This requires draw buffer supports
  133395. */
  133396. get isSupported(): boolean;
  133397. /**
  133398. * Returns the index of the given texture type in the G-Buffer textures array
  133399. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  133400. * @returns the index of the given texture type in the G-Buffer textures array
  133401. */
  133402. getTextureIndex(textureType: number): number;
  133403. /**
  133404. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  133405. */
  133406. get enablePosition(): boolean;
  133407. /**
  133408. * Sets whether or not objects positions are enabled for the G buffer.
  133409. */
  133410. set enablePosition(enable: boolean);
  133411. /**
  133412. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  133413. */
  133414. get enableVelocity(): boolean;
  133415. /**
  133416. * Sets wether or not objects velocities are enabled for the G buffer.
  133417. */
  133418. set enableVelocity(enable: boolean);
  133419. /**
  133420. * Gets the scene associated with the buffer.
  133421. */
  133422. get scene(): Scene;
  133423. /**
  133424. * Gets the ratio used by the buffer during its creation.
  133425. * How big is the buffer related to the main canvas.
  133426. */
  133427. get ratio(): number;
  133428. /** @hidden */
  133429. static _SceneComponentInitialization: (scene: Scene) => void;
  133430. /**
  133431. * Creates a new G Buffer for the scene
  133432. * @param scene The scene the buffer belongs to
  133433. * @param ratio How big is the buffer related to the main canvas.
  133434. */
  133435. constructor(scene: Scene, ratio?: number);
  133436. /**
  133437. * Checks wether everything is ready to render a submesh to the G buffer.
  133438. * @param subMesh the submesh to check readiness for
  133439. * @param useInstances is the mesh drawn using instance or not
  133440. * @returns true if ready otherwise false
  133441. */
  133442. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133443. /**
  133444. * Gets the current underlying G Buffer.
  133445. * @returns the buffer
  133446. */
  133447. getGBuffer(): MultiRenderTarget;
  133448. /**
  133449. * Gets the number of samples used to render the buffer (anti aliasing).
  133450. */
  133451. get samples(): number;
  133452. /**
  133453. * Sets the number of samples used to render the buffer (anti aliasing).
  133454. */
  133455. set samples(value: number);
  133456. /**
  133457. * Disposes the renderer and frees up associated resources.
  133458. */
  133459. dispose(): void;
  133460. protected _createRenderTargets(): void;
  133461. private _copyBonesTransformationMatrices;
  133462. }
  133463. }
  133464. declare module BABYLON {
  133465. interface Scene {
  133466. /** @hidden (Backing field) */
  133467. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133468. /**
  133469. * Gets or Sets the current geometry buffer associated to the scene.
  133470. */
  133471. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133472. /**
  133473. * Enables a GeometryBufferRender and associates it with the scene
  133474. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  133475. * @returns the GeometryBufferRenderer
  133476. */
  133477. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  133478. /**
  133479. * Disables the GeometryBufferRender associated with the scene
  133480. */
  133481. disableGeometryBufferRenderer(): void;
  133482. }
  133483. /**
  133484. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  133485. * in several rendering techniques.
  133486. */
  133487. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  133488. /**
  133489. * The component name helpful to identify the component in the list of scene components.
  133490. */
  133491. readonly name: string;
  133492. /**
  133493. * The scene the component belongs to.
  133494. */
  133495. scene: Scene;
  133496. /**
  133497. * Creates a new instance of the component for the given scene
  133498. * @param scene Defines the scene to register the component in
  133499. */
  133500. constructor(scene: Scene);
  133501. /**
  133502. * Registers the component in a given scene
  133503. */
  133504. register(): void;
  133505. /**
  133506. * Rebuilds the elements related to this component in case of
  133507. * context lost for instance.
  133508. */
  133509. rebuild(): void;
  133510. /**
  133511. * Disposes the component and the associated ressources
  133512. */
  133513. dispose(): void;
  133514. private _gatherRenderTargets;
  133515. }
  133516. }
  133517. declare module BABYLON {
  133518. /** @hidden */
  133519. export var motionBlurPixelShader: {
  133520. name: string;
  133521. shader: string;
  133522. };
  133523. }
  133524. declare module BABYLON {
  133525. /**
  133526. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  133527. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  133528. * As an example, all you have to do is to create the post-process:
  133529. * var mb = new BABYLON.MotionBlurPostProcess(
  133530. * 'mb', // The name of the effect.
  133531. * scene, // The scene containing the objects to blur according to their velocity.
  133532. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  133533. * camera // The camera to apply the render pass to.
  133534. * );
  133535. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  133536. */
  133537. export class MotionBlurPostProcess extends PostProcess {
  133538. /**
  133539. * Defines how much the image is blurred by the movement. Default value is equal to 1
  133540. */
  133541. motionStrength: number;
  133542. /**
  133543. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  133544. */
  133545. get motionBlurSamples(): number;
  133546. /**
  133547. * Sets the number of iterations to be used for motion blur quality
  133548. */
  133549. set motionBlurSamples(samples: number);
  133550. private _motionBlurSamples;
  133551. private _geometryBufferRenderer;
  133552. /**
  133553. * Creates a new instance MotionBlurPostProcess
  133554. * @param name The name of the effect.
  133555. * @param scene The scene containing the objects to blur according to their velocity.
  133556. * @param options The required width/height ratio to downsize to before computing the render pass.
  133557. * @param camera The camera to apply the render pass to.
  133558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133559. * @param engine The engine which the post process will be applied. (default: current engine)
  133560. * @param reusable If the post process can be reused on the same frame. (default: false)
  133561. * @param textureType Type of textures used when performing the post process. (default: 0)
  133562. * @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)
  133563. */
  133564. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133565. /**
  133566. * Excludes the given skinned mesh from computing bones velocities.
  133567. * 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.
  133568. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  133569. */
  133570. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133571. /**
  133572. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  133573. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  133574. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  133575. */
  133576. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133577. /**
  133578. * Disposes the post process.
  133579. * @param camera The camera to dispose the post process on.
  133580. */
  133581. dispose(camera?: Camera): void;
  133582. }
  133583. }
  133584. declare module BABYLON {
  133585. /** @hidden */
  133586. export var refractionPixelShader: {
  133587. name: string;
  133588. shader: string;
  133589. };
  133590. }
  133591. declare module BABYLON {
  133592. /**
  133593. * Post process which applies a refractin texture
  133594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133595. */
  133596. export class RefractionPostProcess extends PostProcess {
  133597. /** the base color of the refraction (used to taint the rendering) */
  133598. color: Color3;
  133599. /** simulated refraction depth */
  133600. depth: number;
  133601. /** the coefficient of the base color (0 to remove base color tainting) */
  133602. colorLevel: number;
  133603. private _refTexture;
  133604. private _ownRefractionTexture;
  133605. /**
  133606. * Gets or sets the refraction texture
  133607. * Please note that you are responsible for disposing the texture if you set it manually
  133608. */
  133609. get refractionTexture(): Texture;
  133610. set refractionTexture(value: Texture);
  133611. /**
  133612. * Initializes the RefractionPostProcess
  133613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133614. * @param name The name of the effect.
  133615. * @param refractionTextureUrl Url of the refraction texture to use
  133616. * @param color the base color of the refraction (used to taint the rendering)
  133617. * @param depth simulated refraction depth
  133618. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  133619. * @param camera The camera to apply the render pass to.
  133620. * @param options The required width/height ratio to downsize to before computing the render pass.
  133621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133622. * @param engine The engine which the post process will be applied. (default: current engine)
  133623. * @param reusable If the post process can be reused on the same frame. (default: false)
  133624. */
  133625. constructor(name: string, refractionTextureUrl: string,
  133626. /** the base color of the refraction (used to taint the rendering) */
  133627. color: Color3,
  133628. /** simulated refraction depth */
  133629. depth: number,
  133630. /** the coefficient of the base color (0 to remove base color tainting) */
  133631. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133632. /**
  133633. * Disposes of the post process
  133634. * @param camera Camera to dispose post process on
  133635. */
  133636. dispose(camera: Camera): void;
  133637. }
  133638. }
  133639. declare module BABYLON {
  133640. /** @hidden */
  133641. export var sharpenPixelShader: {
  133642. name: string;
  133643. shader: string;
  133644. };
  133645. }
  133646. declare module BABYLON {
  133647. /**
  133648. * The SharpenPostProcess applies a sharpen kernel to every pixel
  133649. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133650. */
  133651. export class SharpenPostProcess extends PostProcess {
  133652. /**
  133653. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  133654. */
  133655. colorAmount: number;
  133656. /**
  133657. * How much sharpness should be applied (default: 0.3)
  133658. */
  133659. edgeAmount: number;
  133660. /**
  133661. * Creates a new instance ConvolutionPostProcess
  133662. * @param name The name of the effect.
  133663. * @param options The required width/height ratio to downsize to before computing the render pass.
  133664. * @param camera The camera to apply the render pass to.
  133665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133666. * @param engine The engine which the post process will be applied. (default: current engine)
  133667. * @param reusable If the post process can be reused on the same frame. (default: false)
  133668. * @param textureType Type of textures used when performing the post process. (default: 0)
  133669. * @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)
  133670. */
  133671. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133672. }
  133673. }
  133674. declare module BABYLON {
  133675. /**
  133676. * PostProcessRenderPipeline
  133677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133678. */
  133679. export class PostProcessRenderPipeline {
  133680. private engine;
  133681. private _renderEffects;
  133682. private _renderEffectsForIsolatedPass;
  133683. /**
  133684. * List of inspectable custom properties (used by the Inspector)
  133685. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  133686. */
  133687. inspectableCustomProperties: IInspectable[];
  133688. /**
  133689. * @hidden
  133690. */
  133691. protected _cameras: Camera[];
  133692. /** @hidden */
  133693. _name: string;
  133694. /**
  133695. * Gets pipeline name
  133696. */
  133697. get name(): string;
  133698. /** Gets the list of attached cameras */
  133699. get cameras(): Camera[];
  133700. /**
  133701. * Initializes a PostProcessRenderPipeline
  133702. * @param engine engine to add the pipeline to
  133703. * @param name name of the pipeline
  133704. */
  133705. constructor(engine: Engine, name: string);
  133706. /**
  133707. * Gets the class name
  133708. * @returns "PostProcessRenderPipeline"
  133709. */
  133710. getClassName(): string;
  133711. /**
  133712. * If all the render effects in the pipeline are supported
  133713. */
  133714. get isSupported(): boolean;
  133715. /**
  133716. * Adds an effect to the pipeline
  133717. * @param renderEffect the effect to add
  133718. */
  133719. addEffect(renderEffect: PostProcessRenderEffect): void;
  133720. /** @hidden */
  133721. _rebuild(): void;
  133722. /** @hidden */
  133723. _enableEffect(renderEffectName: string, cameras: Camera): void;
  133724. /** @hidden */
  133725. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  133726. /** @hidden */
  133727. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133728. /** @hidden */
  133729. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133730. /** @hidden */
  133731. _attachCameras(cameras: Camera, unique: boolean): void;
  133732. /** @hidden */
  133733. _attachCameras(cameras: Camera[], unique: boolean): void;
  133734. /** @hidden */
  133735. _detachCameras(cameras: Camera): void;
  133736. /** @hidden */
  133737. _detachCameras(cameras: Nullable<Camera[]>): void;
  133738. /** @hidden */
  133739. _update(): void;
  133740. /** @hidden */
  133741. _reset(): void;
  133742. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  133743. /**
  133744. * Disposes of the pipeline
  133745. */
  133746. dispose(): void;
  133747. }
  133748. }
  133749. declare module BABYLON {
  133750. /**
  133751. * PostProcessRenderPipelineManager class
  133752. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133753. */
  133754. export class PostProcessRenderPipelineManager {
  133755. private _renderPipelines;
  133756. /**
  133757. * Initializes a PostProcessRenderPipelineManager
  133758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133759. */
  133760. constructor();
  133761. /**
  133762. * Gets the list of supported render pipelines
  133763. */
  133764. get supportedPipelines(): PostProcessRenderPipeline[];
  133765. /**
  133766. * Adds a pipeline to the manager
  133767. * @param renderPipeline The pipeline to add
  133768. */
  133769. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  133770. /**
  133771. * Attaches a camera to the pipeline
  133772. * @param renderPipelineName The name of the pipeline to attach to
  133773. * @param cameras the camera to attach
  133774. * @param unique if the camera can be attached multiple times to the pipeline
  133775. */
  133776. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  133777. /**
  133778. * Detaches a camera from the pipeline
  133779. * @param renderPipelineName The name of the pipeline to detach from
  133780. * @param cameras the camera to detach
  133781. */
  133782. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  133783. /**
  133784. * Enables an effect by name on a pipeline
  133785. * @param renderPipelineName the name of the pipeline to enable the effect in
  133786. * @param renderEffectName the name of the effect to enable
  133787. * @param cameras the cameras that the effect should be enabled on
  133788. */
  133789. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133790. /**
  133791. * Disables an effect by name on a pipeline
  133792. * @param renderPipelineName the name of the pipeline to disable the effect in
  133793. * @param renderEffectName the name of the effect to disable
  133794. * @param cameras the cameras that the effect should be disabled on
  133795. */
  133796. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133797. /**
  133798. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  133799. */
  133800. update(): void;
  133801. /** @hidden */
  133802. _rebuild(): void;
  133803. /**
  133804. * Disposes of the manager and pipelines
  133805. */
  133806. dispose(): void;
  133807. }
  133808. }
  133809. declare module BABYLON {
  133810. interface Scene {
  133811. /** @hidden (Backing field) */
  133812. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133813. /**
  133814. * Gets the postprocess render pipeline manager
  133815. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133816. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133817. */
  133818. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133819. }
  133820. /**
  133821. * Defines the Render Pipeline scene component responsible to rendering pipelines
  133822. */
  133823. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  133824. /**
  133825. * The component name helpfull to identify the component in the list of scene components.
  133826. */
  133827. readonly name: string;
  133828. /**
  133829. * The scene the component belongs to.
  133830. */
  133831. scene: Scene;
  133832. /**
  133833. * Creates a new instance of the component for the given scene
  133834. * @param scene Defines the scene to register the component in
  133835. */
  133836. constructor(scene: Scene);
  133837. /**
  133838. * Registers the component in a given scene
  133839. */
  133840. register(): void;
  133841. /**
  133842. * Rebuilds the elements related to this component in case of
  133843. * context lost for instance.
  133844. */
  133845. rebuild(): void;
  133846. /**
  133847. * Disposes the component and the associated ressources
  133848. */
  133849. dispose(): void;
  133850. private _gatherRenderTargets;
  133851. }
  133852. }
  133853. declare module BABYLON {
  133854. /**
  133855. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  133856. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133857. */
  133858. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  133859. private _scene;
  133860. private _camerasToBeAttached;
  133861. /**
  133862. * ID of the sharpen post process,
  133863. */
  133864. private readonly SharpenPostProcessId;
  133865. /**
  133866. * @ignore
  133867. * ID of the image processing post process;
  133868. */
  133869. readonly ImageProcessingPostProcessId: string;
  133870. /**
  133871. * @ignore
  133872. * ID of the Fast Approximate Anti-Aliasing post process;
  133873. */
  133874. readonly FxaaPostProcessId: string;
  133875. /**
  133876. * ID of the chromatic aberration post process,
  133877. */
  133878. private readonly ChromaticAberrationPostProcessId;
  133879. /**
  133880. * ID of the grain post process
  133881. */
  133882. private readonly GrainPostProcessId;
  133883. /**
  133884. * Sharpen post process which will apply a sharpen convolution to enhance edges
  133885. */
  133886. sharpen: SharpenPostProcess;
  133887. private _sharpenEffect;
  133888. private bloom;
  133889. /**
  133890. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  133891. */
  133892. depthOfField: DepthOfFieldEffect;
  133893. /**
  133894. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  133895. */
  133896. fxaa: FxaaPostProcess;
  133897. /**
  133898. * Image post processing pass used to perform operations such as tone mapping or color grading.
  133899. */
  133900. imageProcessing: ImageProcessingPostProcess;
  133901. /**
  133902. * Chromatic aberration post process which will shift rgb colors in the image
  133903. */
  133904. chromaticAberration: ChromaticAberrationPostProcess;
  133905. private _chromaticAberrationEffect;
  133906. /**
  133907. * Grain post process which add noise to the image
  133908. */
  133909. grain: GrainPostProcess;
  133910. private _grainEffect;
  133911. /**
  133912. * Glow post process which adds a glow to emissive areas of the image
  133913. */
  133914. private _glowLayer;
  133915. /**
  133916. * Animations which can be used to tweak settings over a period of time
  133917. */
  133918. animations: Animation[];
  133919. private _imageProcessingConfigurationObserver;
  133920. private _sharpenEnabled;
  133921. private _bloomEnabled;
  133922. private _depthOfFieldEnabled;
  133923. private _depthOfFieldBlurLevel;
  133924. private _fxaaEnabled;
  133925. private _imageProcessingEnabled;
  133926. private _defaultPipelineTextureType;
  133927. private _bloomScale;
  133928. private _chromaticAberrationEnabled;
  133929. private _grainEnabled;
  133930. private _buildAllowed;
  133931. /**
  133932. * Gets active scene
  133933. */
  133934. get scene(): Scene;
  133935. /**
  133936. * Enable or disable the sharpen process from the pipeline
  133937. */
  133938. set sharpenEnabled(enabled: boolean);
  133939. get sharpenEnabled(): boolean;
  133940. private _resizeObserver;
  133941. private _hardwareScaleLevel;
  133942. private _bloomKernel;
  133943. /**
  133944. * Specifies the size of the bloom blur kernel, relative to the final output size
  133945. */
  133946. get bloomKernel(): number;
  133947. set bloomKernel(value: number);
  133948. /**
  133949. * Specifies the weight of the bloom in the final rendering
  133950. */
  133951. private _bloomWeight;
  133952. /**
  133953. * Specifies the luma threshold for the area that will be blurred by the bloom
  133954. */
  133955. private _bloomThreshold;
  133956. private _hdr;
  133957. /**
  133958. * The strength of the bloom.
  133959. */
  133960. set bloomWeight(value: number);
  133961. get bloomWeight(): number;
  133962. /**
  133963. * The strength of the bloom.
  133964. */
  133965. set bloomThreshold(value: number);
  133966. get bloomThreshold(): number;
  133967. /**
  133968. * The scale of the bloom, lower value will provide better performance.
  133969. */
  133970. set bloomScale(value: number);
  133971. get bloomScale(): number;
  133972. /**
  133973. * Enable or disable the bloom from the pipeline
  133974. */
  133975. set bloomEnabled(enabled: boolean);
  133976. get bloomEnabled(): boolean;
  133977. private _rebuildBloom;
  133978. /**
  133979. * If the depth of field is enabled.
  133980. */
  133981. get depthOfFieldEnabled(): boolean;
  133982. set depthOfFieldEnabled(enabled: boolean);
  133983. /**
  133984. * Blur level of the depth of field effect. (Higher blur will effect performance)
  133985. */
  133986. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  133987. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  133988. /**
  133989. * If the anti aliasing is enabled.
  133990. */
  133991. set fxaaEnabled(enabled: boolean);
  133992. get fxaaEnabled(): boolean;
  133993. private _samples;
  133994. /**
  133995. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  133996. */
  133997. set samples(sampleCount: number);
  133998. get samples(): number;
  133999. /**
  134000. * If image processing is enabled.
  134001. */
  134002. set imageProcessingEnabled(enabled: boolean);
  134003. get imageProcessingEnabled(): boolean;
  134004. /**
  134005. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  134006. */
  134007. set glowLayerEnabled(enabled: boolean);
  134008. get glowLayerEnabled(): boolean;
  134009. /**
  134010. * Gets the glow layer (or null if not defined)
  134011. */
  134012. get glowLayer(): Nullable<GlowLayer>;
  134013. /**
  134014. * Enable or disable the chromaticAberration process from the pipeline
  134015. */
  134016. set chromaticAberrationEnabled(enabled: boolean);
  134017. get chromaticAberrationEnabled(): boolean;
  134018. /**
  134019. * Enable or disable the grain process from the pipeline
  134020. */
  134021. set grainEnabled(enabled: boolean);
  134022. get grainEnabled(): boolean;
  134023. /**
  134024. * @constructor
  134025. * @param name - The rendering pipeline name (default: "")
  134026. * @param hdr - If high dynamic range textures should be used (default: true)
  134027. * @param scene - The scene linked to this pipeline (default: the last created scene)
  134028. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  134029. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  134030. */
  134031. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  134032. /**
  134033. * Get the class name
  134034. * @returns "DefaultRenderingPipeline"
  134035. */
  134036. getClassName(): string;
  134037. /**
  134038. * Force the compilation of the entire pipeline.
  134039. */
  134040. prepare(): void;
  134041. private _hasCleared;
  134042. private _prevPostProcess;
  134043. private _prevPrevPostProcess;
  134044. private _setAutoClearAndTextureSharing;
  134045. private _depthOfFieldSceneObserver;
  134046. private _buildPipeline;
  134047. private _disposePostProcesses;
  134048. /**
  134049. * Adds a camera to the pipeline
  134050. * @param camera the camera to be added
  134051. */
  134052. addCamera(camera: Camera): void;
  134053. /**
  134054. * Removes a camera from the pipeline
  134055. * @param camera the camera to remove
  134056. */
  134057. removeCamera(camera: Camera): void;
  134058. /**
  134059. * Dispose of the pipeline and stop all post processes
  134060. */
  134061. dispose(): void;
  134062. /**
  134063. * Serialize the rendering pipeline (Used when exporting)
  134064. * @returns the serialized object
  134065. */
  134066. serialize(): any;
  134067. /**
  134068. * Parse the serialized pipeline
  134069. * @param source Source pipeline.
  134070. * @param scene The scene to load the pipeline to.
  134071. * @param rootUrl The URL of the serialized pipeline.
  134072. * @returns An instantiated pipeline from the serialized object.
  134073. */
  134074. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  134075. }
  134076. }
  134077. declare module BABYLON {
  134078. /** @hidden */
  134079. export var lensHighlightsPixelShader: {
  134080. name: string;
  134081. shader: string;
  134082. };
  134083. }
  134084. declare module BABYLON {
  134085. /** @hidden */
  134086. export var depthOfFieldPixelShader: {
  134087. name: string;
  134088. shader: string;
  134089. };
  134090. }
  134091. declare module BABYLON {
  134092. /**
  134093. * BABYLON.JS Chromatic Aberration GLSL Shader
  134094. * Author: Olivier Guyot
  134095. * Separates very slightly R, G and B colors on the edges of the screen
  134096. * Inspired by Francois Tarlier & Martins Upitis
  134097. */
  134098. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  134099. /**
  134100. * @ignore
  134101. * The chromatic aberration PostProcess id in the pipeline
  134102. */
  134103. LensChromaticAberrationEffect: string;
  134104. /**
  134105. * @ignore
  134106. * The highlights enhancing PostProcess id in the pipeline
  134107. */
  134108. HighlightsEnhancingEffect: string;
  134109. /**
  134110. * @ignore
  134111. * The depth-of-field PostProcess id in the pipeline
  134112. */
  134113. LensDepthOfFieldEffect: string;
  134114. private _scene;
  134115. private _depthTexture;
  134116. private _grainTexture;
  134117. private _chromaticAberrationPostProcess;
  134118. private _highlightsPostProcess;
  134119. private _depthOfFieldPostProcess;
  134120. private _edgeBlur;
  134121. private _grainAmount;
  134122. private _chromaticAberration;
  134123. private _distortion;
  134124. private _highlightsGain;
  134125. private _highlightsThreshold;
  134126. private _dofDistance;
  134127. private _dofAperture;
  134128. private _dofDarken;
  134129. private _dofPentagon;
  134130. private _blurNoise;
  134131. /**
  134132. * @constructor
  134133. *
  134134. * Effect parameters are as follow:
  134135. * {
  134136. * chromatic_aberration: number; // from 0 to x (1 for realism)
  134137. * edge_blur: number; // from 0 to x (1 for realism)
  134138. * distortion: number; // from 0 to x (1 for realism)
  134139. * grain_amount: number; // from 0 to 1
  134140. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  134141. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  134142. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  134143. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  134144. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  134145. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  134146. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  134147. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  134148. * }
  134149. * Note: if an effect parameter is unset, effect is disabled
  134150. *
  134151. * @param name The rendering pipeline name
  134152. * @param parameters - An object containing all parameters (see above)
  134153. * @param scene The scene linked to this pipeline
  134154. * @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)
  134155. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134156. */
  134157. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  134158. /**
  134159. * Get the class name
  134160. * @returns "LensRenderingPipeline"
  134161. */
  134162. getClassName(): string;
  134163. /**
  134164. * Gets associated scene
  134165. */
  134166. get scene(): Scene;
  134167. /**
  134168. * Gets or sets the edge blur
  134169. */
  134170. get edgeBlur(): number;
  134171. set edgeBlur(value: number);
  134172. /**
  134173. * Gets or sets the grain amount
  134174. */
  134175. get grainAmount(): number;
  134176. set grainAmount(value: number);
  134177. /**
  134178. * Gets or sets the chromatic aberration amount
  134179. */
  134180. get chromaticAberration(): number;
  134181. set chromaticAberration(value: number);
  134182. /**
  134183. * Gets or sets the depth of field aperture
  134184. */
  134185. get dofAperture(): number;
  134186. set dofAperture(value: number);
  134187. /**
  134188. * Gets or sets the edge distortion
  134189. */
  134190. get edgeDistortion(): number;
  134191. set edgeDistortion(value: number);
  134192. /**
  134193. * Gets or sets the depth of field distortion
  134194. */
  134195. get dofDistortion(): number;
  134196. set dofDistortion(value: number);
  134197. /**
  134198. * Gets or sets the darken out of focus amount
  134199. */
  134200. get darkenOutOfFocus(): number;
  134201. set darkenOutOfFocus(value: number);
  134202. /**
  134203. * Gets or sets a boolean indicating if blur noise is enabled
  134204. */
  134205. get blurNoise(): boolean;
  134206. set blurNoise(value: boolean);
  134207. /**
  134208. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  134209. */
  134210. get pentagonBokeh(): boolean;
  134211. set pentagonBokeh(value: boolean);
  134212. /**
  134213. * Gets or sets the highlight grain amount
  134214. */
  134215. get highlightsGain(): number;
  134216. set highlightsGain(value: number);
  134217. /**
  134218. * Gets or sets the highlight threshold
  134219. */
  134220. get highlightsThreshold(): number;
  134221. set highlightsThreshold(value: number);
  134222. /**
  134223. * Sets the amount of blur at the edges
  134224. * @param amount blur amount
  134225. */
  134226. setEdgeBlur(amount: number): void;
  134227. /**
  134228. * Sets edge blur to 0
  134229. */
  134230. disableEdgeBlur(): void;
  134231. /**
  134232. * Sets the amout of grain
  134233. * @param amount Amount of grain
  134234. */
  134235. setGrainAmount(amount: number): void;
  134236. /**
  134237. * Set grain amount to 0
  134238. */
  134239. disableGrain(): void;
  134240. /**
  134241. * Sets the chromatic aberration amount
  134242. * @param amount amount of chromatic aberration
  134243. */
  134244. setChromaticAberration(amount: number): void;
  134245. /**
  134246. * Sets chromatic aberration amount to 0
  134247. */
  134248. disableChromaticAberration(): void;
  134249. /**
  134250. * Sets the EdgeDistortion amount
  134251. * @param amount amount of EdgeDistortion
  134252. */
  134253. setEdgeDistortion(amount: number): void;
  134254. /**
  134255. * Sets edge distortion to 0
  134256. */
  134257. disableEdgeDistortion(): void;
  134258. /**
  134259. * Sets the FocusDistance amount
  134260. * @param amount amount of FocusDistance
  134261. */
  134262. setFocusDistance(amount: number): void;
  134263. /**
  134264. * Disables depth of field
  134265. */
  134266. disableDepthOfField(): void;
  134267. /**
  134268. * Sets the Aperture amount
  134269. * @param amount amount of Aperture
  134270. */
  134271. setAperture(amount: number): void;
  134272. /**
  134273. * Sets the DarkenOutOfFocus amount
  134274. * @param amount amount of DarkenOutOfFocus
  134275. */
  134276. setDarkenOutOfFocus(amount: number): void;
  134277. private _pentagonBokehIsEnabled;
  134278. /**
  134279. * Creates a pentagon bokeh effect
  134280. */
  134281. enablePentagonBokeh(): void;
  134282. /**
  134283. * Disables the pentagon bokeh effect
  134284. */
  134285. disablePentagonBokeh(): void;
  134286. /**
  134287. * Enables noise blur
  134288. */
  134289. enableNoiseBlur(): void;
  134290. /**
  134291. * Disables noise blur
  134292. */
  134293. disableNoiseBlur(): void;
  134294. /**
  134295. * Sets the HighlightsGain amount
  134296. * @param amount amount of HighlightsGain
  134297. */
  134298. setHighlightsGain(amount: number): void;
  134299. /**
  134300. * Sets the HighlightsThreshold amount
  134301. * @param amount amount of HighlightsThreshold
  134302. */
  134303. setHighlightsThreshold(amount: number): void;
  134304. /**
  134305. * Disables highlights
  134306. */
  134307. disableHighlights(): void;
  134308. /**
  134309. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  134310. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  134311. */
  134312. dispose(disableDepthRender?: boolean): void;
  134313. private _createChromaticAberrationPostProcess;
  134314. private _createHighlightsPostProcess;
  134315. private _createDepthOfFieldPostProcess;
  134316. private _createGrainTexture;
  134317. }
  134318. }
  134319. declare module BABYLON {
  134320. /** @hidden */
  134321. export var ssao2PixelShader: {
  134322. name: string;
  134323. shader: string;
  134324. };
  134325. }
  134326. declare module BABYLON {
  134327. /** @hidden */
  134328. export var ssaoCombinePixelShader: {
  134329. name: string;
  134330. shader: string;
  134331. };
  134332. }
  134333. declare module BABYLON {
  134334. /**
  134335. * Render pipeline to produce ssao effect
  134336. */
  134337. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  134338. /**
  134339. * @ignore
  134340. * The PassPostProcess id in the pipeline that contains the original scene color
  134341. */
  134342. SSAOOriginalSceneColorEffect: string;
  134343. /**
  134344. * @ignore
  134345. * The SSAO PostProcess id in the pipeline
  134346. */
  134347. SSAORenderEffect: string;
  134348. /**
  134349. * @ignore
  134350. * The horizontal blur PostProcess id in the pipeline
  134351. */
  134352. SSAOBlurHRenderEffect: string;
  134353. /**
  134354. * @ignore
  134355. * The vertical blur PostProcess id in the pipeline
  134356. */
  134357. SSAOBlurVRenderEffect: string;
  134358. /**
  134359. * @ignore
  134360. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134361. */
  134362. SSAOCombineRenderEffect: string;
  134363. /**
  134364. * The output strength of the SSAO post-process. Default value is 1.0.
  134365. */
  134366. totalStrength: number;
  134367. /**
  134368. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  134369. */
  134370. maxZ: number;
  134371. /**
  134372. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  134373. */
  134374. minZAspect: number;
  134375. private _samples;
  134376. /**
  134377. * Number of samples used for the SSAO calculations. Default value is 8
  134378. */
  134379. set samples(n: number);
  134380. get samples(): number;
  134381. private _textureSamples;
  134382. /**
  134383. * Number of samples to use for antialiasing
  134384. */
  134385. set textureSamples(n: number);
  134386. get textureSamples(): number;
  134387. /**
  134388. * Ratio object used for SSAO ratio and blur ratio
  134389. */
  134390. private _ratio;
  134391. /**
  134392. * Dynamically generated sphere sampler.
  134393. */
  134394. private _sampleSphere;
  134395. /**
  134396. * Blur filter offsets
  134397. */
  134398. private _samplerOffsets;
  134399. private _expensiveBlur;
  134400. /**
  134401. * If bilateral blur should be used
  134402. */
  134403. set expensiveBlur(b: boolean);
  134404. get expensiveBlur(): boolean;
  134405. /**
  134406. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  134407. */
  134408. radius: number;
  134409. /**
  134410. * The base color of the SSAO post-process
  134411. * The final result is "base + ssao" between [0, 1]
  134412. */
  134413. base: number;
  134414. /**
  134415. * Support test.
  134416. */
  134417. static get IsSupported(): boolean;
  134418. private _scene;
  134419. private _depthTexture;
  134420. private _normalTexture;
  134421. private _randomTexture;
  134422. private _originalColorPostProcess;
  134423. private _ssaoPostProcess;
  134424. private _blurHPostProcess;
  134425. private _blurVPostProcess;
  134426. private _ssaoCombinePostProcess;
  134427. /**
  134428. * Gets active scene
  134429. */
  134430. get scene(): Scene;
  134431. /**
  134432. * @constructor
  134433. * @param name The rendering pipeline name
  134434. * @param scene The scene linked to this pipeline
  134435. * @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 }
  134436. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134437. */
  134438. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134439. /**
  134440. * Get the class name
  134441. * @returns "SSAO2RenderingPipeline"
  134442. */
  134443. getClassName(): string;
  134444. /**
  134445. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134446. */
  134447. dispose(disableGeometryBufferRenderer?: boolean): void;
  134448. private _createBlurPostProcess;
  134449. /** @hidden */
  134450. _rebuild(): void;
  134451. private _bits;
  134452. private _radicalInverse_VdC;
  134453. private _hammersley;
  134454. private _hemisphereSample_uniform;
  134455. private _generateHemisphere;
  134456. private _createSSAOPostProcess;
  134457. private _createSSAOCombinePostProcess;
  134458. private _createRandomTexture;
  134459. /**
  134460. * Serialize the rendering pipeline (Used when exporting)
  134461. * @returns the serialized object
  134462. */
  134463. serialize(): any;
  134464. /**
  134465. * Parse the serialized pipeline
  134466. * @param source Source pipeline.
  134467. * @param scene The scene to load the pipeline to.
  134468. * @param rootUrl The URL of the serialized pipeline.
  134469. * @returns An instantiated pipeline from the serialized object.
  134470. */
  134471. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  134472. }
  134473. }
  134474. declare module BABYLON {
  134475. /** @hidden */
  134476. export var ssaoPixelShader: {
  134477. name: string;
  134478. shader: string;
  134479. };
  134480. }
  134481. declare module BABYLON {
  134482. /**
  134483. * Render pipeline to produce ssao effect
  134484. */
  134485. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  134486. /**
  134487. * @ignore
  134488. * The PassPostProcess id in the pipeline that contains the original scene color
  134489. */
  134490. SSAOOriginalSceneColorEffect: string;
  134491. /**
  134492. * @ignore
  134493. * The SSAO PostProcess id in the pipeline
  134494. */
  134495. SSAORenderEffect: string;
  134496. /**
  134497. * @ignore
  134498. * The horizontal blur PostProcess id in the pipeline
  134499. */
  134500. SSAOBlurHRenderEffect: string;
  134501. /**
  134502. * @ignore
  134503. * The vertical blur PostProcess id in the pipeline
  134504. */
  134505. SSAOBlurVRenderEffect: string;
  134506. /**
  134507. * @ignore
  134508. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134509. */
  134510. SSAOCombineRenderEffect: string;
  134511. /**
  134512. * The output strength of the SSAO post-process. Default value is 1.0.
  134513. */
  134514. totalStrength: number;
  134515. /**
  134516. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  134517. */
  134518. radius: number;
  134519. /**
  134520. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  134521. * Must not be equal to fallOff and superior to fallOff.
  134522. * Default value is 0.0075
  134523. */
  134524. area: number;
  134525. /**
  134526. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  134527. * Must not be equal to area and inferior to area.
  134528. * Default value is 0.000001
  134529. */
  134530. fallOff: number;
  134531. /**
  134532. * The base color of the SSAO post-process
  134533. * The final result is "base + ssao" between [0, 1]
  134534. */
  134535. base: number;
  134536. private _scene;
  134537. private _depthTexture;
  134538. private _randomTexture;
  134539. private _originalColorPostProcess;
  134540. private _ssaoPostProcess;
  134541. private _blurHPostProcess;
  134542. private _blurVPostProcess;
  134543. private _ssaoCombinePostProcess;
  134544. private _firstUpdate;
  134545. /**
  134546. * Gets active scene
  134547. */
  134548. get scene(): Scene;
  134549. /**
  134550. * @constructor
  134551. * @param name - The rendering pipeline name
  134552. * @param scene - The scene linked to this pipeline
  134553. * @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 }
  134554. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  134555. */
  134556. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134557. /**
  134558. * Get the class name
  134559. * @returns "SSAORenderingPipeline"
  134560. */
  134561. getClassName(): string;
  134562. /**
  134563. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134564. */
  134565. dispose(disableDepthRender?: boolean): void;
  134566. private _createBlurPostProcess;
  134567. /** @hidden */
  134568. _rebuild(): void;
  134569. private _createSSAOPostProcess;
  134570. private _createSSAOCombinePostProcess;
  134571. private _createRandomTexture;
  134572. }
  134573. }
  134574. declare module BABYLON {
  134575. /** @hidden */
  134576. export var standardPixelShader: {
  134577. name: string;
  134578. shader: string;
  134579. };
  134580. }
  134581. declare module BABYLON {
  134582. /**
  134583. * Standard rendering pipeline
  134584. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134585. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  134586. */
  134587. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  134588. /**
  134589. * Public members
  134590. */
  134591. /**
  134592. * Post-process which contains the original scene color before the pipeline applies all the effects
  134593. */
  134594. originalPostProcess: Nullable<PostProcess>;
  134595. /**
  134596. * Post-process used to down scale an image x4
  134597. */
  134598. downSampleX4PostProcess: Nullable<PostProcess>;
  134599. /**
  134600. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  134601. */
  134602. brightPassPostProcess: Nullable<PostProcess>;
  134603. /**
  134604. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  134605. */
  134606. blurHPostProcesses: PostProcess[];
  134607. /**
  134608. * Post-process array storing all the vertical blur post-processes used by the pipeline
  134609. */
  134610. blurVPostProcesses: PostProcess[];
  134611. /**
  134612. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  134613. */
  134614. textureAdderPostProcess: Nullable<PostProcess>;
  134615. /**
  134616. * Post-process used to create volumetric lighting effect
  134617. */
  134618. volumetricLightPostProcess: Nullable<PostProcess>;
  134619. /**
  134620. * Post-process used to smooth the previous volumetric light post-process on the X axis
  134621. */
  134622. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  134623. /**
  134624. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  134625. */
  134626. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  134627. /**
  134628. * Post-process used to merge the volumetric light effect and the real scene color
  134629. */
  134630. volumetricLightMergePostProces: Nullable<PostProcess>;
  134631. /**
  134632. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  134633. */
  134634. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  134635. /**
  134636. * Base post-process used to calculate the average luminance of the final image for HDR
  134637. */
  134638. luminancePostProcess: Nullable<PostProcess>;
  134639. /**
  134640. * Post-processes used to create down sample post-processes in order to get
  134641. * the average luminance of the final image for HDR
  134642. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  134643. */
  134644. luminanceDownSamplePostProcesses: PostProcess[];
  134645. /**
  134646. * Post-process used to create a HDR effect (light adaptation)
  134647. */
  134648. hdrPostProcess: Nullable<PostProcess>;
  134649. /**
  134650. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  134651. */
  134652. textureAdderFinalPostProcess: Nullable<PostProcess>;
  134653. /**
  134654. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  134655. */
  134656. lensFlareFinalPostProcess: Nullable<PostProcess>;
  134657. /**
  134658. * Post-process used to merge the final HDR post-process and the real scene color
  134659. */
  134660. hdrFinalPostProcess: Nullable<PostProcess>;
  134661. /**
  134662. * Post-process used to create a lens flare effect
  134663. */
  134664. lensFlarePostProcess: Nullable<PostProcess>;
  134665. /**
  134666. * Post-process that merges the result of the lens flare post-process and the real scene color
  134667. */
  134668. lensFlareComposePostProcess: Nullable<PostProcess>;
  134669. /**
  134670. * Post-process used to create a motion blur effect
  134671. */
  134672. motionBlurPostProcess: Nullable<PostProcess>;
  134673. /**
  134674. * Post-process used to create a depth of field effect
  134675. */
  134676. depthOfFieldPostProcess: Nullable<PostProcess>;
  134677. /**
  134678. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134679. */
  134680. fxaaPostProcess: Nullable<FxaaPostProcess>;
  134681. /**
  134682. * Represents the brightness threshold in order to configure the illuminated surfaces
  134683. */
  134684. brightThreshold: number;
  134685. /**
  134686. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  134687. */
  134688. blurWidth: number;
  134689. /**
  134690. * Sets if the blur for highlighted surfaces must be only horizontal
  134691. */
  134692. horizontalBlur: boolean;
  134693. /**
  134694. * Gets the overall exposure used by the pipeline
  134695. */
  134696. get exposure(): number;
  134697. /**
  134698. * Sets the overall exposure used by the pipeline
  134699. */
  134700. set exposure(value: number);
  134701. /**
  134702. * Texture used typically to simulate "dirty" on camera lens
  134703. */
  134704. lensTexture: Nullable<Texture>;
  134705. /**
  134706. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  134707. */
  134708. volumetricLightCoefficient: number;
  134709. /**
  134710. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  134711. */
  134712. volumetricLightPower: number;
  134713. /**
  134714. * Used the set the blur intensity to smooth the volumetric lights
  134715. */
  134716. volumetricLightBlurScale: number;
  134717. /**
  134718. * Light (spot or directional) used to generate the volumetric lights rays
  134719. * The source light must have a shadow generate so the pipeline can get its
  134720. * depth map
  134721. */
  134722. sourceLight: Nullable<SpotLight | DirectionalLight>;
  134723. /**
  134724. * For eye adaptation, represents the minimum luminance the eye can see
  134725. */
  134726. hdrMinimumLuminance: number;
  134727. /**
  134728. * For eye adaptation, represents the decrease luminance speed
  134729. */
  134730. hdrDecreaseRate: number;
  134731. /**
  134732. * For eye adaptation, represents the increase luminance speed
  134733. */
  134734. hdrIncreaseRate: number;
  134735. /**
  134736. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134737. */
  134738. get hdrAutoExposure(): boolean;
  134739. /**
  134740. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134741. */
  134742. set hdrAutoExposure(value: boolean);
  134743. /**
  134744. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  134745. */
  134746. lensColorTexture: Nullable<Texture>;
  134747. /**
  134748. * The overall strengh for the lens flare effect
  134749. */
  134750. lensFlareStrength: number;
  134751. /**
  134752. * Dispersion coefficient for lens flare ghosts
  134753. */
  134754. lensFlareGhostDispersal: number;
  134755. /**
  134756. * Main lens flare halo width
  134757. */
  134758. lensFlareHaloWidth: number;
  134759. /**
  134760. * Based on the lens distortion effect, defines how much the lens flare result
  134761. * is distorted
  134762. */
  134763. lensFlareDistortionStrength: number;
  134764. /**
  134765. * Configures the blur intensity used for for lens flare (halo)
  134766. */
  134767. lensFlareBlurWidth: number;
  134768. /**
  134769. * Lens star texture must be used to simulate rays on the flares and is available
  134770. * in the documentation
  134771. */
  134772. lensStarTexture: Nullable<Texture>;
  134773. /**
  134774. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  134775. * flare effect by taking account of the dirt texture
  134776. */
  134777. lensFlareDirtTexture: Nullable<Texture>;
  134778. /**
  134779. * Represents the focal length for the depth of field effect
  134780. */
  134781. depthOfFieldDistance: number;
  134782. /**
  134783. * Represents the blur intensity for the blurred part of the depth of field effect
  134784. */
  134785. depthOfFieldBlurWidth: number;
  134786. /**
  134787. * Gets how much the image is blurred by the movement while using the motion blur post-process
  134788. */
  134789. get motionStrength(): number;
  134790. /**
  134791. * Sets how much the image is blurred by the movement while using the motion blur post-process
  134792. */
  134793. set motionStrength(strength: number);
  134794. /**
  134795. * Gets wether or not the motion blur post-process is object based or screen based.
  134796. */
  134797. get objectBasedMotionBlur(): boolean;
  134798. /**
  134799. * Sets wether or not the motion blur post-process should be object based or screen based
  134800. */
  134801. set objectBasedMotionBlur(value: boolean);
  134802. /**
  134803. * List of animations for the pipeline (IAnimatable implementation)
  134804. */
  134805. animations: Animation[];
  134806. /**
  134807. * Private members
  134808. */
  134809. private _scene;
  134810. private _currentDepthOfFieldSource;
  134811. private _basePostProcess;
  134812. private _fixedExposure;
  134813. private _currentExposure;
  134814. private _hdrAutoExposure;
  134815. private _hdrCurrentLuminance;
  134816. private _motionStrength;
  134817. private _isObjectBasedMotionBlur;
  134818. private _floatTextureType;
  134819. private _camerasToBeAttached;
  134820. private _ratio;
  134821. private _bloomEnabled;
  134822. private _depthOfFieldEnabled;
  134823. private _vlsEnabled;
  134824. private _lensFlareEnabled;
  134825. private _hdrEnabled;
  134826. private _motionBlurEnabled;
  134827. private _fxaaEnabled;
  134828. private _motionBlurSamples;
  134829. private _volumetricLightStepsCount;
  134830. private _samples;
  134831. /**
  134832. * @ignore
  134833. * Specifies if the bloom pipeline is enabled
  134834. */
  134835. get BloomEnabled(): boolean;
  134836. set BloomEnabled(enabled: boolean);
  134837. /**
  134838. * @ignore
  134839. * Specifies if the depth of field pipeline is enabed
  134840. */
  134841. get DepthOfFieldEnabled(): boolean;
  134842. set DepthOfFieldEnabled(enabled: boolean);
  134843. /**
  134844. * @ignore
  134845. * Specifies if the lens flare pipeline is enabed
  134846. */
  134847. get LensFlareEnabled(): boolean;
  134848. set LensFlareEnabled(enabled: boolean);
  134849. /**
  134850. * @ignore
  134851. * Specifies if the HDR pipeline is enabled
  134852. */
  134853. get HDREnabled(): boolean;
  134854. set HDREnabled(enabled: boolean);
  134855. /**
  134856. * @ignore
  134857. * Specifies if the volumetric lights scattering effect is enabled
  134858. */
  134859. get VLSEnabled(): boolean;
  134860. set VLSEnabled(enabled: boolean);
  134861. /**
  134862. * @ignore
  134863. * Specifies if the motion blur effect is enabled
  134864. */
  134865. get MotionBlurEnabled(): boolean;
  134866. set MotionBlurEnabled(enabled: boolean);
  134867. /**
  134868. * Specifies if anti-aliasing is enabled
  134869. */
  134870. get fxaaEnabled(): boolean;
  134871. set fxaaEnabled(enabled: boolean);
  134872. /**
  134873. * Specifies the number of steps used to calculate the volumetric lights
  134874. * Typically in interval [50, 200]
  134875. */
  134876. get volumetricLightStepsCount(): number;
  134877. set volumetricLightStepsCount(count: number);
  134878. /**
  134879. * Specifies the number of samples used for the motion blur effect
  134880. * Typically in interval [16, 64]
  134881. */
  134882. get motionBlurSamples(): number;
  134883. set motionBlurSamples(samples: number);
  134884. /**
  134885. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  134886. */
  134887. get samples(): number;
  134888. set samples(sampleCount: number);
  134889. /**
  134890. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134891. * @constructor
  134892. * @param name The rendering pipeline name
  134893. * @param scene The scene linked to this pipeline
  134894. * @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)
  134895. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  134896. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134897. */
  134898. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  134899. private _buildPipeline;
  134900. private _createDownSampleX4PostProcess;
  134901. private _createBrightPassPostProcess;
  134902. private _createBlurPostProcesses;
  134903. private _createTextureAdderPostProcess;
  134904. private _createVolumetricLightPostProcess;
  134905. private _createLuminancePostProcesses;
  134906. private _createHdrPostProcess;
  134907. private _createLensFlarePostProcess;
  134908. private _createDepthOfFieldPostProcess;
  134909. private _createMotionBlurPostProcess;
  134910. private _getDepthTexture;
  134911. private _disposePostProcesses;
  134912. /**
  134913. * Dispose of the pipeline and stop all post processes
  134914. */
  134915. dispose(): void;
  134916. /**
  134917. * Serialize the rendering pipeline (Used when exporting)
  134918. * @returns the serialized object
  134919. */
  134920. serialize(): any;
  134921. /**
  134922. * Parse the serialized pipeline
  134923. * @param source Source pipeline.
  134924. * @param scene The scene to load the pipeline to.
  134925. * @param rootUrl The URL of the serialized pipeline.
  134926. * @returns An instantiated pipeline from the serialized object.
  134927. */
  134928. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  134929. /**
  134930. * Luminance steps
  134931. */
  134932. static LuminanceSteps: number;
  134933. }
  134934. }
  134935. declare module BABYLON {
  134936. /** @hidden */
  134937. export var tonemapPixelShader: {
  134938. name: string;
  134939. shader: string;
  134940. };
  134941. }
  134942. declare module BABYLON {
  134943. /** Defines operator used for tonemapping */
  134944. export enum TonemappingOperator {
  134945. /** Hable */
  134946. Hable = 0,
  134947. /** Reinhard */
  134948. Reinhard = 1,
  134949. /** HejiDawson */
  134950. HejiDawson = 2,
  134951. /** Photographic */
  134952. Photographic = 3
  134953. }
  134954. /**
  134955. * Defines a post process to apply tone mapping
  134956. */
  134957. export class TonemapPostProcess extends PostProcess {
  134958. private _operator;
  134959. /** Defines the required exposure adjustement */
  134960. exposureAdjustment: number;
  134961. /**
  134962. * Creates a new TonemapPostProcess
  134963. * @param name defines the name of the postprocess
  134964. * @param _operator defines the operator to use
  134965. * @param exposureAdjustment defines the required exposure adjustement
  134966. * @param camera defines the camera to use (can be null)
  134967. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  134968. * @param engine defines the hosting engine (can be ignore if camera is set)
  134969. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  134970. */
  134971. constructor(name: string, _operator: TonemappingOperator,
  134972. /** Defines the required exposure adjustement */
  134973. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  134974. }
  134975. }
  134976. declare module BABYLON {
  134977. /** @hidden */
  134978. export var depthVertexShader: {
  134979. name: string;
  134980. shader: string;
  134981. };
  134982. }
  134983. declare module BABYLON {
  134984. /** @hidden */
  134985. export var volumetricLightScatteringPixelShader: {
  134986. name: string;
  134987. shader: string;
  134988. };
  134989. }
  134990. declare module BABYLON {
  134991. /** @hidden */
  134992. export var volumetricLightScatteringPassVertexShader: {
  134993. name: string;
  134994. shader: string;
  134995. };
  134996. }
  134997. declare module BABYLON {
  134998. /** @hidden */
  134999. export var volumetricLightScatteringPassPixelShader: {
  135000. name: string;
  135001. shader: string;
  135002. };
  135003. }
  135004. declare module BABYLON {
  135005. /**
  135006. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  135007. */
  135008. export class VolumetricLightScatteringPostProcess extends PostProcess {
  135009. private _volumetricLightScatteringPass;
  135010. private _volumetricLightScatteringRTT;
  135011. private _viewPort;
  135012. private _screenCoordinates;
  135013. private _cachedDefines;
  135014. /**
  135015. * If not undefined, the mesh position is computed from the attached node position
  135016. */
  135017. attachedNode: {
  135018. position: Vector3;
  135019. };
  135020. /**
  135021. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  135022. */
  135023. customMeshPosition: Vector3;
  135024. /**
  135025. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  135026. */
  135027. useCustomMeshPosition: boolean;
  135028. /**
  135029. * If the post-process should inverse the light scattering direction
  135030. */
  135031. invert: boolean;
  135032. /**
  135033. * The internal mesh used by the post-process
  135034. */
  135035. mesh: Mesh;
  135036. /**
  135037. * @hidden
  135038. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  135039. */
  135040. get useDiffuseColor(): boolean;
  135041. set useDiffuseColor(useDiffuseColor: boolean);
  135042. /**
  135043. * Array containing the excluded meshes not rendered in the internal pass
  135044. */
  135045. excludedMeshes: AbstractMesh[];
  135046. /**
  135047. * Controls the overall intensity of the post-process
  135048. */
  135049. exposure: number;
  135050. /**
  135051. * Dissipates each sample's contribution in range [0, 1]
  135052. */
  135053. decay: number;
  135054. /**
  135055. * Controls the overall intensity of each sample
  135056. */
  135057. weight: number;
  135058. /**
  135059. * Controls the density of each sample
  135060. */
  135061. density: number;
  135062. /**
  135063. * @constructor
  135064. * @param name The post-process name
  135065. * @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)
  135066. * @param camera The camera that the post-process will be attached to
  135067. * @param mesh The mesh used to create the light scattering
  135068. * @param samples The post-process quality, default 100
  135069. * @param samplingModeThe post-process filtering mode
  135070. * @param engine The babylon engine
  135071. * @param reusable If the post-process is reusable
  135072. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  135073. */
  135074. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  135075. /**
  135076. * Returns the string "VolumetricLightScatteringPostProcess"
  135077. * @returns "VolumetricLightScatteringPostProcess"
  135078. */
  135079. getClassName(): string;
  135080. private _isReady;
  135081. /**
  135082. * Sets the new light position for light scattering effect
  135083. * @param position The new custom light position
  135084. */
  135085. setCustomMeshPosition(position: Vector3): void;
  135086. /**
  135087. * Returns the light position for light scattering effect
  135088. * @return Vector3 The custom light position
  135089. */
  135090. getCustomMeshPosition(): Vector3;
  135091. /**
  135092. * Disposes the internal assets and detaches the post-process from the camera
  135093. */
  135094. dispose(camera: Camera): void;
  135095. /**
  135096. * Returns the render target texture used by the post-process
  135097. * @return the render target texture used by the post-process
  135098. */
  135099. getPass(): RenderTargetTexture;
  135100. private _meshExcluded;
  135101. private _createPass;
  135102. private _updateMeshScreenCoordinates;
  135103. /**
  135104. * Creates a default mesh for the Volumeric Light Scattering post-process
  135105. * @param name The mesh name
  135106. * @param scene The scene where to create the mesh
  135107. * @return the default mesh
  135108. */
  135109. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  135110. }
  135111. }
  135112. declare module BABYLON {
  135113. interface Scene {
  135114. /** @hidden (Backing field) */
  135115. _boundingBoxRenderer: BoundingBoxRenderer;
  135116. /** @hidden (Backing field) */
  135117. _forceShowBoundingBoxes: boolean;
  135118. /**
  135119. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  135120. */
  135121. forceShowBoundingBoxes: boolean;
  135122. /**
  135123. * Gets the bounding box renderer associated with the scene
  135124. * @returns a BoundingBoxRenderer
  135125. */
  135126. getBoundingBoxRenderer(): BoundingBoxRenderer;
  135127. }
  135128. interface AbstractMesh {
  135129. /** @hidden (Backing field) */
  135130. _showBoundingBox: boolean;
  135131. /**
  135132. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  135133. */
  135134. showBoundingBox: boolean;
  135135. }
  135136. /**
  135137. * Component responsible of rendering the bounding box of the meshes in a scene.
  135138. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  135139. */
  135140. export class BoundingBoxRenderer implements ISceneComponent {
  135141. /**
  135142. * The component name helpfull to identify the component in the list of scene components.
  135143. */
  135144. readonly name: string;
  135145. /**
  135146. * The scene the component belongs to.
  135147. */
  135148. scene: Scene;
  135149. /**
  135150. * Color of the bounding box lines placed in front of an object
  135151. */
  135152. frontColor: Color3;
  135153. /**
  135154. * Color of the bounding box lines placed behind an object
  135155. */
  135156. backColor: Color3;
  135157. /**
  135158. * Defines if the renderer should show the back lines or not
  135159. */
  135160. showBackLines: boolean;
  135161. /**
  135162. * @hidden
  135163. */
  135164. renderList: SmartArray<BoundingBox>;
  135165. private _colorShader;
  135166. private _vertexBuffers;
  135167. private _indexBuffer;
  135168. private _fillIndexBuffer;
  135169. private _fillIndexData;
  135170. /**
  135171. * Instantiates a new bounding box renderer in a scene.
  135172. * @param scene the scene the renderer renders in
  135173. */
  135174. constructor(scene: Scene);
  135175. /**
  135176. * Registers the component in a given scene
  135177. */
  135178. register(): void;
  135179. private _evaluateSubMesh;
  135180. private _activeMesh;
  135181. private _prepareRessources;
  135182. private _createIndexBuffer;
  135183. /**
  135184. * Rebuilds the elements related to this component in case of
  135185. * context lost for instance.
  135186. */
  135187. rebuild(): void;
  135188. /**
  135189. * @hidden
  135190. */
  135191. reset(): void;
  135192. /**
  135193. * Render the bounding boxes of a specific rendering group
  135194. * @param renderingGroupId defines the rendering group to render
  135195. */
  135196. render(renderingGroupId: number): void;
  135197. /**
  135198. * In case of occlusion queries, we can render the occlusion bounding box through this method
  135199. * @param mesh Define the mesh to render the occlusion bounding box for
  135200. */
  135201. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  135202. /**
  135203. * Dispose and release the resources attached to this renderer.
  135204. */
  135205. dispose(): void;
  135206. }
  135207. }
  135208. declare module BABYLON {
  135209. /** @hidden */
  135210. export var depthPixelShader: {
  135211. name: string;
  135212. shader: string;
  135213. };
  135214. }
  135215. declare module BABYLON {
  135216. /**
  135217. * This represents a depth renderer in Babylon.
  135218. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135219. */
  135220. export class DepthRenderer {
  135221. private _scene;
  135222. private _depthMap;
  135223. private _effect;
  135224. private readonly _storeNonLinearDepth;
  135225. private readonly _clearColor;
  135226. /** Get if the depth renderer is using packed depth or not */
  135227. readonly isPacked: boolean;
  135228. private _cachedDefines;
  135229. private _camera;
  135230. /**
  135231. * Specifiess that the depth renderer will only be used within
  135232. * the camera it is created for.
  135233. * This can help forcing its rendering during the camera processing.
  135234. */
  135235. useOnlyInActiveCamera: boolean;
  135236. /** @hidden */
  135237. static _SceneComponentInitialization: (scene: Scene) => void;
  135238. /**
  135239. * Instantiates a depth renderer
  135240. * @param scene The scene the renderer belongs to
  135241. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135242. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135243. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135244. */
  135245. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135246. /**
  135247. * Creates the depth rendering effect and checks if the effect is ready.
  135248. * @param subMesh The submesh to be used to render the depth map of
  135249. * @param useInstances If multiple world instances should be used
  135250. * @returns if the depth renderer is ready to render the depth map
  135251. */
  135252. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135253. /**
  135254. * Gets the texture which the depth map will be written to.
  135255. * @returns The depth map texture
  135256. */
  135257. getDepthMap(): RenderTargetTexture;
  135258. /**
  135259. * Disposes of the depth renderer.
  135260. */
  135261. dispose(): void;
  135262. }
  135263. }
  135264. declare module BABYLON {
  135265. interface Scene {
  135266. /** @hidden (Backing field) */
  135267. _depthRenderer: {
  135268. [id: string]: DepthRenderer;
  135269. };
  135270. /**
  135271. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  135272. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  135273. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135274. * @returns the created depth renderer
  135275. */
  135276. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  135277. /**
  135278. * Disables a depth renderer for a given camera
  135279. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  135280. */
  135281. disableDepthRenderer(camera?: Nullable<Camera>): void;
  135282. }
  135283. /**
  135284. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  135285. * in several rendering techniques.
  135286. */
  135287. export class DepthRendererSceneComponent implements ISceneComponent {
  135288. /**
  135289. * The component name helpfull to identify the component in the list of scene components.
  135290. */
  135291. readonly name: string;
  135292. /**
  135293. * The scene the component belongs to.
  135294. */
  135295. scene: Scene;
  135296. /**
  135297. * Creates a new instance of the component for the given scene
  135298. * @param scene Defines the scene to register the component in
  135299. */
  135300. constructor(scene: Scene);
  135301. /**
  135302. * Registers the component in a given scene
  135303. */
  135304. register(): void;
  135305. /**
  135306. * Rebuilds the elements related to this component in case of
  135307. * context lost for instance.
  135308. */
  135309. rebuild(): void;
  135310. /**
  135311. * Disposes the component and the associated ressources
  135312. */
  135313. dispose(): void;
  135314. private _gatherRenderTargets;
  135315. private _gatherActiveCameraRenderTargets;
  135316. }
  135317. }
  135318. declare module BABYLON {
  135319. /** @hidden */
  135320. export var outlinePixelShader: {
  135321. name: string;
  135322. shader: string;
  135323. };
  135324. }
  135325. declare module BABYLON {
  135326. /** @hidden */
  135327. export var outlineVertexShader: {
  135328. name: string;
  135329. shader: string;
  135330. };
  135331. }
  135332. declare module BABYLON {
  135333. interface Scene {
  135334. /** @hidden */
  135335. _outlineRenderer: OutlineRenderer;
  135336. /**
  135337. * Gets the outline renderer associated with the scene
  135338. * @returns a OutlineRenderer
  135339. */
  135340. getOutlineRenderer(): OutlineRenderer;
  135341. }
  135342. interface AbstractMesh {
  135343. /** @hidden (Backing field) */
  135344. _renderOutline: boolean;
  135345. /**
  135346. * Gets or sets a boolean indicating if the outline must be rendered as well
  135347. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  135348. */
  135349. renderOutline: boolean;
  135350. /** @hidden (Backing field) */
  135351. _renderOverlay: boolean;
  135352. /**
  135353. * Gets or sets a boolean indicating if the overlay must be rendered as well
  135354. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  135355. */
  135356. renderOverlay: boolean;
  135357. }
  135358. /**
  135359. * This class is responsible to draw bothe outline/overlay of meshes.
  135360. * It should not be used directly but through the available method on mesh.
  135361. */
  135362. export class OutlineRenderer implements ISceneComponent {
  135363. /**
  135364. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  135365. */
  135366. private static _StencilReference;
  135367. /**
  135368. * The name of the component. Each component must have a unique name.
  135369. */
  135370. name: string;
  135371. /**
  135372. * The scene the component belongs to.
  135373. */
  135374. scene: Scene;
  135375. /**
  135376. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  135377. */
  135378. zOffset: number;
  135379. private _engine;
  135380. private _effect;
  135381. private _cachedDefines;
  135382. private _savedDepthWrite;
  135383. /**
  135384. * Instantiates a new outline renderer. (There could be only one per scene).
  135385. * @param scene Defines the scene it belongs to
  135386. */
  135387. constructor(scene: Scene);
  135388. /**
  135389. * Register the component to one instance of a scene.
  135390. */
  135391. register(): void;
  135392. /**
  135393. * Rebuilds the elements related to this component in case of
  135394. * context lost for instance.
  135395. */
  135396. rebuild(): void;
  135397. /**
  135398. * Disposes the component and the associated ressources.
  135399. */
  135400. dispose(): void;
  135401. /**
  135402. * Renders the outline in the canvas.
  135403. * @param subMesh Defines the sumesh to render
  135404. * @param batch Defines the batch of meshes in case of instances
  135405. * @param useOverlay Defines if the rendering is for the overlay or the outline
  135406. */
  135407. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  135408. /**
  135409. * Returns whether or not the outline renderer is ready for a given submesh.
  135410. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  135411. * @param subMesh Defines the submesh to check readyness for
  135412. * @param useInstances Defines wheter wee are trying to render instances or not
  135413. * @returns true if ready otherwise false
  135414. */
  135415. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135416. private _beforeRenderingMesh;
  135417. private _afterRenderingMesh;
  135418. }
  135419. }
  135420. declare module BABYLON {
  135421. /**
  135422. * Defines the basic options interface of a Sprite Frame Source Size.
  135423. */
  135424. export interface ISpriteJSONSpriteSourceSize {
  135425. /**
  135426. * number of the original width of the Frame
  135427. */
  135428. w: number;
  135429. /**
  135430. * number of the original height of the Frame
  135431. */
  135432. h: number;
  135433. }
  135434. /**
  135435. * Defines the basic options interface of a Sprite Frame Data.
  135436. */
  135437. export interface ISpriteJSONSpriteFrameData {
  135438. /**
  135439. * number of the x offset of the Frame
  135440. */
  135441. x: number;
  135442. /**
  135443. * number of the y offset of the Frame
  135444. */
  135445. y: number;
  135446. /**
  135447. * number of the width of the Frame
  135448. */
  135449. w: number;
  135450. /**
  135451. * number of the height of the Frame
  135452. */
  135453. h: number;
  135454. }
  135455. /**
  135456. * Defines the basic options interface of a JSON Sprite.
  135457. */
  135458. export interface ISpriteJSONSprite {
  135459. /**
  135460. * string name of the Frame
  135461. */
  135462. filename: string;
  135463. /**
  135464. * ISpriteJSONSpriteFrame basic object of the frame data
  135465. */
  135466. frame: ISpriteJSONSpriteFrameData;
  135467. /**
  135468. * boolean to flag is the frame was rotated.
  135469. */
  135470. rotated: boolean;
  135471. /**
  135472. * boolean to flag is the frame was trimmed.
  135473. */
  135474. trimmed: boolean;
  135475. /**
  135476. * ISpriteJSONSpriteFrame basic object of the source data
  135477. */
  135478. spriteSourceSize: ISpriteJSONSpriteFrameData;
  135479. /**
  135480. * ISpriteJSONSpriteFrame basic object of the source data
  135481. */
  135482. sourceSize: ISpriteJSONSpriteSourceSize;
  135483. }
  135484. /**
  135485. * Defines the basic options interface of a JSON atlas.
  135486. */
  135487. export interface ISpriteJSONAtlas {
  135488. /**
  135489. * Array of objects that contain the frame data.
  135490. */
  135491. frames: Array<ISpriteJSONSprite>;
  135492. /**
  135493. * object basic object containing the sprite meta data.
  135494. */
  135495. meta?: object;
  135496. }
  135497. }
  135498. declare module BABYLON {
  135499. /** @hidden */
  135500. export var spriteMapPixelShader: {
  135501. name: string;
  135502. shader: string;
  135503. };
  135504. }
  135505. declare module BABYLON {
  135506. /** @hidden */
  135507. export var spriteMapVertexShader: {
  135508. name: string;
  135509. shader: string;
  135510. };
  135511. }
  135512. declare module BABYLON {
  135513. /**
  135514. * Defines the basic options interface of a SpriteMap
  135515. */
  135516. export interface ISpriteMapOptions {
  135517. /**
  135518. * Vector2 of the number of cells in the grid.
  135519. */
  135520. stageSize?: Vector2;
  135521. /**
  135522. * Vector2 of the size of the output plane in World Units.
  135523. */
  135524. outputSize?: Vector2;
  135525. /**
  135526. * Vector3 of the position of the output plane in World Units.
  135527. */
  135528. outputPosition?: Vector3;
  135529. /**
  135530. * Vector3 of the rotation of the output plane.
  135531. */
  135532. outputRotation?: Vector3;
  135533. /**
  135534. * number of layers that the system will reserve in resources.
  135535. */
  135536. layerCount?: number;
  135537. /**
  135538. * number of max animation frames a single cell will reserve in resources.
  135539. */
  135540. maxAnimationFrames?: number;
  135541. /**
  135542. * number cell index of the base tile when the system compiles.
  135543. */
  135544. baseTile?: number;
  135545. /**
  135546. * boolean flip the sprite after its been repositioned by the framing data.
  135547. */
  135548. flipU?: boolean;
  135549. /**
  135550. * Vector3 scalar of the global RGB values of the SpriteMap.
  135551. */
  135552. colorMultiply?: Vector3;
  135553. }
  135554. /**
  135555. * Defines the IDisposable interface in order to be cleanable from resources.
  135556. */
  135557. export interface ISpriteMap extends IDisposable {
  135558. /**
  135559. * String name of the SpriteMap.
  135560. */
  135561. name: string;
  135562. /**
  135563. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  135564. */
  135565. atlasJSON: ISpriteJSONAtlas;
  135566. /**
  135567. * Texture of the SpriteMap.
  135568. */
  135569. spriteSheet: Texture;
  135570. /**
  135571. * The parameters to initialize the SpriteMap with.
  135572. */
  135573. options: ISpriteMapOptions;
  135574. }
  135575. /**
  135576. * Class used to manage a grid restricted sprite deployment on an Output plane.
  135577. */
  135578. export class SpriteMap implements ISpriteMap {
  135579. /** The Name of the spriteMap */
  135580. name: string;
  135581. /** The JSON file with the frame and meta data */
  135582. atlasJSON: ISpriteJSONAtlas;
  135583. /** The systems Sprite Sheet Texture */
  135584. spriteSheet: Texture;
  135585. /** Arguments passed with the Constructor */
  135586. options: ISpriteMapOptions;
  135587. /** Public Sprite Storage array, parsed from atlasJSON */
  135588. sprites: Array<ISpriteJSONSprite>;
  135589. /** Returns the Number of Sprites in the System */
  135590. get spriteCount(): number;
  135591. /** Returns the Position of Output Plane*/
  135592. get position(): Vector3;
  135593. /** Returns the Position of Output Plane*/
  135594. set position(v: Vector3);
  135595. /** Returns the Rotation of Output Plane*/
  135596. get rotation(): Vector3;
  135597. /** Returns the Rotation of Output Plane*/
  135598. set rotation(v: Vector3);
  135599. /** Sets the AnimationMap*/
  135600. get animationMap(): RawTexture;
  135601. /** Sets the AnimationMap*/
  135602. set animationMap(v: RawTexture);
  135603. /** Scene that the SpriteMap was created in */
  135604. private _scene;
  135605. /** Texture Buffer of Float32 that holds tile frame data*/
  135606. private _frameMap;
  135607. /** Texture Buffers of Float32 that holds tileMap data*/
  135608. private _tileMaps;
  135609. /** Texture Buffer of Float32 that holds Animation Data*/
  135610. private _animationMap;
  135611. /** Custom ShaderMaterial Central to the System*/
  135612. private _material;
  135613. /** Custom ShaderMaterial Central to the System*/
  135614. private _output;
  135615. /** Systems Time Ticker*/
  135616. private _time;
  135617. /**
  135618. * Creates a new SpriteMap
  135619. * @param name defines the SpriteMaps Name
  135620. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  135621. * @param spriteSheet is the Texture that the Sprites are on.
  135622. * @param options a basic deployment configuration
  135623. * @param scene The Scene that the map is deployed on
  135624. */
  135625. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  135626. /**
  135627. * Returns tileID location
  135628. * @returns Vector2 the cell position ID
  135629. */
  135630. getTileID(): Vector2;
  135631. /**
  135632. * Gets the UV location of the mouse over the SpriteMap.
  135633. * @returns Vector2 the UV position of the mouse interaction
  135634. */
  135635. getMousePosition(): Vector2;
  135636. /**
  135637. * Creates the "frame" texture Buffer
  135638. * -------------------------------------
  135639. * Structure of frames
  135640. * "filename": "Falling-Water-2.png",
  135641. * "frame": {"x":69,"y":103,"w":24,"h":32},
  135642. * "rotated": true,
  135643. * "trimmed": true,
  135644. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  135645. * "sourceSize": {"w":32,"h":32}
  135646. * @returns RawTexture of the frameMap
  135647. */
  135648. private _createFrameBuffer;
  135649. /**
  135650. * Creates the tileMap texture Buffer
  135651. * @param buffer normally and array of numbers, or a false to generate from scratch
  135652. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  135653. * @returns RawTexture of the tileMap
  135654. */
  135655. private _createTileBuffer;
  135656. /**
  135657. * Modifies the data of the tileMaps
  135658. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  135659. * @param pos is the iVector2 Coordinates of the Tile
  135660. * @param tile The SpriteIndex of the new Tile
  135661. */
  135662. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  135663. /**
  135664. * Creates the animationMap texture Buffer
  135665. * @param buffer normally and array of numbers, or a false to generate from scratch
  135666. * @returns RawTexture of the animationMap
  135667. */
  135668. private _createTileAnimationBuffer;
  135669. /**
  135670. * Modifies the data of the animationMap
  135671. * @param cellID is the Index of the Sprite
  135672. * @param _frame is the target Animation frame
  135673. * @param toCell is the Target Index of the next frame of the animation
  135674. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  135675. * @param speed is a global scalar of the time variable on the map.
  135676. */
  135677. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  135678. /**
  135679. * Exports the .tilemaps file
  135680. */
  135681. saveTileMaps(): void;
  135682. /**
  135683. * Imports the .tilemaps file
  135684. * @param url of the .tilemaps file
  135685. */
  135686. loadTileMaps(url: string): void;
  135687. /**
  135688. * Release associated resources
  135689. */
  135690. dispose(): void;
  135691. }
  135692. }
  135693. declare module BABYLON {
  135694. /**
  135695. * Class used to manage multiple sprites of different sizes on the same spritesheet
  135696. * @see http://doc.babylonjs.com/babylon101/sprites
  135697. */
  135698. export class SpritePackedManager extends SpriteManager {
  135699. /** defines the packed manager's name */
  135700. name: string;
  135701. /**
  135702. * Creates a new sprite manager from a packed sprite sheet
  135703. * @param name defines the manager's name
  135704. * @param imgUrl defines the sprite sheet url
  135705. * @param capacity defines the maximum allowed number of sprites
  135706. * @param scene defines the hosting scene
  135707. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  135708. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  135709. * @param samplingMode defines the smapling mode to use with spritesheet
  135710. * @param fromPacked set to true; do not alter
  135711. */
  135712. constructor(
  135713. /** defines the packed manager's name */
  135714. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  135715. }
  135716. }
  135717. declare module BABYLON {
  135718. /**
  135719. * Defines the list of states available for a task inside a AssetsManager
  135720. */
  135721. export enum AssetTaskState {
  135722. /**
  135723. * Initialization
  135724. */
  135725. INIT = 0,
  135726. /**
  135727. * Running
  135728. */
  135729. RUNNING = 1,
  135730. /**
  135731. * Done
  135732. */
  135733. DONE = 2,
  135734. /**
  135735. * Error
  135736. */
  135737. ERROR = 3
  135738. }
  135739. /**
  135740. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  135741. */
  135742. export abstract class AbstractAssetTask {
  135743. /**
  135744. * Task name
  135745. */ name: string;
  135746. /**
  135747. * Callback called when the task is successful
  135748. */
  135749. onSuccess: (task: any) => void;
  135750. /**
  135751. * Callback called when the task is not successful
  135752. */
  135753. onError: (task: any, message?: string, exception?: any) => void;
  135754. /**
  135755. * Creates a new AssetsManager
  135756. * @param name defines the name of the task
  135757. */
  135758. constructor(
  135759. /**
  135760. * Task name
  135761. */ name: string);
  135762. private _isCompleted;
  135763. private _taskState;
  135764. private _errorObject;
  135765. /**
  135766. * Get if the task is completed
  135767. */
  135768. get isCompleted(): boolean;
  135769. /**
  135770. * Gets the current state of the task
  135771. */
  135772. get taskState(): AssetTaskState;
  135773. /**
  135774. * Gets the current error object (if task is in error)
  135775. */
  135776. get errorObject(): {
  135777. message?: string;
  135778. exception?: any;
  135779. };
  135780. /**
  135781. * Internal only
  135782. * @hidden
  135783. */
  135784. _setErrorObject(message?: string, exception?: any): void;
  135785. /**
  135786. * Execute the current task
  135787. * @param scene defines the scene where you want your assets to be loaded
  135788. * @param onSuccess is a callback called when the task is successfully executed
  135789. * @param onError is a callback called if an error occurs
  135790. */
  135791. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135792. /**
  135793. * Execute the current task
  135794. * @param scene defines the scene where you want your assets to be loaded
  135795. * @param onSuccess is a callback called when the task is successfully executed
  135796. * @param onError is a callback called if an error occurs
  135797. */
  135798. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135799. /**
  135800. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  135801. * This can be used with failed tasks that have the reason for failure fixed.
  135802. */
  135803. reset(): void;
  135804. private onErrorCallback;
  135805. private onDoneCallback;
  135806. }
  135807. /**
  135808. * Define the interface used by progress events raised during assets loading
  135809. */
  135810. export interface IAssetsProgressEvent {
  135811. /**
  135812. * Defines the number of remaining tasks to process
  135813. */
  135814. remainingCount: number;
  135815. /**
  135816. * Defines the total number of tasks
  135817. */
  135818. totalCount: number;
  135819. /**
  135820. * Defines the task that was just processed
  135821. */
  135822. task: AbstractAssetTask;
  135823. }
  135824. /**
  135825. * Class used to share progress information about assets loading
  135826. */
  135827. export class AssetsProgressEvent implements IAssetsProgressEvent {
  135828. /**
  135829. * Defines the number of remaining tasks to process
  135830. */
  135831. remainingCount: number;
  135832. /**
  135833. * Defines the total number of tasks
  135834. */
  135835. totalCount: number;
  135836. /**
  135837. * Defines the task that was just processed
  135838. */
  135839. task: AbstractAssetTask;
  135840. /**
  135841. * Creates a AssetsProgressEvent
  135842. * @param remainingCount defines the number of remaining tasks to process
  135843. * @param totalCount defines the total number of tasks
  135844. * @param task defines the task that was just processed
  135845. */
  135846. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  135847. }
  135848. /**
  135849. * Define a task used by AssetsManager to load meshes
  135850. */
  135851. export class MeshAssetTask extends AbstractAssetTask {
  135852. /**
  135853. * Defines the name of the task
  135854. */
  135855. name: string;
  135856. /**
  135857. * Defines the list of mesh's names you want to load
  135858. */
  135859. meshesNames: any;
  135860. /**
  135861. * Defines the root url to use as a base to load your meshes and associated resources
  135862. */
  135863. rootUrl: string;
  135864. /**
  135865. * Defines the filename of the scene to load from
  135866. */
  135867. sceneFilename: string;
  135868. /**
  135869. * Gets the list of loaded meshes
  135870. */
  135871. loadedMeshes: Array<AbstractMesh>;
  135872. /**
  135873. * Gets the list of loaded particle systems
  135874. */
  135875. loadedParticleSystems: Array<IParticleSystem>;
  135876. /**
  135877. * Gets the list of loaded skeletons
  135878. */
  135879. loadedSkeletons: Array<Skeleton>;
  135880. /**
  135881. * Gets the list of loaded animation groups
  135882. */
  135883. loadedAnimationGroups: Array<AnimationGroup>;
  135884. /**
  135885. * Callback called when the task is successful
  135886. */
  135887. onSuccess: (task: MeshAssetTask) => void;
  135888. /**
  135889. * Callback called when the task is successful
  135890. */
  135891. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  135892. /**
  135893. * Creates a new MeshAssetTask
  135894. * @param name defines the name of the task
  135895. * @param meshesNames defines the list of mesh's names you want to load
  135896. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  135897. * @param sceneFilename defines the filename of the scene to load from
  135898. */
  135899. constructor(
  135900. /**
  135901. * Defines the name of the task
  135902. */
  135903. name: string,
  135904. /**
  135905. * Defines the list of mesh's names you want to load
  135906. */
  135907. meshesNames: any,
  135908. /**
  135909. * Defines the root url to use as a base to load your meshes and associated resources
  135910. */
  135911. rootUrl: string,
  135912. /**
  135913. * Defines the filename of the scene to load from
  135914. */
  135915. sceneFilename: string);
  135916. /**
  135917. * Execute the current task
  135918. * @param scene defines the scene where you want your assets to be loaded
  135919. * @param onSuccess is a callback called when the task is successfully executed
  135920. * @param onError is a callback called if an error occurs
  135921. */
  135922. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135923. }
  135924. /**
  135925. * Define a task used by AssetsManager to load text content
  135926. */
  135927. export class TextFileAssetTask extends AbstractAssetTask {
  135928. /**
  135929. * Defines the name of the task
  135930. */
  135931. name: string;
  135932. /**
  135933. * Defines the location of the file to load
  135934. */
  135935. url: string;
  135936. /**
  135937. * Gets the loaded text string
  135938. */
  135939. text: string;
  135940. /**
  135941. * Callback called when the task is successful
  135942. */
  135943. onSuccess: (task: TextFileAssetTask) => void;
  135944. /**
  135945. * Callback called when the task is successful
  135946. */
  135947. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  135948. /**
  135949. * Creates a new TextFileAssetTask object
  135950. * @param name defines the name of the task
  135951. * @param url defines the location of the file to load
  135952. */
  135953. constructor(
  135954. /**
  135955. * Defines the name of the task
  135956. */
  135957. name: string,
  135958. /**
  135959. * Defines the location of the file to load
  135960. */
  135961. url: string);
  135962. /**
  135963. * Execute the current task
  135964. * @param scene defines the scene where you want your assets to be loaded
  135965. * @param onSuccess is a callback called when the task is successfully executed
  135966. * @param onError is a callback called if an error occurs
  135967. */
  135968. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135969. }
  135970. /**
  135971. * Define a task used by AssetsManager to load binary data
  135972. */
  135973. export class BinaryFileAssetTask extends AbstractAssetTask {
  135974. /**
  135975. * Defines the name of the task
  135976. */
  135977. name: string;
  135978. /**
  135979. * Defines the location of the file to load
  135980. */
  135981. url: string;
  135982. /**
  135983. * Gets the lodaded data (as an array buffer)
  135984. */
  135985. data: ArrayBuffer;
  135986. /**
  135987. * Callback called when the task is successful
  135988. */
  135989. onSuccess: (task: BinaryFileAssetTask) => void;
  135990. /**
  135991. * Callback called when the task is successful
  135992. */
  135993. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  135994. /**
  135995. * Creates a new BinaryFileAssetTask object
  135996. * @param name defines the name of the new task
  135997. * @param url defines the location of the file to load
  135998. */
  135999. constructor(
  136000. /**
  136001. * Defines the name of the task
  136002. */
  136003. name: string,
  136004. /**
  136005. * Defines the location of the file to load
  136006. */
  136007. url: string);
  136008. /**
  136009. * Execute the current task
  136010. * @param scene defines the scene where you want your assets to be loaded
  136011. * @param onSuccess is a callback called when the task is successfully executed
  136012. * @param onError is a callback called if an error occurs
  136013. */
  136014. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136015. }
  136016. /**
  136017. * Define a task used by AssetsManager to load images
  136018. */
  136019. export class ImageAssetTask extends AbstractAssetTask {
  136020. /**
  136021. * Defines the name of the task
  136022. */
  136023. name: string;
  136024. /**
  136025. * Defines the location of the image to load
  136026. */
  136027. url: string;
  136028. /**
  136029. * Gets the loaded images
  136030. */
  136031. image: HTMLImageElement;
  136032. /**
  136033. * Callback called when the task is successful
  136034. */
  136035. onSuccess: (task: ImageAssetTask) => void;
  136036. /**
  136037. * Callback called when the task is successful
  136038. */
  136039. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  136040. /**
  136041. * Creates a new ImageAssetTask
  136042. * @param name defines the name of the task
  136043. * @param url defines the location of the image to load
  136044. */
  136045. constructor(
  136046. /**
  136047. * Defines the name of the task
  136048. */
  136049. name: string,
  136050. /**
  136051. * Defines the location of the image to load
  136052. */
  136053. url: string);
  136054. /**
  136055. * Execute the current task
  136056. * @param scene defines the scene where you want your assets to be loaded
  136057. * @param onSuccess is a callback called when the task is successfully executed
  136058. * @param onError is a callback called if an error occurs
  136059. */
  136060. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136061. }
  136062. /**
  136063. * Defines the interface used by texture loading tasks
  136064. */
  136065. export interface ITextureAssetTask<TEX extends BaseTexture> {
  136066. /**
  136067. * Gets the loaded texture
  136068. */
  136069. texture: TEX;
  136070. }
  136071. /**
  136072. * Define a task used by AssetsManager to load 2D textures
  136073. */
  136074. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  136075. /**
  136076. * Defines the name of the task
  136077. */
  136078. name: string;
  136079. /**
  136080. * Defines the location of the file to load
  136081. */
  136082. url: string;
  136083. /**
  136084. * Defines if mipmap should not be generated (default is false)
  136085. */
  136086. noMipmap?: boolean | undefined;
  136087. /**
  136088. * Defines if texture must be inverted on Y axis (default is false)
  136089. */
  136090. invertY?: boolean | undefined;
  136091. /**
  136092. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136093. */
  136094. samplingMode: number;
  136095. /**
  136096. * Gets the loaded texture
  136097. */
  136098. texture: Texture;
  136099. /**
  136100. * Callback called when the task is successful
  136101. */
  136102. onSuccess: (task: TextureAssetTask) => void;
  136103. /**
  136104. * Callback called when the task is successful
  136105. */
  136106. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  136107. /**
  136108. * Creates a new TextureAssetTask object
  136109. * @param name defines the name of the task
  136110. * @param url defines the location of the file to load
  136111. * @param noMipmap defines if mipmap should not be generated (default is false)
  136112. * @param invertY defines if texture must be inverted on Y axis (default is false)
  136113. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136114. */
  136115. constructor(
  136116. /**
  136117. * Defines the name of the task
  136118. */
  136119. name: string,
  136120. /**
  136121. * Defines the location of the file to load
  136122. */
  136123. url: string,
  136124. /**
  136125. * Defines if mipmap should not be generated (default is false)
  136126. */
  136127. noMipmap?: boolean | undefined,
  136128. /**
  136129. * Defines if texture must be inverted on Y axis (default is false)
  136130. */
  136131. invertY?: boolean | undefined,
  136132. /**
  136133. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136134. */
  136135. samplingMode?: number);
  136136. /**
  136137. * Execute the current task
  136138. * @param scene defines the scene where you want your assets to be loaded
  136139. * @param onSuccess is a callback called when the task is successfully executed
  136140. * @param onError is a callback called if an error occurs
  136141. */
  136142. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136143. }
  136144. /**
  136145. * Define a task used by AssetsManager to load cube textures
  136146. */
  136147. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  136148. /**
  136149. * Defines the name of the task
  136150. */
  136151. name: string;
  136152. /**
  136153. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136154. */
  136155. url: string;
  136156. /**
  136157. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136158. */
  136159. extensions?: string[] | undefined;
  136160. /**
  136161. * Defines if mipmaps should not be generated (default is false)
  136162. */
  136163. noMipmap?: boolean | undefined;
  136164. /**
  136165. * Defines the explicit list of files (undefined by default)
  136166. */
  136167. files?: string[] | undefined;
  136168. /**
  136169. * Gets the loaded texture
  136170. */
  136171. texture: CubeTexture;
  136172. /**
  136173. * Callback called when the task is successful
  136174. */
  136175. onSuccess: (task: CubeTextureAssetTask) => void;
  136176. /**
  136177. * Callback called when the task is successful
  136178. */
  136179. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  136180. /**
  136181. * Creates a new CubeTextureAssetTask
  136182. * @param name defines the name of the task
  136183. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136184. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136185. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136186. * @param files defines the explicit list of files (undefined by default)
  136187. */
  136188. constructor(
  136189. /**
  136190. * Defines the name of the task
  136191. */
  136192. name: string,
  136193. /**
  136194. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136195. */
  136196. url: string,
  136197. /**
  136198. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136199. */
  136200. extensions?: string[] | undefined,
  136201. /**
  136202. * Defines if mipmaps should not be generated (default is false)
  136203. */
  136204. noMipmap?: boolean | undefined,
  136205. /**
  136206. * Defines the explicit list of files (undefined by default)
  136207. */
  136208. files?: string[] | undefined);
  136209. /**
  136210. * Execute the current task
  136211. * @param scene defines the scene where you want your assets to be loaded
  136212. * @param onSuccess is a callback called when the task is successfully executed
  136213. * @param onError is a callback called if an error occurs
  136214. */
  136215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136216. }
  136217. /**
  136218. * Define a task used by AssetsManager to load HDR cube textures
  136219. */
  136220. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  136221. /**
  136222. * Defines the name of the task
  136223. */
  136224. name: string;
  136225. /**
  136226. * Defines the location of the file to load
  136227. */
  136228. url: string;
  136229. /**
  136230. * Defines the desired size (the more it increases the longer the generation will be)
  136231. */
  136232. size: number;
  136233. /**
  136234. * Defines if mipmaps should not be generated (default is false)
  136235. */
  136236. noMipmap: boolean;
  136237. /**
  136238. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136239. */
  136240. generateHarmonics: boolean;
  136241. /**
  136242. * 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)
  136243. */
  136244. gammaSpace: boolean;
  136245. /**
  136246. * Internal Use Only
  136247. */
  136248. reserved: boolean;
  136249. /**
  136250. * Gets the loaded texture
  136251. */
  136252. texture: HDRCubeTexture;
  136253. /**
  136254. * Callback called when the task is successful
  136255. */
  136256. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  136257. /**
  136258. * Callback called when the task is successful
  136259. */
  136260. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  136261. /**
  136262. * Creates a new HDRCubeTextureAssetTask object
  136263. * @param name defines the name of the task
  136264. * @param url defines the location of the file to load
  136265. * @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.
  136266. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136267. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136268. * @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)
  136269. * @param reserved Internal use only
  136270. */
  136271. constructor(
  136272. /**
  136273. * Defines the name of the task
  136274. */
  136275. name: string,
  136276. /**
  136277. * Defines the location of the file to load
  136278. */
  136279. url: string,
  136280. /**
  136281. * Defines the desired size (the more it increases the longer the generation will be)
  136282. */
  136283. size: number,
  136284. /**
  136285. * Defines if mipmaps should not be generated (default is false)
  136286. */
  136287. noMipmap?: boolean,
  136288. /**
  136289. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136290. */
  136291. generateHarmonics?: boolean,
  136292. /**
  136293. * 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)
  136294. */
  136295. gammaSpace?: boolean,
  136296. /**
  136297. * Internal Use Only
  136298. */
  136299. reserved?: boolean);
  136300. /**
  136301. * Execute the current task
  136302. * @param scene defines the scene where you want your assets to be loaded
  136303. * @param onSuccess is a callback called when the task is successfully executed
  136304. * @param onError is a callback called if an error occurs
  136305. */
  136306. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136307. }
  136308. /**
  136309. * Define a task used by AssetsManager to load Equirectangular cube textures
  136310. */
  136311. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  136312. /**
  136313. * Defines the name of the task
  136314. */
  136315. name: string;
  136316. /**
  136317. * Defines the location of the file to load
  136318. */
  136319. url: string;
  136320. /**
  136321. * Defines the desired size (the more it increases the longer the generation will be)
  136322. */
  136323. size: number;
  136324. /**
  136325. * Defines if mipmaps should not be generated (default is false)
  136326. */
  136327. noMipmap: boolean;
  136328. /**
  136329. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136330. * but the standard material would require them in Gamma space) (default is true)
  136331. */
  136332. gammaSpace: boolean;
  136333. /**
  136334. * Gets the loaded texture
  136335. */
  136336. texture: EquiRectangularCubeTexture;
  136337. /**
  136338. * Callback called when the task is successful
  136339. */
  136340. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  136341. /**
  136342. * Callback called when the task is successful
  136343. */
  136344. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  136345. /**
  136346. * Creates a new EquiRectangularCubeTextureAssetTask object
  136347. * @param name defines the name of the task
  136348. * @param url defines the location of the file to load
  136349. * @param size defines the desired size (the more it increases the longer the generation will be)
  136350. * If the size is omitted this implies you are using a preprocessed cubemap.
  136351. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136352. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  136353. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  136354. * (default is true)
  136355. */
  136356. constructor(
  136357. /**
  136358. * Defines the name of the task
  136359. */
  136360. name: string,
  136361. /**
  136362. * Defines the location of the file to load
  136363. */
  136364. url: string,
  136365. /**
  136366. * Defines the desired size (the more it increases the longer the generation will be)
  136367. */
  136368. size: number,
  136369. /**
  136370. * Defines if mipmaps should not be generated (default is false)
  136371. */
  136372. noMipmap?: boolean,
  136373. /**
  136374. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136375. * but the standard material would require them in Gamma space) (default is true)
  136376. */
  136377. gammaSpace?: boolean);
  136378. /**
  136379. * Execute the current task
  136380. * @param scene defines the scene where you want your assets to be loaded
  136381. * @param onSuccess is a callback called when the task is successfully executed
  136382. * @param onError is a callback called if an error occurs
  136383. */
  136384. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136385. }
  136386. /**
  136387. * This class can be used to easily import assets into a scene
  136388. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  136389. */
  136390. export class AssetsManager {
  136391. private _scene;
  136392. private _isLoading;
  136393. protected _tasks: AbstractAssetTask[];
  136394. protected _waitingTasksCount: number;
  136395. protected _totalTasksCount: number;
  136396. /**
  136397. * Callback called when all tasks are processed
  136398. */
  136399. onFinish: (tasks: AbstractAssetTask[]) => void;
  136400. /**
  136401. * Callback called when a task is successful
  136402. */
  136403. onTaskSuccess: (task: AbstractAssetTask) => void;
  136404. /**
  136405. * Callback called when a task had an error
  136406. */
  136407. onTaskError: (task: AbstractAssetTask) => void;
  136408. /**
  136409. * Callback called when a task is done (whatever the result is)
  136410. */
  136411. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  136412. /**
  136413. * Observable called when all tasks are processed
  136414. */
  136415. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  136416. /**
  136417. * Observable called when a task had an error
  136418. */
  136419. onTaskErrorObservable: Observable<AbstractAssetTask>;
  136420. /**
  136421. * Observable called when all tasks were executed
  136422. */
  136423. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  136424. /**
  136425. * Observable called when a task is done (whatever the result is)
  136426. */
  136427. onProgressObservable: Observable<IAssetsProgressEvent>;
  136428. /**
  136429. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  136430. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  136431. */
  136432. useDefaultLoadingScreen: boolean;
  136433. /**
  136434. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  136435. * when all assets have been downloaded.
  136436. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  136437. */
  136438. autoHideLoadingUI: boolean;
  136439. /**
  136440. * Creates a new AssetsManager
  136441. * @param scene defines the scene to work on
  136442. */
  136443. constructor(scene: Scene);
  136444. /**
  136445. * Add a MeshAssetTask to the list of active tasks
  136446. * @param taskName defines the name of the new task
  136447. * @param meshesNames defines the name of meshes to load
  136448. * @param rootUrl defines the root url to use to locate files
  136449. * @param sceneFilename defines the filename of the scene file
  136450. * @returns a new MeshAssetTask object
  136451. */
  136452. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  136453. /**
  136454. * Add a TextFileAssetTask to the list of active tasks
  136455. * @param taskName defines the name of the new task
  136456. * @param url defines the url of the file to load
  136457. * @returns a new TextFileAssetTask object
  136458. */
  136459. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  136460. /**
  136461. * Add a BinaryFileAssetTask to the list of active tasks
  136462. * @param taskName defines the name of the new task
  136463. * @param url defines the url of the file to load
  136464. * @returns a new BinaryFileAssetTask object
  136465. */
  136466. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  136467. /**
  136468. * Add a ImageAssetTask to the list of active tasks
  136469. * @param taskName defines the name of the new task
  136470. * @param url defines the url of the file to load
  136471. * @returns a new ImageAssetTask object
  136472. */
  136473. addImageTask(taskName: string, url: string): ImageAssetTask;
  136474. /**
  136475. * Add a TextureAssetTask to the list of active tasks
  136476. * @param taskName defines the name of the new task
  136477. * @param url defines the url of the file to load
  136478. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136479. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  136480. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  136481. * @returns a new TextureAssetTask object
  136482. */
  136483. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  136484. /**
  136485. * Add a CubeTextureAssetTask to the list of active tasks
  136486. * @param taskName defines the name of the new task
  136487. * @param url defines the url of the file to load
  136488. * @param extensions defines the extension to use to load the cube map (can be null)
  136489. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136490. * @param files defines the list of files to load (can be null)
  136491. * @returns a new CubeTextureAssetTask object
  136492. */
  136493. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  136494. /**
  136495. *
  136496. * Add a HDRCubeTextureAssetTask to the list of active tasks
  136497. * @param taskName defines the name of the new task
  136498. * @param url defines the url of the file to load
  136499. * @param size defines the size you want for the cubemap (can be null)
  136500. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136501. * @param generateHarmonics defines if you want to automatically generate (true by default)
  136502. * @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)
  136503. * @param reserved Internal use only
  136504. * @returns a new HDRCubeTextureAssetTask object
  136505. */
  136506. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  136507. /**
  136508. *
  136509. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  136510. * @param taskName defines the name of the new task
  136511. * @param url defines the url of the file to load
  136512. * @param size defines the size you want for the cubemap (can be null)
  136513. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136514. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  136515. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  136516. * @returns a new EquiRectangularCubeTextureAssetTask object
  136517. */
  136518. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  136519. /**
  136520. * Remove a task from the assets manager.
  136521. * @param task the task to remove
  136522. */
  136523. removeTask(task: AbstractAssetTask): void;
  136524. private _decreaseWaitingTasksCount;
  136525. private _runTask;
  136526. /**
  136527. * Reset the AssetsManager and remove all tasks
  136528. * @return the current instance of the AssetsManager
  136529. */
  136530. reset(): AssetsManager;
  136531. /**
  136532. * Start the loading process
  136533. * @return the current instance of the AssetsManager
  136534. */
  136535. load(): AssetsManager;
  136536. /**
  136537. * Start the loading process as an async operation
  136538. * @return a promise returning the list of failed tasks
  136539. */
  136540. loadAsync(): Promise<void>;
  136541. }
  136542. }
  136543. declare module BABYLON {
  136544. /**
  136545. * Wrapper class for promise with external resolve and reject.
  136546. */
  136547. export class Deferred<T> {
  136548. /**
  136549. * The promise associated with this deferred object.
  136550. */
  136551. readonly promise: Promise<T>;
  136552. private _resolve;
  136553. private _reject;
  136554. /**
  136555. * The resolve method of the promise associated with this deferred object.
  136556. */
  136557. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  136558. /**
  136559. * The reject method of the promise associated with this deferred object.
  136560. */
  136561. get reject(): (reason?: any) => void;
  136562. /**
  136563. * Constructor for this deferred object.
  136564. */
  136565. constructor();
  136566. }
  136567. }
  136568. declare module BABYLON {
  136569. /**
  136570. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  136571. */
  136572. export class MeshExploder {
  136573. private _centerMesh;
  136574. private _meshes;
  136575. private _meshesOrigins;
  136576. private _toCenterVectors;
  136577. private _scaledDirection;
  136578. private _newPosition;
  136579. private _centerPosition;
  136580. /**
  136581. * Explodes meshes from a center mesh.
  136582. * @param meshes The meshes to explode.
  136583. * @param centerMesh The mesh to be center of explosion.
  136584. */
  136585. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  136586. private _setCenterMesh;
  136587. /**
  136588. * Get class name
  136589. * @returns "MeshExploder"
  136590. */
  136591. getClassName(): string;
  136592. /**
  136593. * "Exploded meshes"
  136594. * @returns Array of meshes with the centerMesh at index 0.
  136595. */
  136596. getMeshes(): Array<Mesh>;
  136597. /**
  136598. * Explodes meshes giving a specific direction
  136599. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  136600. */
  136601. explode(direction?: number): void;
  136602. }
  136603. }
  136604. declare module BABYLON {
  136605. /**
  136606. * Class used to help managing file picking and drag'n'drop
  136607. */
  136608. export class FilesInput {
  136609. /**
  136610. * List of files ready to be loaded
  136611. */
  136612. static get FilesToLoad(): {
  136613. [key: string]: File;
  136614. };
  136615. /**
  136616. * Callback called when a file is processed
  136617. */
  136618. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  136619. private _engine;
  136620. private _currentScene;
  136621. private _sceneLoadedCallback;
  136622. private _progressCallback;
  136623. private _additionalRenderLoopLogicCallback;
  136624. private _textureLoadingCallback;
  136625. private _startingProcessingFilesCallback;
  136626. private _onReloadCallback;
  136627. private _errorCallback;
  136628. private _elementToMonitor;
  136629. private _sceneFileToLoad;
  136630. private _filesToLoad;
  136631. /**
  136632. * Creates a new FilesInput
  136633. * @param engine defines the rendering engine
  136634. * @param scene defines the hosting scene
  136635. * @param sceneLoadedCallback callback called when scene is loaded
  136636. * @param progressCallback callback called to track progress
  136637. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  136638. * @param textureLoadingCallback callback called when a texture is loading
  136639. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  136640. * @param onReloadCallback callback called when a reload is requested
  136641. * @param errorCallback callback call if an error occurs
  136642. */
  136643. 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);
  136644. private _dragEnterHandler;
  136645. private _dragOverHandler;
  136646. private _dropHandler;
  136647. /**
  136648. * Calls this function to listen to drag'n'drop events on a specific DOM element
  136649. * @param elementToMonitor defines the DOM element to track
  136650. */
  136651. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  136652. /**
  136653. * Release all associated resources
  136654. */
  136655. dispose(): void;
  136656. private renderFunction;
  136657. private drag;
  136658. private drop;
  136659. private _traverseFolder;
  136660. private _processFiles;
  136661. /**
  136662. * Load files from a drop event
  136663. * @param event defines the drop event to use as source
  136664. */
  136665. loadFiles(event: any): void;
  136666. private _processReload;
  136667. /**
  136668. * Reload the current scene from the loaded files
  136669. */
  136670. reload(): void;
  136671. }
  136672. }
  136673. declare module BABYLON {
  136674. /**
  136675. * Defines the root class used to create scene optimization to use with SceneOptimizer
  136676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136677. */
  136678. export class SceneOptimization {
  136679. /**
  136680. * Defines the priority of this optimization (0 by default which means first in the list)
  136681. */
  136682. priority: number;
  136683. /**
  136684. * Gets a string describing the action executed by the current optimization
  136685. * @returns description string
  136686. */
  136687. getDescription(): string;
  136688. /**
  136689. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136690. * @param scene defines the current scene where to apply this optimization
  136691. * @param optimizer defines the current optimizer
  136692. * @returns true if everything that can be done was applied
  136693. */
  136694. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136695. /**
  136696. * Creates the SceneOptimization object
  136697. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136698. * @param desc defines the description associated with the optimization
  136699. */
  136700. constructor(
  136701. /**
  136702. * Defines the priority of this optimization (0 by default which means first in the list)
  136703. */
  136704. priority?: number);
  136705. }
  136706. /**
  136707. * Defines an optimization used to reduce the size of render target textures
  136708. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136709. */
  136710. export class TextureOptimization extends SceneOptimization {
  136711. /**
  136712. * Defines the priority of this optimization (0 by default which means first in the list)
  136713. */
  136714. priority: number;
  136715. /**
  136716. * 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
  136717. */
  136718. maximumSize: number;
  136719. /**
  136720. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136721. */
  136722. step: number;
  136723. /**
  136724. * Gets a string describing the action executed by the current optimization
  136725. * @returns description string
  136726. */
  136727. getDescription(): string;
  136728. /**
  136729. * Creates the TextureOptimization object
  136730. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136731. * @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
  136732. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136733. */
  136734. constructor(
  136735. /**
  136736. * Defines the priority of this optimization (0 by default which means first in the list)
  136737. */
  136738. priority?: number,
  136739. /**
  136740. * 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
  136741. */
  136742. maximumSize?: number,
  136743. /**
  136744. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136745. */
  136746. step?: number);
  136747. /**
  136748. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136749. * @param scene defines the current scene where to apply this optimization
  136750. * @param optimizer defines the current optimizer
  136751. * @returns true if everything that can be done was applied
  136752. */
  136753. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136754. }
  136755. /**
  136756. * Defines an optimization used to increase or decrease the rendering resolution
  136757. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136758. */
  136759. export class HardwareScalingOptimization extends SceneOptimization {
  136760. /**
  136761. * Defines the priority of this optimization (0 by default which means first in the list)
  136762. */
  136763. priority: number;
  136764. /**
  136765. * Defines the maximum scale to use (2 by default)
  136766. */
  136767. maximumScale: number;
  136768. /**
  136769. * Defines the step to use between two passes (0.5 by default)
  136770. */
  136771. step: number;
  136772. private _currentScale;
  136773. private _directionOffset;
  136774. /**
  136775. * Gets a string describing the action executed by the current optimization
  136776. * @return description string
  136777. */
  136778. getDescription(): string;
  136779. /**
  136780. * Creates the HardwareScalingOptimization object
  136781. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136782. * @param maximumScale defines the maximum scale to use (2 by default)
  136783. * @param step defines the step to use between two passes (0.5 by default)
  136784. */
  136785. constructor(
  136786. /**
  136787. * Defines the priority of this optimization (0 by default which means first in the list)
  136788. */
  136789. priority?: number,
  136790. /**
  136791. * Defines the maximum scale to use (2 by default)
  136792. */
  136793. maximumScale?: number,
  136794. /**
  136795. * Defines the step to use between two passes (0.5 by default)
  136796. */
  136797. step?: number);
  136798. /**
  136799. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136800. * @param scene defines the current scene where to apply this optimization
  136801. * @param optimizer defines the current optimizer
  136802. * @returns true if everything that can be done was applied
  136803. */
  136804. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136805. }
  136806. /**
  136807. * Defines an optimization used to remove shadows
  136808. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136809. */
  136810. export class ShadowsOptimization extends SceneOptimization {
  136811. /**
  136812. * Gets a string describing the action executed by the current optimization
  136813. * @return description string
  136814. */
  136815. getDescription(): string;
  136816. /**
  136817. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136818. * @param scene defines the current scene where to apply this optimization
  136819. * @param optimizer defines the current optimizer
  136820. * @returns true if everything that can be done was applied
  136821. */
  136822. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136823. }
  136824. /**
  136825. * Defines an optimization used to turn post-processes off
  136826. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136827. */
  136828. export class PostProcessesOptimization extends SceneOptimization {
  136829. /**
  136830. * Gets a string describing the action executed by the current optimization
  136831. * @return description string
  136832. */
  136833. getDescription(): string;
  136834. /**
  136835. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136836. * @param scene defines the current scene where to apply this optimization
  136837. * @param optimizer defines the current optimizer
  136838. * @returns true if everything that can be done was applied
  136839. */
  136840. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136841. }
  136842. /**
  136843. * Defines an optimization used to turn lens flares off
  136844. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136845. */
  136846. export class LensFlaresOptimization extends SceneOptimization {
  136847. /**
  136848. * Gets a string describing the action executed by the current optimization
  136849. * @return description string
  136850. */
  136851. getDescription(): string;
  136852. /**
  136853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136854. * @param scene defines the current scene where to apply this optimization
  136855. * @param optimizer defines the current optimizer
  136856. * @returns true if everything that can be done was applied
  136857. */
  136858. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136859. }
  136860. /**
  136861. * Defines an optimization based on user defined callback.
  136862. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136863. */
  136864. export class CustomOptimization extends SceneOptimization {
  136865. /**
  136866. * Callback called to apply the custom optimization.
  136867. */
  136868. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  136869. /**
  136870. * Callback called to get custom description
  136871. */
  136872. onGetDescription: () => string;
  136873. /**
  136874. * Gets a string describing the action executed by the current optimization
  136875. * @returns description string
  136876. */
  136877. getDescription(): string;
  136878. /**
  136879. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136880. * @param scene defines the current scene where to apply this optimization
  136881. * @param optimizer defines the current optimizer
  136882. * @returns true if everything that can be done was applied
  136883. */
  136884. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136885. }
  136886. /**
  136887. * Defines an optimization used to turn particles off
  136888. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136889. */
  136890. export class ParticlesOptimization extends SceneOptimization {
  136891. /**
  136892. * Gets a string describing the action executed by the current optimization
  136893. * @return description string
  136894. */
  136895. getDescription(): string;
  136896. /**
  136897. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136898. * @param scene defines the current scene where to apply this optimization
  136899. * @param optimizer defines the current optimizer
  136900. * @returns true if everything that can be done was applied
  136901. */
  136902. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136903. }
  136904. /**
  136905. * Defines an optimization used to turn render targets off
  136906. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136907. */
  136908. export class RenderTargetsOptimization extends SceneOptimization {
  136909. /**
  136910. * Gets a string describing the action executed by the current optimization
  136911. * @return description string
  136912. */
  136913. getDescription(): string;
  136914. /**
  136915. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136916. * @param scene defines the current scene where to apply this optimization
  136917. * @param optimizer defines the current optimizer
  136918. * @returns true if everything that can be done was applied
  136919. */
  136920. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136921. }
  136922. /**
  136923. * Defines an optimization used to merge meshes with compatible materials
  136924. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136925. */
  136926. export class MergeMeshesOptimization extends SceneOptimization {
  136927. private static _UpdateSelectionTree;
  136928. /**
  136929. * Gets or sets a boolean which defines if optimization octree has to be updated
  136930. */
  136931. static get UpdateSelectionTree(): boolean;
  136932. /**
  136933. * Gets or sets a boolean which defines if optimization octree has to be updated
  136934. */
  136935. static set UpdateSelectionTree(value: boolean);
  136936. /**
  136937. * Gets a string describing the action executed by the current optimization
  136938. * @return description string
  136939. */
  136940. getDescription(): string;
  136941. private _canBeMerged;
  136942. /**
  136943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136944. * @param scene defines the current scene where to apply this optimization
  136945. * @param optimizer defines the current optimizer
  136946. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  136947. * @returns true if everything that can be done was applied
  136948. */
  136949. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  136950. }
  136951. /**
  136952. * Defines a list of options used by SceneOptimizer
  136953. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136954. */
  136955. export class SceneOptimizerOptions {
  136956. /**
  136957. * Defines the target frame rate to reach (60 by default)
  136958. */
  136959. targetFrameRate: number;
  136960. /**
  136961. * Defines the interval between two checkes (2000ms by default)
  136962. */
  136963. trackerDuration: number;
  136964. /**
  136965. * Gets the list of optimizations to apply
  136966. */
  136967. optimizations: SceneOptimization[];
  136968. /**
  136969. * Creates a new list of options used by SceneOptimizer
  136970. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  136971. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  136972. */
  136973. constructor(
  136974. /**
  136975. * Defines the target frame rate to reach (60 by default)
  136976. */
  136977. targetFrameRate?: number,
  136978. /**
  136979. * Defines the interval between two checkes (2000ms by default)
  136980. */
  136981. trackerDuration?: number);
  136982. /**
  136983. * Add a new optimization
  136984. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  136985. * @returns the current SceneOptimizerOptions
  136986. */
  136987. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  136988. /**
  136989. * Add a new custom optimization
  136990. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  136991. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  136992. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136993. * @returns the current SceneOptimizerOptions
  136994. */
  136995. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  136996. /**
  136997. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  136998. * @param targetFrameRate defines the target frame rate (60 by default)
  136999. * @returns a SceneOptimizerOptions object
  137000. */
  137001. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137002. /**
  137003. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  137004. * @param targetFrameRate defines the target frame rate (60 by default)
  137005. * @returns a SceneOptimizerOptions object
  137006. */
  137007. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137008. /**
  137009. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  137010. * @param targetFrameRate defines the target frame rate (60 by default)
  137011. * @returns a SceneOptimizerOptions object
  137012. */
  137013. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137014. }
  137015. /**
  137016. * Class used to run optimizations in order to reach a target frame rate
  137017. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137018. */
  137019. export class SceneOptimizer implements IDisposable {
  137020. private _isRunning;
  137021. private _options;
  137022. private _scene;
  137023. private _currentPriorityLevel;
  137024. private _targetFrameRate;
  137025. private _trackerDuration;
  137026. private _currentFrameRate;
  137027. private _sceneDisposeObserver;
  137028. private _improvementMode;
  137029. /**
  137030. * Defines an observable called when the optimizer reaches the target frame rate
  137031. */
  137032. onSuccessObservable: Observable<SceneOptimizer>;
  137033. /**
  137034. * Defines an observable called when the optimizer enables an optimization
  137035. */
  137036. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  137037. /**
  137038. * Defines an observable called when the optimizer is not able to reach the target frame rate
  137039. */
  137040. onFailureObservable: Observable<SceneOptimizer>;
  137041. /**
  137042. * Gets a boolean indicating if the optimizer is in improvement mode
  137043. */
  137044. get isInImprovementMode(): boolean;
  137045. /**
  137046. * Gets the current priority level (0 at start)
  137047. */
  137048. get currentPriorityLevel(): number;
  137049. /**
  137050. * Gets the current frame rate checked by the SceneOptimizer
  137051. */
  137052. get currentFrameRate(): number;
  137053. /**
  137054. * Gets or sets the current target frame rate (60 by default)
  137055. */
  137056. get targetFrameRate(): number;
  137057. /**
  137058. * Gets or sets the current target frame rate (60 by default)
  137059. */
  137060. set targetFrameRate(value: number);
  137061. /**
  137062. * Gets or sets the current interval between two checks (every 2000ms by default)
  137063. */
  137064. get trackerDuration(): number;
  137065. /**
  137066. * Gets or sets the current interval between two checks (every 2000ms by default)
  137067. */
  137068. set trackerDuration(value: number);
  137069. /**
  137070. * Gets the list of active optimizations
  137071. */
  137072. get optimizations(): SceneOptimization[];
  137073. /**
  137074. * Creates a new SceneOptimizer
  137075. * @param scene defines the scene to work on
  137076. * @param options defines the options to use with the SceneOptimizer
  137077. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  137078. * @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)
  137079. */
  137080. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  137081. /**
  137082. * Stops the current optimizer
  137083. */
  137084. stop(): void;
  137085. /**
  137086. * Reset the optimizer to initial step (current priority level = 0)
  137087. */
  137088. reset(): void;
  137089. /**
  137090. * Start the optimizer. By default it will try to reach a specific framerate
  137091. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  137092. */
  137093. start(): void;
  137094. private _checkCurrentState;
  137095. /**
  137096. * Release all resources
  137097. */
  137098. dispose(): void;
  137099. /**
  137100. * Helper function to create a SceneOptimizer with one single line of code
  137101. * @param scene defines the scene to work on
  137102. * @param options defines the options to use with the SceneOptimizer
  137103. * @param onSuccess defines a callback to call on success
  137104. * @param onFailure defines a callback to call on failure
  137105. * @returns the new SceneOptimizer object
  137106. */
  137107. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  137108. }
  137109. }
  137110. declare module BABYLON {
  137111. /**
  137112. * Class used to serialize a scene into a string
  137113. */
  137114. export class SceneSerializer {
  137115. /**
  137116. * Clear cache used by a previous serialization
  137117. */
  137118. static ClearCache(): void;
  137119. /**
  137120. * Serialize a scene into a JSON compatible object
  137121. * @param scene defines the scene to serialize
  137122. * @returns a JSON compatible object
  137123. */
  137124. static Serialize(scene: Scene): any;
  137125. /**
  137126. * Serialize a mesh into a JSON compatible object
  137127. * @param toSerialize defines the mesh to serialize
  137128. * @param withParents defines if parents must be serialized as well
  137129. * @param withChildren defines if children must be serialized as well
  137130. * @returns a JSON compatible object
  137131. */
  137132. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  137133. }
  137134. }
  137135. declare module BABYLON {
  137136. /**
  137137. * Class used to host texture specific utilities
  137138. */
  137139. export class TextureTools {
  137140. /**
  137141. * Uses the GPU to create a copy texture rescaled at a given size
  137142. * @param texture Texture to copy from
  137143. * @param width defines the desired width
  137144. * @param height defines the desired height
  137145. * @param useBilinearMode defines if bilinear mode has to be used
  137146. * @return the generated texture
  137147. */
  137148. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  137149. }
  137150. }
  137151. declare module BABYLON {
  137152. /**
  137153. * This represents the different options available for the video capture.
  137154. */
  137155. export interface VideoRecorderOptions {
  137156. /** Defines the mime type of the video. */
  137157. mimeType: string;
  137158. /** Defines the FPS the video should be recorded at. */
  137159. fps: number;
  137160. /** Defines the chunk size for the recording data. */
  137161. recordChunckSize: number;
  137162. /** The audio tracks to attach to the recording. */
  137163. audioTracks?: MediaStreamTrack[];
  137164. }
  137165. /**
  137166. * This can help with recording videos from BabylonJS.
  137167. * This is based on the available WebRTC functionalities of the browser.
  137168. *
  137169. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  137170. */
  137171. export class VideoRecorder {
  137172. private static readonly _defaultOptions;
  137173. /**
  137174. * Returns whether or not the VideoRecorder is available in your browser.
  137175. * @param engine Defines the Babylon Engine.
  137176. * @returns true if supported otherwise false.
  137177. */
  137178. static IsSupported(engine: Engine): boolean;
  137179. private readonly _options;
  137180. private _canvas;
  137181. private _mediaRecorder;
  137182. private _recordedChunks;
  137183. private _fileName;
  137184. private _resolve;
  137185. private _reject;
  137186. /**
  137187. * True when a recording is already in progress.
  137188. */
  137189. get isRecording(): boolean;
  137190. /**
  137191. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  137192. * @param engine Defines the BabylonJS Engine you wish to record.
  137193. * @param options Defines options that can be used to customize the capture.
  137194. */
  137195. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  137196. /**
  137197. * Stops the current recording before the default capture timeout passed in the startRecording function.
  137198. */
  137199. stopRecording(): void;
  137200. /**
  137201. * Starts recording the canvas for a max duration specified in parameters.
  137202. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  137203. * If null no automatic download will start and you can rely on the promise to get the data back.
  137204. * @param maxDuration Defines the maximum recording time in seconds.
  137205. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  137206. * @return A promise callback at the end of the recording with the video data in Blob.
  137207. */
  137208. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  137209. /**
  137210. * Releases internal resources used during the recording.
  137211. */
  137212. dispose(): void;
  137213. private _handleDataAvailable;
  137214. private _handleError;
  137215. private _handleStop;
  137216. }
  137217. }
  137218. declare module BABYLON {
  137219. /**
  137220. * Class containing a set of static utilities functions for screenshots
  137221. */
  137222. export class ScreenshotTools {
  137223. /**
  137224. * Captures a screenshot of the current rendering
  137225. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137226. * @param engine defines the rendering engine
  137227. * @param camera defines the source camera
  137228. * @param size This parameter can be set to a single number or to an object with the
  137229. * following (optional) properties: precision, width, height. If a single number is passed,
  137230. * it will be used for both width and height. If an object is passed, the screenshot size
  137231. * will be derived from the parameters. The precision property is a multiplier allowing
  137232. * rendering at a higher or lower resolution
  137233. * @param successCallback defines the callback receives a single parameter which contains the
  137234. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137235. * src parameter of an <img> to display it
  137236. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137237. * Check your browser for supported MIME types
  137238. */
  137239. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  137240. /**
  137241. * Captures a screenshot of the current rendering
  137242. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137243. * @param engine defines the rendering engine
  137244. * @param camera defines the source camera
  137245. * @param size This parameter can be set to a single number or to an object with the
  137246. * following (optional) properties: precision, width, height. If a single number is passed,
  137247. * it will be used for both width and height. If an object is passed, the screenshot size
  137248. * will be derived from the parameters. The precision property is a multiplier allowing
  137249. * rendering at a higher or lower resolution
  137250. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137251. * Check your browser for supported MIME types
  137252. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137253. * to the src parameter of an <img> to display it
  137254. */
  137255. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  137256. /**
  137257. * Generates an image screenshot from the specified camera.
  137258. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137259. * @param engine The engine to use for rendering
  137260. * @param camera The camera to use for rendering
  137261. * @param size This parameter can be set to a single number or to an object with the
  137262. * following (optional) properties: precision, width, height. If a single number is passed,
  137263. * it will be used for both width and height. If an object is passed, the screenshot size
  137264. * will be derived from the parameters. The precision property is a multiplier allowing
  137265. * rendering at a higher or lower resolution
  137266. * @param successCallback The callback receives a single parameter which contains the
  137267. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137268. * src parameter of an <img> to display it
  137269. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137270. * Check your browser for supported MIME types
  137271. * @param samples Texture samples (default: 1)
  137272. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137273. * @param fileName A name for for the downloaded file.
  137274. */
  137275. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  137276. /**
  137277. * Generates an image screenshot from the specified camera.
  137278. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137279. * @param engine The engine to use for rendering
  137280. * @param camera The camera to use for rendering
  137281. * @param size This parameter can be set to a single number or to an object with the
  137282. * following (optional) properties: precision, width, height. If a single number is passed,
  137283. * it will be used for both width and height. If an object is passed, the screenshot size
  137284. * will be derived from the parameters. The precision property is a multiplier allowing
  137285. * rendering at a higher or lower resolution
  137286. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137287. * Check your browser for supported MIME types
  137288. * @param samples Texture samples (default: 1)
  137289. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137290. * @param fileName A name for for the downloaded file.
  137291. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137292. * to the src parameter of an <img> to display it
  137293. */
  137294. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  137295. /**
  137296. * Gets height and width for screenshot size
  137297. * @private
  137298. */
  137299. private static _getScreenshotSize;
  137300. }
  137301. }
  137302. declare module BABYLON {
  137303. /**
  137304. * Interface for a data buffer
  137305. */
  137306. export interface IDataBuffer {
  137307. /**
  137308. * Reads bytes from the data buffer.
  137309. * @param byteOffset The byte offset to read
  137310. * @param byteLength The byte length to read
  137311. * @returns A promise that resolves when the bytes are read
  137312. */
  137313. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  137314. /**
  137315. * The byte length of the buffer.
  137316. */
  137317. readonly byteLength: number;
  137318. }
  137319. /**
  137320. * Utility class for reading from a data buffer
  137321. */
  137322. export class DataReader {
  137323. /**
  137324. * The data buffer associated with this data reader.
  137325. */
  137326. readonly buffer: IDataBuffer;
  137327. /**
  137328. * The current byte offset from the beginning of the data buffer.
  137329. */
  137330. byteOffset: number;
  137331. private _dataView;
  137332. private _dataByteOffset;
  137333. /**
  137334. * Constructor
  137335. * @param buffer The buffer to read
  137336. */
  137337. constructor(buffer: IDataBuffer);
  137338. /**
  137339. * Loads the given byte length.
  137340. * @param byteLength The byte length to load
  137341. * @returns A promise that resolves when the load is complete
  137342. */
  137343. loadAsync(byteLength: number): Promise<void>;
  137344. /**
  137345. * Read a unsigned 32-bit integer from the currently loaded data range.
  137346. * @returns The 32-bit integer read
  137347. */
  137348. readUint32(): number;
  137349. /**
  137350. * Read a byte array from the currently loaded data range.
  137351. * @param byteLength The byte length to read
  137352. * @returns The byte array read
  137353. */
  137354. readUint8Array(byteLength: number): Uint8Array;
  137355. /**
  137356. * Read a string from the currently loaded data range.
  137357. * @param byteLength The byte length to read
  137358. * @returns The string read
  137359. */
  137360. readString(byteLength: number): string;
  137361. /**
  137362. * Skips the given byte length the currently loaded data range.
  137363. * @param byteLength The byte length to skip
  137364. */
  137365. skipBytes(byteLength: number): void;
  137366. }
  137367. }
  137368. declare module BABYLON {
  137369. /**
  137370. * A cursor which tracks a point on a path
  137371. */
  137372. export class PathCursor {
  137373. private path;
  137374. /**
  137375. * Stores path cursor callbacks for when an onchange event is triggered
  137376. */
  137377. private _onchange;
  137378. /**
  137379. * The value of the path cursor
  137380. */
  137381. value: number;
  137382. /**
  137383. * The animation array of the path cursor
  137384. */
  137385. animations: Animation[];
  137386. /**
  137387. * Initializes the path cursor
  137388. * @param path The path to track
  137389. */
  137390. constructor(path: Path2);
  137391. /**
  137392. * Gets the cursor point on the path
  137393. * @returns A point on the path cursor at the cursor location
  137394. */
  137395. getPoint(): Vector3;
  137396. /**
  137397. * Moves the cursor ahead by the step amount
  137398. * @param step The amount to move the cursor forward
  137399. * @returns This path cursor
  137400. */
  137401. moveAhead(step?: number): PathCursor;
  137402. /**
  137403. * Moves the cursor behind by the step amount
  137404. * @param step The amount to move the cursor back
  137405. * @returns This path cursor
  137406. */
  137407. moveBack(step?: number): PathCursor;
  137408. /**
  137409. * Moves the cursor by the step amount
  137410. * If the step amount is greater than one, an exception is thrown
  137411. * @param step The amount to move the cursor
  137412. * @returns This path cursor
  137413. */
  137414. move(step: number): PathCursor;
  137415. /**
  137416. * Ensures that the value is limited between zero and one
  137417. * @returns This path cursor
  137418. */
  137419. private ensureLimits;
  137420. /**
  137421. * Runs onchange callbacks on change (used by the animation engine)
  137422. * @returns This path cursor
  137423. */
  137424. private raiseOnChange;
  137425. /**
  137426. * Executes a function on change
  137427. * @param f A path cursor onchange callback
  137428. * @returns This path cursor
  137429. */
  137430. onchange(f: (cursor: PathCursor) => void): PathCursor;
  137431. }
  137432. }
  137433. declare module BABYLON {
  137434. /** @hidden */
  137435. export var blurPixelShader: {
  137436. name: string;
  137437. shader: string;
  137438. };
  137439. }
  137440. declare module BABYLON {
  137441. /** @hidden */
  137442. export var pointCloudVertexDeclaration: {
  137443. name: string;
  137444. shader: string;
  137445. };
  137446. }
  137447. // Mixins
  137448. interface Window {
  137449. mozIndexedDB: IDBFactory;
  137450. webkitIndexedDB: IDBFactory;
  137451. msIndexedDB: IDBFactory;
  137452. webkitURL: typeof URL;
  137453. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  137454. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  137455. WebGLRenderingContext: WebGLRenderingContext;
  137456. MSGesture: MSGesture;
  137457. CANNON: any;
  137458. AudioContext: AudioContext;
  137459. webkitAudioContext: AudioContext;
  137460. PointerEvent: any;
  137461. Math: Math;
  137462. Uint8Array: Uint8ArrayConstructor;
  137463. Float32Array: Float32ArrayConstructor;
  137464. mozURL: typeof URL;
  137465. msURL: typeof URL;
  137466. VRFrameData: any; // WebVR, from specs 1.1
  137467. DracoDecoderModule: any;
  137468. setImmediate(handler: (...args: any[]) => void): number;
  137469. }
  137470. interface HTMLCanvasElement {
  137471. requestPointerLock(): void;
  137472. msRequestPointerLock?(): void;
  137473. mozRequestPointerLock?(): void;
  137474. webkitRequestPointerLock?(): void;
  137475. /** Track wether a record is in progress */
  137476. isRecording: boolean;
  137477. /** Capture Stream method defined by some browsers */
  137478. captureStream(fps?: number): MediaStream;
  137479. }
  137480. interface CanvasRenderingContext2D {
  137481. msImageSmoothingEnabled: boolean;
  137482. }
  137483. interface MouseEvent {
  137484. mozMovementX: number;
  137485. mozMovementY: number;
  137486. webkitMovementX: number;
  137487. webkitMovementY: number;
  137488. msMovementX: number;
  137489. msMovementY: number;
  137490. }
  137491. interface Navigator {
  137492. mozGetVRDevices: (any: any) => any;
  137493. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137494. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137495. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137496. webkitGetGamepads(): Gamepad[];
  137497. msGetGamepads(): Gamepad[];
  137498. webkitGamepads(): Gamepad[];
  137499. }
  137500. interface HTMLVideoElement {
  137501. mozSrcObject: any;
  137502. }
  137503. interface Math {
  137504. fround(x: number): number;
  137505. imul(a: number, b: number): number;
  137506. }
  137507. interface WebGLRenderingContext {
  137508. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  137509. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  137510. vertexAttribDivisor(index: number, divisor: number): void;
  137511. createVertexArray(): any;
  137512. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  137513. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  137514. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  137515. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  137516. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  137517. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  137518. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  137519. // Queries
  137520. createQuery(): WebGLQuery;
  137521. deleteQuery(query: WebGLQuery): void;
  137522. beginQuery(target: number, query: WebGLQuery): void;
  137523. endQuery(target: number): void;
  137524. getQueryParameter(query: WebGLQuery, pname: number): any;
  137525. getQuery(target: number, pname: number): any;
  137526. MAX_SAMPLES: number;
  137527. RGBA8: number;
  137528. READ_FRAMEBUFFER: number;
  137529. DRAW_FRAMEBUFFER: number;
  137530. UNIFORM_BUFFER: number;
  137531. HALF_FLOAT_OES: number;
  137532. RGBA16F: number;
  137533. RGBA32F: number;
  137534. R32F: number;
  137535. RG32F: number;
  137536. RGB32F: number;
  137537. R16F: number;
  137538. RG16F: number;
  137539. RGB16F: number;
  137540. RED: number;
  137541. RG: number;
  137542. R8: number;
  137543. RG8: number;
  137544. UNSIGNED_INT_24_8: number;
  137545. DEPTH24_STENCIL8: number;
  137546. MIN: number;
  137547. MAX: number;
  137548. /* Multiple Render Targets */
  137549. drawBuffers(buffers: number[]): void;
  137550. readBuffer(src: number): void;
  137551. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  137552. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  137553. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  137554. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  137555. // Occlusion Query
  137556. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  137557. ANY_SAMPLES_PASSED: number;
  137558. QUERY_RESULT_AVAILABLE: number;
  137559. QUERY_RESULT: number;
  137560. }
  137561. interface WebGLProgram {
  137562. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  137563. }
  137564. interface EXT_disjoint_timer_query {
  137565. QUERY_COUNTER_BITS_EXT: number;
  137566. TIME_ELAPSED_EXT: number;
  137567. TIMESTAMP_EXT: number;
  137568. GPU_DISJOINT_EXT: number;
  137569. QUERY_RESULT_EXT: number;
  137570. QUERY_RESULT_AVAILABLE_EXT: number;
  137571. queryCounterEXT(query: WebGLQuery, target: number): void;
  137572. createQueryEXT(): WebGLQuery;
  137573. beginQueryEXT(target: number, query: WebGLQuery): void;
  137574. endQueryEXT(target: number): void;
  137575. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  137576. deleteQueryEXT(query: WebGLQuery): void;
  137577. }
  137578. interface WebGLUniformLocation {
  137579. _currentState: any;
  137580. }
  137581. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  137582. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  137583. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  137584. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137585. interface WebGLRenderingContext {
  137586. readonly RASTERIZER_DISCARD: number;
  137587. readonly DEPTH_COMPONENT24: number;
  137588. readonly TEXTURE_3D: number;
  137589. readonly TEXTURE_2D_ARRAY: number;
  137590. readonly TEXTURE_COMPARE_FUNC: number;
  137591. readonly TEXTURE_COMPARE_MODE: number;
  137592. readonly COMPARE_REF_TO_TEXTURE: number;
  137593. readonly TEXTURE_WRAP_R: number;
  137594. readonly HALF_FLOAT: number;
  137595. readonly RGB8: number;
  137596. readonly RED_INTEGER: number;
  137597. readonly RG_INTEGER: number;
  137598. readonly RGB_INTEGER: number;
  137599. readonly RGBA_INTEGER: number;
  137600. readonly R8_SNORM: number;
  137601. readonly RG8_SNORM: number;
  137602. readonly RGB8_SNORM: number;
  137603. readonly RGBA8_SNORM: number;
  137604. readonly R8I: number;
  137605. readonly RG8I: number;
  137606. readonly RGB8I: number;
  137607. readonly RGBA8I: number;
  137608. readonly R8UI: number;
  137609. readonly RG8UI: number;
  137610. readonly RGB8UI: number;
  137611. readonly RGBA8UI: number;
  137612. readonly R16I: number;
  137613. readonly RG16I: number;
  137614. readonly RGB16I: number;
  137615. readonly RGBA16I: number;
  137616. readonly R16UI: number;
  137617. readonly RG16UI: number;
  137618. readonly RGB16UI: number;
  137619. readonly RGBA16UI: number;
  137620. readonly R32I: number;
  137621. readonly RG32I: number;
  137622. readonly RGB32I: number;
  137623. readonly RGBA32I: number;
  137624. readonly R32UI: number;
  137625. readonly RG32UI: number;
  137626. readonly RGB32UI: number;
  137627. readonly RGBA32UI: number;
  137628. readonly RGB10_A2UI: number;
  137629. readonly R11F_G11F_B10F: number;
  137630. readonly RGB9_E5: number;
  137631. readonly RGB10_A2: number;
  137632. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  137633. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  137634. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  137635. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  137636. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  137637. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  137638. 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;
  137639. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  137640. readonly TRANSFORM_FEEDBACK: number;
  137641. readonly INTERLEAVED_ATTRIBS: number;
  137642. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  137643. createTransformFeedback(): WebGLTransformFeedback;
  137644. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  137645. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  137646. beginTransformFeedback(primitiveMode: number): void;
  137647. endTransformFeedback(): void;
  137648. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  137649. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137650. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137651. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137652. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  137653. }
  137654. interface ImageBitmap {
  137655. readonly width: number;
  137656. readonly height: number;
  137657. close(): void;
  137658. }
  137659. interface WebGLQuery extends WebGLObject {
  137660. }
  137661. declare var WebGLQuery: {
  137662. prototype: WebGLQuery;
  137663. new(): WebGLQuery;
  137664. };
  137665. interface WebGLSampler extends WebGLObject {
  137666. }
  137667. declare var WebGLSampler: {
  137668. prototype: WebGLSampler;
  137669. new(): WebGLSampler;
  137670. };
  137671. interface WebGLSync extends WebGLObject {
  137672. }
  137673. declare var WebGLSync: {
  137674. prototype: WebGLSync;
  137675. new(): WebGLSync;
  137676. };
  137677. interface WebGLTransformFeedback extends WebGLObject {
  137678. }
  137679. declare var WebGLTransformFeedback: {
  137680. prototype: WebGLTransformFeedback;
  137681. new(): WebGLTransformFeedback;
  137682. };
  137683. interface WebGLVertexArrayObject extends WebGLObject {
  137684. }
  137685. declare var WebGLVertexArrayObject: {
  137686. prototype: WebGLVertexArrayObject;
  137687. new(): WebGLVertexArrayObject;
  137688. };
  137689. // Type definitions for WebVR API
  137690. // Project: https://w3c.github.io/webvr/
  137691. // Definitions by: six a <https://github.com/lostfictions>
  137692. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137693. interface VRDisplay extends EventTarget {
  137694. /**
  137695. * Dictionary of capabilities describing the VRDisplay.
  137696. */
  137697. readonly capabilities: VRDisplayCapabilities;
  137698. /**
  137699. * z-depth defining the far plane of the eye view frustum
  137700. * enables mapping of values in the render target depth
  137701. * attachment to scene coordinates. Initially set to 10000.0.
  137702. */
  137703. depthFar: number;
  137704. /**
  137705. * z-depth defining the near plane of the eye view frustum
  137706. * enables mapping of values in the render target depth
  137707. * attachment to scene coordinates. Initially set to 0.01.
  137708. */
  137709. depthNear: number;
  137710. /**
  137711. * An identifier for this distinct VRDisplay. Used as an
  137712. * association point in the Gamepad API.
  137713. */
  137714. readonly displayId: number;
  137715. /**
  137716. * A display name, a user-readable name identifying it.
  137717. */
  137718. readonly displayName: string;
  137719. readonly isConnected: boolean;
  137720. readonly isPresenting: boolean;
  137721. /**
  137722. * If this VRDisplay supports room-scale experiences, the optional
  137723. * stage attribute contains details on the room-scale parameters.
  137724. */
  137725. readonly stageParameters: VRStageParameters | null;
  137726. /**
  137727. * Passing the value returned by `requestAnimationFrame` to
  137728. * `cancelAnimationFrame` will unregister the callback.
  137729. * @param handle Define the hanle of the request to cancel
  137730. */
  137731. cancelAnimationFrame(handle: number): void;
  137732. /**
  137733. * Stops presenting to the VRDisplay.
  137734. * @returns a promise to know when it stopped
  137735. */
  137736. exitPresent(): Promise<void>;
  137737. /**
  137738. * Return the current VREyeParameters for the given eye.
  137739. * @param whichEye Define the eye we want the parameter for
  137740. * @returns the eye parameters
  137741. */
  137742. getEyeParameters(whichEye: string): VREyeParameters;
  137743. /**
  137744. * Populates the passed VRFrameData with the information required to render
  137745. * the current frame.
  137746. * @param frameData Define the data structure to populate
  137747. * @returns true if ok otherwise false
  137748. */
  137749. getFrameData(frameData: VRFrameData): boolean;
  137750. /**
  137751. * Get the layers currently being presented.
  137752. * @returns the list of VR layers
  137753. */
  137754. getLayers(): VRLayer[];
  137755. /**
  137756. * Return a VRPose containing the future predicted pose of the VRDisplay
  137757. * when the current frame will be presented. The value returned will not
  137758. * change until JavaScript has returned control to the browser.
  137759. *
  137760. * The VRPose will contain the position, orientation, velocity,
  137761. * and acceleration of each of these properties.
  137762. * @returns the pose object
  137763. */
  137764. getPose(): VRPose;
  137765. /**
  137766. * Return the current instantaneous pose of the VRDisplay, with no
  137767. * prediction applied.
  137768. * @returns the current instantaneous pose
  137769. */
  137770. getImmediatePose(): VRPose;
  137771. /**
  137772. * The callback passed to `requestAnimationFrame` will be called
  137773. * any time a new frame should be rendered. When the VRDisplay is
  137774. * presenting the callback will be called at the native refresh
  137775. * rate of the HMD. When not presenting this function acts
  137776. * identically to how window.requestAnimationFrame acts. Content should
  137777. * make no assumptions of frame rate or vsync behavior as the HMD runs
  137778. * asynchronously from other displays and at differing refresh rates.
  137779. * @param callback Define the eaction to run next frame
  137780. * @returns the request handle it
  137781. */
  137782. requestAnimationFrame(callback: FrameRequestCallback): number;
  137783. /**
  137784. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  137785. * Repeat calls while already presenting will update the VRLayers being displayed.
  137786. * @param layers Define the list of layer to present
  137787. * @returns a promise to know when the request has been fulfilled
  137788. */
  137789. requestPresent(layers: VRLayer[]): Promise<void>;
  137790. /**
  137791. * Reset the pose for this display, treating its current position and
  137792. * orientation as the "origin/zero" values. VRPose.position,
  137793. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  137794. * updated when calling resetPose(). This should be called in only
  137795. * sitting-space experiences.
  137796. */
  137797. resetPose(): void;
  137798. /**
  137799. * The VRLayer provided to the VRDisplay will be captured and presented
  137800. * in the HMD. Calling this function has the same effect on the source
  137801. * canvas as any other operation that uses its source image, and canvases
  137802. * created without preserveDrawingBuffer set to true will be cleared.
  137803. * @param pose Define the pose to submit
  137804. */
  137805. submitFrame(pose?: VRPose): void;
  137806. }
  137807. declare var VRDisplay: {
  137808. prototype: VRDisplay;
  137809. new(): VRDisplay;
  137810. };
  137811. interface VRLayer {
  137812. leftBounds?: number[] | Float32Array | null;
  137813. rightBounds?: number[] | Float32Array | null;
  137814. source?: HTMLCanvasElement | null;
  137815. }
  137816. interface VRDisplayCapabilities {
  137817. readonly canPresent: boolean;
  137818. readonly hasExternalDisplay: boolean;
  137819. readonly hasOrientation: boolean;
  137820. readonly hasPosition: boolean;
  137821. readonly maxLayers: number;
  137822. }
  137823. interface VREyeParameters {
  137824. /** @deprecated */
  137825. readonly fieldOfView: VRFieldOfView;
  137826. readonly offset: Float32Array;
  137827. readonly renderHeight: number;
  137828. readonly renderWidth: number;
  137829. }
  137830. interface VRFieldOfView {
  137831. readonly downDegrees: number;
  137832. readonly leftDegrees: number;
  137833. readonly rightDegrees: number;
  137834. readonly upDegrees: number;
  137835. }
  137836. interface VRFrameData {
  137837. readonly leftProjectionMatrix: Float32Array;
  137838. readonly leftViewMatrix: Float32Array;
  137839. readonly pose: VRPose;
  137840. readonly rightProjectionMatrix: Float32Array;
  137841. readonly rightViewMatrix: Float32Array;
  137842. readonly timestamp: number;
  137843. }
  137844. interface VRPose {
  137845. readonly angularAcceleration: Float32Array | null;
  137846. readonly angularVelocity: Float32Array | null;
  137847. readonly linearAcceleration: Float32Array | null;
  137848. readonly linearVelocity: Float32Array | null;
  137849. readonly orientation: Float32Array | null;
  137850. readonly position: Float32Array | null;
  137851. readonly timestamp: number;
  137852. }
  137853. interface VRStageParameters {
  137854. sittingToStandingTransform?: Float32Array;
  137855. sizeX?: number;
  137856. sizeY?: number;
  137857. }
  137858. interface Navigator {
  137859. getVRDisplays(): Promise<VRDisplay[]>;
  137860. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  137861. }
  137862. interface Window {
  137863. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  137864. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  137865. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  137866. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137867. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137868. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  137869. }
  137870. interface Gamepad {
  137871. readonly displayId: number;
  137872. }
  137873. type XRSessionMode =
  137874. | "inline"
  137875. | "immersive-vr"
  137876. | "immersive-ar";
  137877. type XRReferenceSpaceType =
  137878. | "viewer"
  137879. | "local"
  137880. | "local-floor"
  137881. | "bounded-floor"
  137882. | "unbounded";
  137883. type XREnvironmentBlendMode =
  137884. | "opaque"
  137885. | "additive"
  137886. | "alpha-blend";
  137887. type XRVisibilityState =
  137888. | "visible"
  137889. | "visible-blurred"
  137890. | "hidden";
  137891. type XRHandedness =
  137892. | "none"
  137893. | "left"
  137894. | "right";
  137895. type XRTargetRayMode =
  137896. | "gaze"
  137897. | "tracked-pointer"
  137898. | "screen";
  137899. type XREye =
  137900. | "none"
  137901. | "left"
  137902. | "right";
  137903. interface XRSpace extends EventTarget {
  137904. }
  137905. interface XRRenderState {
  137906. depthNear?: number;
  137907. depthFar?: number;
  137908. inlineVerticalFieldOfView?: number;
  137909. baseLayer?: XRWebGLLayer;
  137910. }
  137911. interface XRInputSource {
  137912. handedness: XRHandedness;
  137913. targetRayMode: XRTargetRayMode;
  137914. targetRaySpace: XRSpace;
  137915. gripSpace: XRSpace | undefined;
  137916. gamepad: Gamepad | undefined;
  137917. profiles: Array<string>;
  137918. }
  137919. interface XRSession extends XRAnchorCreator {
  137920. addEventListener: Function;
  137921. removeEventListener: Function;
  137922. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  137923. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  137924. requestAnimationFrame: Function;
  137925. end(): Promise<void>;
  137926. renderState: XRRenderState;
  137927. inputSources: Array<XRInputSource>;
  137928. // AR hit test
  137929. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  137930. updateWorldTrackingState(options: {
  137931. planeDetectionState?: { enabled: boolean; }
  137932. }): void;
  137933. }
  137934. interface XRReferenceSpace extends XRSpace {
  137935. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  137936. onreset: any;
  137937. }
  137938. type XRPlaneSet = Set<XRPlane>;
  137939. type XRAnchorSet = Set<XRAnchor>;
  137940. interface XRFrame {
  137941. session: XRSession;
  137942. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  137943. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  137944. // Anchors
  137945. trackedAnchors?: XRAnchorSet;
  137946. // Planes
  137947. worldInformation: {
  137948. detectedPlanes?: XRPlaneSet;
  137949. };
  137950. }
  137951. interface XRViewerPose extends XRPose {
  137952. views: Array<XRView>;
  137953. }
  137954. interface XRPose {
  137955. transform: XRRigidTransform;
  137956. emulatedPosition: boolean;
  137957. }
  137958. interface XRWebGLLayerOptions {
  137959. antialias?: boolean;
  137960. depth?: boolean;
  137961. stencil?: boolean;
  137962. alpha?: boolean;
  137963. multiview?: boolean;
  137964. framebufferScaleFactor?: number;
  137965. }
  137966. declare var XRWebGLLayer: {
  137967. prototype: XRWebGLLayer;
  137968. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  137969. };
  137970. interface XRWebGLLayer {
  137971. framebuffer: WebGLFramebuffer;
  137972. framebufferWidth: number;
  137973. framebufferHeight: number;
  137974. getViewport: Function;
  137975. }
  137976. declare class XRRigidTransform {
  137977. constructor(matrix: Float32Array);
  137978. position: DOMPointReadOnly;
  137979. orientation: DOMPointReadOnly;
  137980. matrix: Float32Array;
  137981. inverse: XRRigidTransform;
  137982. }
  137983. interface XRView {
  137984. eye: XREye;
  137985. projectionMatrix: Float32Array;
  137986. transform: XRRigidTransform;
  137987. }
  137988. interface XRInputSourceChangeEvent {
  137989. session: XRSession;
  137990. removed: Array<XRInputSource>;
  137991. added: Array<XRInputSource>;
  137992. }
  137993. interface XRInputSourceEvent extends Event {
  137994. readonly frame: XRFrame;
  137995. readonly inputSource: XRInputSource;
  137996. }
  137997. // Experimental(er) features
  137998. declare class XRRay {
  137999. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  138000. origin: DOMPointReadOnly;
  138001. direction: DOMPointReadOnly;
  138002. matrix: Float32Array;
  138003. }
  138004. interface XRHitResult {
  138005. hitMatrix: Float32Array;
  138006. }
  138007. interface XRAnchor {
  138008. // remove?
  138009. id?: string;
  138010. anchorSpace: XRSpace;
  138011. lastChangedTime: number;
  138012. detach(): void;
  138013. }
  138014. interface XRPlane extends XRAnchorCreator {
  138015. orientation: "Horizontal" | "Vertical";
  138016. planeSpace: XRSpace;
  138017. polygon: Array<DOMPointReadOnly>;
  138018. lastChangedTime: number;
  138019. }
  138020. interface XRAnchorCreator {
  138021. // AR Anchors
  138022. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  138023. }